@kodelyth/memory-lancedb 2026.5.39 → 2026.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3205 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs/promises";
3
+ import { resolvePreferredKlawTmpDir } from "klaw/plugin-sdk/temp-path";
4
+ //#region node_modules/tinyrainbow/dist/index.js
5
+ var b = {
6
+ reset: [0, 0],
7
+ bold: [
8
+ 1,
9
+ 22,
10
+ "\x1B[22m\x1B[1m"
11
+ ],
12
+ dim: [
13
+ 2,
14
+ 22,
15
+ "\x1B[22m\x1B[2m"
16
+ ],
17
+ italic: [3, 23],
18
+ underline: [4, 24],
19
+ inverse: [7, 27],
20
+ hidden: [8, 28],
21
+ strikethrough: [9, 29],
22
+ black: [30, 39],
23
+ red: [31, 39],
24
+ green: [32, 39],
25
+ yellow: [33, 39],
26
+ blue: [34, 39],
27
+ magenta: [35, 39],
28
+ cyan: [36, 39],
29
+ white: [37, 39],
30
+ gray: [90, 39],
31
+ bgBlack: [40, 49],
32
+ bgRed: [41, 49],
33
+ bgGreen: [42, 49],
34
+ bgYellow: [43, 49],
35
+ bgBlue: [44, 49],
36
+ bgMagenta: [45, 49],
37
+ bgCyan: [46, 49],
38
+ bgWhite: [47, 49],
39
+ blackBright: [90, 39],
40
+ redBright: [91, 39],
41
+ greenBright: [92, 39],
42
+ yellowBright: [93, 39],
43
+ blueBright: [94, 39],
44
+ magentaBright: [95, 39],
45
+ cyanBright: [96, 39],
46
+ whiteBright: [97, 39],
47
+ bgBlackBright: [100, 49],
48
+ bgRedBright: [101, 49],
49
+ bgGreenBright: [102, 49],
50
+ bgYellowBright: [103, 49],
51
+ bgBlueBright: [104, 49],
52
+ bgMagentaBright: [105, 49],
53
+ bgCyanBright: [106, 49],
54
+ bgWhiteBright: [107, 49]
55
+ };
56
+ function i(e) {
57
+ return String(e);
58
+ }
59
+ i.open = "";
60
+ i.close = "";
61
+ function B() {
62
+ let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
63
+ return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
64
+ }
65
+ function C({ force: e } = {}) {
66
+ let r = e || B(), a = (t, o, u, n) => {
67
+ let g = "", s = 0;
68
+ do
69
+ g += t.substring(s, n) + u, s = n + o.length, n = t.indexOf(o, s);
70
+ while (~n);
71
+ return g + t.substring(s);
72
+ }, l = (t, o, u = t) => {
73
+ let n = (g) => {
74
+ let s = String(g), h = s.indexOf(o, t.length);
75
+ return ~h ? t + a(s, o, u, h) + o : t + s + o;
76
+ };
77
+ return n.open = t, n.close = o, n;
78
+ }, c = { isColorSupported: r }, f = (t) => `\x1B[${t}m`;
79
+ for (let t in b) {
80
+ let o = b[t];
81
+ c[t] = r ? l(f(o[0]), f(o[1]), o[2]) : i;
82
+ }
83
+ return c;
84
+ }
85
+ var y = C();
86
+ //#endregion
87
+ //#region node_modules/@vitest/pretty-format/dist/index.js
88
+ function _mergeNamespaces(n, m) {
89
+ m.forEach(function(e) {
90
+ e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
91
+ if (k !== "default" && !(k in n)) {
92
+ var d = Object.getOwnPropertyDescriptor(e, k);
93
+ Object.defineProperty(n, k, d.get ? d : {
94
+ enumerable: true,
95
+ get: function() {
96
+ return e[k];
97
+ }
98
+ });
99
+ }
100
+ });
101
+ });
102
+ return Object.freeze(n);
103
+ }
104
+ function getKeysOfEnumerableProperties(object, compareKeys) {
105
+ const rawKeys = Object.keys(object);
106
+ const keys = compareKeys === null ? rawKeys : rawKeys.sort(compareKeys);
107
+ if (Object.getOwnPropertySymbols) {
108
+ for (const symbol of Object.getOwnPropertySymbols(object)) if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) keys.push(symbol);
109
+ }
110
+ return keys;
111
+ }
112
+ /**
113
+ * Return entries (for example, of a map)
114
+ * with spacing, indentation, and comma
115
+ * without surrounding punctuation (for example, braces)
116
+ */
117
+ function printIteratorEntries(iterator, config, indentation, depth, refs, printer, separator = ": ") {
118
+ let result = "";
119
+ let width = 0;
120
+ let current = iterator.next();
121
+ if (!current.done) {
122
+ result += config.spacingOuter;
123
+ const indentationNext = indentation + config.indent;
124
+ while (!current.done) {
125
+ result += indentationNext;
126
+ if (width++ === config.maxWidth) {
127
+ result += "…";
128
+ break;
129
+ }
130
+ const name = printer(current.value[0], config, indentationNext, depth, refs);
131
+ const value = printer(current.value[1], config, indentationNext, depth, refs);
132
+ result += name + separator + value;
133
+ current = iterator.next();
134
+ if (!current.done) result += `,${config.spacingInner}`;
135
+ else if (!config.min) result += ",";
136
+ }
137
+ result += config.spacingOuter + indentation;
138
+ }
139
+ return result;
140
+ }
141
+ /**
142
+ * Return values (for example, of a set)
143
+ * with spacing, indentation, and comma
144
+ * without surrounding punctuation (braces or brackets)
145
+ */
146
+ function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
147
+ let result = "";
148
+ let width = 0;
149
+ let current = iterator.next();
150
+ if (!current.done) {
151
+ result += config.spacingOuter;
152
+ const indentationNext = indentation + config.indent;
153
+ while (!current.done) {
154
+ result += indentationNext;
155
+ if (width++ === config.maxWidth) {
156
+ result += "…";
157
+ break;
158
+ }
159
+ result += printer(current.value, config, indentationNext, depth, refs);
160
+ current = iterator.next();
161
+ if (!current.done) result += `,${config.spacingInner}`;
162
+ else if (!config.min) result += ",";
163
+ }
164
+ result += config.spacingOuter + indentation;
165
+ }
166
+ return result;
167
+ }
168
+ /**
169
+ * Return items (for example, of an array)
170
+ * with spacing, indentation, and comma
171
+ * without surrounding punctuation (for example, brackets)
172
+ */
173
+ function printListItems(list, config, indentation, depth, refs, printer) {
174
+ let result = "";
175
+ list = list instanceof ArrayBuffer ? new DataView(list) : list;
176
+ const isDataView = (l) => l instanceof DataView;
177
+ const length = isDataView(list) ? list.byteLength : list.length;
178
+ if (length > 0) {
179
+ result += config.spacingOuter;
180
+ const indentationNext = indentation + config.indent;
181
+ for (let i = 0; i < length; i++) {
182
+ result += indentationNext;
183
+ if (i === config.maxWidth) {
184
+ result += "…";
185
+ break;
186
+ }
187
+ if (isDataView(list) || i in list) result += printer(isDataView(list) ? list.getInt8(i) : list[i], config, indentationNext, depth, refs);
188
+ if (i < length - 1) result += `,${config.spacingInner}`;
189
+ else if (!config.min) result += ",";
190
+ }
191
+ result += config.spacingOuter + indentation;
192
+ }
193
+ return result;
194
+ }
195
+ /**
196
+ * Return properties of an object
197
+ * with spacing, indentation, and comma
198
+ * without surrounding punctuation (for example, braces)
199
+ */
200
+ function printObjectProperties(val, config, indentation, depth, refs, printer) {
201
+ let result = "";
202
+ const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
203
+ if (keys.length > 0) {
204
+ result += config.spacingOuter;
205
+ const indentationNext = indentation + config.indent;
206
+ for (let i = 0; i < keys.length; i++) {
207
+ const key = keys[i];
208
+ const name = printer(key, config, indentationNext, depth, refs);
209
+ const value = printer(val[key], config, indentationNext, depth, refs);
210
+ result += `${indentationNext + name}: ${value}`;
211
+ if (i < keys.length - 1) result += `,${config.spacingInner}`;
212
+ else if (!config.min) result += ",";
213
+ }
214
+ result += config.spacingOuter + indentation;
215
+ }
216
+ return result;
217
+ }
218
+ const asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? Symbol.for("jest.asymmetricMatcher") : 1267621;
219
+ const SPACE$2 = " ";
220
+ const serialize$5 = (val, config, indentation, depth, refs, printer) => {
221
+ const stringedValue = val.toString();
222
+ if (stringedValue === "ArrayContaining" || stringedValue === "ArrayNotContaining") {
223
+ if (++depth > config.maxDepth) return `[${stringedValue}]`;
224
+ return `${stringedValue + SPACE$2}[${printListItems(val.sample, config, indentation, depth, refs, printer)}]`;
225
+ }
226
+ if (stringedValue === "ObjectContaining" || stringedValue === "ObjectNotContaining") {
227
+ if (++depth > config.maxDepth) return `[${stringedValue}]`;
228
+ return `${stringedValue + SPACE$2}{${printObjectProperties(val.sample, config, indentation, depth, refs, printer)}}`;
229
+ }
230
+ if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
231
+ if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
232
+ if (typeof val.toAsymmetricMatcher !== "function") throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
233
+ return val.toAsymmetricMatcher();
234
+ };
235
+ const test$5 = (val) => val && val.$$typeof === asymmetricMatcher;
236
+ const plugin$5 = {
237
+ serialize: serialize$5,
238
+ test: test$5
239
+ };
240
+ const SPACE$1 = " ";
241
+ const OBJECT_NAMES = new Set(["DOMStringMap", "NamedNodeMap"]);
242
+ const ARRAY_REGEXP = /^(?:HTML\w*Collection|NodeList)$/;
243
+ function testName(name) {
244
+ return OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name);
245
+ }
246
+ const test$4 = (val) => val && val.constructor && !!val.constructor.name && testName(val.constructor.name);
247
+ function isNamedNodeMap(collection) {
248
+ return collection.constructor.name === "NamedNodeMap";
249
+ }
250
+ const serialize$4 = (collection, config, indentation, depth, refs, printer) => {
251
+ const name = collection.constructor.name;
252
+ if (++depth > config.maxDepth) return `[${name}]`;
253
+ return (config.min ? "" : name + SPACE$1) + (OBJECT_NAMES.has(name) ? `{${printObjectProperties(isNamedNodeMap(collection) ? [...collection].reduce((props, attribute) => {
254
+ props[attribute.name] = attribute.value;
255
+ return props;
256
+ }, {}) : { ...collection }, config, indentation, depth, refs, printer)}}` : `[${printListItems([...collection], config, indentation, depth, refs, printer)}]`);
257
+ };
258
+ const plugin$4 = {
259
+ serialize: serialize$4,
260
+ test: test$4
261
+ };
262
+ /**
263
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
264
+ *
265
+ * This source code is licensed under the MIT license found in the
266
+ * LICENSE file in the root directory of this source tree.
267
+ */
268
+ function escapeHTML(str) {
269
+ return str.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
270
+ }
271
+ function printProps(keys, props, config, indentation, depth, refs, printer) {
272
+ const indentationNext = indentation + config.indent;
273
+ const colors = config.colors;
274
+ return keys.map((key) => {
275
+ const value = props[key];
276
+ if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) return "";
277
+ let printed = printer(value, config, indentationNext, depth, refs);
278
+ if (typeof value !== "string") {
279
+ if (printed.includes("\n")) printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
280
+ printed = `{${printed}}`;
281
+ }
282
+ return `${config.spacingInner + indentation + colors.prop.open + key + colors.prop.close}=${colors.value.open}${printed}${colors.value.close}`;
283
+ }).join("");
284
+ }
285
+ function printChildren(children, config, indentation, depth, refs, printer) {
286
+ return children.map((child) => config.spacingOuter + indentation + (typeof child === "string" ? printText(child, config) : printer(child, config, indentation, depth, refs))).join("");
287
+ }
288
+ function printShadowRoot(children, config, indentation, depth, refs, printer) {
289
+ if (config.printShadowRoot === false) return "";
290
+ return [`${config.spacingOuter + indentation}#shadow-root`, printChildren(children, config, indentation + config.indent, depth, refs, printer)].join("");
291
+ }
292
+ function printText(text, config) {
293
+ const contentColor = config.colors.content;
294
+ return contentColor.open + escapeHTML(text) + contentColor.close;
295
+ }
296
+ function printComment(comment, config) {
297
+ const commentColor = config.colors.comment;
298
+ return `${commentColor.open}<!--${escapeHTML(comment)}-->${commentColor.close}`;
299
+ }
300
+ function printElement(type, printedProps, printedChildren, config, indentation) {
301
+ const tagColor = config.colors.tag;
302
+ return `${tagColor.open}<${type}${printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open}${printedChildren ? `>${tagColor.close}${printedChildren}${config.spacingOuter}${indentation}${tagColor.open}</${type}` : `${printedProps && !config.min ? "" : " "}/`}>${tagColor.close}`;
303
+ }
304
+ function printElementAsLeaf(type, config) {
305
+ const tagColor = config.colors.tag;
306
+ return `${tagColor.open}<${type}${tagColor.close} …${tagColor.open} />${tagColor.close}`;
307
+ }
308
+ const ELEMENT_NODE = 1;
309
+ const TEXT_NODE = 3;
310
+ const COMMENT_NODE = 8;
311
+ const FRAGMENT_NODE = 11;
312
+ const ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/;
313
+ function testHasAttribute(val) {
314
+ try {
315
+ return typeof val.hasAttribute === "function" && val.hasAttribute("is");
316
+ } catch {
317
+ return false;
318
+ }
319
+ }
320
+ function testNode(val) {
321
+ const constructorName = val.constructor.name;
322
+ const { nodeType, tagName } = val;
323
+ const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val);
324
+ return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment";
325
+ }
326
+ const test$3 = (val) => val?.constructor?.name && testNode(val);
327
+ function nodeIsText(node) {
328
+ return node.nodeType === TEXT_NODE;
329
+ }
330
+ function nodeIsComment(node) {
331
+ return node.nodeType === COMMENT_NODE;
332
+ }
333
+ function nodeIsFragment(node) {
334
+ return node.nodeType === FRAGMENT_NODE;
335
+ }
336
+ function filterChildren(children, filterNode) {
337
+ let filtered = children.filter((node) => {
338
+ if (node.nodeType === TEXT_NODE) return (node.data || "").trim().length > 0;
339
+ return true;
340
+ });
341
+ if (filterNode) filtered = filtered.filter(filterNode);
342
+ return filtered;
343
+ }
344
+ function serializeDOM(node, config, indentation, depth, refs, printer, filterNode) {
345
+ if (nodeIsText(node)) return printText(node.data, config);
346
+ if (nodeIsComment(node)) return printComment(node.data, config);
347
+ const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
348
+ if (++depth > config.maxDepth) return printElementAsLeaf(type, config);
349
+ const children = Array.prototype.slice.call(node.childNodes || node.children);
350
+ const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
351
+ const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children;
352
+ const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren;
353
+ return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
354
+ props[attribute.name] = attribute.value;
355
+ return props;
356
+ }, {}), config, indentation + config.indent, depth, refs, printer), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer), config, indentation);
357
+ }
358
+ const serialize$3 = (node, config, indentation, depth, refs, printer) => serializeDOM(node, config, indentation, depth, refs, printer);
359
+ function createDOMElementFilter(filterNode) {
360
+ return {
361
+ test: test$3,
362
+ serialize: (node, config, indentation, depth, refs, printer) => serializeDOM(node, config, indentation, depth, refs, printer, filterNode)
363
+ };
364
+ }
365
+ const plugin$3 = {
366
+ serialize: serialize$3,
367
+ test: test$3
368
+ };
369
+ const IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
370
+ const IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
371
+ const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
372
+ const IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
373
+ const IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
374
+ const IS_RECORD_SENTINEL = "@@__IMMUTABLE_RECORD__@@";
375
+ const IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
376
+ const IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
377
+ const IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
378
+ const getImmutableName = (name) => `Immutable.${name}`;
379
+ const printAsLeaf = (name) => `[${name}]`;
380
+ const SPACE = " ";
381
+ const LAZY = "…";
382
+ function printImmutableEntries(val, config, indentation, depth, refs, printer, type) {
383
+ return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}{${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer)}}`;
384
+ }
385
+ function getRecordEntries(val) {
386
+ let i = 0;
387
+ return { next() {
388
+ if (i < val._keys.length) {
389
+ const key = val._keys[i++];
390
+ return {
391
+ done: false,
392
+ value: [key, val.get(key)]
393
+ };
394
+ }
395
+ return {
396
+ done: true,
397
+ value: void 0
398
+ };
399
+ } };
400
+ }
401
+ function printImmutableRecord(val, config, indentation, depth, refs, printer) {
402
+ const name = getImmutableName(val._name || "Record");
403
+ return ++depth > config.maxDepth ? printAsLeaf(name) : `${name + SPACE}{${printIteratorEntries(getRecordEntries(val), config, indentation, depth, refs, printer)}}`;
404
+ }
405
+ function printImmutableSeq(val, config, indentation, depth, refs, printer) {
406
+ const name = getImmutableName("Seq");
407
+ if (++depth > config.maxDepth) return printAsLeaf(name);
408
+ if (val[IS_KEYED_SENTINEL]) return `${name + SPACE}{${val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer) : LAZY}}`;
409
+ return `${name + SPACE}[${val._iter || val._array || val._collection || val._iterable ? printIteratorValues(val.values(), config, indentation, depth, refs, printer) : LAZY}]`;
410
+ }
411
+ function printImmutableValues(val, config, indentation, depth, refs, printer, type) {
412
+ return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}[${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}]`;
413
+ }
414
+ const serialize$2 = (val, config, indentation, depth, refs, printer) => {
415
+ if (val[IS_MAP_SENTINEL]) return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? "OrderedMap" : "Map");
416
+ if (val[IS_LIST_SENTINEL]) return printImmutableValues(val, config, indentation, depth, refs, printer, "List");
417
+ if (val[IS_SET_SENTINEL]) return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? "OrderedSet" : "Set");
418
+ if (val[IS_STACK_SENTINEL]) return printImmutableValues(val, config, indentation, depth, refs, printer, "Stack");
419
+ if (val[IS_SEQ_SENTINEL]) return printImmutableSeq(val, config, indentation, depth, refs, printer);
420
+ return printImmutableRecord(val, config, indentation, depth, refs, printer);
421
+ };
422
+ const test$2 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
423
+ const plugin$2 = {
424
+ serialize: serialize$2,
425
+ test: test$2
426
+ };
427
+ function getDefaultExportFromCjs(x) {
428
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
429
+ }
430
+ var reactIs$1 = { exports: {} };
431
+ var reactIs_production = {};
432
+ /**
433
+ * @license React
434
+ * react-is.production.js
435
+ *
436
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
437
+ *
438
+ * This source code is licensed under the MIT license found in the
439
+ * LICENSE file in the root directory of this source tree.
440
+ */
441
+ var hasRequiredReactIs_production;
442
+ function requireReactIs_production() {
443
+ if (hasRequiredReactIs_production) return reactIs_production;
444
+ hasRequiredReactIs_production = 1;
445
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
446
+ function typeOf(object) {
447
+ if ("object" === typeof object && null !== object) {
448
+ var $$typeof = object.$$typeof;
449
+ switch ($$typeof) {
450
+ case REACT_ELEMENT_TYPE: switch (object = object.type, object) {
451
+ case REACT_FRAGMENT_TYPE:
452
+ case REACT_PROFILER_TYPE:
453
+ case REACT_STRICT_MODE_TYPE:
454
+ case REACT_SUSPENSE_TYPE:
455
+ case REACT_SUSPENSE_LIST_TYPE:
456
+ case REACT_VIEW_TRANSITION_TYPE: return object;
457
+ default: switch (object = object && object.$$typeof, object) {
458
+ case REACT_CONTEXT_TYPE:
459
+ case REACT_FORWARD_REF_TYPE:
460
+ case REACT_LAZY_TYPE:
461
+ case REACT_MEMO_TYPE: return object;
462
+ case REACT_CONSUMER_TYPE: return object;
463
+ default: return $$typeof;
464
+ }
465
+ }
466
+ case REACT_PORTAL_TYPE: return $$typeof;
467
+ }
468
+ }
469
+ }
470
+ reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
471
+ reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
472
+ reactIs_production.Element = REACT_ELEMENT_TYPE;
473
+ reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
474
+ reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
475
+ reactIs_production.Lazy = REACT_LAZY_TYPE;
476
+ reactIs_production.Memo = REACT_MEMO_TYPE;
477
+ reactIs_production.Portal = REACT_PORTAL_TYPE;
478
+ reactIs_production.Profiler = REACT_PROFILER_TYPE;
479
+ reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
480
+ reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
481
+ reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
482
+ reactIs_production.isContextConsumer = function(object) {
483
+ return typeOf(object) === REACT_CONSUMER_TYPE;
484
+ };
485
+ reactIs_production.isContextProvider = function(object) {
486
+ return typeOf(object) === REACT_CONTEXT_TYPE;
487
+ };
488
+ reactIs_production.isElement = function(object) {
489
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
490
+ };
491
+ reactIs_production.isForwardRef = function(object) {
492
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
493
+ };
494
+ reactIs_production.isFragment = function(object) {
495
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
496
+ };
497
+ reactIs_production.isLazy = function(object) {
498
+ return typeOf(object) === REACT_LAZY_TYPE;
499
+ };
500
+ reactIs_production.isMemo = function(object) {
501
+ return typeOf(object) === REACT_MEMO_TYPE;
502
+ };
503
+ reactIs_production.isPortal = function(object) {
504
+ return typeOf(object) === REACT_PORTAL_TYPE;
505
+ };
506
+ reactIs_production.isProfiler = function(object) {
507
+ return typeOf(object) === REACT_PROFILER_TYPE;
508
+ };
509
+ reactIs_production.isStrictMode = function(object) {
510
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
511
+ };
512
+ reactIs_production.isSuspense = function(object) {
513
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
514
+ };
515
+ reactIs_production.isSuspenseList = function(object) {
516
+ return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
517
+ };
518
+ reactIs_production.isValidElementType = function(type) {
519
+ return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false;
520
+ };
521
+ reactIs_production.typeOf = typeOf;
522
+ return reactIs_production;
523
+ }
524
+ var hasRequiredReactIs$1;
525
+ function requireReactIs$1() {
526
+ if (hasRequiredReactIs$1) return reactIs$1.exports;
527
+ hasRequiredReactIs$1 = 1;
528
+ reactIs$1.exports = requireReactIs_production();
529
+ return reactIs$1.exports;
530
+ }
531
+ var reactIsExports$1 = requireReactIs$1();
532
+ var ReactIs19 = /* @__PURE__ */ _mergeNamespaces({
533
+ __proto__: null,
534
+ default: /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports$1)
535
+ }, [reactIsExports$1]);
536
+ var reactIs = { exports: {} };
537
+ var reactIs_production_min = {};
538
+ /**
539
+ * @license React
540
+ * react-is.production.min.js
541
+ *
542
+ * Copyright (c) Facebook, Inc. and its affiliates.
543
+ *
544
+ * This source code is licensed under the MIT license found in the
545
+ * LICENSE file in the root directory of this source tree.
546
+ */
547
+ var hasRequiredReactIs_production_min;
548
+ function requireReactIs_production_min() {
549
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
550
+ hasRequiredReactIs_production_min = 1;
551
+ var b = Symbol.for("react.element"), c = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), u = Symbol.for("react.module.reference");
552
+ function v(a) {
553
+ if ("object" === typeof a && null !== a) {
554
+ var r = a.$$typeof;
555
+ switch (r) {
556
+ case b: switch (a = a.type, a) {
557
+ case d:
558
+ case f:
559
+ case e:
560
+ case m:
561
+ case n: return a;
562
+ default: switch (a = a && a.$$typeof, a) {
563
+ case k:
564
+ case h:
565
+ case l:
566
+ case q:
567
+ case p:
568
+ case g: return a;
569
+ default: return r;
570
+ }
571
+ }
572
+ case c: return r;
573
+ }
574
+ }
575
+ }
576
+ reactIs_production_min.ContextConsumer = h;
577
+ reactIs_production_min.ContextProvider = g;
578
+ reactIs_production_min.Element = b;
579
+ reactIs_production_min.ForwardRef = l;
580
+ reactIs_production_min.Fragment = d;
581
+ reactIs_production_min.Lazy = q;
582
+ reactIs_production_min.Memo = p;
583
+ reactIs_production_min.Portal = c;
584
+ reactIs_production_min.Profiler = f;
585
+ reactIs_production_min.StrictMode = e;
586
+ reactIs_production_min.Suspense = m;
587
+ reactIs_production_min.SuspenseList = n;
588
+ reactIs_production_min.isAsyncMode = function() {
589
+ return false;
590
+ };
591
+ reactIs_production_min.isConcurrentMode = function() {
592
+ return false;
593
+ };
594
+ reactIs_production_min.isContextConsumer = function(a) {
595
+ return v(a) === h;
596
+ };
597
+ reactIs_production_min.isContextProvider = function(a) {
598
+ return v(a) === g;
599
+ };
600
+ reactIs_production_min.isElement = function(a) {
601
+ return "object" === typeof a && null !== a && a.$$typeof === b;
602
+ };
603
+ reactIs_production_min.isForwardRef = function(a) {
604
+ return v(a) === l;
605
+ };
606
+ reactIs_production_min.isFragment = function(a) {
607
+ return v(a) === d;
608
+ };
609
+ reactIs_production_min.isLazy = function(a) {
610
+ return v(a) === q;
611
+ };
612
+ reactIs_production_min.isMemo = function(a) {
613
+ return v(a) === p;
614
+ };
615
+ reactIs_production_min.isPortal = function(a) {
616
+ return v(a) === c;
617
+ };
618
+ reactIs_production_min.isProfiler = function(a) {
619
+ return v(a) === f;
620
+ };
621
+ reactIs_production_min.isStrictMode = function(a) {
622
+ return v(a) === e;
623
+ };
624
+ reactIs_production_min.isSuspense = function(a) {
625
+ return v(a) === m;
626
+ };
627
+ reactIs_production_min.isSuspenseList = function(a) {
628
+ return v(a) === n;
629
+ };
630
+ reactIs_production_min.isValidElementType = function(a) {
631
+ return "string" === typeof a || "function" === typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? true : false;
632
+ };
633
+ reactIs_production_min.typeOf = v;
634
+ return reactIs_production_min;
635
+ }
636
+ var hasRequiredReactIs;
637
+ function requireReactIs() {
638
+ if (hasRequiredReactIs) return reactIs.exports;
639
+ hasRequiredReactIs = 1;
640
+ reactIs.exports = requireReactIs_production_min();
641
+ return reactIs.exports;
642
+ }
643
+ var reactIsExports = requireReactIs();
644
+ var ReactIs18 = /* @__PURE__ */ _mergeNamespaces({
645
+ __proto__: null,
646
+ default: /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports)
647
+ }, [reactIsExports]);
648
+ const ReactIs = Object.fromEntries([
649
+ "isAsyncMode",
650
+ "isConcurrentMode",
651
+ "isContextConsumer",
652
+ "isContextProvider",
653
+ "isElement",
654
+ "isForwardRef",
655
+ "isFragment",
656
+ "isLazy",
657
+ "isMemo",
658
+ "isPortal",
659
+ "isProfiler",
660
+ "isStrictMode",
661
+ "isSuspense",
662
+ "isSuspenseList",
663
+ "isValidElementType"
664
+ ].map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
665
+ function getChildren(arg, children = []) {
666
+ if (Array.isArray(arg)) for (const item of arg) getChildren(item, children);
667
+ else if (arg != null && arg !== false && arg !== "") children.push(arg);
668
+ return children;
669
+ }
670
+ function getType(element) {
671
+ const type = element.type;
672
+ if (typeof type === "string") return type;
673
+ if (typeof type === "function") return type.displayName || type.name || "Unknown";
674
+ if (ReactIs.isFragment(element)) return "React.Fragment";
675
+ if (ReactIs.isSuspense(element)) return "React.Suspense";
676
+ if (typeof type === "object" && type !== null) {
677
+ if (ReactIs.isContextProvider(element)) return "Context.Provider";
678
+ if (ReactIs.isContextConsumer(element)) return "Context.Consumer";
679
+ if (ReactIs.isForwardRef(element)) {
680
+ if (type.displayName) return type.displayName;
681
+ const functionName = type.render.displayName || type.render.name || "";
682
+ return functionName === "" ? "ForwardRef" : `ForwardRef(${functionName})`;
683
+ }
684
+ if (ReactIs.isMemo(element)) {
685
+ const functionName = type.displayName || type.type.displayName || type.type.name || "";
686
+ return functionName === "" ? "Memo" : `Memo(${functionName})`;
687
+ }
688
+ }
689
+ return "UNDEFINED";
690
+ }
691
+ function getPropKeys$1(element) {
692
+ const { props } = element;
693
+ return Object.keys(props).filter((key) => key !== "children" && props[key] !== void 0).sort();
694
+ }
695
+ const serialize$1 = (element, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(getPropKeys$1(element), element.props, config, indentation + config.indent, depth, refs, printer), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
696
+ const test$1 = (val) => val != null && ReactIs.isElement(val);
697
+ const plugin$1 = {
698
+ serialize: serialize$1,
699
+ test: test$1
700
+ };
701
+ const testSymbol = typeof Symbol === "function" && Symbol.for ? Symbol.for("react.test.json") : 245830487;
702
+ function getPropKeys(object) {
703
+ const { props } = object;
704
+ return props ? Object.keys(props).filter((key) => props[key] !== void 0).sort() : [];
705
+ }
706
+ const serialize = (object, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer) : "", object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer) : "", config, indentation);
707
+ const test$6 = (val) => val && val.$$typeof === testSymbol;
708
+ const plugin = {
709
+ serialize,
710
+ test: test$6
711
+ };
712
+ const toString$1 = Object.prototype.toString;
713
+ const toISOString = Date.prototype.toISOString;
714
+ const errorToString = Error.prototype.toString;
715
+ const regExpToString = RegExp.prototype.toString;
716
+ /**
717
+ * Explicitly comparing typeof constructor to function avoids undefined as name
718
+ * when mock identity-obj-proxy returns the key as the value for any key.
719
+ */
720
+ function getConstructorName(val) {
721
+ return typeof val.constructor === "function" && val.constructor.name || "Object";
722
+ }
723
+ /** Is val is equal to global window object? Works even if it does not exist :) */
724
+ function isWindow(val) {
725
+ return typeof window !== "undefined" && val === window;
726
+ }
727
+ const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
728
+ const NEWLINE_REGEXP = /\n/g;
729
+ var PrettyFormatPluginError = class extends Error {
730
+ constructor(message, stack) {
731
+ super(message);
732
+ this.stack = stack;
733
+ this.name = this.constructor.name;
734
+ }
735
+ };
736
+ function isToStringedArrayType(toStringed) {
737
+ return toStringed === "[object Array]" || toStringed === "[object ArrayBuffer]" || toStringed === "[object DataView]" || toStringed === "[object Float32Array]" || toStringed === "[object Float64Array]" || toStringed === "[object Int8Array]" || toStringed === "[object Int16Array]" || toStringed === "[object Int32Array]" || toStringed === "[object Uint8Array]" || toStringed === "[object Uint8ClampedArray]" || toStringed === "[object Uint16Array]" || toStringed === "[object Uint32Array]";
738
+ }
739
+ function printNumber(val) {
740
+ return Object.is(val, -0) ? "-0" : String(val);
741
+ }
742
+ function printBigInt(val) {
743
+ return String(`${val}n`);
744
+ }
745
+ function printFunction(val, printFunctionName) {
746
+ if (!printFunctionName) return "[Function]";
747
+ return `[Function ${val.name || "anonymous"}]`;
748
+ }
749
+ function printSymbol(val) {
750
+ return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
751
+ }
752
+ function printError(val) {
753
+ return `[${errorToString.call(val)}]`;
754
+ }
755
+ /**
756
+ * The first port of call for printing an object, handles most of the
757
+ * data-types in JS.
758
+ */
759
+ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
760
+ if (val === true || val === false) return `${val}`;
761
+ if (val === void 0) return "undefined";
762
+ if (val === null) return "null";
763
+ const typeOf = typeof val;
764
+ if (typeOf === "number") return printNumber(val);
765
+ if (typeOf === "bigint") return printBigInt(val);
766
+ if (typeOf === "string") {
767
+ if (escapeString) return `"${val.replaceAll(/"|\\/g, "\\$&")}"`;
768
+ return `"${val}"`;
769
+ }
770
+ if (typeOf === "function") return printFunction(val, printFunctionName);
771
+ if (typeOf === "symbol") return printSymbol(val);
772
+ const toStringed = toString$1.call(val);
773
+ if (toStringed === "[object WeakMap]") return "WeakMap {}";
774
+ if (toStringed === "[object WeakSet]") return "WeakSet {}";
775
+ if (toStringed === "[object Function]" || toStringed === "[object GeneratorFunction]") return printFunction(val, printFunctionName);
776
+ if (toStringed === "[object Symbol]") return printSymbol(val);
777
+ if (toStringed === "[object Date]") return Number.isNaN(+val) ? "Date { NaN }" : toISOString.call(val);
778
+ if (toStringed === "[object Error]") return printError(val);
779
+ if (toStringed === "[object RegExp]") {
780
+ if (escapeRegex) return regExpToString.call(val).replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
781
+ return regExpToString.call(val);
782
+ }
783
+ if (val instanceof Error) return printError(val);
784
+ return null;
785
+ }
786
+ /**
787
+ * Handles more complex objects ( such as objects with circular references.
788
+ * maps and sets etc )
789
+ */
790
+ function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
791
+ if (refs.includes(val)) return "[Circular]";
792
+ refs = [...refs];
793
+ refs.push(val);
794
+ const hitMaxDepth = ++depth > config.maxDepth;
795
+ const min = config.min;
796
+ if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === "function" && !hasCalledToJSON) return printer(val.toJSON(), config, indentation, depth, refs, true);
797
+ const toStringed = toString$1.call(val);
798
+ if (toStringed === "[object Arguments]") return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
799
+ if (isToStringedArrayType(toStringed)) return hitMaxDepth ? `[${val.constructor.name}]` : `${min ? "" : !config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
800
+ if (toStringed === "[object Map]") return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ")}}`;
801
+ if (toStringed === "[object Set]") return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}}`;
802
+ return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${min ? "" : !config.printBasicPrototype && getConstructorName(val) === "Object" ? "" : `${getConstructorName(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
803
+ }
804
+ const ErrorPlugin = {
805
+ test: (val) => val && val instanceof Error,
806
+ serialize(val, config, indentation, depth, refs, printer) {
807
+ if (refs.includes(val)) return "[Circular]";
808
+ refs = [...refs, val];
809
+ const hitMaxDepth = ++depth > config.maxDepth;
810
+ const { message, cause, ...rest } = val;
811
+ const entries = {
812
+ message,
813
+ ...typeof cause !== "undefined" ? { cause } : {},
814
+ ...val instanceof AggregateError ? { errors: val.errors } : {},
815
+ ...rest
816
+ };
817
+ const name = val.name !== "Error" ? val.name : getConstructorName(val);
818
+ return hitMaxDepth ? `[${name}]` : `${name} {${printIteratorEntries(Object.entries(entries).values(), config, indentation, depth, refs, printer)}}`;
819
+ }
820
+ };
821
+ function isNewPlugin(plugin) {
822
+ return plugin.serialize != null;
823
+ }
824
+ function printPlugin(plugin, val, config, indentation, depth, refs) {
825
+ let printed;
826
+ try {
827
+ printed = isNewPlugin(plugin) ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, (valChild) => printer(valChild, config, indentation, depth, refs), (str) => {
828
+ const indentationNext = indentation + config.indent;
829
+ return indentationNext + str.replaceAll(NEWLINE_REGEXP, `\n${indentationNext}`);
830
+ }, {
831
+ edgeSpacing: config.spacingOuter,
832
+ min: config.min,
833
+ spacing: config.spacingInner
834
+ }, config.colors);
835
+ } catch (error) {
836
+ throw new PrettyFormatPluginError(error.message, error.stack);
837
+ }
838
+ if (typeof printed !== "string") throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
839
+ return printed;
840
+ }
841
+ function findPlugin(plugins, val) {
842
+ for (const plugin of plugins) try {
843
+ if (plugin.test(val)) return plugin;
844
+ } catch (error) {
845
+ throw new PrettyFormatPluginError(error.message, error.stack);
846
+ }
847
+ return null;
848
+ }
849
+ function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
850
+ let result;
851
+ const plugin = findPlugin(config.plugins, val);
852
+ if (plugin !== null) result = printPlugin(plugin, val, config, indentation, depth, refs);
853
+ else {
854
+ const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
855
+ if (basicResult !== null) result = basicResult;
856
+ else result = printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
857
+ }
858
+ config._outputLengthPerDepth[depth] ??= 0;
859
+ config._outputLengthPerDepth[depth] += result.length;
860
+ if (config._outputLengthPerDepth[depth] > config.maxOutputLength) config.maxDepth = 0;
861
+ return result;
862
+ }
863
+ const DEFAULT_THEME = {
864
+ comment: "gray",
865
+ content: "reset",
866
+ prop: "yellow",
867
+ tag: "cyan",
868
+ value: "green"
869
+ };
870
+ const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
871
+ const DEFAULT_OPTIONS = {
872
+ callToJSON: true,
873
+ compareKeys: void 0,
874
+ escapeRegex: false,
875
+ escapeString: true,
876
+ highlight: false,
877
+ indent: 2,
878
+ maxDepth: Number.POSITIVE_INFINITY,
879
+ maxOutputLength: 1e6,
880
+ maxWidth: Number.POSITIVE_INFINITY,
881
+ min: false,
882
+ plugins: [],
883
+ printBasicPrototype: true,
884
+ printFunctionName: true,
885
+ printShadowRoot: true,
886
+ theme: DEFAULT_THEME
887
+ };
888
+ function validateOptions(options) {
889
+ for (const key of Object.keys(options)) if (!Object.hasOwn(DEFAULT_OPTIONS, key)) throw new Error(`pretty-format: Unknown option "${key}".`);
890
+ if (options.min && options.indent !== void 0 && options.indent !== 0) throw new Error("pretty-format: Options \"min\" and \"indent\" cannot be used together.");
891
+ }
892
+ function getColorsHighlight() {
893
+ return DEFAULT_THEME_KEYS.reduce((colors, key) => {
894
+ const value = DEFAULT_THEME[key];
895
+ const color = value && y[value];
896
+ if (color && typeof color.close === "string" && typeof color.open === "string") colors[key] = color;
897
+ else throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
898
+ return colors;
899
+ }, Object.create(null));
900
+ }
901
+ function getColorsEmpty() {
902
+ return DEFAULT_THEME_KEYS.reduce((colors, key) => {
903
+ colors[key] = {
904
+ close: "",
905
+ open: ""
906
+ };
907
+ return colors;
908
+ }, Object.create(null));
909
+ }
910
+ function getPrintFunctionName(options) {
911
+ return options?.printFunctionName ?? DEFAULT_OPTIONS.printFunctionName;
912
+ }
913
+ function getEscapeRegex(options) {
914
+ return options?.escapeRegex ?? DEFAULT_OPTIONS.escapeRegex;
915
+ }
916
+ function getEscapeString(options) {
917
+ return options?.escapeString ?? DEFAULT_OPTIONS.escapeString;
918
+ }
919
+ function getConfig(options) {
920
+ return {
921
+ callToJSON: options?.callToJSON ?? DEFAULT_OPTIONS.callToJSON,
922
+ colors: options?.highlight ? getColorsHighlight() : getColorsEmpty(),
923
+ compareKeys: typeof options?.compareKeys === "function" || options?.compareKeys === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
924
+ escapeRegex: getEscapeRegex(options),
925
+ escapeString: getEscapeString(options),
926
+ indent: options?.min ? "" : createIndent(options?.indent ?? DEFAULT_OPTIONS.indent),
927
+ maxDepth: options?.maxDepth ?? DEFAULT_OPTIONS.maxDepth,
928
+ maxWidth: options?.maxWidth ?? DEFAULT_OPTIONS.maxWidth,
929
+ min: options?.min ?? DEFAULT_OPTIONS.min,
930
+ plugins: options?.plugins ?? DEFAULT_OPTIONS.plugins,
931
+ printBasicPrototype: options?.printBasicPrototype ?? true,
932
+ printFunctionName: getPrintFunctionName(options),
933
+ printShadowRoot: options?.printShadowRoot ?? true,
934
+ spacingInner: options?.min ? " " : "\n",
935
+ spacingOuter: options?.min ? "" : "\n",
936
+ maxOutputLength: options?.maxOutputLength ?? DEFAULT_OPTIONS.maxOutputLength,
937
+ _outputLengthPerDepth: []
938
+ };
939
+ }
940
+ function createIndent(indent) {
941
+ return Array.from({ length: indent + 1 }).join(" ");
942
+ }
943
+ /**
944
+ * Returns a presentation string of your `val` object
945
+ * @param val any potential JavaScript object
946
+ * @param options Custom settings
947
+ */
948
+ function format$1(val, options) {
949
+ if (options) {
950
+ validateOptions(options);
951
+ if (options.plugins) {
952
+ const plugin = findPlugin(options.plugins, val);
953
+ if (plugin !== null) return printPlugin(plugin, val, getConfig(options), "", 0, []);
954
+ }
955
+ }
956
+ const basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options), getEscapeString(options));
957
+ if (basicResult !== null) return basicResult;
958
+ return printComplexValue(val, getConfig(options), "", 0, []);
959
+ }
960
+ const plugins = {
961
+ AsymmetricMatcher: plugin$5,
962
+ DOMCollection: plugin$4,
963
+ DOMElement: plugin$3,
964
+ Immutable: plugin$2,
965
+ ReactElement: plugin$1,
966
+ ReactTestComponent: plugin,
967
+ Error: ErrorPlugin
968
+ };
969
+ //#endregion
970
+ //#region node_modules/@vitest/utils/dist/display.js
971
+ const ansiColors = {
972
+ bold: ["1", "22"],
973
+ dim: ["2", "22"],
974
+ italic: ["3", "23"],
975
+ underline: ["4", "24"],
976
+ inverse: ["7", "27"],
977
+ hidden: ["8", "28"],
978
+ strike: ["9", "29"],
979
+ black: ["30", "39"],
980
+ red: ["31", "39"],
981
+ green: ["32", "39"],
982
+ yellow: ["33", "39"],
983
+ blue: ["34", "39"],
984
+ magenta: ["35", "39"],
985
+ cyan: ["36", "39"],
986
+ white: ["37", "39"],
987
+ brightblack: ["30;1", "39"],
988
+ brightred: ["31;1", "39"],
989
+ brightgreen: ["32;1", "39"],
990
+ brightyellow: ["33;1", "39"],
991
+ brightblue: ["34;1", "39"],
992
+ brightmagenta: ["35;1", "39"],
993
+ brightcyan: ["36;1", "39"],
994
+ brightwhite: ["37;1", "39"],
995
+ grey: ["90", "39"]
996
+ };
997
+ const styles = {
998
+ special: "cyan",
999
+ number: "yellow",
1000
+ bigint: "yellow",
1001
+ boolean: "yellow",
1002
+ undefined: "grey",
1003
+ null: "bold",
1004
+ string: "green",
1005
+ symbol: "green",
1006
+ date: "magenta",
1007
+ regexp: "red"
1008
+ };
1009
+ const truncator = "…";
1010
+ function colorise(value, styleType) {
1011
+ const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
1012
+ if (!color) return String(value);
1013
+ return `\u001b[${color[0]}m${String(value)}\u001b[${color[1]}m`;
1014
+ }
1015
+ function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = Infinity, breakLength = Infinity, seen = [], truncate = Infinity, stylize = String } = {}, inspect) {
1016
+ const options = {
1017
+ showHidden: Boolean(showHidden),
1018
+ depth: Number(depth),
1019
+ colors: Boolean(colors),
1020
+ customInspect: Boolean(customInspect),
1021
+ showProxy: Boolean(showProxy),
1022
+ maxArrayLength: Number(maxArrayLength),
1023
+ breakLength: Number(breakLength),
1024
+ truncate: Number(truncate),
1025
+ seen,
1026
+ inspect,
1027
+ stylize
1028
+ };
1029
+ if (options.colors) options.stylize = colorise;
1030
+ return options;
1031
+ }
1032
+ function isHighSurrogate(char) {
1033
+ return char >= "\ud800" && char <= "\udbff";
1034
+ }
1035
+ function truncate(string, length, tail = truncator) {
1036
+ string = String(string);
1037
+ const tailLength = tail.length;
1038
+ const stringLength = string.length;
1039
+ if (tailLength > length && stringLength > tailLength) return tail;
1040
+ if (stringLength > length && stringLength > tailLength) {
1041
+ let end = length - tailLength;
1042
+ if (end > 0 && isHighSurrogate(string[end - 1])) end = end - 1;
1043
+ return `${string.slice(0, end)}${tail}`;
1044
+ }
1045
+ return string;
1046
+ }
1047
+ function inspectList(list, options, inspectItem, separator = ", ") {
1048
+ inspectItem = inspectItem || options.inspect;
1049
+ const size = list.length;
1050
+ if (size === 0) return "";
1051
+ const originalLength = options.truncate;
1052
+ let output = "";
1053
+ let peek = "";
1054
+ let truncated = "";
1055
+ for (let i = 0; i < size; i += 1) {
1056
+ const last = i + 1 === list.length;
1057
+ const secondToLast = i + 2 === list.length;
1058
+ truncated = `${truncator}(${list.length - i})`;
1059
+ const value = list[i];
1060
+ options.truncate = originalLength - output.length - (last ? 0 : separator.length);
1061
+ const string = peek || inspectItem(value, options) + (last ? "" : separator);
1062
+ const nextLength = output.length + string.length;
1063
+ const truncatedLength = nextLength + truncated.length;
1064
+ if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) break;
1065
+ if (!last && !secondToLast && truncatedLength > originalLength) break;
1066
+ peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
1067
+ if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) break;
1068
+ output += string;
1069
+ if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
1070
+ truncated = `${truncator}(${list.length - i - 1})`;
1071
+ break;
1072
+ }
1073
+ truncated = "";
1074
+ }
1075
+ return `${output}${truncated}`;
1076
+ }
1077
+ function quoteComplexKey(key) {
1078
+ if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) return key;
1079
+ return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
1080
+ }
1081
+ function inspectProperty([key, value], options) {
1082
+ options.truncate -= 2;
1083
+ if (typeof key === "string") key = quoteComplexKey(key);
1084
+ else if (typeof key !== "number") key = `[${options.inspect(key, options)}]`;
1085
+ options.truncate -= key.length;
1086
+ value = options.inspect(value, options);
1087
+ return `${key}: ${value}`;
1088
+ }
1089
+ function inspectArray(array, options) {
1090
+ const nonIndexProperties = Object.keys(array).slice(array.length);
1091
+ if (!array.length && !nonIndexProperties.length) return "[]";
1092
+ options.truncate -= 4;
1093
+ const listContents = inspectList(array, options);
1094
+ options.truncate -= listContents.length;
1095
+ let propertyContents = "";
1096
+ if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
1097
+ return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
1098
+ }
1099
+ const getArrayName = (array) => {
1100
+ if (typeof Buffer === "function" && array instanceof Buffer) return "Buffer";
1101
+ if (array[Symbol.toStringTag]) return array[Symbol.toStringTag];
1102
+ return array.constructor.name;
1103
+ };
1104
+ function inspectTypedArray(array, options) {
1105
+ const name = getArrayName(array);
1106
+ options.truncate -= name.length + 4;
1107
+ const nonIndexProperties = Object.keys(array).slice(array.length);
1108
+ if (!array.length && !nonIndexProperties.length) return `${name}[]`;
1109
+ let output = "";
1110
+ for (let i = 0; i < array.length; i++) {
1111
+ const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
1112
+ options.truncate -= string.length;
1113
+ if (array[i] !== array.length && options.truncate <= 3) {
1114
+ output += `${truncator}(${array.length - array[i] + 1})`;
1115
+ break;
1116
+ }
1117
+ output += string;
1118
+ }
1119
+ let propertyContents = "";
1120
+ if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
1121
+ return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
1122
+ }
1123
+ function inspectDate(dateObject, options) {
1124
+ const stringRepresentation = dateObject.toJSON();
1125
+ if (stringRepresentation === null) return "Invalid Date";
1126
+ const split = stringRepresentation.split("T");
1127
+ const date = split[0];
1128
+ return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
1129
+ }
1130
+ function inspectFunction(func, options) {
1131
+ const functionType = func[Symbol.toStringTag] || "Function";
1132
+ const name = func.name;
1133
+ if (!name) return options.stylize(`[${functionType}]`, "special");
1134
+ return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
1135
+ }
1136
+ function inspectMapEntry([key, value], options) {
1137
+ options.truncate -= 4;
1138
+ key = options.inspect(key, options);
1139
+ options.truncate -= key.length;
1140
+ value = options.inspect(value, options);
1141
+ return `${key} => ${value}`;
1142
+ }
1143
+ function mapToEntries(map) {
1144
+ const entries = [];
1145
+ map.forEach((value, key) => {
1146
+ entries.push([key, value]);
1147
+ });
1148
+ return entries;
1149
+ }
1150
+ function inspectMap(map, options) {
1151
+ if (map.size === 0) return "Map{}";
1152
+ options.truncate -= 7;
1153
+ return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
1154
+ }
1155
+ const isNaN = Number.isNaN || ((i) => i !== i);
1156
+ function inspectNumber(number, options) {
1157
+ if (isNaN(number)) return options.stylize("NaN", "number");
1158
+ if (number === Infinity) return options.stylize("Infinity", "number");
1159
+ if (number === -Infinity) return options.stylize("-Infinity", "number");
1160
+ if (number === 0) return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
1161
+ return options.stylize(truncate(String(number), options.truncate), "number");
1162
+ }
1163
+ function inspectBigInt(number, options) {
1164
+ let nums = truncate(number.toString(), options.truncate - 1);
1165
+ if (nums !== truncator) nums += "n";
1166
+ return options.stylize(nums, "bigint");
1167
+ }
1168
+ function inspectRegExp(value, options) {
1169
+ const flags = value.toString().split("/")[2];
1170
+ const sourceLength = options.truncate - (2 + flags.length);
1171
+ const source = value.source;
1172
+ return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
1173
+ }
1174
+ function arrayFromSet(set) {
1175
+ const values = [];
1176
+ set.forEach((value) => {
1177
+ values.push(value);
1178
+ });
1179
+ return values;
1180
+ }
1181
+ function inspectSet(set, options) {
1182
+ if (set.size === 0) return "Set{}";
1183
+ options.truncate -= 7;
1184
+ return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
1185
+ }
1186
+ const stringEscapeChars = /* @__PURE__ */ new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
1187
+ const escapeCharacters = {
1188
+ "\b": "\\b",
1189
+ " ": "\\t",
1190
+ "\n": "\\n",
1191
+ "\f": "\\f",
1192
+ "\r": "\\r",
1193
+ "'": "\\'",
1194
+ "\\": "\\\\"
1195
+ };
1196
+ const hex = 16;
1197
+ function escape(char) {
1198
+ return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
1199
+ }
1200
+ function inspectString(string, options) {
1201
+ if (stringEscapeChars.test(string)) string = string.replace(stringEscapeChars, escape);
1202
+ return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
1203
+ }
1204
+ function inspectSymbol(value) {
1205
+ if ("description" in Symbol.prototype) return value.description ? `Symbol(${value.description})` : "Symbol()";
1206
+ return value.toString();
1207
+ }
1208
+ const getPromiseValue = () => "Promise{…}";
1209
+ function inspectObject$1(object, options) {
1210
+ const properties = Object.getOwnPropertyNames(object);
1211
+ const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
1212
+ if (properties.length === 0 && symbols.length === 0) return "{}";
1213
+ options.truncate -= 4;
1214
+ options.seen = options.seen || [];
1215
+ if (options.seen.includes(object)) return "[Circular]";
1216
+ options.seen.push(object);
1217
+ const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
1218
+ const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
1219
+ options.seen.pop();
1220
+ let sep = "";
1221
+ if (propertyContents && symbolContents) sep = ", ";
1222
+ return `{ ${propertyContents}${sep}${symbolContents} }`;
1223
+ }
1224
+ const toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
1225
+ function inspectClass(value, options) {
1226
+ let name = "";
1227
+ if (toStringTag && toStringTag in value) name = value[toStringTag];
1228
+ name = name || value.constructor.name;
1229
+ if (!name || name === "_class") name = "<Anonymous Class>";
1230
+ options.truncate -= name.length;
1231
+ return `${name}${inspectObject$1(value, options)}`;
1232
+ }
1233
+ function inspectArguments(args, options) {
1234
+ if (args.length === 0) return "Arguments[]";
1235
+ options.truncate -= 13;
1236
+ return `Arguments[ ${inspectList(args, options)} ]`;
1237
+ }
1238
+ const errorKeys = [
1239
+ "stack",
1240
+ "line",
1241
+ "column",
1242
+ "name",
1243
+ "message",
1244
+ "fileName",
1245
+ "lineNumber",
1246
+ "columnNumber",
1247
+ "number",
1248
+ "description",
1249
+ "cause"
1250
+ ];
1251
+ function inspectObject(error, options) {
1252
+ const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
1253
+ const name = error.name;
1254
+ options.truncate -= name.length;
1255
+ let message = "";
1256
+ if (typeof error.message === "string") message = truncate(error.message, options.truncate);
1257
+ else properties.unshift("message");
1258
+ message = message ? `: ${message}` : "";
1259
+ options.truncate -= message.length + 5;
1260
+ options.seen = options.seen || [];
1261
+ if (options.seen.includes(error)) return "[Circular]";
1262
+ options.seen.push(error);
1263
+ const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
1264
+ return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
1265
+ }
1266
+ function inspectAttribute([key, value], options) {
1267
+ options.truncate -= 3;
1268
+ if (!value) return `${options.stylize(String(key), "yellow")}`;
1269
+ return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
1270
+ }
1271
+ function inspectNodeCollection(collection, options) {
1272
+ return inspectList(collection, options, inspectNode, "\n");
1273
+ }
1274
+ function inspectNode(node, options) {
1275
+ switch (node.nodeType) {
1276
+ case 1: return inspectHTML(node, options);
1277
+ case 3: return options.inspect(node.data, options);
1278
+ default: return options.inspect(node, options);
1279
+ }
1280
+ }
1281
+ function inspectHTML(element, options) {
1282
+ const properties = element.getAttributeNames();
1283
+ const name = element.tagName.toLowerCase();
1284
+ const head = options.stylize(`<${name}`, "special");
1285
+ const headClose = options.stylize(`>`, "special");
1286
+ const tail = options.stylize(`</${name}>`, "special");
1287
+ options.truncate -= name.length * 2 + 5;
1288
+ let propertyContents = "";
1289
+ if (properties.length > 0) {
1290
+ propertyContents += " ";
1291
+ propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
1292
+ }
1293
+ options.truncate -= propertyContents.length;
1294
+ const truncate = options.truncate;
1295
+ let children = inspectNodeCollection(element.children, options);
1296
+ if (children && children.length > truncate) children = `${truncator}(${element.children.length})`;
1297
+ return `${head}${propertyContents}${headClose}${children}${tail}`;
1298
+ }
1299
+ const chaiInspect = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("chai/inspect") : "@@chai/inspect";
1300
+ const nodeInspect = Symbol.for("nodejs.util.inspect.custom");
1301
+ const constructorMap = /* @__PURE__ */ new WeakMap();
1302
+ const stringTagMap = {};
1303
+ const baseTypesMap = {
1304
+ undefined: (value, options) => options.stylize("undefined", "undefined"),
1305
+ null: (value, options) => options.stylize("null", "null"),
1306
+ boolean: (value, options) => options.stylize(String(value), "boolean"),
1307
+ Boolean: (value, options) => options.stylize(String(value), "boolean"),
1308
+ number: inspectNumber,
1309
+ Number: inspectNumber,
1310
+ bigint: inspectBigInt,
1311
+ BigInt: inspectBigInt,
1312
+ string: inspectString,
1313
+ String: inspectString,
1314
+ function: inspectFunction,
1315
+ Function: inspectFunction,
1316
+ symbol: inspectSymbol,
1317
+ Symbol: inspectSymbol,
1318
+ Array: inspectArray,
1319
+ Date: inspectDate,
1320
+ Map: inspectMap,
1321
+ Set: inspectSet,
1322
+ RegExp: inspectRegExp,
1323
+ Promise: getPromiseValue,
1324
+ WeakSet: (value, options) => options.stylize("WeakSet{…}", "special"),
1325
+ WeakMap: (value, options) => options.stylize("WeakMap{…}", "special"),
1326
+ Arguments: inspectArguments,
1327
+ Int8Array: inspectTypedArray,
1328
+ Uint8Array: inspectTypedArray,
1329
+ Uint8ClampedArray: inspectTypedArray,
1330
+ Int16Array: inspectTypedArray,
1331
+ Uint16Array: inspectTypedArray,
1332
+ Int32Array: inspectTypedArray,
1333
+ Uint32Array: inspectTypedArray,
1334
+ Float32Array: inspectTypedArray,
1335
+ Float64Array: inspectTypedArray,
1336
+ Generator: () => "",
1337
+ DataView: () => "",
1338
+ ArrayBuffer: () => "",
1339
+ Error: inspectObject,
1340
+ HTMLCollection: inspectNodeCollection,
1341
+ NodeList: inspectNodeCollection
1342
+ };
1343
+ const inspectCustom = (value, options, type, inspectFn) => {
1344
+ if (chaiInspect in value && typeof value[chaiInspect] === "function") return value[chaiInspect](options);
1345
+ if (nodeInspect in value && typeof value[nodeInspect] === "function") return value[nodeInspect](options.depth, options, inspectFn);
1346
+ if ("inspect" in value && typeof value.inspect === "function") return value.inspect(options.depth, options);
1347
+ if ("constructor" in value && constructorMap.has(value.constructor)) return constructorMap.get(value.constructor)(value, options);
1348
+ if (stringTagMap[type]) return stringTagMap[type](value, options);
1349
+ return "";
1350
+ };
1351
+ const toString = Object.prototype.toString;
1352
+ function inspect$1(value, opts = {}) {
1353
+ const options = normaliseOptions(opts, inspect$1);
1354
+ const { customInspect } = options;
1355
+ let type = value === null ? "null" : typeof value;
1356
+ if (type === "object") type = toString.call(value).slice(8, -1);
1357
+ if (type in baseTypesMap) return baseTypesMap[type](value, options);
1358
+ if (customInspect && value) {
1359
+ const output = inspectCustom(value, options, type, inspect$1);
1360
+ if (output) {
1361
+ if (typeof output === "string") return output;
1362
+ return inspect$1(output, options);
1363
+ }
1364
+ }
1365
+ const proto = value ? Object.getPrototypeOf(value) : false;
1366
+ if (proto === Object.prototype || proto === null) return inspectObject$1(value, options);
1367
+ if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) return inspectHTML(value, options);
1368
+ if ("constructor" in value) {
1369
+ if (value.constructor !== Object) return inspectClass(value, options);
1370
+ return inspectObject$1(value, options);
1371
+ }
1372
+ if (value === Object(value)) return inspectObject$1(value, options);
1373
+ return options.stylize(String(value), type);
1374
+ }
1375
+ const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
1376
+ const PLUGINS = [
1377
+ ReactTestComponent,
1378
+ ReactElement,
1379
+ DOMElement,
1380
+ DOMCollection,
1381
+ Immutable,
1382
+ AsymmetricMatcher
1383
+ ];
1384
+ function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
1385
+ const MAX_LENGTH = maxLength ?? 1e4;
1386
+ let result;
1387
+ const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
1388
+ const plugins = filterFn ? [
1389
+ ReactTestComponent,
1390
+ ReactElement,
1391
+ createDOMElementFilter(filterFn),
1392
+ DOMCollection,
1393
+ Immutable,
1394
+ AsymmetricMatcher
1395
+ ] : PLUGINS;
1396
+ try {
1397
+ result = format$1(object, {
1398
+ maxDepth,
1399
+ escapeString: false,
1400
+ plugins,
1401
+ ...options
1402
+ });
1403
+ } catch {
1404
+ result = format$1(object, {
1405
+ callToJSON: false,
1406
+ maxDepth,
1407
+ escapeString: false,
1408
+ plugins,
1409
+ ...options
1410
+ });
1411
+ }
1412
+ return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
1413
+ maxLength,
1414
+ filterNode,
1415
+ ...options
1416
+ }) : result;
1417
+ }
1418
+ function createNodeFilterFromSelector(selector) {
1419
+ const ELEMENT_NODE = 1;
1420
+ const COMMENT_NODE = 8;
1421
+ return (node) => {
1422
+ if (node.nodeType === COMMENT_NODE) return false;
1423
+ if (node.nodeType === ELEMENT_NODE && node.matches) try {
1424
+ return !node.matches(selector);
1425
+ } catch {
1426
+ return true;
1427
+ }
1428
+ return true;
1429
+ };
1430
+ }
1431
+ const formatRegExp = /%[sdjifoOc%]/g;
1432
+ function baseFormat(args, options = {}) {
1433
+ const formatArg = (item, inspecOptions) => {
1434
+ if (options.prettifyObject) return stringify(item, void 0, {
1435
+ printBasicPrototype: false,
1436
+ escapeString: false
1437
+ });
1438
+ return inspect(item, inspecOptions);
1439
+ };
1440
+ if (typeof args[0] !== "string") {
1441
+ const objects = [];
1442
+ for (let i = 0; i < args.length; i++) objects.push(formatArg(args[i], {
1443
+ depth: 0,
1444
+ colors: false
1445
+ }));
1446
+ return objects.join(" ");
1447
+ }
1448
+ const len = args.length;
1449
+ let i = 1;
1450
+ const template = args[0];
1451
+ let str = String(template).replace(formatRegExp, (x) => {
1452
+ if (x === "%%") return "%";
1453
+ if (i >= len) return x;
1454
+ switch (x) {
1455
+ case "%s": {
1456
+ const value = args[i++];
1457
+ if (typeof value === "bigint") return `${value.toString()}n`;
1458
+ if (typeof value === "number" && value === 0 && 1 / value < 0) return "-0";
1459
+ if (typeof value === "object" && value !== null) {
1460
+ if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) return value.toString();
1461
+ return formatArg(value, {
1462
+ depth: 0,
1463
+ colors: false
1464
+ });
1465
+ }
1466
+ return String(value);
1467
+ }
1468
+ case "%d": {
1469
+ const value = args[i++];
1470
+ if (typeof value === "bigint") return `${value.toString()}n`;
1471
+ if (typeof value === "symbol") return "NaN";
1472
+ return Number(value).toString();
1473
+ }
1474
+ case "%i": {
1475
+ const value = args[i++];
1476
+ if (typeof value === "bigint") return `${value.toString()}n`;
1477
+ return Number.parseInt(String(value)).toString();
1478
+ }
1479
+ case "%f": return Number.parseFloat(String(args[i++])).toString();
1480
+ case "%o": return formatArg(args[i++], {
1481
+ showHidden: true,
1482
+ showProxy: true
1483
+ });
1484
+ case "%O": return formatArg(args[i++]);
1485
+ case "%c":
1486
+ i++;
1487
+ return "";
1488
+ case "%j": try {
1489
+ return JSON.stringify(args[i++]);
1490
+ } catch (err) {
1491
+ const m = err.message;
1492
+ if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) return "[Circular]";
1493
+ throw err;
1494
+ }
1495
+ default: return x;
1496
+ }
1497
+ });
1498
+ for (let x = args[i]; i < len; x = args[++i]) if (x === null || typeof x !== "object") str += ` ${typeof x === "symbol" ? x.toString() : x}`;
1499
+ else str += ` ${formatArg(x)}`;
1500
+ return str;
1501
+ }
1502
+ function format(...args) {
1503
+ return baseFormat(args);
1504
+ }
1505
+ function inspect(obj, options = {}) {
1506
+ if (options.truncate === 0) options.truncate = Number.POSITIVE_INFINITY;
1507
+ return inspect$1(obj, options);
1508
+ }
1509
+ function objDisplay(obj, options = {}) {
1510
+ if (typeof options.truncate === "undefined") options.truncate = 40;
1511
+ const str = inspect(obj, options);
1512
+ const type = Object.prototype.toString.call(obj);
1513
+ if (options.truncate && str.length >= options.truncate) if (type === "[object Function]") {
1514
+ const fn = obj;
1515
+ return !fn.name ? "[Function]" : `[Function: ${fn.name}]`;
1516
+ } else if (type === "[object Array]") return `[ Array(${obj.length}) ]`;
1517
+ else if (type === "[object Object]") {
1518
+ const keys = Object.keys(obj);
1519
+ return `{ Object (${keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ")}) }`;
1520
+ } else return str;
1521
+ return str;
1522
+ }
1523
+ //#endregion
1524
+ //#region node_modules/@vitest/utils/dist/helpers.js
1525
+ function assertTypes(value, name, types) {
1526
+ const receivedType = typeof value;
1527
+ if (!types.includes(receivedType)) throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
1528
+ }
1529
+ function filterOutComments(s) {
1530
+ const result = [];
1531
+ let commentState = "none";
1532
+ for (let i = 0; i < s.length; ++i) if (commentState === "singleline") {
1533
+ if (s[i] === "\n") commentState = "none";
1534
+ } else if (commentState === "multiline") {
1535
+ if (s[i - 1] === "*" && s[i] === "/") commentState = "none";
1536
+ } else if (commentState === "none") if (s[i] === "/" && s[i + 1] === "/") commentState = "singleline";
1537
+ else if (s[i] === "/" && s[i + 1] === "*") {
1538
+ commentState = "multiline";
1539
+ i += 2;
1540
+ } else result.push(s[i]);
1541
+ return result.join("");
1542
+ }
1543
+ function toArray(array) {
1544
+ if (array === null || array === void 0) array = [];
1545
+ if (Array.isArray(array)) return array;
1546
+ return [array];
1547
+ }
1548
+ function isObject(item) {
1549
+ return item != null && typeof item === "object" && !Array.isArray(item);
1550
+ }
1551
+ function objectAttr(source, path, defaultValue = void 0) {
1552
+ const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
1553
+ let result = source;
1554
+ for (const p of paths) {
1555
+ result = new Object(result)[p];
1556
+ if (result === void 0) return defaultValue;
1557
+ }
1558
+ return result;
1559
+ }
1560
+ function createDefer() {
1561
+ let resolve = null;
1562
+ let reject = null;
1563
+ const p = new Promise((_resolve, _reject) => {
1564
+ resolve = _resolve;
1565
+ reject = _reject;
1566
+ });
1567
+ p.resolve = resolve;
1568
+ p.reject = reject;
1569
+ return p;
1570
+ }
1571
+ function isNegativeNaN(val) {
1572
+ if (!Number.isNaN(val)) return false;
1573
+ const f64 = new Float64Array(1);
1574
+ f64[0] = val;
1575
+ return new Uint32Array(f64.buffer)[1] >>> 31 === 1;
1576
+ }
1577
+ function ordinal(i) {
1578
+ const j = i % 10;
1579
+ const k = i % 100;
1580
+ if (j === 1 && k !== 11) return `${i}st`;
1581
+ if (j === 2 && k !== 12) return `${i}nd`;
1582
+ if (j === 3 && k !== 13) return `${i}rd`;
1583
+ return `${i}th`;
1584
+ }
1585
+ function unique(array) {
1586
+ return Array.from(new Set(array));
1587
+ }
1588
+ //#endregion
1589
+ //#region node_modules/@vitest/utils/dist/timers.js
1590
+ const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
1591
+ function getSafeTimers() {
1592
+ const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
1593
+ const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || {};
1594
+ return {
1595
+ nextTick: safeNextTick,
1596
+ setTimeout: safeSetTimeout,
1597
+ setInterval: safeSetInterval,
1598
+ clearInterval: safeClearInterval,
1599
+ clearTimeout: safeClearTimeout,
1600
+ setImmediate: safeSetImmediate,
1601
+ clearImmediate: safeClearImmediate,
1602
+ queueMicrotask: safeQueueMicrotask
1603
+ };
1604
+ }
1605
+ //#endregion
1606
+ //#region node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
1607
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
1608
+ function normalizeWindowsPath(input = "") {
1609
+ if (!input) return input;
1610
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
1611
+ }
1612
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
1613
+ function cwd() {
1614
+ if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
1615
+ return "/";
1616
+ }
1617
+ const resolve = function(...arguments_) {
1618
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
1619
+ let resolvedPath = "";
1620
+ let resolvedAbsolute = false;
1621
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
1622
+ const path = index >= 0 ? arguments_[index] : cwd();
1623
+ if (!path || path.length === 0) continue;
1624
+ resolvedPath = `${path}/${resolvedPath}`;
1625
+ resolvedAbsolute = isAbsolute(path);
1626
+ }
1627
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
1628
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
1629
+ return resolvedPath.length > 0 ? resolvedPath : ".";
1630
+ };
1631
+ function normalizeString(path, allowAboveRoot) {
1632
+ let res = "";
1633
+ let lastSegmentLength = 0;
1634
+ let lastSlash = -1;
1635
+ let dots = 0;
1636
+ let char = null;
1637
+ for (let index = 0; index <= path.length; ++index) {
1638
+ if (index < path.length) char = path[index];
1639
+ else if (char === "/") break;
1640
+ else char = "/";
1641
+ if (char === "/") {
1642
+ if (lastSlash === index - 1 || dots === 1);
1643
+ else if (dots === 2) {
1644
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
1645
+ if (res.length > 2) {
1646
+ const lastSlashIndex = res.lastIndexOf("/");
1647
+ if (lastSlashIndex === -1) {
1648
+ res = "";
1649
+ lastSegmentLength = 0;
1650
+ } else {
1651
+ res = res.slice(0, lastSlashIndex);
1652
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1653
+ }
1654
+ lastSlash = index;
1655
+ dots = 0;
1656
+ continue;
1657
+ } else if (res.length > 0) {
1658
+ res = "";
1659
+ lastSegmentLength = 0;
1660
+ lastSlash = index;
1661
+ dots = 0;
1662
+ continue;
1663
+ }
1664
+ }
1665
+ if (allowAboveRoot) {
1666
+ res += res.length > 0 ? "/.." : "..";
1667
+ lastSegmentLength = 2;
1668
+ }
1669
+ } else {
1670
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
1671
+ else res = path.slice(lastSlash + 1, index);
1672
+ lastSegmentLength = index - lastSlash - 1;
1673
+ }
1674
+ lastSlash = index;
1675
+ dots = 0;
1676
+ } else if (char === "." && dots !== -1) ++dots;
1677
+ else dots = -1;
1678
+ }
1679
+ return res;
1680
+ }
1681
+ const isAbsolute = function(p) {
1682
+ return _IS_ABSOLUTE_RE.test(p);
1683
+ };
1684
+ ",".charCodeAt(0);
1685
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1686
+ var intToChar = new Uint8Array(64);
1687
+ var charToInt = new Uint8Array(128);
1688
+ for (let i = 0; i < chars.length; i++) {
1689
+ const c = chars.charCodeAt(i);
1690
+ intToChar[i] = c;
1691
+ charToInt[c] = i;
1692
+ }
1693
+ const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
1694
+ const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
1695
+ const NOW_LENGTH = Date.now().toString().length;
1696
+ const REGEXP_VITEST = new RegExp(`vitest=\\d{${NOW_LENGTH}}`);
1697
+ function extractLocation(urlLike) {
1698
+ if (!urlLike.includes(":")) return [urlLike];
1699
+ const parts = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/^\(|\)$/g, ""));
1700
+ if (!parts) return [urlLike];
1701
+ let url = parts[1];
1702
+ if (url.startsWith("async ")) url = url.slice(6);
1703
+ if (url.startsWith("http:") || url.startsWith("https:")) {
1704
+ const urlObj = new URL(url);
1705
+ urlObj.searchParams.delete("import");
1706
+ urlObj.searchParams.delete("browserv");
1707
+ url = urlObj.pathname + urlObj.hash + urlObj.search;
1708
+ }
1709
+ if (url.startsWith("/@fs/")) {
1710
+ const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
1711
+ url = url.slice(isWindows ? 5 : 4);
1712
+ }
1713
+ if (url.includes("vitest=")) url = url.replace(REGEXP_VITEST, "").replace(/[?&]$/, "");
1714
+ return [
1715
+ url,
1716
+ parts[2] || void 0,
1717
+ parts[3] || void 0
1718
+ ];
1719
+ }
1720
+ function parseSingleFFOrSafariStack(raw) {
1721
+ let line = raw.trim();
1722
+ if (SAFARI_NATIVE_CODE_REGEXP.test(line)) return null;
1723
+ if (line.includes(" > eval")) line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
1724
+ if (!line.includes("@")) return null;
1725
+ let atIndex = -1;
1726
+ let locationPart = "";
1727
+ let functionName;
1728
+ for (let i = 0; i < line.length; i++) if (line[i] === "@") {
1729
+ const candidateLocation = line.slice(i + 1);
1730
+ if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
1731
+ atIndex = i;
1732
+ locationPart = candidateLocation;
1733
+ functionName = i > 0 ? line.slice(0, i) : void 0;
1734
+ break;
1735
+ }
1736
+ }
1737
+ if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) return null;
1738
+ const [url, lineNumber, columnNumber] = extractLocation(locationPart);
1739
+ if (!url || !lineNumber || !columnNumber) return null;
1740
+ return {
1741
+ file: url,
1742
+ method: functionName || "",
1743
+ line: Number.parseInt(lineNumber),
1744
+ column: Number.parseInt(columnNumber)
1745
+ };
1746
+ }
1747
+ function parseSingleStack(raw) {
1748
+ const line = raw.trim();
1749
+ if (!CHROME_IE_STACK_REGEXP.test(line)) return parseSingleFFOrSafariStack(line);
1750
+ return parseSingleV8Stack(line);
1751
+ }
1752
+ function parseSingleV8Stack(raw) {
1753
+ let line = raw.trim();
1754
+ if (!CHROME_IE_STACK_REGEXP.test(line)) return null;
1755
+ if (line.includes("(eval ")) line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
1756
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
1757
+ const location = sanitizedLine.match(/ (\(.+\)$)/);
1758
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
1759
+ const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
1760
+ let method = location && sanitizedLine || "";
1761
+ let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
1762
+ if (!file || !lineNumber || !columnNumber) return null;
1763
+ if (method.startsWith("async ")) method = method.slice(6);
1764
+ if (file.startsWith("file://")) file = file.slice(7);
1765
+ file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
1766
+ if (method) method = method.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
1767
+ return {
1768
+ method,
1769
+ file,
1770
+ line: Number.parseInt(lineNumber),
1771
+ column: Number.parseInt(columnNumber)
1772
+ };
1773
+ }
1774
+ //#endregion
1775
+ //#region node_modules/@vitest/runner/dist/chunk-artifact.js
1776
+ var PendingError = class extends Error {
1777
+ code = "VITEST_PENDING";
1778
+ taskId;
1779
+ constructor(message, task, note) {
1780
+ super(message);
1781
+ this.message = message;
1782
+ this.note = note;
1783
+ this.taskId = task.id;
1784
+ }
1785
+ };
1786
+ var FixtureDependencyError = class extends Error {
1787
+ name = "FixtureDependencyError";
1788
+ };
1789
+ var FixtureAccessError = class extends Error {
1790
+ name = "FixtureAccessError";
1791
+ };
1792
+ var FixtureParseError = class extends Error {
1793
+ name = "FixtureParseError";
1794
+ };
1795
+ const fnMap = /* @__PURE__ */ new WeakMap();
1796
+ const testFixtureMap = /* @__PURE__ */ new WeakMap();
1797
+ const hooksMap = /* @__PURE__ */ new WeakMap();
1798
+ function setFn(key, fn) {
1799
+ fnMap.set(key, fn);
1800
+ }
1801
+ function setTestFixture(key, fixture) {
1802
+ testFixtureMap.set(key, fixture);
1803
+ }
1804
+ function getTestFixtures(key) {
1805
+ return testFixtureMap.get(key);
1806
+ }
1807
+ function setHooks(key, hooks) {
1808
+ hooksMap.set(key, hooks);
1809
+ }
1810
+ function getHooks(key) {
1811
+ return hooksMap.get(key);
1812
+ }
1813
+ const FIXTURE_STACK_TRACE_KEY = Symbol.for("VITEST_FIXTURE_STACK_TRACE");
1814
+ var TestFixtures = class TestFixtures {
1815
+ _suiteContexts;
1816
+ _overrides = /* @__PURE__ */ new WeakMap();
1817
+ _registrations;
1818
+ static _definitions = [];
1819
+ static _builtinFixtures = [
1820
+ "task",
1821
+ "signal",
1822
+ "onTestFailed",
1823
+ "onTestFinished",
1824
+ "skip",
1825
+ "annotate"
1826
+ ];
1827
+ static _fixtureOptionKeys = [
1828
+ "auto",
1829
+ "injected",
1830
+ "scope"
1831
+ ];
1832
+ static _fixtureScopes = [
1833
+ "test",
1834
+ "file",
1835
+ "worker"
1836
+ ];
1837
+ static _workerContextSuite = { type: "worker" };
1838
+ static clearDefinitions() {
1839
+ TestFixtures._definitions.length = 0;
1840
+ }
1841
+ static getWorkerContexts() {
1842
+ return TestFixtures._definitions.map((f) => f.getWorkerContext());
1843
+ }
1844
+ static getFileContexts(file) {
1845
+ return TestFixtures._definitions.map((f) => f.getFileContext(file));
1846
+ }
1847
+ static isFixtureOptions(obj) {
1848
+ return isObject(obj) && Object.keys(obj).some((key) => TestFixtures._fixtureOptionKeys.includes(key));
1849
+ }
1850
+ constructor(registrations) {
1851
+ this._registrations = registrations ?? /* @__PURE__ */ new Map();
1852
+ this._suiteContexts = /* @__PURE__ */ new WeakMap();
1853
+ TestFixtures._definitions.push(this);
1854
+ }
1855
+ extend(runner, userFixtures) {
1856
+ const { suite } = getCurrentSuite();
1857
+ const isTopLevel = !suite || suite.file === suite;
1858
+ return new TestFixtures(this.parseUserFixtures(runner, userFixtures, isTopLevel));
1859
+ }
1860
+ get(suite) {
1861
+ let currentSuite = suite;
1862
+ while (currentSuite) {
1863
+ const overrides = this._overrides.get(currentSuite);
1864
+ if (overrides) return overrides;
1865
+ if (currentSuite === currentSuite.file) break;
1866
+ currentSuite = currentSuite.suite || currentSuite.file;
1867
+ }
1868
+ return this._registrations;
1869
+ }
1870
+ override(runner, userFixtures) {
1871
+ const { suite: currentSuite, file } = getCurrentSuite();
1872
+ const suite = currentSuite || file;
1873
+ const isTopLevel = !currentSuite || currentSuite.file === currentSuite;
1874
+ const suiteRegistrations = new Map(this.get(suite));
1875
+ const registrations = this.parseUserFixtures(runner, userFixtures, isTopLevel, suiteRegistrations);
1876
+ if (isTopLevel) this._registrations = registrations;
1877
+ else this._overrides.set(suite, registrations);
1878
+ }
1879
+ getFileContext(file) {
1880
+ if (!this._suiteContexts.has(file)) this._suiteContexts.set(file, Object.create(null));
1881
+ return this._suiteContexts.get(file);
1882
+ }
1883
+ getWorkerContext() {
1884
+ if (!this._suiteContexts.has(TestFixtures._workerContextSuite)) this._suiteContexts.set(TestFixtures._workerContextSuite, Object.create(null));
1885
+ return this._suiteContexts.get(TestFixtures._workerContextSuite);
1886
+ }
1887
+ parseUserFixtures(runner, userFixtures, supportNonTest, registrations = new Map(this._registrations)) {
1888
+ const errors = [];
1889
+ Object.entries(userFixtures).forEach(([name, fn]) => {
1890
+ let options;
1891
+ let value;
1892
+ let _options;
1893
+ if (Array.isArray(fn) && fn.length >= 2 && TestFixtures.isFixtureOptions(fn[1])) {
1894
+ _options = fn[1];
1895
+ options = {
1896
+ auto: _options.auto ?? false,
1897
+ scope: _options.scope ?? "test",
1898
+ injected: _options.injected ?? false
1899
+ };
1900
+ value = options.injected ? runner.injectValue?.(name) ?? fn[0] : fn[0];
1901
+ } else value = fn;
1902
+ const parent = registrations.get(name);
1903
+ if (parent && options) {
1904
+ if (parent.scope !== options.scope) errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered with a "${options.scope}" scope.`));
1905
+ if (parent.auto !== options.auto) errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered as { auto: ${options.auto} }.`));
1906
+ } else if (parent) options = {
1907
+ auto: parent.auto,
1908
+ scope: parent.scope,
1909
+ injected: parent.injected
1910
+ };
1911
+ else if (!options) options = {
1912
+ auto: false,
1913
+ injected: false,
1914
+ scope: "test"
1915
+ };
1916
+ if (options.scope && !TestFixtures._fixtureScopes.includes(options.scope)) errors.push(new FixtureDependencyError(`The "${name}" fixture has unknown scope "${options.scope}".`));
1917
+ if (!supportNonTest && options.scope !== "test") errors.push(new FixtureDependencyError(`The "${name}" fixture cannot be defined with a ${options.scope} scope${!_options?.scope && parent?.scope ? " (inherited from the base fixture)" : ""} inside the describe block. Define it at the top level of the file instead.`));
1918
+ const deps = isFixtureFunction(value) ? getUsedProps(value) : /* @__PURE__ */ new Set();
1919
+ const item = {
1920
+ name,
1921
+ value,
1922
+ auto: options.auto ?? false,
1923
+ injected: options.injected ?? false,
1924
+ scope: options.scope ?? "test",
1925
+ deps,
1926
+ parent
1927
+ };
1928
+ if (isFixtureFunction(value)) Object.assign(value, { [FIXTURE_STACK_TRACE_KEY]: /* @__PURE__ */ new Error("STACK_TRACE_ERROR") });
1929
+ registrations.set(name, item);
1930
+ if (item.scope === "worker" && (runner.pool === "vmThreads" || runner.pool === "vmForks")) item.scope = "file";
1931
+ });
1932
+ for (const fixture of registrations.values()) for (const depName of fixture.deps) {
1933
+ if (TestFixtures._builtinFixtures.includes(depName)) continue;
1934
+ const dep = registrations.get(depName);
1935
+ if (!dep) {
1936
+ errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on unknown fixture "${depName}".`));
1937
+ continue;
1938
+ }
1939
+ if (depName === fixture.name && !fixture.parent) {
1940
+ errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on itself, but does not have a base implementation.`));
1941
+ continue;
1942
+ }
1943
+ if (TestFixtures._fixtureScopes.indexOf(fixture.scope) > TestFixtures._fixtureScopes.indexOf(dep.scope)) {
1944
+ errors.push(new FixtureDependencyError(`The ${fixture.scope} "${fixture.name}" fixture cannot depend on a ${dep.scope} fixture "${dep.name}".`));
1945
+ continue;
1946
+ }
1947
+ }
1948
+ if (errors.length === 1) throw errors[0];
1949
+ else if (errors.length > 1) throw new AggregateError(errors, "Cannot resolve user fixtures. See errors for more information.");
1950
+ return registrations;
1951
+ }
1952
+ };
1953
+ const cleanupFnArrayMap = /* @__PURE__ */ new WeakMap();
1954
+ const contextHasFixturesCache = /* @__PURE__ */ new WeakMap();
1955
+ function withFixtures(fn, options) {
1956
+ const collector = getCurrentSuite();
1957
+ const suite = options?.suite || collector.suite || collector.file;
1958
+ return async (hookContext) => {
1959
+ const context = hookContext || options?.context;
1960
+ if (!context) {
1961
+ if (options?.suiteHook) validateSuiteHook(fn, options.suiteHook, options.stackTraceError);
1962
+ return fn({});
1963
+ }
1964
+ const fixtures = options?.fixtures || getTestFixtures(context);
1965
+ if (!fixtures) return fn(context);
1966
+ const registrations = fixtures.get(suite);
1967
+ if (!registrations.size) return fn(context);
1968
+ const usedFixtures = [];
1969
+ const usedProps = getUsedProps(fn);
1970
+ for (const fixture of registrations.values()) if (isAutoFixture(fixture, options) || usedProps.has(fixture.name)) usedFixtures.push(fixture);
1971
+ if (!usedFixtures.length) return fn(context);
1972
+ if (!cleanupFnArrayMap.has(context)) cleanupFnArrayMap.set(context, []);
1973
+ const cleanupFnArray = cleanupFnArrayMap.get(context);
1974
+ const pendingFixtures = resolveDeps(usedFixtures, registrations);
1975
+ if (!pendingFixtures.length) return fn(context);
1976
+ if (options?.suiteHook) {
1977
+ const testScopedFixtures = pendingFixtures.filter((f) => f.scope === "test");
1978
+ if (testScopedFixtures.length > 0) {
1979
+ const fixtureNames = testScopedFixtures.map((f) => `"${f.name}"`).join(", ");
1980
+ const error = new FixtureDependencyError(`Test-scoped fixtures cannot be used inside ${options.suiteHook} hook. The following fixtures are test-scoped: ${fixtureNames}. Use { scope: 'file' } or { scope: 'worker' } fixtures instead, or move the logic to ${{
1981
+ aroundAll: "aroundEach",
1982
+ beforeAll: "beforeEach",
1983
+ afterAll: "afterEach"
1984
+ }[options.suiteHook]} hook.`);
1985
+ if (options.stackTraceError?.stack) error.stack = error.message + options.stackTraceError.stack.replace(options.stackTraceError.message, "");
1986
+ throw error;
1987
+ }
1988
+ }
1989
+ if (!contextHasFixturesCache.has(context)) contextHasFixturesCache.set(context, /* @__PURE__ */ new WeakSet());
1990
+ const cachedFixtures = contextHasFixturesCache.get(context);
1991
+ for (const fixture of pendingFixtures) if (fixture.scope === "test") {
1992
+ if (cachedFixtures.has(fixture)) continue;
1993
+ cachedFixtures.add(fixture);
1994
+ const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
1995
+ context[fixture.name] = resolvedValue;
1996
+ cleanupFnArray.push(() => {
1997
+ cachedFixtures.delete(fixture);
1998
+ });
1999
+ } else {
2000
+ const resolvedValue = await resolveScopeFixtureValue(fixtures, suite, fixture);
2001
+ context[fixture.name] = resolvedValue;
2002
+ }
2003
+ return fn(context);
2004
+ };
2005
+ }
2006
+ function isAutoFixture(fixture, options) {
2007
+ if (!fixture.auto) return false;
2008
+ if (options?.suiteHook && fixture.scope === "test") return false;
2009
+ return true;
2010
+ }
2011
+ function isFixtureFunction(value) {
2012
+ return typeof value === "function";
2013
+ }
2014
+ function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
2015
+ if (!isFixtureFunction(fixture.value)) return fixture.value;
2016
+ return resolveFixtureFunction(fixture.value, fixture.name, context, cleanupFnArray);
2017
+ }
2018
+ const scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
2019
+ async function resolveScopeFixtureValue(fixtures, suite, fixture) {
2020
+ const workerContext = fixtures.getWorkerContext();
2021
+ const fileContext = fixtures.getFileContext(suite.file);
2022
+ const fixtureContext = fixture.scope === "worker" ? workerContext : fileContext;
2023
+ if (!isFixtureFunction(fixture.value)) {
2024
+ fixtureContext[fixture.name] = fixture.value;
2025
+ return fixture.value;
2026
+ }
2027
+ if (fixture.name in fixtureContext) return fixtureContext[fixture.name];
2028
+ if (scopedFixturePromiseCache.has(fixture)) return scopedFixturePromiseCache.get(fixture);
2029
+ if (!cleanupFnArrayMap.has(fixtureContext)) cleanupFnArrayMap.set(fixtureContext, []);
2030
+ const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
2031
+ const promise = resolveFixtureFunction(fixture.value, fixture.name, fixture.scope === "file" ? {
2032
+ ...workerContext,
2033
+ ...fileContext
2034
+ } : fixtureContext, cleanupFnFileArray).then((value) => {
2035
+ fixtureContext[fixture.name] = value;
2036
+ scopedFixturePromiseCache.delete(fixture);
2037
+ return value;
2038
+ });
2039
+ scopedFixturePromiseCache.set(fixture, promise);
2040
+ return promise;
2041
+ }
2042
+ async function resolveFixtureFunction(fixtureFn, fixtureName, context, cleanupFnArray) {
2043
+ const useFnArgPromise = createDefer();
2044
+ const stackTraceError = FIXTURE_STACK_TRACE_KEY in fixtureFn && fixtureFn[FIXTURE_STACK_TRACE_KEY] instanceof Error ? fixtureFn[FIXTURE_STACK_TRACE_KEY] : void 0;
2045
+ let isUseFnArgResolved = false;
2046
+ const fixtureReturn = fixtureFn(context, async (useFnArg) => {
2047
+ isUseFnArgResolved = true;
2048
+ useFnArgPromise.resolve(useFnArg);
2049
+ const useReturnPromise = createDefer();
2050
+ cleanupFnArray.push(async () => {
2051
+ useReturnPromise.resolve();
2052
+ await fixtureReturn;
2053
+ });
2054
+ await useReturnPromise;
2055
+ }).then(() => {
2056
+ if (!isUseFnArgResolved) {
2057
+ const error = /* @__PURE__ */ new Error(`Fixture "${fixtureName}" returned without calling "use". Make sure to call "use" in every code path of the fixture function.`);
2058
+ if (stackTraceError?.stack) error.stack = error.message + stackTraceError.stack.replace(stackTraceError.message, "");
2059
+ useFnArgPromise.reject(error);
2060
+ }
2061
+ }).catch((e) => {
2062
+ if (!isUseFnArgResolved) {
2063
+ useFnArgPromise.reject(e);
2064
+ return;
2065
+ }
2066
+ throw e;
2067
+ });
2068
+ return useFnArgPromise;
2069
+ }
2070
+ function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
2071
+ usedFixtures.forEach((fixture) => {
2072
+ if (pendingFixtures.includes(fixture)) return;
2073
+ if (!isFixtureFunction(fixture.value) || !fixture.deps) {
2074
+ pendingFixtures.push(fixture);
2075
+ return;
2076
+ }
2077
+ if (depSet.has(fixture)) if (fixture.parent) fixture = fixture.parent;
2078
+ else throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d) => d.name).join(" <- ")}`);
2079
+ depSet.add(fixture);
2080
+ resolveDeps([...fixture.deps].map((n) => n === fixture.name ? fixture.parent : registrations.get(n)).filter((n) => !!n), registrations, depSet, pendingFixtures);
2081
+ pendingFixtures.push(fixture);
2082
+ depSet.clear();
2083
+ });
2084
+ return pendingFixtures;
2085
+ }
2086
+ function validateSuiteHook(fn, hook, suiteError) {
2087
+ const usedProps = getUsedProps(fn, {
2088
+ sourceError: suiteError,
2089
+ suiteHook: hook
2090
+ });
2091
+ if (usedProps.size) {
2092
+ const error = new FixtureAccessError(`The ${hook} hook uses fixtures "${[...usedProps].join("\", \"")}", but has no access to context. Did you forget to call it as "test.${hook}()" instead of "${hook}()"?\nIf you used internal "suite" task as the first argument previously, access it in the second argument instead. See https://vitest.dev/guide/test-context#suite-level-hooks`);
2093
+ if (suiteError) error.stack = suiteError.stack?.replace(suiteError.message, error.message);
2094
+ throw error;
2095
+ }
2096
+ }
2097
+ const kPropsSymbol = Symbol("$vitest:fixture-props");
2098
+ const kPropNamesSymbol = Symbol("$vitest:fixture-prop-names");
2099
+ function configureProps(fn, options) {
2100
+ Object.defineProperty(fn, kPropsSymbol, {
2101
+ value: options,
2102
+ enumerable: false
2103
+ });
2104
+ }
2105
+ function memoProps(fn, props) {
2106
+ fn[kPropNamesSymbol] = props;
2107
+ return props;
2108
+ }
2109
+ function getUsedProps(fn, { sourceError, suiteHook } = {}) {
2110
+ if (kPropNamesSymbol in fn) return fn[kPropNamesSymbol];
2111
+ const { index: fixturesIndex = 0, original: implementation = fn } = kPropsSymbol in fn ? fn[kPropsSymbol] : {};
2112
+ let fnString = filterOutComments(implementation.toString());
2113
+ if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) fnString = fnString.split(/__async\((?:this|null),/)[1];
2114
+ const match = fnString.match(/[^(]*\(([^)]*)/);
2115
+ if (!match) return memoProps(fn, /* @__PURE__ */ new Set());
2116
+ const args = splitByComma(match[1]);
2117
+ if (!args.length) return memoProps(fn, /* @__PURE__ */ new Set());
2118
+ const fixturesArgument = args[fixturesIndex];
2119
+ if (!fixturesArgument) return memoProps(fn, /* @__PURE__ */ new Set());
2120
+ if (!(fixturesArgument[0] === "{" && fixturesArgument.endsWith("}"))) {
2121
+ const ordinalArgument = ordinal(fixturesIndex + 1);
2122
+ const error = new FixtureParseError(`The ${ordinalArgument} argument inside a fixture must use object destructuring pattern, e.g. ({ task } => {}). Instead, received "${fixturesArgument}".${suiteHook ? ` If you used internal "suite" task as the ${ordinalArgument} argument previously, access it in the ${ordinal(fixturesIndex + 2)} argument instead.` : ""}`);
2123
+ if (sourceError) error.stack = sourceError.stack?.replace(sourceError.message, error.message);
2124
+ throw error;
2125
+ }
2126
+ const props = splitByComma(fixturesArgument.slice(1, -1).replace(/\s/g, "")).map((prop) => {
2127
+ return prop.replace(/:.*|=.*/g, "");
2128
+ });
2129
+ const last = props.at(-1);
2130
+ if (last && last.startsWith("...")) {
2131
+ const error = new FixtureParseError(`Rest parameters are not supported in fixtures, received "${last}".`);
2132
+ if (sourceError) error.stack = sourceError.stack?.replace(sourceError.message, error.message);
2133
+ throw error;
2134
+ }
2135
+ return memoProps(fn, new Set(props));
2136
+ }
2137
+ function splitByComma(s) {
2138
+ const result = [];
2139
+ const stack = [];
2140
+ let start = 0;
2141
+ for (let i = 0; i < s.length; i++) if (s[i] === "{" || s[i] === "[") stack.push(s[i] === "{" ? "}" : "]");
2142
+ else if (s[i] === stack.at(-1)) stack.pop();
2143
+ else if (!stack.length && s[i] === ",") {
2144
+ const token = s.substring(start, i).trim();
2145
+ if (token) result.push(token);
2146
+ start = i + 1;
2147
+ }
2148
+ const lastToken = s.substring(start).trim();
2149
+ if (lastToken) result.push(lastToken);
2150
+ return result;
2151
+ }
2152
+ let _test;
2153
+ function getCurrentTest() {
2154
+ return _test;
2155
+ }
2156
+ const kChainableContext = Symbol("kChainableContext");
2157
+ function getChainableContext(chainable) {
2158
+ return chainable?.[kChainableContext];
2159
+ }
2160
+ function createChainable(keys, fn, context) {
2161
+ function create(context) {
2162
+ const chain = function(...args) {
2163
+ return fn.apply(context, args);
2164
+ };
2165
+ Object.assign(chain, fn);
2166
+ Object.defineProperty(chain, kChainableContext, {
2167
+ value: {
2168
+ withContext: () => chain.bind(context),
2169
+ getFixtures: () => context.fixtures,
2170
+ setContext: (key, value) => {
2171
+ context[key] = value;
2172
+ },
2173
+ mergeContext: (ctx) => {
2174
+ Object.assign(context, ctx);
2175
+ }
2176
+ },
2177
+ enumerable: false
2178
+ });
2179
+ for (const key of keys) Object.defineProperty(chain, key, { get() {
2180
+ return create({
2181
+ ...context,
2182
+ [key]: true
2183
+ });
2184
+ } });
2185
+ return chain;
2186
+ }
2187
+ const chain = create(context ?? {});
2188
+ Object.defineProperty(chain, "fn", {
2189
+ value: fn,
2190
+ enumerable: false
2191
+ });
2192
+ return chain;
2193
+ }
2194
+ function getDefaultHookTimeout() {
2195
+ return getRunner().config.hookTimeout;
2196
+ }
2197
+ const CLEANUP_TIMEOUT_KEY = Symbol.for("VITEST_CLEANUP_TIMEOUT");
2198
+ const CLEANUP_STACK_TRACE_KEY = Symbol.for("VITEST_CLEANUP_STACK_TRACE");
2199
+ const AROUND_TIMEOUT_KEY = Symbol.for("VITEST_AROUND_TIMEOUT");
2200
+ const AROUND_STACK_TRACE_KEY = Symbol.for("VITEST_AROUND_STACK_TRACE");
2201
+ /**
2202
+ * Registers a callback function to be executed once before all tests within the current suite.
2203
+ * This hook is useful for scenarios where you need to perform setup operations that are common to all tests in a suite, such as initializing a database connection or setting up a test environment.
2204
+ *
2205
+ * **Note:** The `beforeAll` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
2206
+ *
2207
+ * @param {Function} fn - The callback function to be executed before all tests.
2208
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2209
+ * @returns {void}
2210
+ * @example
2211
+ * ```ts
2212
+ * // Example of using beforeAll to set up a database connection
2213
+ * beforeAll(async () => {
2214
+ * await database.connect();
2215
+ * });
2216
+ * ```
2217
+ */
2218
+ function beforeAll(fn, timeout = getDefaultHookTimeout()) {
2219
+ assertTypes(fn, "\"beforeAll\" callback", ["function"]);
2220
+ const stackTraceError = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2221
+ const context = getChainableContext(this);
2222
+ return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(withSuiteFixtures("beforeAll", fn, context, stackTraceError), timeout, true, stackTraceError), {
2223
+ [CLEANUP_TIMEOUT_KEY]: timeout,
2224
+ [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2225
+ }));
2226
+ }
2227
+ /**
2228
+ * Registers a callback function to be executed once after all tests within the current suite have completed.
2229
+ * This hook is useful for scenarios where you need to perform cleanup operations after all tests in a suite have run, such as closing database connections or cleaning up temporary files.
2230
+ *
2231
+ * **Note:** The `afterAll` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
2232
+ *
2233
+ * @param {Function} fn - The callback function to be executed after all tests.
2234
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2235
+ * @returns {void}
2236
+ * @example
2237
+ * ```ts
2238
+ * // Example of using afterAll to close a database connection
2239
+ * afterAll(async () => {
2240
+ * await database.disconnect();
2241
+ * });
2242
+ * ```
2243
+ */
2244
+ function afterAll(fn, timeout) {
2245
+ assertTypes(fn, "\"afterAll\" callback", ["function"]);
2246
+ const context = getChainableContext(this);
2247
+ const stackTraceError = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2248
+ return getCurrentSuite().on("afterAll", withTimeout(withSuiteFixtures("afterAll", fn, context, stackTraceError), timeout ?? getDefaultHookTimeout(), true, stackTraceError));
2249
+ }
2250
+ /**
2251
+ * Registers a callback function to be executed before each test within the current suite.
2252
+ * This hook is useful for scenarios where you need to reset or reinitialize the test environment before each test runs, such as resetting database states, clearing caches, or reinitializing variables.
2253
+ *
2254
+ * **Note:** The `beforeEach` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
2255
+ *
2256
+ * @param {Function} fn - The callback function to be executed before each test. This function receives an `TestContext` parameter if additional test context is needed.
2257
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2258
+ * @returns {void}
2259
+ * @example
2260
+ * ```ts
2261
+ * // Example of using beforeEach to reset a database state
2262
+ * beforeEach(async () => {
2263
+ * await database.reset();
2264
+ * });
2265
+ * ```
2266
+ */
2267
+ function beforeEach(fn, timeout = getDefaultHookTimeout()) {
2268
+ assertTypes(fn, "\"beforeEach\" callback", ["function"]);
2269
+ const stackTraceError = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2270
+ const wrapper = (context, suite) => {
2271
+ return withFixtures(fn, { suite })(context);
2272
+ };
2273
+ return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
2274
+ [CLEANUP_TIMEOUT_KEY]: timeout,
2275
+ [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2276
+ }));
2277
+ }
2278
+ /**
2279
+ * Registers a callback function to be executed after each test within the current suite has completed.
2280
+ * This hook is useful for scenarios where you need to clean up or reset the test environment after each test runs, such as deleting temporary files, clearing test-specific database entries, or resetting mocked functions.
2281
+ *
2282
+ * **Note:** The `afterEach` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
2283
+ *
2284
+ * @param {Function} fn - The callback function to be executed after each test. This function receives an `TestContext` parameter if additional test context is needed.
2285
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2286
+ * @returns {void}
2287
+ * @example
2288
+ * ```ts
2289
+ * // Example of using afterEach to delete temporary files created during a test
2290
+ * afterEach(async () => {
2291
+ * await fileSystem.deleteTempFiles();
2292
+ * });
2293
+ * ```
2294
+ */
2295
+ function afterEach(fn, timeout) {
2296
+ assertTypes(fn, "\"afterEach\" callback", ["function"]);
2297
+ const wrapper = (context, suite) => {
2298
+ return withFixtures(fn, { suite })(context);
2299
+ };
2300
+ return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, /* @__PURE__ */ new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2301
+ }
2302
+ /**
2303
+ * Registers a callback function that wraps around all tests within the current suite.
2304
+ * The callback receives a `runSuite` function that must be called to run the suite's tests.
2305
+ * This hook is useful for scenarios where you need to wrap an entire suite in a context
2306
+ * (e.g., starting a server, opening a database connection that all tests share).
2307
+ *
2308
+ * **Note:** When multiple `aroundAll` hooks are registered, they are nested inside each other.
2309
+ * The first registered hook is the outermost wrapper.
2310
+ *
2311
+ * @param {Function} fn - The callback function that wraps the suite. Must call `runSuite()` to run the tests.
2312
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2313
+ * @returns {void}
2314
+ * @example
2315
+ * ```ts
2316
+ * // Example of using aroundAll to wrap suite in a tracing span
2317
+ * aroundAll(async (runSuite) => {
2318
+ * await tracer.trace('test-suite', runSuite);
2319
+ * });
2320
+ * ```
2321
+ * @example
2322
+ * ```ts
2323
+ * // Example of using aroundAll with fixtures
2324
+ * aroundAll(async (runSuite, { db }) => {
2325
+ * await db.transaction(() => runSuite());
2326
+ * });
2327
+ * ```
2328
+ */
2329
+ function aroundAll(fn, timeout) {
2330
+ assertTypes(fn, "\"aroundAll\" callback", ["function"]);
2331
+ const stackTraceError = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2332
+ const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2333
+ const context = getChainableContext(this);
2334
+ return getCurrentSuite().on("aroundAll", Object.assign(withSuiteFixtures("aroundAll", fn, context, stackTraceError, 1), {
2335
+ [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2336
+ [AROUND_STACK_TRACE_KEY]: stackTraceError
2337
+ }));
2338
+ }
2339
+ /**
2340
+ * Registers a callback function that wraps around each test within the current suite.
2341
+ * The callback receives a `runTest` function that must be called to run the test.
2342
+ * This hook is useful for scenarios where you need to wrap tests in a context (e.g., database transactions).
2343
+ *
2344
+ * **Note:** When multiple `aroundEach` hooks are registered, they are nested inside each other.
2345
+ * The first registered hook is the outermost wrapper.
2346
+ *
2347
+ * @param {Function} fn - The callback function that wraps the test. Must call `runTest()` to run the test.
2348
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2349
+ * @returns {void}
2350
+ * @example
2351
+ * ```ts
2352
+ * // Example of using aroundEach to wrap tests in a database transaction
2353
+ * aroundEach(async (runTest) => {
2354
+ * await database.transaction(() => runTest());
2355
+ * });
2356
+ * ```
2357
+ * @example
2358
+ * ```ts
2359
+ * // Example of using aroundEach with fixtures
2360
+ * aroundEach(async (runTest, { db }) => {
2361
+ * await db.transaction(() => runTest());
2362
+ * });
2363
+ * ```
2364
+ */
2365
+ function aroundEach(fn, timeout) {
2366
+ assertTypes(fn, "\"aroundEach\" callback", ["function"]);
2367
+ const stackTraceError = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2368
+ const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2369
+ const wrapper = (runTest, context, suite) => {
2370
+ const innerFn = (ctx) => fn(runTest, ctx, suite);
2371
+ configureProps(innerFn, {
2372
+ index: 1,
2373
+ original: fn
2374
+ });
2375
+ return withFixtures(innerFn, { suite })(context);
2376
+ };
2377
+ return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
2378
+ [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2379
+ [AROUND_STACK_TRACE_KEY]: stackTraceError
2380
+ }));
2381
+ }
2382
+ function withSuiteFixtures(suiteHook, fn, context, stackTraceError, contextIndex = 0) {
2383
+ return (...args) => {
2384
+ const suite = args.at(-1);
2385
+ const prefix = args.slice(0, -1);
2386
+ const wrapper = (ctx) => fn(...prefix, ctx, suite);
2387
+ configureProps(wrapper, {
2388
+ index: contextIndex,
2389
+ original: fn
2390
+ });
2391
+ const fixtures = context?.getFixtures();
2392
+ const fileContext = fixtures?.getFileContext(suite.file);
2393
+ return withFixtures(wrapper, {
2394
+ suiteHook,
2395
+ fixtures,
2396
+ context: fileContext,
2397
+ stackTraceError
2398
+ })();
2399
+ };
2400
+ }
2401
+ function findTestFileStackTrace(testFilePath, error) {
2402
+ const lines = error.split("\n").slice(1);
2403
+ for (const line of lines) {
2404
+ const stack = parseSingleStack(line);
2405
+ if (stack && stack.file === testFilePath) return stack;
2406
+ }
2407
+ }
2408
+ function validateTags(config, tags) {
2409
+ if (!config.strictTags) return;
2410
+ const availableTags = new Set(config.tags.map((tag) => tag.name));
2411
+ for (const tag of tags) if (!availableTags.has(tag)) throw createNoTagsError(config.tags, tag);
2412
+ }
2413
+ function createNoTagsError(availableTags, tag, prefix = "tag") {
2414
+ if (!availableTags.length) throw new Error(`The Vitest config does't define any "tags", cannot apply "${tag}" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`);
2415
+ throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:\n${availableTags.map((t) => `- ${t.name}${t.description ? `: ${t.description}` : ""}`).join("\n")}`);
2416
+ }
2417
+ function createTaskName(names, separator = " > ") {
2418
+ return names.filter((name) => name !== void 0).join(separator);
2419
+ }
2420
+ /**
2421
+ * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
2422
+ * Suites can contain both tests and other suites, enabling complex test structures.
2423
+ *
2424
+ * @param {string} name - The name of the suite, used for identification and reporting.
2425
+ * @param {Function} fn - A function that defines the tests and suites within this suite.
2426
+ * @example
2427
+ * ```ts
2428
+ * // Define a suite with two tests
2429
+ * suite('Math operations', () => {
2430
+ * test('should add two numbers', () => {
2431
+ * expect(add(1, 2)).toBe(3);
2432
+ * });
2433
+ *
2434
+ * test('should subtract two numbers', () => {
2435
+ * expect(subtract(5, 2)).toBe(3);
2436
+ * });
2437
+ * });
2438
+ * ```
2439
+ * @example
2440
+ * ```ts
2441
+ * // Define nested suites
2442
+ * suite('String operations', () => {
2443
+ * suite('Trimming', () => {
2444
+ * test('should trim whitespace from start and end', () => {
2445
+ * expect(' hello '.trim()).toBe('hello');
2446
+ * });
2447
+ * });
2448
+ *
2449
+ * suite('Concatenation', () => {
2450
+ * test('should concatenate two strings', () => {
2451
+ * expect('hello' + ' ' + 'world').toBe('hello world');
2452
+ * });
2453
+ * });
2454
+ * });
2455
+ * ```
2456
+ */
2457
+ const suite = createSuite();
2458
+ createTest(function(name, optionsOrFn, optionsOrTest) {
2459
+ if (getCurrentTest()) throw new Error("Calling the test function inside another test function is not allowed. Please put it inside \"describe\" or \"suite\" so it can be properly collected.");
2460
+ getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
2461
+ });
2462
+ let runner;
2463
+ let defaultSuite;
2464
+ let currentTestFilepath;
2465
+ function assert(condition, message) {
2466
+ if (!condition) throw new Error(`Vitest failed to find ${message}. One of the following is possible:
2467
+ - "vitest" is imported directly without running "vitest" command
2468
+ - "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
2469
+ - "vitest" is imported inside Vite / Vitest config file
2470
+ - Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues
2471
+ `);
2472
+ }
2473
+ function getRunner() {
2474
+ assert(runner, "the runner");
2475
+ return runner;
2476
+ }
2477
+ function getCurrentSuite() {
2478
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
2479
+ assert(currentSuite, "the current suite");
2480
+ return currentSuite;
2481
+ }
2482
+ function createSuiteHooks() {
2483
+ return {
2484
+ beforeAll: [],
2485
+ afterAll: [],
2486
+ beforeEach: [],
2487
+ afterEach: [],
2488
+ aroundEach: [],
2489
+ aroundAll: []
2490
+ };
2491
+ }
2492
+ const POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
2493
+ function parseArguments(optionsOrFn, timeoutOrTest) {
2494
+ if (timeoutOrTest != null && typeof timeoutOrTest === "object") throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
2495
+ let options = {};
2496
+ let fn;
2497
+ if (typeof timeoutOrTest === "number") options = { timeout: timeoutOrTest };
2498
+ else if (typeof optionsOrFn === "object") options = optionsOrFn;
2499
+ if (typeof optionsOrFn === "function") {
2500
+ if (typeof timeoutOrTest === "function") throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
2501
+ fn = optionsOrFn;
2502
+ } else if (typeof timeoutOrTest === "function") fn = timeoutOrTest;
2503
+ return {
2504
+ options,
2505
+ handler: fn
2506
+ };
2507
+ }
2508
+ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions) {
2509
+ const tasks = [];
2510
+ let suite;
2511
+ initSuite(true);
2512
+ const task = function(name = "", options = {}) {
2513
+ const currentSuite = collectorContext.currentSuite?.suite;
2514
+ const testTags = unique([...(currentSuite ?? collectorContext.currentSuite?.file)?.tags || [], ...toArray(options.tags)]);
2515
+ const tagsOptions = testTags.map((tag) => {
2516
+ const tagDefinition = runner.config.tags?.find((t) => t.name === tag);
2517
+ if (!tagDefinition && runner.config.strictTags) throw createNoTagsError(runner.config.tags, tag);
2518
+ return tagDefinition;
2519
+ }).filter((r) => r != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
2520
+ const { name, description, priority, meta, ...options } = tag;
2521
+ Object.assign(acc, options);
2522
+ if (meta) acc.meta = Object.assign(acc.meta ?? Object.create(null), meta);
2523
+ return acc;
2524
+ }, {});
2525
+ const testOwnMeta = options.meta;
2526
+ options = {
2527
+ ...tagsOptions,
2528
+ ...options
2529
+ };
2530
+ const timeout = options.timeout ?? runner.config.testTimeout;
2531
+ const parentMeta = currentSuite?.meta;
2532
+ const tagMeta = tagsOptions.meta;
2533
+ const testMeta = Object.create(null);
2534
+ if (tagMeta) Object.assign(testMeta, tagMeta);
2535
+ if (parentMeta) Object.assign(testMeta, parentMeta);
2536
+ if (testOwnMeta) Object.assign(testMeta, testOwnMeta);
2537
+ const task = {
2538
+ id: "",
2539
+ name,
2540
+ fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name]),
2541
+ fullTestName: createTaskName([currentSuite?.fullTestName, name]),
2542
+ suite: currentSuite,
2543
+ each: options.each,
2544
+ fails: options.fails,
2545
+ context: void 0,
2546
+ type: "test",
2547
+ file: currentSuite?.file ?? collectorContext.currentSuite?.file,
2548
+ timeout,
2549
+ retry: options.retry ?? runner.config.retry,
2550
+ repeats: options.repeats,
2551
+ mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
2552
+ meta: testMeta,
2553
+ annotations: [],
2554
+ artifacts: [],
2555
+ tags: testTags
2556
+ };
2557
+ const handler = options.handler;
2558
+ if (task.mode === "run" && !handler) task.mode = "todo";
2559
+ if (options.concurrent ?? (!options.sequential && runner.config.sequence.concurrent)) task.concurrent = true;
2560
+ task.shuffle = suiteOptions?.shuffle;
2561
+ const context = createTestContext(task, runner);
2562
+ Object.defineProperty(task, "context", {
2563
+ value: context,
2564
+ enumerable: false
2565
+ });
2566
+ setTestFixture(context, options.fixtures ?? new TestFixtures());
2567
+ const limit = Error.stackTraceLimit;
2568
+ Error.stackTraceLimit = 10;
2569
+ const stackTraceError = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2570
+ Error.stackTraceLimit = limit;
2571
+ if (handler) setFn(task, withTimeout(withCancel(withAwaitAsyncAssertions(withFixtures(handler, { context }), task), task.context.signal), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
2572
+ if (runner.config.includeTaskLocation) {
2573
+ const error = stackTraceError.stack;
2574
+ const stack = findTestFileStackTrace(currentTestFilepath, error);
2575
+ if (stack) task.location = {
2576
+ line: stack.line,
2577
+ column: stack.column
2578
+ };
2579
+ }
2580
+ tasks.push(task);
2581
+ return task;
2582
+ };
2583
+ const test = createTest(function(name, optionsOrFn, timeoutOrTest) {
2584
+ let { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
2585
+ if (typeof suiteOptions === "object") options = Object.assign({}, suiteOptions, options);
2586
+ const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
2587
+ if (options.concurrent != null && concurrent != null) options.concurrent = concurrent;
2588
+ const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
2589
+ if (options.sequential != null && sequential != null) options.sequential = sequential;
2590
+ const test = task(formatName(name), {
2591
+ ...this,
2592
+ ...options,
2593
+ handler
2594
+ });
2595
+ test.type = "test";
2596
+ });
2597
+ const collector = {
2598
+ type: "collector",
2599
+ name,
2600
+ mode,
2601
+ suite,
2602
+ options: suiteOptions,
2603
+ test,
2604
+ file: suite.file,
2605
+ tasks,
2606
+ collect,
2607
+ task,
2608
+ clear,
2609
+ on: addHook
2610
+ };
2611
+ function addHook(name, ...fn) {
2612
+ getHooks(suite)[name].push(...fn);
2613
+ }
2614
+ function initSuite(includeLocation) {
2615
+ if (typeof suiteOptions === "number") suiteOptions = { timeout: suiteOptions };
2616
+ const currentSuite = collectorContext.currentSuite?.suite;
2617
+ const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
2618
+ const suiteTags = toArray(suiteOptions?.tags);
2619
+ validateTags(runner.config, suiteTags);
2620
+ suite = {
2621
+ id: "",
2622
+ type: "suite",
2623
+ name,
2624
+ fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name]),
2625
+ fullTestName: createTaskName([currentSuite?.fullTestName, name]),
2626
+ suite: currentSuite,
2627
+ mode,
2628
+ each,
2629
+ file: currentSuite?.file ?? collectorContext.currentSuite?.file,
2630
+ shuffle: suiteOptions?.shuffle,
2631
+ tasks: [],
2632
+ meta: suiteOptions?.meta ?? Object.create(null),
2633
+ concurrent: suiteOptions?.concurrent,
2634
+ tags: unique([...parentTask?.tags || [], ...suiteTags])
2635
+ };
2636
+ setHooks(suite, createSuiteHooks());
2637
+ }
2638
+ function clear() {
2639
+ tasks.length = 0;
2640
+ initSuite(false);
2641
+ }
2642
+ async function collect(file) {
2643
+ if (!file) throw new TypeError("File is required to collect tasks.");
2644
+ if (factory) await runWithSuite(collector, () => factory(test));
2645
+ const allChildren = [];
2646
+ for (const i of tasks) allChildren.push(i.type === "collector" ? await i.collect(file) : i);
2647
+ suite.tasks = allChildren;
2648
+ return suite;
2649
+ }
2650
+ collectTask(collector);
2651
+ return collector;
2652
+ }
2653
+ function withAwaitAsyncAssertions(fn, task) {
2654
+ return (async (...args) => {
2655
+ const fnResult = await fn(...args);
2656
+ if (task.promises) {
2657
+ const errors = (await Promise.allSettled(task.promises)).map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
2658
+ if (errors.length) throw errors;
2659
+ }
2660
+ return fnResult;
2661
+ });
2662
+ }
2663
+ function createSuite() {
2664
+ function suiteFn(name, factoryOrOptions, optionsOrFactory) {
2665
+ if (getCurrentTest()) throw new Error("Calling the suite function inside test function is not allowed. It can be only called at the top level or inside another suite function.");
2666
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
2667
+ let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
2668
+ const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
2669
+ const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
2670
+ const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
2671
+ options = {
2672
+ ...parentOptions,
2673
+ ...options
2674
+ };
2675
+ const shuffle = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? runner?.config.sequence.shuffle;
2676
+ if (shuffle != null) options.shuffle = shuffle;
2677
+ let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
2678
+ if (mode === "run" && !factory) mode = "todo";
2679
+ const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
2680
+ const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
2681
+ if (isConcurrent != null) options.concurrent = isConcurrent && !isSequential;
2682
+ if (isSequential != null) options.sequential = isSequential && !isConcurrent;
2683
+ if (parentMeta) options.meta = Object.assign(Object.create(null), parentMeta, options.meta);
2684
+ return createSuiteCollector(formatName(name), factory, mode, this.each, options);
2685
+ }
2686
+ suiteFn.each = function(cases, ...args) {
2687
+ const context = getChainableContext(this);
2688
+ const suite = context.withContext();
2689
+ context.setContext("each", true);
2690
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
2691
+ return (name, optionsOrFn, fnOrOptions) => {
2692
+ const _name = formatName(name);
2693
+ const arrayOnlyCases = cases.every(Array.isArray);
2694
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2695
+ const fnFirst = typeof optionsOrFn === "function";
2696
+ cases.forEach((i, idx) => {
2697
+ const items = Array.isArray(i) ? i : [i];
2698
+ if (fnFirst) if (arrayOnlyCases) suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2699
+ else suite(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
2700
+ else if (arrayOnlyCases) suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2701
+ else suite(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
2702
+ });
2703
+ context.setContext("each", void 0);
2704
+ };
2705
+ };
2706
+ suiteFn.for = function(cases, ...args) {
2707
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
2708
+ return (name, optionsOrFn, fnOrOptions) => {
2709
+ const name_ = formatName(name);
2710
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2711
+ cases.forEach((item, idx) => {
2712
+ suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : void 0);
2713
+ });
2714
+ };
2715
+ };
2716
+ suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
2717
+ suiteFn.runIf = (condition) => condition ? suite : suite.skip;
2718
+ return createChainable([
2719
+ "concurrent",
2720
+ "sequential",
2721
+ "shuffle",
2722
+ "skip",
2723
+ "only",
2724
+ "todo"
2725
+ ], suiteFn);
2726
+ }
2727
+ function createTaskCollector(fn) {
2728
+ const taskFn = fn;
2729
+ taskFn.each = function(cases, ...args) {
2730
+ const context = getChainableContext(this);
2731
+ const test = context.withContext();
2732
+ context.setContext("each", true);
2733
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
2734
+ return (name, optionsOrFn, fnOrOptions) => {
2735
+ const _name = formatName(name);
2736
+ const arrayOnlyCases = cases.every(Array.isArray);
2737
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2738
+ const fnFirst = typeof optionsOrFn === "function";
2739
+ cases.forEach((i, idx) => {
2740
+ const items = Array.isArray(i) ? i : [i];
2741
+ if (fnFirst) if (arrayOnlyCases) test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2742
+ else test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
2743
+ else if (arrayOnlyCases) test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2744
+ else test(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
2745
+ });
2746
+ context.setContext("each", void 0);
2747
+ };
2748
+ };
2749
+ taskFn.for = function(cases, ...args) {
2750
+ const test = getChainableContext(this).withContext();
2751
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
2752
+ return (name, optionsOrFn, fnOrOptions) => {
2753
+ const _name = formatName(name);
2754
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2755
+ cases.forEach((item, idx) => {
2756
+ const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
2757
+ if (handlerWrapper) configureProps(handlerWrapper, {
2758
+ index: 1,
2759
+ original: handler
2760
+ });
2761
+ test(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
2762
+ });
2763
+ };
2764
+ };
2765
+ taskFn.skipIf = function(condition) {
2766
+ return condition ? this.skip : this;
2767
+ };
2768
+ taskFn.runIf = function(condition) {
2769
+ return condition ? this : this.skip;
2770
+ };
2771
+ /**
2772
+ * Parse builder pattern arguments into a fixtures object.
2773
+ * Handles both builder pattern (name, options?, value) and object syntax.
2774
+ */
2775
+ function parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn) {
2776
+ if (typeof fixturesOrName !== "string") return fixturesOrName;
2777
+ const fixtureName = fixturesOrName;
2778
+ let fixtureOptions;
2779
+ let fixtureValue;
2780
+ if (maybeFn !== void 0) {
2781
+ fixtureOptions = optionsOrFn;
2782
+ fixtureValue = maybeFn;
2783
+ } else if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && TestFixtures.isFixtureOptions(optionsOrFn)) {
2784
+ fixtureOptions = optionsOrFn;
2785
+ fixtureValue = {};
2786
+ } else {
2787
+ fixtureOptions = void 0;
2788
+ fixtureValue = optionsOrFn;
2789
+ }
2790
+ if (typeof fixtureValue === "function") {
2791
+ const builderFn = fixtureValue;
2792
+ const fixture = async (ctx, use) => {
2793
+ let cleanup;
2794
+ const onCleanup = (fn) => {
2795
+ if (cleanup !== void 0) throw new Error("onCleanup can only be called once per fixture. Define separate fixtures if you need multiple cleanup functions.");
2796
+ cleanup = fn;
2797
+ };
2798
+ await use(await builderFn(ctx, { onCleanup }));
2799
+ if (cleanup) await cleanup();
2800
+ };
2801
+ configureProps(fixture, { original: builderFn });
2802
+ if (fixtureOptions) return { [fixtureName]: [fixture, fixtureOptions] };
2803
+ return { [fixtureName]: fixture };
2804
+ }
2805
+ if (fixtureOptions) return { [fixtureName]: [fixtureValue, fixtureOptions] };
2806
+ return { [fixtureName]: fixtureValue };
2807
+ }
2808
+ taskFn.override = function(fixturesOrName, optionsOrFn, maybeFn) {
2809
+ const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
2810
+ getChainableContext(this).getFixtures().override(runner, userFixtures);
2811
+ return this;
2812
+ };
2813
+ taskFn.scoped = function(fixtures) {
2814
+ console.warn(`test.scoped() is deprecated and will be removed in future versions. Please use test.override() instead.`);
2815
+ return this.override(fixtures);
2816
+ };
2817
+ taskFn.extend = function(fixturesOrName, optionsOrFn, maybeFn) {
2818
+ const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
2819
+ const fixtures = getChainableContext(this).getFixtures().extend(runner, userFixtures);
2820
+ const _test = createTest(function(name, optionsOrFn, optionsOrTest) {
2821
+ fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
2822
+ });
2823
+ getChainableContext(_test).mergeContext({ fixtures });
2824
+ return _test;
2825
+ };
2826
+ taskFn.describe = suite;
2827
+ taskFn.suite = suite;
2828
+ taskFn.beforeEach = beforeEach;
2829
+ taskFn.afterEach = afterEach;
2830
+ taskFn.beforeAll = beforeAll;
2831
+ taskFn.afterAll = afterAll;
2832
+ taskFn.aroundEach = aroundEach;
2833
+ taskFn.aroundAll = aroundAll;
2834
+ return createChainable([
2835
+ "concurrent",
2836
+ "sequential",
2837
+ "skip",
2838
+ "only",
2839
+ "todo",
2840
+ "fails"
2841
+ ], taskFn, { fixtures: new TestFixtures() });
2842
+ }
2843
+ function createTest(fn) {
2844
+ return createTaskCollector(fn);
2845
+ }
2846
+ function formatName(name) {
2847
+ return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
2848
+ }
2849
+ function formatTitle(template, items, idx) {
2850
+ if (template.includes("%#") || template.includes("%$")) template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
2851
+ const count = template.split("%").length - 1;
2852
+ if (template.includes("%f")) (template.match(/%f/g) || []).forEach((_, i) => {
2853
+ if (isNegativeNaN(items[i]) || Object.is(items[i], -0)) {
2854
+ let occurrence = 0;
2855
+ template = template.replace(/%f/g, (match) => {
2856
+ occurrence++;
2857
+ return occurrence === i + 1 ? "-%f" : match;
2858
+ });
2859
+ }
2860
+ });
2861
+ const isObjectItem = isObject(items[0]);
2862
+ function formatAttribute(s) {
2863
+ return s.replace(/\$([$\w.]+)/g, (_, key) => {
2864
+ const isArrayKey = /^\d+$/.test(key);
2865
+ if (!isObjectItem && !isArrayKey) return `$${key}`;
2866
+ const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
2867
+ return objDisplay(isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement, { truncate: runner?.config?.chaiConfig?.truncateThreshold });
2868
+ });
2869
+ }
2870
+ let output = "";
2871
+ let i = 0;
2872
+ handleRegexMatch(template, formatRegExp, (match) => {
2873
+ if (i < count) output += format(match[0], items[i++]);
2874
+ else output += match[0];
2875
+ }, (nonMatch) => {
2876
+ output += formatAttribute(nonMatch);
2877
+ });
2878
+ return output;
2879
+ }
2880
+ function handleRegexMatch(input, regex, onMatch, onNonMatch) {
2881
+ let lastIndex = 0;
2882
+ for (const m of input.matchAll(regex)) {
2883
+ if (lastIndex < m.index) onNonMatch(input.slice(lastIndex, m.index));
2884
+ onMatch(m);
2885
+ lastIndex = m.index + m[0].length;
2886
+ }
2887
+ if (lastIndex < input.length) onNonMatch(input.slice(lastIndex));
2888
+ }
2889
+ function formatTemplateString(cases, args) {
2890
+ const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i) => i.split("|"))[0];
2891
+ const res = [];
2892
+ for (let i = 0; i < Math.floor(args.length / header.length); i++) {
2893
+ const oneCase = {};
2894
+ for (let j = 0; j < header.length; j++) oneCase[header[j]] = args[i * header.length + j];
2895
+ res.push(oneCase);
2896
+ }
2897
+ return res;
2898
+ }
2899
+ const now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2900
+ const collectorContext = {
2901
+ tasks: [],
2902
+ currentSuite: null
2903
+ };
2904
+ function collectTask(task) {
2905
+ collectorContext.currentSuite?.tasks.push(task);
2906
+ }
2907
+ async function runWithSuite(suite, fn) {
2908
+ const prev = collectorContext.currentSuite;
2909
+ collectorContext.currentSuite = suite;
2910
+ await fn();
2911
+ collectorContext.currentSuite = prev;
2912
+ }
2913
+ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
2914
+ if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) return fn;
2915
+ const { setTimeout, clearTimeout } = getSafeTimers();
2916
+ return (function runWithTimeout(...args) {
2917
+ const startTime = now$2();
2918
+ const runner = getRunner();
2919
+ runner._currentTaskStartTime = startTime;
2920
+ runner._currentTaskTimeout = timeout;
2921
+ return new Promise((resolve_, reject_) => {
2922
+ const timer = setTimeout(() => {
2923
+ clearTimeout(timer);
2924
+ rejectTimeoutError();
2925
+ }, timeout);
2926
+ timer.unref?.();
2927
+ function rejectTimeoutError() {
2928
+ const error = makeTimeoutError(isHook, timeout, stackTraceError);
2929
+ onTimeout?.(args, error);
2930
+ reject_(error);
2931
+ }
2932
+ function resolve(result) {
2933
+ runner._currentTaskStartTime = void 0;
2934
+ runner._currentTaskTimeout = void 0;
2935
+ clearTimeout(timer);
2936
+ if (now$2() - startTime >= timeout) {
2937
+ rejectTimeoutError();
2938
+ return;
2939
+ }
2940
+ resolve_(result);
2941
+ }
2942
+ function reject(error) {
2943
+ runner._currentTaskStartTime = void 0;
2944
+ runner._currentTaskTimeout = void 0;
2945
+ clearTimeout(timer);
2946
+ reject_(error);
2947
+ }
2948
+ try {
2949
+ const result = fn(...args);
2950
+ if (typeof result === "object" && result != null && typeof result.then === "function") result.then(resolve, reject);
2951
+ else resolve(result);
2952
+ } catch (error) {
2953
+ reject(error);
2954
+ }
2955
+ });
2956
+ });
2957
+ }
2958
+ function withCancel(fn, signal) {
2959
+ return (function runWithCancel(...args) {
2960
+ return new Promise((resolve, reject) => {
2961
+ signal.addEventListener("abort", () => reject(signal.reason));
2962
+ try {
2963
+ const result = fn(...args);
2964
+ if (typeof result === "object" && result != null && typeof result.then === "function") result.then(resolve, reject);
2965
+ else resolve(result);
2966
+ } catch (error) {
2967
+ reject(error);
2968
+ }
2969
+ });
2970
+ });
2971
+ }
2972
+ const abortControllers = /* @__PURE__ */ new WeakMap();
2973
+ function abortIfTimeout([context], error) {
2974
+ if (context) abortContextSignal(context, error);
2975
+ }
2976
+ function abortContextSignal(context, error) {
2977
+ abortControllers.get(context)?.abort(error);
2978
+ }
2979
+ function createTestContext(test, runner) {
2980
+ const context = function() {
2981
+ throw new Error("done() callback is deprecated, use promise instead");
2982
+ };
2983
+ let abortController = abortControllers.get(context);
2984
+ if (!abortController) {
2985
+ abortController = new AbortController();
2986
+ abortControllers.set(context, abortController);
2987
+ }
2988
+ context.signal = abortController.signal;
2989
+ context.task = test;
2990
+ context.skip = (condition, note) => {
2991
+ if (condition === false) return;
2992
+ test.result ??= { state: "skip" };
2993
+ test.result.pending = true;
2994
+ throw new PendingError("test is skipped; abort execution", test, typeof condition === "string" ? condition : note);
2995
+ };
2996
+ context.annotate = ((message, type, attachment) => {
2997
+ if (test.result && test.result.state !== "run") throw new Error(`Cannot annotate tests outside of the test run. The test "${test.name}" finished running with the "${test.result.state}" state already.`);
2998
+ const annotation = {
2999
+ message,
3000
+ type: typeof type === "object" || type === void 0 ? "notice" : type
3001
+ };
3002
+ const annotationAttachment = typeof type === "object" ? type : attachment;
3003
+ if (annotationAttachment) {
3004
+ annotation.attachment = annotationAttachment;
3005
+ manageArtifactAttachment(annotation.attachment);
3006
+ }
3007
+ return recordAsyncOperation(test, recordArtifact(test, {
3008
+ type: "internal:annotation",
3009
+ annotation
3010
+ }).then(async ({ annotation }) => {
3011
+ if (!runner.onTestAnnotate) throw new Error(`Test runner doesn't support test annotations.`);
3012
+ await finishSendTasksUpdate(runner);
3013
+ const resolvedAnnotation = await runner.onTestAnnotate(test, annotation);
3014
+ test.annotations.push(resolvedAnnotation);
3015
+ return resolvedAnnotation;
3016
+ }));
3017
+ });
3018
+ context.onTestFailed = (handler, timeout) => {
3019
+ test.onFailed ||= [];
3020
+ test.onFailed.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, /* @__PURE__ */ new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
3021
+ };
3022
+ context.onTestFinished = (handler, timeout) => {
3023
+ test.onFinished ||= [];
3024
+ test.onFinished.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, /* @__PURE__ */ new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
3025
+ };
3026
+ return runner.extendTaskContext?.(context) || context;
3027
+ }
3028
+ function makeTimeoutError(isHook, timeout, stackTraceError) {
3029
+ const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.\nIf this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
3030
+ const error = new Error(message);
3031
+ if (stackTraceError?.stack) error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
3032
+ return error;
3033
+ }
3034
+ globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3035
+ globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3036
+ Date.now;
3037
+ const { clearTimeout, setTimeout: setTimeout$1 } = getSafeTimers();
3038
+ const packs = /* @__PURE__ */ new Map();
3039
+ const eventsPacks = [];
3040
+ const pendingTasksUpdates = [];
3041
+ function sendTasksUpdate(runner) {
3042
+ if (packs.size) {
3043
+ const taskPacks = Array.from(packs).map(([id, task]) => {
3044
+ return [
3045
+ id,
3046
+ task[0],
3047
+ task[1]
3048
+ ];
3049
+ });
3050
+ const p = runner.onTaskUpdate?.(taskPacks, eventsPacks);
3051
+ if (p) {
3052
+ pendingTasksUpdates.push(p);
3053
+ p.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p), 1), () => {});
3054
+ }
3055
+ eventsPacks.length = 0;
3056
+ packs.clear();
3057
+ }
3058
+ }
3059
+ async function finishSendTasksUpdate(runner) {
3060
+ sendTasksUpdate(runner);
3061
+ await Promise.all(pendingTasksUpdates);
3062
+ }
3063
+ /**
3064
+ * @experimental
3065
+ * @advanced
3066
+ *
3067
+ * Records a custom test artifact during test execution.
3068
+ *
3069
+ * This function allows you to attach structured data, files, or metadata to a test.
3070
+ *
3071
+ * Vitest automatically injects the source location where the artifact was created and manages any attachments you include.
3072
+ *
3073
+ * **Note:** artifacts must be recorded before the task is reported. Any artifacts recorded after that will not be included in the task.
3074
+ *
3075
+ * @param task - The test task context, typically accessed via `this.task` in custom matchers or `context.task` in tests
3076
+ * @param artifact - The artifact to record. Must extend {@linkcode TestArtifactBase}
3077
+ *
3078
+ * @returns A promise that resolves to the recorded artifact with location injected
3079
+ *
3080
+ * @throws {Error} If the test runner doesn't support artifacts
3081
+ *
3082
+ * @example
3083
+ * ```ts
3084
+ * // In a custom assertion
3085
+ * async function toHaveValidSchema(this: MatcherState, actual: unknown) {
3086
+ * const validation = validateSchema(actual)
3087
+ *
3088
+ * await recordArtifact(this.task, {
3089
+ * type: 'my-plugin:schema-validation',
3090
+ * passed: validation.valid,
3091
+ * errors: validation.errors,
3092
+ * })
3093
+ *
3094
+ * return { pass: validation.valid, message: () => '...' }
3095
+ * }
3096
+ * ```
3097
+ */
3098
+ async function recordArtifact(task, artifact) {
3099
+ const runner = getRunner();
3100
+ const stack = findTestFileStackTrace(task.file.filepath, (/* @__PURE__ */ new Error("STACK_TRACE")).stack);
3101
+ if (stack) {
3102
+ artifact.location = {
3103
+ file: stack.file,
3104
+ line: stack.line,
3105
+ column: stack.column
3106
+ };
3107
+ if (artifact.type === "internal:annotation") artifact.annotation.location = artifact.location;
3108
+ }
3109
+ if (Array.isArray(artifact.attachments)) for (const attachment of artifact.attachments) manageArtifactAttachment(attachment);
3110
+ if (artifact.type === "internal:annotation") return artifact;
3111
+ if (!runner.onTestArtifactRecord) throw new Error(`Test runner doesn't support test artifacts.`);
3112
+ await finishSendTasksUpdate(runner);
3113
+ const resolvedArtifact = await runner.onTestArtifactRecord(task, artifact);
3114
+ task.artifacts.push(resolvedArtifact);
3115
+ return resolvedArtifact;
3116
+ }
3117
+ const table = [];
3118
+ for (let i = 65; i < 91; i++) table.push(String.fromCharCode(i));
3119
+ for (let i = 97; i < 123; i++) table.push(String.fromCharCode(i));
3120
+ for (let i = 0; i < 10; i++) table.push(i.toString(10));
3121
+ table.push("+", "/");
3122
+ function encodeUint8Array(bytes) {
3123
+ let base64 = "";
3124
+ const len = bytes.byteLength;
3125
+ for (let i = 0; i < len; i += 3) if (len === i + 1) {
3126
+ const a = (bytes[i] & 252) >> 2;
3127
+ const b = (bytes[i] & 3) << 4;
3128
+ base64 += table[a];
3129
+ base64 += table[b];
3130
+ base64 += "==";
3131
+ } else if (len === i + 2) {
3132
+ const a = (bytes[i] & 252) >> 2;
3133
+ const b = (bytes[i] & 3) << 4 | (bytes[i + 1] & 240) >> 4;
3134
+ const c = (bytes[i + 1] & 15) << 2;
3135
+ base64 += table[a];
3136
+ base64 += table[b];
3137
+ base64 += table[c];
3138
+ base64 += "=";
3139
+ } else {
3140
+ const a = (bytes[i] & 252) >> 2;
3141
+ const b = (bytes[i] & 3) << 4 | (bytes[i + 1] & 240) >> 4;
3142
+ const c = (bytes[i + 1] & 15) << 2 | (bytes[i + 2] & 192) >> 6;
3143
+ const d = bytes[i + 2] & 63;
3144
+ base64 += table[a];
3145
+ base64 += table[b];
3146
+ base64 += table[c];
3147
+ base64 += table[d];
3148
+ }
3149
+ return base64;
3150
+ }
3151
+ /**
3152
+ * Records an async operation associated with a test task.
3153
+ *
3154
+ * This function tracks promises that should be awaited before a test completes.
3155
+ * The promise is automatically removed from the test's promise list once it settles.
3156
+ */
3157
+ function recordAsyncOperation(test, promise) {
3158
+ promise = promise.finally(() => {
3159
+ if (!test.promises) return;
3160
+ const index = test.promises.indexOf(promise);
3161
+ if (index !== -1) test.promises.splice(index, 1);
3162
+ });
3163
+ if (!test.promises) test.promises = [];
3164
+ test.promises.push(promise);
3165
+ return promise;
3166
+ }
3167
+ /**
3168
+ * Validates and prepares a test attachment for serialization.
3169
+ *
3170
+ * This function ensures attachments have either `body` or `path` set (but not both), and converts `Uint8Array` bodies to base64-encoded strings for easier serialization.
3171
+ *
3172
+ * @param attachment - The attachment to validate and prepare
3173
+ *
3174
+ * @throws {TypeError} If neither `body` nor `path` is provided
3175
+ * @throws {TypeError} If both `body` and `path` are provided
3176
+ */
3177
+ function manageArtifactAttachment(attachment) {
3178
+ if (attachment.body == null && !attachment.path) throw new TypeError(`Test attachment requires "body" or "path" to be set. Both are missing.`);
3179
+ if (attachment.body && attachment.path) throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
3180
+ if (attachment.path && attachment.bodyEncoding) throw new TypeError(`Test attachment with "path" should not have "bodyEncoding" specified.`);
3181
+ if (attachment.body instanceof Uint8Array) attachment.body = encodeUint8Array(attachment.body);
3182
+ if (attachment.body != null) attachment.bodyEncoding ??= "base64";
3183
+ }
3184
+ //#endregion
3185
+ //#region extensions/memory-lancedb/test-helpers.ts
3186
+ function installTmpDirHarness(params) {
3187
+ let tmpDir = "";
3188
+ let dbPath = "";
3189
+ beforeEach(async () => {
3190
+ tmpDir = await fs.mkdtemp(path.join(resolvePreferredKlawTmpDir(), params.prefix));
3191
+ dbPath = path.join(tmpDir, "lancedb");
3192
+ });
3193
+ afterEach(async () => {
3194
+ if (tmpDir) await fs.rm(tmpDir, {
3195
+ recursive: true,
3196
+ force: true
3197
+ });
3198
+ });
3199
+ return {
3200
+ getTmpDir: () => tmpDir,
3201
+ getDbPath: () => dbPath
3202
+ };
3203
+ }
3204
+ //#endregion
3205
+ export { installTmpDirHarness };