@vitest/browser 4.1.0-beta.5 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@
23
23
  })();
24
24
  </script>
25
25
  <!-- !LOAD_METADATA! -->
26
- <script type="module" src="./assets/index-vKQ25zpc.js"></script>
26
+ <script type="module" src="./assets/index-Di71CKDo.js"></script>
27
27
  <link rel="stylesheet" href="./assets/index-Da0hb3oU.css">
28
28
  </head>
29
29
  <body>
@@ -66,8 +66,7 @@ const object = "object";
66
66
  const noop = (_, value) => value;
67
67
  const primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
68
68
  const Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
69
- const revive = (input, parsed, output, $) => {
70
- const lazy = [];
69
+ const resolver = (input, lazy, parsed, $) => (output) => {
71
70
  for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
72
71
  const k = ke[y];
73
72
  const value = output[k];
@@ -76,24 +75,29 @@ const revive = (input, parsed, output, $) => {
76
75
  if (typeof tmp === object && !parsed.has(tmp)) {
77
76
  parsed.add(tmp);
78
77
  output[k] = ignore;
79
- lazy.push({ k, a: [input, parsed, tmp, $] });
78
+ lazy.push({ o: output, k, r: tmp });
80
79
  } else
81
80
  output[k] = $.call(output, k, tmp);
82
81
  } else if (output[k] !== ignore)
83
82
  output[k] = $.call(output, k, value);
84
83
  }
85
- for (let { length } = lazy, i = 0; i < length; i++) {
86
- const { k, a } = lazy[i];
87
- output[k] = $.call(output, k, revive.apply(null, a));
88
- }
89
84
  return output;
90
85
  };
91
86
  const parse = (text, reviver) => {
92
87
  const input = $parse(text, Primitives).map(primitives);
93
- const value = input[0];
94
88
  const $ = noop;
95
- const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $) : value;
96
- return $.call({ "": tmp }, "", tmp);
89
+ let value = input[0];
90
+ if (typeof value === object && value) {
91
+ const lazy = [];
92
+ const revive = resolver(input, lazy, /* @__PURE__ */ new Set(), $);
93
+ value = revive(value);
94
+ let i = 0;
95
+ while (i < lazy.length) {
96
+ const { o, k, r } = lazy[i++];
97
+ o[k] = $.call(o, k, revive(r));
98
+ }
99
+ }
100
+ return $.call({ "": value }, "", value);
97
101
  };
98
102
  function showPopupWarning(name, value, defaultValue) {
99
103
  return (...params) => {
@@ -839,16 +843,13 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
839
843
  await ((_a = super.onBeforeTryTask) == null ? void 0 : _a.call(this, ...args));
840
844
  const trace = this.config.browser.trace;
841
845
  const test = args[0];
842
- if (trace === "off") {
843
- return;
844
- }
845
846
  const { retry, repeats } = args[1];
846
- if (trace === "on-all-retries" && retry === 0) {
847
- return;
848
- }
849
- if (trace === "on-first-retry" && retry !== 1) {
847
+ const shouldTrace = trace !== "off" && !(trace === "on-all-retries" && retry === 0) && !(trace === "on-first-retry" && retry !== 1);
848
+ if (!shouldTrace) {
849
+ getBrowserState().activeTraceTaskIds.delete(test.id);
850
850
  return;
851
851
  }
852
+ getBrowserState().activeTraceTaskIds.add(test.id);
852
853
  let title = getTestName(test);
853
854
  if (retry) {
854
855
  title += ` (retry x${retry})`;
@@ -863,16 +864,14 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
863
864
  );
864
865
  };
865
866
  onAfterRetryTask = async (test, { retry, repeats }) => {
866
- const trace = this.config.browser.trace;
867
- if (trace === "off") {
868
- return;
869
- }
870
- if (trace === "on-all-retries" && retry === 0) {
871
- return;
872
- }
873
- if (trace === "on-first-retry" && retry !== 1) {
867
+ var _a, _b, _c;
868
+ if (!getBrowserState().activeTraceTaskIds.has(test.id)) {
874
869
  return;
875
870
  }
871
+ await this.commands.triggerCommand("__vitest_markTrace", [{
872
+ name: `onAfterRetryTask [${(_a = test.result) == null ? void 0 : _a.state}]`,
873
+ stack: (_c = (_b = test.result) == null ? void 0 : _b.errors) == null ? void 0 : _c[0].stack
874
+ }]);
876
875
  const name = getTraceName(test, retry, repeats);
877
876
  if (!this.traces.has(test.id)) {
878
877
  this.traces.set(test.id, []);
@@ -1989,6 +1988,22 @@ function createModuleMockerInterceptor() {
1989
1988
  function rpc() {
1990
1989
  return getWorkerState().rpc;
1991
1990
  }
1991
+ const ACTION_TRACE_COMMANDS = /* @__PURE__ */ new Set([
1992
+ "__vitest_click",
1993
+ "__vitest_dblClick",
1994
+ "__vitest_tripleClick",
1995
+ "__vitest_wheel",
1996
+ "__vitest_type",
1997
+ "__vitest_clear",
1998
+ "__vitest_fill",
1999
+ "__vitest_selectOptions",
2000
+ "__vitest_dragAndDrop",
2001
+ "__vitest_hover",
2002
+ "__vitest_upload",
2003
+ "__vitest_tab",
2004
+ "__vitest_keyboard",
2005
+ "__vitest_takeScreenshot"
2006
+ ]);
1992
2007
  class CommandsManager {
1993
2008
  _listeners = [];
1994
2009
  onCommand(listener) {
@@ -2001,6 +2016,9 @@ class CommandsManager {
2001
2016
  const { sessionId, traces: traces2 } = getBrowserState();
2002
2017
  const filepath = state.filepath || ((_b = (_a = state.current) == null ? void 0 : _a.file) == null ? void 0 : _b.filepath);
2003
2018
  args = args.filter((arg) => arg !== void 0);
2019
+ const actionTraceGroupName = ACTION_TRACE_COMMANDS.has(command) ? command : void 0;
2020
+ const currentTest = getWorkerState().current;
2021
+ const shouldMarkTrace = actionTraceGroupName && !!currentTest && getBrowserState().activeTraceTaskIds.has(currentTest.id);
2004
2022
  if (this._listeners.length) {
2005
2023
  await Promise.all(this._listeners.map((listener) => listener(command, args)));
2006
2024
  }
@@ -2012,16 +2030,41 @@ class CommandsManager {
2012
2030
  "code.file.path": filepath
2013
2031
  }
2014
2032
  },
2015
- () => rpc2.triggerCommand(sessionId, command, filepath, args).catch((err) => {
2033
+ async () => {
2016
2034
  var _a2;
2017
- clientError.message = err.message;
2018
- clientError.name = err.name;
2019
- clientError.stack = (_a2 = clientError.stack) == null ? void 0 : _a2.replace(clientError.message, err.message);
2020
- throw clientError;
2021
- })
2035
+ if (shouldMarkTrace) {
2036
+ await rpc2.triggerCommand(
2037
+ sessionId,
2038
+ "__vitest_groupTraceStart",
2039
+ filepath,
2040
+ [{
2041
+ name: actionTraceGroupName,
2042
+ stack: clientError.stack
2043
+ }]
2044
+ );
2045
+ }
2046
+ try {
2047
+ return await rpc2.triggerCommand(sessionId, command, filepath, args);
2048
+ } catch (err) {
2049
+ clientError.message = err.message;
2050
+ clientError.name = err.name;
2051
+ clientError.stack = (_a2 = clientError.stack) == null ? void 0 : _a2.replace(clientError.message, err.message);
2052
+ throw clientError;
2053
+ } finally {
2054
+ if (shouldMarkTrace) {
2055
+ await rpc2.triggerCommand(
2056
+ sessionId,
2057
+ "__vitest_groupTraceEnd",
2058
+ filepath,
2059
+ []
2060
+ );
2061
+ }
2062
+ }
2063
+ }
2022
2064
  );
2023
2065
  }
2024
2066
  }
2067
+ globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2025
2068
  getBrowserState().provider;
2026
2069
  const debugVar = getConfig().env.VITEST_BROWSER_DEBUG;
2027
2070
  const debug = debugVar && debugVar !== "false" ? (...args) => {
@@ -2098,6 +2141,7 @@ const url = new URL(location.href);
2098
2141
  const iframeId = url.searchParams.get("iframeId");
2099
2142
  const commands = new CommandsManager();
2100
2143
  getBrowserState().commands = commands;
2144
+ getBrowserState().activeTraceTaskIds = /* @__PURE__ */ new Set();
2101
2145
  getBrowserState().iframeId = iframeId;
2102
2146
  let contextSwitched = false;
2103
2147
  async function prepareTestEnvironment(options) {
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vitest Browser Tester</title>
8
- <script type="module" crossorigin src="/__vitest_browser__/tester-C0ZOZX6s.js"></script>
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-K5NNxh1O.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-C2ISqq1C.js">
10
10
  </head>
11
11
  <body>
package/dist/client.js CHANGED
@@ -226,8 +226,7 @@ const Primitives = (_, value) => (
226
226
  typeof value === primitive ? new Primitive(value) : value
227
227
  );
228
228
 
229
- const revive = (input, parsed, output, $) => {
230
- const lazy = [];
229
+ const resolver = (input, lazy, parsed, $) => output => {
231
230
  for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {
232
231
  const k = ke[y];
233
232
  const value = output[k];
@@ -236,7 +235,7 @@ const revive = (input, parsed, output, $) => {
236
235
  if (typeof tmp === object && !parsed.has(tmp)) {
237
236
  parsed.add(tmp);
238
237
  output[k] = ignore;
239
- lazy.push({k, a: [input, parsed, tmp, $]});
238
+ lazy.push({ o: output, k, r: tmp });
240
239
  }
241
240
  else
242
241
  output[k] = $.call(output, k, tmp);
@@ -244,10 +243,6 @@ const revive = (input, parsed, output, $) => {
244
243
  else if (output[k] !== ignore)
245
244
  output[k] = $.call(output, k, value);
246
245
  }
247
- for (let {length} = lazy, i = 0; i < length; i++) {
248
- const {k, a} = lazy[i];
249
- output[k] = $.call(output, k, revive.apply(null, a));
250
- }
251
246
  return output;
252
247
  };
253
248
 
@@ -265,12 +260,24 @@ const set = (known, input, value) => {
265
260
  */
266
261
  const parse = (text, reviver) => {
267
262
  const input = $parse(text, Primitives).map(primitives);
268
- const value = input[0];
269
263
  const $ = reviver || noop;
270
- const tmp = typeof value === object && value ?
271
- revive(input, new Set, value, $) :
272
- value;
273
- return $.call({'': tmp}, '', tmp);
264
+
265
+ let value = input[0];
266
+
267
+ if (typeof value === object && value) {
268
+ const lazy = [];
269
+ const revive = resolver(input, lazy, new Set, $);
270
+ value = revive(value);
271
+
272
+ let i = 0;
273
+ while (i < lazy.length) {
274
+ // it could be a lazy.shift() but that's costly
275
+ const {o, k, r} = lazy[i++];
276
+ o[k] = $.call(o, k, revive(r));
277
+ }
278
+ }
279
+
280
+ return $.call({'': value}, '', value);
274
281
  };
275
282
 
276
283
  /**
package/dist/context.js CHANGED
@@ -23,9 +23,11 @@ function ensureAwaited(promise) {
23
23
  return (promiseResult ||= promise(sourceError)).then(onFulfilled, onRejected);
24
24
  },
25
25
  catch(onRejected) {
26
+ awaited = true;
26
27
  return (promiseResult ||= promise(sourceError)).catch(onRejected);
27
28
  },
28
29
  finally(onFinally) {
30
+ awaited = true;
29
31
  return (promiseResult ||= promise(sourceError)).finally(onFinally);
30
32
  },
31
33
  [Symbol.toStringTag]: "Promise"
@@ -118,7 +120,7 @@ function getParent(el) {
118
120
  }
119
121
  return parent;
120
122
  }
121
- const now = Date.now;
123
+ const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
122
124
  function processTimeoutOptions(options_) {
123
125
  if (options_ && options_.timeout != null) {
124
126
  return options_;
@@ -140,7 +142,7 @@ function processTimeoutOptions(options_) {
140
142
  options_ = options_ || {};
141
143
  const currentTime = now();
142
144
  const endTime = startTime + timeout;
143
- const remainingTime = endTime - currentTime;
145
+ const remainingTime = Math.floor(endTime - currentTime);
144
146
  if (remainingTime <= 0) {
145
147
  return options_;
146
148
  }
@@ -461,6 +463,34 @@ const page = {
461
463
  /** TODO */
462
464
  )], error));
463
465
  },
466
+ mark(name, bodyOrOptions, options) {
467
+ const currentTest = getWorkerState().current;
468
+ const hasActiveTrace = !!currentTest && getBrowserState().activeTraceTaskIds.has(currentTest.id);
469
+ if (typeof bodyOrOptions === "function") {
470
+ return ensureAwaited(async (error) => {
471
+ if (hasActiveTrace) {
472
+ await triggerCommand("__vitest_groupTraceStart", [{
473
+ name,
474
+ stack: options?.stack ?? error?.stack
475
+ }], error);
476
+ }
477
+ try {
478
+ return await bodyOrOptions();
479
+ } finally {
480
+ if (hasActiveTrace) {
481
+ await triggerCommand("__vitest_groupTraceEnd", [], error);
482
+ }
483
+ }
484
+ });
485
+ }
486
+ if (!hasActiveTrace) {
487
+ return Promise.resolve();
488
+ }
489
+ return ensureAwaited((error) => triggerCommand("__vitest_markTrace", [{
490
+ name,
491
+ stack: bodyOrOptions?.stack ?? error?.stack
492
+ }], error));
493
+ },
464
494
  getByRole() {
465
495
  throw new Error(`Method "getByRole" is not supported by the "${provider}" provider.`);
466
496
  },
@@ -1,27 +1,27 @@
1
- import{recordArtifact,expect,chai}from"vitest";import{getType}from"vitest/internal/browser";import{k as kAriaCheckedRoles,L as Locator,g as getAriaChecked,a as getAriaRole,b as getAriaDisabled,c as beginAriaCaches,e as endAriaCaches,i as isElementVisible$1,d as getElementAccessibleDescription,f as getElementAccessibleErrorMessage,h as getElementAccessibleName,j as cssEscape,l as convertToSelector,m as getBrowserState,p as processTimeoutOptions}from"./index-BvKPfXh9.js";import{server}from"vitest/browser";function getAriaCheckedRoles(){return[...kAriaCheckedRoles]}function queryElementFromUserInput(h,W,G){return h instanceof Locator&&(h=h.query()),h==null?null:getElementFromUserInput(h,W,G)}function getElementFromUserInput(h,W,G){h instanceof Locator&&(h=h.element());let K=h?.ownerDocument?.defaultView||window;if(h instanceof K.HTMLElement||h instanceof K.SVGElement)return h;throw new UserInputElementTypeError(h,W,G)}function getNodeFromUserInput(h,W,G){h instanceof Locator&&(h=h.element());let K=h.ownerDocument?.defaultView||window;if(h instanceof K.Node)return h;throw new UserInputNodeTypeError(h,W,G)}function getMessage(h,W,G,K,q,J){return[`${W}\n`,`${G}:\n${h.utils.EXPECTED_COLOR(redent(display(h,K),2))}`,`${q}:\n${h.utils.RECEIVED_COLOR(redent(display(h,J),2))}`].join(`
2
- `)}function redent(h,W){return indentString(stripIndent(h),W)}function indentString(h,W){return h.replace(/^(?!\s*$)/gm,` `.repeat(W))}function minIndent(h){let W=h.match(/^[ \t]*(?=\S)/gm);return W?W.reduce((h,W)=>Math.min(h,W.length),1/0):0}function stripIndent(h){let W=minIndent(h);if(W===0)return h;let G=RegExp(`^[ \\t]{${W}}`,`gm`);return h.replace(G,``)}function display(h,W){return typeof W==`string`?W:h.utils.stringify(W)}function toSentence(h,{wordConnector:W=`, `,lastWordConnector:G=` and `}={}){return[h.slice(0,-1).join(W),h.at(-1)].join(h.length>1?G:``)}class GenericTypeError extends Error{constructor(h,W,G,K){super(),Error.captureStackTrace&&Error.captureStackTrace(this,G);let q=``;try{q=K.utils.printWithType(`Received`,W,K.utils.printReceived)}catch{}this.message=[K.utils.matcherHint(`${K.isNot?`.not`:``}.${G.name}`,`received`,``),``,`${K.utils.RECEIVED_COLOR(`received`)} value must ${h} or a Locator that returns ${h}.`,q].join(`
3
- `)}}class UserInputElementTypeError extends GenericTypeError{constructor(h,W,G){super(`an HTMLElement or an SVGElement`,h,W,G)}}class UserInputNodeTypeError extends GenericTypeError{constructor(h,W,G){super(`a Node`,h,W,G)}}function getTag(h){return h instanceof HTMLFormElement?`FORM`:h.tagName.toUpperCase()}function isInputElement(h){return getTag(h)===`INPUT`}function getSingleElementValue(h){if(h)switch(getTag(h)){case`INPUT`:return getInputValue(h);case`SELECT`:return getSelectValue(h);default:return h.value??getAccessibleValue(h)}}function getSelectValue({multiple:h,options:W}){let G=[...W].filter(h=>h.selected);if(h)return[...G].map(h=>h.value);if(G.length!==0)return G[0].value}function getInputValue(h){switch(h.type){case`number`:return h.value===``?null:Number(h.value);case`checkbox`:return h.checked;default:return h.value}}const rolesSupportingValues=[`meter`,`progressbar`,`slider`,`spinbutton`];function getAccessibleValue(h){if(rolesSupportingValues.includes(h.getAttribute(`role`)||``))return Number(h.getAttribute(`aria-valuenow`))}function normalize(h){return h.replace(/\s+/g,` `).trim()}function matches(h,W){return W instanceof RegExp?W.test(h):h.includes(String(W))}function arrayAsSetComparison(h,W){if(Array.isArray(h)&&Array.isArray(W)){let G=new Set(W);for(let W of new Set(h))if(!G.has(W))return!1;return!0}}const supportedRoles=getAriaCheckedRoles();function toBeChecked(h){let W=getElementFromUserInput(h,toBeChecked,this);if(!(isInputElement(W)&&[`checkbox`,`radio`].includes(W.type))&&!(supportedRoles.includes(getAriaRole(W)||``)&&[`true`,`false`].includes(W.getAttribute(`aria-checked`)||``)))return{pass:!1,message:()=>`only inputs with type="checkbox" or type="radio" or elements with ${supportedRolesSentence()} and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead`};let G=getAriaChecked(W)===!0;return{pass:G,message:()=>{let h=G?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeChecked`,`element`,``),``,`Received element ${h} checked:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
4
- `)}}}function supportedRolesSentence(){return toSentence(supportedRoles.map(h=>`role="${h}"`),{lastWordConnector:` or `})}function toBeEmptyDOMElement(h){let W=getElementFromUserInput(h,toBeEmptyDOMElement,this);return{pass:isEmptyElement(W),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEmptyDOMElement`,`element`,``),``,`Received:`,` ${this.utils.printReceived(W.innerHTML)}`].join(`
5
- `)}}function isEmptyElement(h){return[...h.childNodes].filter(h=>h.nodeType!==Node.COMMENT_NODE).length===0}function toBeDisabled(h){let W=getElementFromUserInput(h,toBeDisabled,this),G=isElementDisabled(W);return{pass:G,message:()=>{let h=G?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeDisabled`,`element`,``),``,`Received element ${h} disabled:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
6
- `)}}}function toBeEnabled(h){let W=getElementFromUserInput(h,toBeEnabled,this),G=isElementDisabled(W);return{pass:!G,message:()=>{let h=G?`is not`:`is`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEnabled`,`element`,``),``,`Received element ${h} enabled:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
7
- `)}}}function isElementDisabled(h){return getTag(h).includes(`-`)?h.hasAttribute(`disabled`):getAriaDisabled(h)}function toBeInTheDocument(h){let W=null;(h!==null||!this.isNot)&&(W=queryElementFromUserInput(h,toBeInTheDocument,this));let G=W===null?!1:W.ownerDocument===W.getRootNode({composed:!0}),K=()=>`expected document not to contain element, found ${this.utils.stringify(W?.cloneNode(!0))} instead`,q=()=>`element could not be found in the document`;return{pass:G,message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInTheDocument`,`element`,``),``,this.utils.RECEIVED_COLOR(this.isNot?K():q())].join(`
8
- `)}}const FORM_TAGS$1=[`FORM`,`INPUT`,`SELECT`,`TEXTAREA`];function isElementHavingAriaInvalid(h){return h.hasAttribute(`aria-invalid`)&&h.getAttribute(`aria-invalid`)!==`false`}function isSupportsValidityMethod(h){return FORM_TAGS$1.includes(getTag(h))}function isElementInvalid(h){let W=isElementHavingAriaInvalid(h);return isSupportsValidityMethod(h)?W||!h.checkValidity():W}function toBeInvalid(h){let W=getElementFromUserInput(h,toBeInvalid,this),G=isElementInvalid(W);return{pass:G,message:()=>{let h=G?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInvalid`,`element`,``),``,`Received element ${h} currently invalid:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
9
- `)}}}function toBeValid(h){let W=getElementFromUserInput(h,toBeInvalid,this),G=!isElementInvalid(W);return{pass:G,message:()=>{let h=G?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeValid`,`element`,``),``,`Received element ${h} currently valid:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
10
- `)}}}function toBeInViewport(h,W){let G=getElementFromUserInput(h,toBeInViewport,this),K=W?.ratio??0;return getViewportIntersection(G,K).then(({pass:h,ratio:W})=>({pass:h,message:()=>{let q=h?`is`:`is not`,J=K>0?` with ratio ${K}`:``,Y=W===void 0?``:` (actual ratio: ${W.toFixed(3)})`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInViewport`,`element`,``),``,`Received element ${q} in viewport${J}${Y}:`,` ${this.utils.printReceived(G.cloneNode(!1))}`].join(`
11
- `)}}))}async function getViewportIntersection(h,W){let G=await new Promise(W=>{let G=new IntersectionObserver(h=>{h.length>0?W(h[0].intersectionRatio):W(0),G.disconnect()});G.observe(h),requestAnimationFrame(()=>{})});return{pass:G>0&&G>W-1e-9,ratio:G}}function toBePartiallyChecked(h){let W=getElementFromUserInput(h,toBePartiallyChecked,this);if(!(isInputElement(W)&&W.type===`checkbox`)&&W.getAttribute(`role`)!==`checkbox`)return{pass:!1,message:()=>`only inputs with type="checkbox" or elements with role="checkbox" and a valid aria-checked attribute can be used with .toBePartiallyChecked(). Use .toHaveValue() instead`};let G=isAriaMixed(W);return{pass:G,message:()=>{let h=G?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBePartiallyChecked`,`element`,``),``,`Received element ${h} partially checked:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
12
- `)}}}function isAriaMixed(h){let W=getAriaChecked(h)===`mixed`;return!W&&isInputElement(h)&&[`checkbox`,`radio`].includes(h.type)&&h.getAttribute(`aria-checked`)===`mixed`?!0:W}const FORM_TAGS=[`SELECT`,`TEXTAREA`],ARIA_FORM_TAGS=[`INPUT`,`SELECT`,`TEXTAREA`],UNSUPPORTED_INPUT_TYPES=[`color`,`hidden`,`range`,`submit`,`image`,`reset`],SUPPORTED_ARIA_ROLES=[`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`spinbutton`,`textbox`,`tree`];function isRequiredOnFormTagsExceptInput(h){return FORM_TAGS.includes(getTag(h))&&h.hasAttribute(`required`)}function isRequiredOnSupportedInput(h){return getTag(h)===`INPUT`&&h.hasAttribute(`required`)&&(h.hasAttribute(`type`)&&!UNSUPPORTED_INPUT_TYPES.includes(h.getAttribute(`type`)||``)||!h.hasAttribute(`type`))}function isElementRequiredByARIA(h){return h.hasAttribute(`aria-required`)&&h.getAttribute(`aria-required`)===`true`&&(ARIA_FORM_TAGS.includes(getTag(h))||h.hasAttribute(`role`)&&SUPPORTED_ARIA_ROLES.includes(h.getAttribute(`role`)||``))}function toBeRequired(h){let W=getElementFromUserInput(h,toBeRequired,this),G=isRequiredOnFormTagsExceptInput(W)||isRequiredOnSupportedInput(W)||isElementRequiredByARIA(W);return{pass:G,message:()=>{let h=G?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeRequired`,`element`,``),``,`Received element ${h} required:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
13
- `)}}}function toBeVisible(h){let W=getElementFromUserInput(h,toBeVisible,this),G=W.ownerDocument===W.getRootNode({composed:!0});beginAriaCaches();let K=G&&isElementVisible(W);return endAriaCaches(),{pass:K,message:()=>{let h=K?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeVisible`,`element`,``),``,`Received element ${h} visible${G?``:` (element is not in the document)`}:`,` ${this.utils.printReceived(W.cloneNode(!1))}`].join(`
14
- `)}}}function isElementVisible(h){let W=isElementVisible$1(h);if(server.browser!==`webkit`)return W;let G=h.closest(`details`);return!G||h===G?W:isElementVisibleInDetails(h)}function isElementVisibleInDetails(h){let W=h;for(;W;){if(W.tagName===`DETAILS`){let G=W.querySelector(`summary`)===h;if(!W.open&&!G)return!1}W=W.parentElement}return h.offsetParent!==null}function toContainElement(h,W){let G=getElementFromUserInput(h,toContainElement,this),K=W===null?null:getElementFromUserInput(W,toContainElement,this);return{pass:G.contains(K),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toContainElement`,`element`,`element`),``,this.utils.RECEIVED_COLOR(`${this.utils.stringify(G.cloneNode(!1))} ${this.isNot?`contains:`:`does not contain:`} ${this.utils.stringify(K?K.cloneNode(!1):null)}
1
+ import{recordArtifact as e,expect as t,chai as n}from"vitest";import{getType as r}from"vitest/internal/browser";import{k as i,L as a,g as o,a as s,b as c,c as l,e as u,i as ee,d as te,f as ne,h as re,j as ie,l as d,m as f,p as ae,n as oe}from"./index-5Pe7X7sp.js";import{server as p}from"vitest/browser";function se(){return[...i]}function ce(e,t,n){return e instanceof a&&(e=e.query()),e==null?null:m(e,t,n)}function m(e,t,n){e instanceof a&&(e=e.element());let r=e?.ownerDocument?.defaultView||window;if(e instanceof r.HTMLElement||e instanceof r.SVGElement)return e;throw new me(e,t,n)}function le(e,t,n){e instanceof a&&(e=e.element());let r=e.ownerDocument?.defaultView||window;if(e instanceof r.Node)return e;throw new he(e,t,n)}function h(e,t,n,r,i,a){return[`${t}\n`,`${n}:\n${e.utils.EXPECTED_COLOR(g(_(e,r),2))}`,`${i}:\n${e.utils.RECEIVED_COLOR(g(_(e,a),2))}`].join(`
2
+ `)}function g(e,t){return ue(fe(e),t)}function ue(e,t){return e.replace(/^(?!\s*$)/gm,` `.repeat(t))}function de(e){let t=e.match(/^[ \t]*(?=\S)/gm);return t?t.reduce((e,t)=>Math.min(e,t.length),1/0):0}function fe(e){let t=de(e);if(t===0)return e;let n=RegExp(`^[ \\t]{${t}}`,`gm`);return e.replace(n,``)}function _(e,t){return typeof t==`string`?t:e.utils.stringify(t)}function pe(e,{wordConnector:t=`, `,lastWordConnector:n=` and `}={}){return[e.slice(0,-1).join(t),e.at(-1)].join(e.length>1?n:``)}class v extends Error{constructor(e,t,n,r){super(),Error.captureStackTrace&&Error.captureStackTrace(this,n);let i=``;try{i=r.utils.printWithType(`Received`,t,r.utils.printReceived)}catch{}this.message=[r.utils.matcherHint(`${r.isNot?`.not`:``}.${n.name}`,`received`,``),``,`${r.utils.RECEIVED_COLOR(`received`)} value must ${e} or a Locator that returns ${e}.`,i].join(`
3
+ `)}}class me extends v{constructor(e,t,n){super(`an HTMLElement or an SVGElement`,e,t,n)}}class he extends v{constructor(e,t,n){super(`a Node`,e,t,n)}}function y(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function b(e){return y(e)===`INPUT`}function x(e){if(e)switch(y(e)){case`INPUT`:return _e(e);case`SELECT`:return ge(e);default:return e.value??ye(e)}}function ge({multiple:e,options:t}){let n=[...t].filter(e=>e.selected);if(e)return[...n].map(e=>e.value);if(n.length!==0)return n[0].value}function _e(e){switch(e.type){case`number`:return e.value===``?null:Number(e.value);case`checkbox`:return e.checked;default:return e.value}}const ve=[`meter`,`progressbar`,`slider`,`spinbutton`];function ye(e){if(ve.includes(e.getAttribute(`role`)||``))return Number(e.getAttribute(`aria-valuenow`))}function be(e){return e.replace(/\s+/g,` `).trim()}function xe(e,t){return t instanceof RegExp?t.test(e):e.includes(String(t))}function S(e,t){if(Array.isArray(e)&&Array.isArray(t)){let n=new Set(t);for(let t of new Set(e))if(!n.has(t))return!1;return!0}}const C=se();function w(e){let t=m(e,w,this);if(!(b(t)&&[`checkbox`,`radio`].includes(t.type))&&!(C.includes(s(t)||``)&&[`true`,`false`].includes(t.getAttribute(`aria-checked`)||``)))return{pass:!1,message:()=>`only inputs with type="checkbox" or type="radio" or elements with ${Se()} and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead`};let n=o(t)===!0;return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeChecked`,`element`,``),``,`Received element ${e} checked:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
4
+ `)}}}function Se(){return pe(C.map(e=>`role="${e}"`),{lastWordConnector:` or `})}function T(e){let t=m(e,T,this);return{pass:Ce(t),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEmptyDOMElement`,`element`,``),``,`Received:`,` ${this.utils.printReceived(t.innerHTML)}`].join(`
5
+ `)}}function Ce(e){return[...e.childNodes].filter(e=>e.nodeType!==Node.COMMENT_NODE).length===0}function E(e){let t=m(e,E,this),n=O(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeDisabled`,`element`,``),``,`Received element ${e} disabled:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
6
+ `)}}}function D(e){let t=m(e,D,this),n=O(t);return{pass:!n,message:()=>{let e=n?`is not`:`is`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEnabled`,`element`,``),``,`Received element ${e} enabled:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
7
+ `)}}}function O(e){return y(e).includes(`-`)?e.hasAttribute(`disabled`):c(e)}function k(e){let t=null;(e!==null||!this.isNot)&&(t=ce(e,k,this));let n=t===null?!1:t.ownerDocument===t.getRootNode({composed:!0}),r=()=>`expected document not to contain element, found ${this.utils.stringify(t?.cloneNode(!0))} instead`,i=()=>`element could not be found in the document`;return{pass:n,message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInTheDocument`,`element`,``),``,this.utils.RECEIVED_COLOR(this.isNot?r():i())].join(`
8
+ `)}}const we=[`FORM`,`INPUT`,`SELECT`,`TEXTAREA`];function Te(e){return e.hasAttribute(`aria-invalid`)&&e.getAttribute(`aria-invalid`)!==`false`}function Ee(e){return we.includes(y(e))}function A(e){let t=Te(e);return Ee(e)?t||!e.checkValidity():t}function j(e){let t=m(e,j,this),n=A(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInvalid`,`element`,``),``,`Received element ${e} currently invalid:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
9
+ `)}}}function De(e){let t=m(e,j,this),n=!A(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeValid`,`element`,``),``,`Received element ${e} currently valid:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
10
+ `)}}}function M(e,t){let n=m(e,M,this),r=t?.ratio??0;return Oe(n,r).then(({pass:e,ratio:t})=>({pass:e,message:()=>{let i=e?`is`:`is not`,a=r>0?` with ratio ${r}`:``,o=t===void 0?``:` (actual ratio: ${t.toFixed(3)})`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeInViewport`,`element`,``),``,`Received element ${i} in viewport${a}${o}:`,` ${this.utils.printReceived(n.cloneNode(!1))}`].join(`
11
+ `)}}))}async function Oe(e,t){let n=await new Promise(t=>{let n=new IntersectionObserver(e=>{e.length>0?t(e[0].intersectionRatio):t(0),n.disconnect()});n.observe(e),requestAnimationFrame(()=>{})});return{pass:n>0&&n>t-1e-9,ratio:n}}function N(e){let t=m(e,N,this);if(!(b(t)&&t.type===`checkbox`)&&t.getAttribute(`role`)!==`checkbox`)return{pass:!1,message:()=>`only inputs with type="checkbox" or elements with role="checkbox" and a valid aria-checked attribute can be used with .toBePartiallyChecked(). Use .toHaveValue() instead`};let n=ke(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBePartiallyChecked`,`element`,``),``,`Received element ${e} partially checked:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
12
+ `)}}}function ke(e){let t=o(e)===`mixed`;return!t&&b(e)&&[`checkbox`,`radio`].includes(e.type)&&e.getAttribute(`aria-checked`)===`mixed`?!0:t}const Ae=[`SELECT`,`TEXTAREA`],je=[`INPUT`,`SELECT`,`TEXTAREA`],Me=[`color`,`hidden`,`range`,`submit`,`image`,`reset`],Ne=[`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`spinbutton`,`textbox`,`tree`];function Pe(e){return Ae.includes(y(e))&&e.hasAttribute(`required`)}function Fe(e){return y(e)===`INPUT`&&e.hasAttribute(`required`)&&(e.hasAttribute(`type`)&&!Me.includes(e.getAttribute(`type`)||``)||!e.hasAttribute(`type`))}function Ie(e){return e.hasAttribute(`aria-required`)&&e.getAttribute(`aria-required`)===`true`&&(je.includes(y(e))||e.hasAttribute(`role`)&&Ne.includes(e.getAttribute(`role`)||``))}function P(e){let t=m(e,P,this),n=Pe(t)||Fe(t)||Ie(t);return{pass:n,message:()=>{let e=n?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeRequired`,`element`,``),``,`Received element ${e} required:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
13
+ `)}}}function Le(e){let t=m(e,Le,this),n=t.ownerDocument===t.getRootNode({composed:!0});l();let r=n&&Re(t);return u(),{pass:r,message:()=>{let e=r?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeVisible`,`element`,``),``,`Received element ${e} visible${n?``:` (element is not in the document)`}:`,` ${this.utils.printReceived(t.cloneNode(!1))}`].join(`
14
+ `)}}}function Re(e){let t=ee(e);if(p.browser!==`webkit`)return t;let n=e.closest(`details`);return!n||e===n?t:ze(e)}function ze(e){let t=e;for(;t;){if(t.tagName===`DETAILS`){let n=t.querySelector(`summary`)===e;if(!t.open&&!n)return!1}t=t.parentElement}return e.offsetParent!==null}function F(e,t){let n=m(e,F,this),r=t===null?null:m(t,F,this);return{pass:n.contains(r),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toContainElement`,`element`,`element`),``,this.utils.RECEIVED_COLOR(`${this.utils.stringify(n.cloneNode(!1))} ${this.isNot?`contains:`:`does not contain:`} ${this.utils.stringify(r?r.cloneNode(!1):null)}
15
15
  `)].join(`
16
- `)}}function getNormalizedHtml(h,W){let G=h.ownerDocument.createElement(`div`);return G.innerHTML=W,G.innerHTML}function toContainHTML(h,W){let G=getElementFromUserInput(h,toContainHTML,this);if(typeof W!=`string`)throw TypeError(`.toContainHTML() expects a string value, got ${W}`);return{pass:G.outerHTML.includes(getNormalizedHtml(G,W)),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toContainHTML`,`element`,``),`Expected:`,` ${this.utils.EXPECTED_COLOR(W)}`,`Received:`,` ${this.utils.printReceived(G.cloneNode(!0))}`].join(`
17
- `)}}function toHaveAccessibleDescription(h,W){let G=getElementFromUserInput(h,toHaveAccessibleDescription,this),K=getElementAccessibleDescription(G,!1),q=G.ownerDocument.defaultView||window,J=arguments.length===1,Y=!1;return Y=J?K!==``:W instanceof q.RegExp?W.test(K):this.equals(K,W,this.customTesters),{pass:Y,message:()=>{let h=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleDescription`,`element`,``),`Expected element ${h} have accessible description`,W,`Received`,K)}}}function toHaveAccessibleErrorMessage(h,W){let G=getElementFromUserInput(h,toHaveAccessibleErrorMessage,this),K=getElementAccessibleErrorMessage(G)??``,q=G.ownerDocument.defaultView||window,J=arguments.length===1,Y=!1;return Y=J?K!==``:W instanceof q.RegExp?W.test(K):this.equals(K,W,this.customTesters),{pass:Y,message:()=>{let h=this.isNot?`not to`:`to`;return W==null?[this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleErrorMessage`,`element`,``),`Expected element ${h} have accessible error message, but got${this.isNot?``:` nothing`}`,this.isNot?this.utils.RECEIVED_COLOR(redent(K,2)):``].filter(Boolean).join(`
16
+ `)}}function Be(e,t){let n=e.ownerDocument.createElement(`div`);return n.innerHTML=t,n.innerHTML}function I(e,t){let n=m(e,I,this);if(typeof t!=`string`)throw TypeError(`.toContainHTML() expects a string value, got ${t}`);return{pass:n.outerHTML.includes(Be(n,t)),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toContainHTML`,`element`,``),`Expected:`,` ${this.utils.EXPECTED_COLOR(t)}`,`Received:`,` ${this.utils.printReceived(n.cloneNode(!0))}`].join(`
17
+ `)}}function L(e,t){let n=m(e,L,this),r=te(n,!1),i=n.ownerDocument.defaultView||window,a=arguments.length===1,o=!1;return o=a?r!==``:t instanceof i.RegExp?t.test(r):this.equals(r,t,this.customTesters),{pass:o,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleDescription`,`element`,``),`Expected element ${e} have accessible description`,t,`Received`,r)}}}function R(e,t){let n=m(e,R,this),r=ne(n)??``,i=n.ownerDocument.defaultView||window,a=arguments.length===1,o=!1;return o=a?r!==``:t instanceof i.RegExp?t.test(r):this.equals(r,t,this.customTesters),{pass:o,message:()=>{let e=this.isNot?`not to`:`to`;return t==null?[this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleErrorMessage`,`element`,``),`Expected element ${e} have accessible error message, but got${this.isNot?``:` nothing`}`,this.isNot?this.utils.RECEIVED_COLOR(g(r,2)):``].filter(Boolean).join(`
18
18
 
19
- `):getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleErrorMessage`,`element`,``),`Expected element ${h} have accessible error message`,W,`Received`,K)}}}function toHaveAccessibleName(h,W){let G=getElementFromUserInput(h,toHaveAccessibleName,this),K=getElementAccessibleName(G,!1),q=arguments.length===1,J=G.ownerDocument.defaultView||window,Y=!1;return Y=q?K!==``:W instanceof J.RegExp?W.test(K):this.equals(K,W,this.customTesters),{pass:Y,message:()=>{let h=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.${toHaveAccessibleName.name}`,`element`,``),`Expected element ${h} have accessible name`,W,`Received`,K)}}}function toHaveAttribute(h,W,G){let K=getElementFromUserInput(h,toHaveAttribute,this),q=G!==void 0,J=K.hasAttribute(W),Y=K.getAttribute(W);return{pass:q?J&&this.equals(Y,G,this.customTesters):J,message:()=>{let h=this.isNot?`not to`:`to`,K=J?printAttribute(this.utils.stringify,W,Y):null,X=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAttribute`,`element`,this.utils.printExpected(W),{secondArgument:q?this.utils.printExpected(G):void 0,comment:getAttributeComment(this.utils.stringify,W,G)});return getMessage(this,X,`Expected the element ${h} have attribute`,printAttribute(this.utils.stringify,W,G),`Received`,K)}}}function printAttribute(h,W,G){return G===void 0?W:`${W}=${h(G)}`}function getAttributeComment(h,W,G){return G===void 0?`element.hasAttribute(${h(W)})`:`element.getAttribute(${h(W)}) === ${h(G)}`}function toHaveClass(h,...W){let G=getElementFromUserInput(h,toHaveClass,this),{expectedClassNames:K,options:q}=getExpectedClassNamesAndOptions(W),J=splitClassNames(G.getAttribute(`class`)),Y=K.reduce((h,W)=>h.concat(typeof W==`string`||!W?splitClassNames(W):W),[]),X=Y.some(h=>h instanceof RegExp);if(q.exact&&X)throw Error(`Exact option does not support RegExp expected class names`);return q.exact?{pass:isSubset$1(Y,J)&&Y.length===J.length,message:()=>{let h=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveClass`,`element`,this.utils.printExpected(Y.join(` `))),`Expected the element ${h} have EXACTLY defined classes`,Y.join(` `),`Received`,J.join(` `))}}:Y.length>0?{pass:isSubset$1(Y,J),message:()=>{let h=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveClass`,`element`,this.utils.printExpected(Y.join(` `))),`Expected the element ${h} have class`,Y.join(` `),`Received`,J.join(` `))}}:{pass:this.isNot?J.length>0:!1,message:()=>this.isNot?getMessage(this,this.utils.matcherHint(`.not.toHaveClass`,`element`,``),`Expected the element to have classes`,`(none)`,`Received`,J.join(` `)):[this.utils.matcherHint(`.toHaveClass`,`element`),`At least one expected class must be provided.`].join(`
20
- `)}}function getExpectedClassNamesAndOptions(h){let W=h.pop(),G,K;return typeof W==`object`&&!(W instanceof RegExp)?(G=h,K=W):(G=h.concat(W),K={exact:!1}),{expectedClassNames:G,options:K}}function splitClassNames(h){return h?h.split(/\s+/).filter(h=>h.length>0):[]}function isSubset$1(h,W){return h.every(h=>typeof h==`string`?W.includes(h):W.some(W=>h.test(W)))}function toHaveDisplayValue(h,W){let G=getElementFromUserInput(h,toHaveDisplayValue,this),K=getTag(G);if(![`SELECT`,`INPUT`,`TEXTAREA`].includes(K))throw Error(`.toHaveDisplayValue() currently supports only input, textarea or select elements, try with another matcher instead.`);if(isInputElement(G)&&[`radio`,`checkbox`].includes(G.type))throw Error(`.toHaveDisplayValue() currently does not support input[type="${G.type}"], try with another matcher instead.`);let q=getValues(K,G),J=getExpectedValues(W),Y=J.filter(h=>q.some(W=>h instanceof RegExp?h.test(W):this.equals(W,String(h),this.customTesters))).length,X=Y===q.length,Z=Y===J.length;return{pass:X&&Z,message:()=>getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveDisplayValue`,`element`,``),`Expected element ${this.isNot?`not `:``}to have display value`,W,`Received`,q)}}function getValues(h,W){return h===`SELECT`?Array.from(W).filter(h=>h.selected).map(h=>h.textContent||``):[W.value]}function getExpectedValues(h){return Array.isArray(h)?h:[h]}function toHaveFocus(h){let W=getElementFromUserInput(h,toHaveFocus,this);return{pass:W.ownerDocument.activeElement===W,message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveFocus`,`element`,``),``,...this.isNot?[`Received element is focused:`,` ${this.utils.printReceived(W)}`]:[`Expected element with focus:`,` ${this.utils.printExpected(W)}`,`Received element with focus:`,` ${this.utils.printReceived(W.ownerDocument.activeElement)}`]].join(`
21
- `)}}function toHaveFormValues(h,W){let G=getElementFromUserInput(h,toHaveFormValues,this),K=G.ownerDocument.defaultView||window;if(!(G instanceof K.HTMLFieldSetElement)&&!(G instanceof K.HTMLFormElement))throw TypeError(`toHaveFormValues must be called on a form or a fieldset, instead got ${getTag(G)}`);if(!W||typeof W!=`object`)throw TypeError(`toHaveFormValues must be called with an object of expected form values. Got ${W}`);let q=getAllFormValues(G);return{pass:Object.entries(W).every(([h,W])=>this.equals(q[h],W,[arrayAsSetComparison,...this.customTesters])),message:()=>{let h=this.isNot?`not to`:`to`,G=`${this.isNot?`.not`:``}.toHaveFormValues`,K={};for(let h in q)Object.hasOwn(W,h)&&(K[h]=q[h]);return[this.utils.matcherHint(G,`element`,``),`Expected the element ${h} have form values`,this.utils.diff(W,K)].join(`
19
+ `):h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAccessibleErrorMessage`,`element`,``),`Expected element ${e} have accessible error message`,t,`Received`,r)}}}function z(e,t){let n=m(e,z,this),r=re(n,!1),i=arguments.length===1,a=n.ownerDocument.defaultView||window,o=!1;return o=i?r!==``:t instanceof a.RegExp?t.test(r):this.equals(r,t,this.customTesters),{pass:o,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.${z.name}`,`element`,``),`Expected element ${e} have accessible name`,t,`Received`,r)}}}function B(e,t,n){let r=m(e,B,this),i=n!==void 0,a=r.hasAttribute(t),o=r.getAttribute(t);return{pass:i?a&&this.equals(o,n,this.customTesters):a,message:()=>{let e=this.isNot?`not to`:`to`,r=a?V(this.utils.stringify,t,o):null,s=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveAttribute`,`element`,this.utils.printExpected(t),{secondArgument:i?this.utils.printExpected(n):void 0,comment:Ve(this.utils.stringify,t,n)});return h(this,s,`Expected the element ${e} have attribute`,V(this.utils.stringify,t,n),`Received`,r)}}}function V(e,t,n){return n===void 0?t:`${t}=${e(n)}`}function Ve(e,t,n){return n===void 0?`element.hasAttribute(${e(t)})`:`element.getAttribute(${e(t)}) === ${e(n)}`}function H(e,...t){let n=m(e,H,this),{expectedClassNames:r,options:i}=He(t),a=U(n.getAttribute(`class`)),o=r.reduce((e,t)=>e.concat(typeof t==`string`||!t?U(t):t),[]),s=o.some(e=>e instanceof RegExp);if(i.exact&&s)throw Error(`Exact option does not support RegExp expected class names`);return i.exact?{pass:W(o,a)&&o.length===a.length,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveClass`,`element`,this.utils.printExpected(o.join(` `))),`Expected the element ${e} have EXACTLY defined classes`,o.join(` `),`Received`,a.join(` `))}}:o.length>0?{pass:W(o,a),message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveClass`,`element`,this.utils.printExpected(o.join(` `))),`Expected the element ${e} have class`,o.join(` `),`Received`,a.join(` `))}}:{pass:this.isNot?a.length>0:!1,message:()=>this.isNot?h(this,this.utils.matcherHint(`.not.toHaveClass`,`element`,``),`Expected the element to have classes`,`(none)`,`Received`,a.join(` `)):[this.utils.matcherHint(`.toHaveClass`,`element`),`At least one expected class must be provided.`].join(`
20
+ `)}}function He(e){let t=e.pop(),n,r;return typeof t==`object`&&!(t instanceof RegExp)?(n=e,r=t):(n=e.concat(t),r={exact:!1}),{expectedClassNames:n,options:r}}function U(e){return e?e.split(/\s+/).filter(e=>e.length>0):[]}function W(e,t){return e.every(e=>typeof e==`string`?t.includes(e):t.some(t=>e.test(t)))}function G(e,t){let n=m(e,G,this),r=y(n);if(![`SELECT`,`INPUT`,`TEXTAREA`].includes(r))throw Error(`.toHaveDisplayValue() currently supports only input, textarea or select elements, try with another matcher instead.`);if(b(n)&&[`radio`,`checkbox`].includes(n.type))throw Error(`.toHaveDisplayValue() currently does not support input[type="${n.type}"], try with another matcher instead.`);let i=Ue(r,n),a=We(t),o=a.filter(e=>i.some(t=>e instanceof RegExp?e.test(t):this.equals(t,String(e),this.customTesters))).length,s=o===i.length,c=o===a.length;return{pass:s&&c,message:()=>h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveDisplayValue`,`element`,``),`Expected element ${this.isNot?`not `:``}to have display value`,t,`Received`,i)}}function Ue(e,t){return e===`SELECT`?Array.from(t).filter(e=>e.selected).map(e=>e.textContent||``):[t.value]}function We(e){return Array.isArray(e)?e:[e]}function K(e){let t=m(e,K,this);return{pass:t.ownerDocument.activeElement===t,message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveFocus`,`element`,``),``,...this.isNot?[`Received element is focused:`,` ${this.utils.printReceived(t)}`]:[`Expected element with focus:`,` ${this.utils.printExpected(t)}`,`Received element with focus:`,` ${this.utils.printReceived(t.ownerDocument.activeElement)}`]].join(`
21
+ `)}}function q(e,t){let n=m(e,q,this),r=n.ownerDocument.defaultView||window;if(!(n instanceof r.HTMLFieldSetElement)&&!(n instanceof r.HTMLFormElement))throw TypeError(`toHaveFormValues must be called on a form or a fieldset, instead got ${y(n)}`);if(!t||typeof t!=`object`)throw TypeError(`toHaveFormValues must be called with an object of expected form values. Got ${t}`);let i=Je(n);return{pass:Object.entries(t).every(([e,t])=>this.equals(i[e],t,[S,...this.customTesters])),message:()=>{let e=this.isNot?`not to`:`to`,n=`${this.isNot?`.not`:``}.toHaveFormValues`,r={};for(let e in i)Object.hasOwn(t,e)&&(r[e]=i[e]);return[this.utils.matcherHint(n,`element`,``),`Expected the element ${e} have form values`,this.utils.diff(t,r)].join(`
22
22
 
23
- `)}}}function getMultiElementValue(h){let W=``;for(let G of h){if(W&&W!==G.type)throw Error(`Multiple form elements with the same name must be of the same type`);W=G.type}switch(W){case`radio`:{let W=h.find(h=>h.checked);return W?W.value:void 0}case`checkbox`:return h.filter(h=>h.checked).map(h=>h.value);default:return h.map(h=>h.value)}}function getFormValue(h,W){let G=[...h.querySelectorAll(`[name="${cssEscape(W)}"]`)];if(G.length!==0)switch(G.length){case 1:return getSingleElementValue(G[0]);default:return getMultiElementValue(G)}}function getPureName(h){return/\[\]$/.test(h)?h.slice(0,-2):h}function getAllFormValues(h){let W={};for(let G of h.elements){if(!(`name`in G))continue;let K=G.name;W[getPureName(K)]=getFormValue(h,K)}return W}function toHaveRole(h,W){let G=getElementFromUserInput(h,toHaveRole,this);beginAriaCaches();let K=getAriaRole(G);return endAriaCaches(),{pass:K===W,message:()=>{let h=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveRole`,`element`,``),`Expected element ${h} have role`,W,`Received`,K)}}}function toHaveSelection(h,W){let G=getElementFromUserInput(h,toHaveSelection,this),K=W!==void 0;if(K&&typeof W!=`string`)throw Error(`expected selection must be a string or undefined`);let q=getSelection(G);return{pass:K?this.equals(q,W,[arrayAsSetComparison,...this.customTesters]):!!q,message:()=>{let h=this.isNot?`not to`:`to`,G=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveSelection`,`element`,W);return getMessage(this,G,`Expected the element ${h} have selection`,K?W:`(any)`,`Received`,q)}}}function getSelection(h){let W=h.ownerDocument.getSelection();if(!W)return``;if([`INPUT`,`TEXTAREA`].includes(getTag(h))){let W=h;return[`radio`,`checkbox`].includes(W.type)||W.selectionStart==null||W.selectionEnd==null?``:W.value.toString().substring(W.selectionStart,W.selectionEnd)}if(W.anchorNode===null||W.focusNode===null)return``;let G=W.getRangeAt(0),K=h.ownerDocument.createRange();if(W.containsNode(h,!1))K.selectNodeContents(h),W.removeAllRanges(),W.addRange(K);else if(!(h.contains(W.anchorNode)&&h.contains(W.focusNode))){let q=h===G.startContainer||h.contains(G.startContainer),J=h===G.endContainer||h.contains(G.endContainer);W.removeAllRanges(),(q||J)&&(K.selectNodeContents(h),q&&K.setStart(G.startContainer,G.startOffset),J&&K.setEnd(G.endContainer,G.endOffset),W.addRange(K))}let q=W.toString();return W.removeAllRanges(),W.addRange(G),q}const browser=server.config.browser.name,usedValuesProps=new Set(`backgroundPosition.background-position.bottom.left.right.top.height.width.margin-bottom.marginBottom.margin-left.marginLeft.margin-right.marginRight.margin-top.marginTop.min-height.minHeight.min-width.minWidth.padding-bottom.padding-left.padding-right.padding-top.text-indent.paddingBottom.paddingLeft.paddingRight.paddingTop.textIndent`.split(`.`));function toHaveStyle(h,W){let G=getElementFromUserInput(h,toHaveStyle,this),{getComputedStyle:K}=G.ownerDocument.defaultView,q=typeof W==`object`?getStyleFromObjectCSS(W):computeCSSStyleDeclaration(W),J=K(G),Y=new Set(Array.from(G.style));return{pass:isSubset(q,G,J,Y),message:()=>{let h=`${this.isNot?`.not`:``}.toHaveStyle`,W=new Set(Object.keys(q)),K=printoutObjectStyles(Array.from(J).filter(h=>W.has(h)).reduce((h,W)=>(h[W]=(Y.has(W)&&usedValuesProps.has(W)?G.style:J)[W],h),{})),X=K===``?`Expected styles could not be parsed by the browser. Did you make a typo?`:this.utils.diff(printoutObjectStyles(q),K);return[this.utils.matcherHint(h,`element`,``),X].join(`
23
+ `)}}}function Ge(e){let t=``;for(let n of e){if(t&&t!==n.type)throw Error(`Multiple form elements with the same name must be of the same type`);t=n.type}switch(t){case`radio`:{let t=e.find(e=>e.checked);return t?t.value:void 0}case`checkbox`:return e.filter(e=>e.checked).map(e=>e.value);default:return e.map(e=>e.value)}}function Ke(e,t){let n=[...e.querySelectorAll(`[name="${ie(t)}"]`)];if(n.length!==0)switch(n.length){case 1:return x(n[0]);default:return Ge(n)}}function qe(e){return/\[\]$/.test(e)?e.slice(0,-2):e}function Je(e){let t={};for(let n of e.elements){if(!(`name`in n))continue;let r=n.name;t[qe(r)]=Ke(e,r)}return t}function J(e,t){let n=m(e,J,this);l();let r=s(n);return u(),{pass:r===t,message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveRole`,`element`,``),`Expected element ${e} have role`,t,`Received`,r)}}}function Y(e,t){let n=m(e,Y,this),r=t!==void 0;if(r&&typeof t!=`string`)throw Error(`expected selection must be a string or undefined`);let i=Ye(n);return{pass:r?this.equals(i,t,[S,...this.customTesters]):!!i,message:()=>{let e=this.isNot?`not to`:`to`,n=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveSelection`,`element`,t);return h(this,n,`Expected the element ${e} have selection`,r?t:`(any)`,`Received`,i)}}}function Ye(e){let t=e.ownerDocument.getSelection();if(!t)return``;if([`INPUT`,`TEXTAREA`].includes(y(e))){let t=e;return[`radio`,`checkbox`].includes(t.type)||t.selectionStart==null||t.selectionEnd==null?``:t.value.toString().substring(t.selectionStart,t.selectionEnd)}if(t.anchorNode===null||t.focusNode===null)return``;let n=t.getRangeAt(0),r=e.ownerDocument.createRange();if(t.containsNode(e,!1))r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r);else if(!(e.contains(t.anchorNode)&&e.contains(t.focusNode))){let i=e===n.startContainer||e.contains(n.startContainer),a=e===n.endContainer||e.contains(n.endContainer);t.removeAllRanges(),(i||a)&&(r.selectNodeContents(e),i&&r.setStart(n.startContainer,n.startOffset),a&&r.setEnd(n.endContainer,n.endOffset),t.addRange(r))}let i=t.toString();return t.removeAllRanges(),t.addRange(n),i}const X=p.config.browser.name,Z=new Set(`backgroundPosition.background-position.bottom.left.right.top.height.width.margin-bottom.marginBottom.margin-left.marginLeft.margin-right.marginRight.margin-top.marginTop.min-height.minHeight.min-width.minWidth.padding-bottom.padding-left.padding-right.padding-top.text-indent.paddingBottom.paddingLeft.paddingRight.paddingTop.textIndent`.split(`.`));function Q(e,t){let n=m(e,Q,this),{getComputedStyle:r}=n.ownerDocument.defaultView,i=typeof t==`object`?Xe(t):Ze(t),a=r(n),o=new Set(Array.from(n.style));return{pass:$e(i,n,a,o),message:()=>{let e=`${this.isNot?`.not`:``}.toHaveStyle`,t=new Set(Object.keys(i)),r=Qe(Array.from(a).filter(e=>t.has(e)).reduce((e,t)=>(e[t]=(o.has(t)&&Z.has(t)?n.style:a)[t],e),{})),s=r===``?`Expected styles could not be parsed by the browser. Did you make a typo?`:this.utils.diff(Qe(i),r);return[this.utils.matcherHint(e,`element`,``),s].join(`
24
24
 
25
- `)}}}function getStyleFromObjectCSS(h){let W=browser===`chrome`||browser===`chromium`?document:document.implementation.createHTMLDocument(``),G=W.createElement(`div`);W.body.appendChild(G);let K=Object.keys(h);K.forEach(W=>{G.style[W]=h[W]});let q={},J=window.getComputedStyle(G);return K.forEach(h=>{let W=(usedValuesProps.has(h)?G.style:J)[h];W!=null&&(q[h]=W)}),G.remove(),q}function computeCSSStyleDeclaration(h){let W=browser===`chrome`||browser===`chromium`||browser===`webkit`?document:document.implementation.createHTMLDocument(``),G=W.createElement(`div`);G.setAttribute(`style`,h.replace(/\n/g,``)),W.body.appendChild(G);let K=window.getComputedStyle(G),q=Array.from(G.style).reduce((h,W)=>(h[W]=usedValuesProps.has(W)?G.style.getPropertyValue(W):K.getPropertyValue(W),h),{});return G.remove(),q}function printoutObjectStyles(h){return Object.keys(h).sort().map(W=>`${W}: ${h[W]};`).join(`
26
- `)}function isSubset(h,W,G,K){let q=Object.keys(h);return q.length?q.every(q=>{let J=h[q],Y=q.startsWith(`--`),X=[q];return Y||X.push(q.toLowerCase()),X.some(h=>{let Y=K.has(q)&&usedValuesProps.has(q)?W.style:G;return Y[h]===J||Y.getPropertyValue(h)===J})}):!1}function toHaveTextContent(h,W,G={normalizeWhitespace:!0}){let K=getNodeFromUserInput(h,toHaveTextContent,this),q=G.normalizeWhitespace?normalize(K.textContent||``):(K.textContent||``).replace(/\u00A0/g,` `),J=q!==``&&W===``;return{pass:!J&&matches(q,W),message:()=>{let h=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveTextContent`,`element`,``),J?`Checking with empty string will always match, use .toBeEmptyDOMElement() instead`:`Expected element ${h} have text content`,W,`Received`,q)}}}function toHaveValue(h,W){let G=getElementFromUserInput(h,toHaveValue,this);if(isInputElement(G)&&[`checkbox`,`radio`].includes(G.type))throw Error(`input with type=checkbox or type=radio cannot be used with .toHaveValue(). Use .toBeChecked() for type=checkbox or .toHaveFormValues() instead`);let K=getSingleElementValue(G),q=W!==void 0,J=W,Y=K;return W==K&&W!==K&&(J=`${W} (${typeof W})`,Y=`${K} (${typeof K})`),{pass:q?this.equals(K,W,[arrayAsSetComparison,...this.customTesters]):!!K,message:()=>{let h=this.isNot?`not to`:`to`,G=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveValue`,`element`,W);return getMessage(this,G,`Expected the element ${h} have value`,q?J:`(any)`,`Received`,Y)}}}const counters=new Map([]);async function toMatchScreenshot(W,G,K=typeof G==`object`?G:{}){if(this.isNot)throw Error(`'toMatchScreenshot' cannot be used with "not"`);if(this.task===void 0||this.currentTestName===void 0)throw Error(`'toMatchScreenshot' cannot be used without test context`);let q=`${this.task.result?.repeatCount??0}${this.testPath}${this.currentTestName}`,J=counters.get(q);J===void 0&&(J={current:0},counters.set(q,J)),J.current+=1;let Y=typeof G==`string`?G:`${this.currentTestName} ${J.current}`,[X,...Z]=await Promise.all([convertToSelector(W,K),...K.screenshotOptions&&`mask`in K.screenshotOptions?K.screenshotOptions.mask.map(h=>convertToSelector(h,K)):[]]),Q=K.screenshotOptions&&`mask`in K.screenshotOptions?{...K,screenshotOptions:{...K.screenshotOptions,mask:Z}}:K,$=await getBrowserState().commands.triggerCommand(`__vitest_screenshotMatcher`,[Y,this.currentTestName,{element:X,...Q}]);if($.pass===!1){let W=[];$.reference&&W.push({name:`reference`,...$.reference}),$.actual&&W.push({name:`actual`,...$.actual}),$.diff&&W.push({name:`diff`,...$.diff}),W.length>0&&await recordArtifact(this.task,{type:`internal:toMatchScreenshot`,kind:`visual-regression`,message:$.message,attachments:W})}return{pass:$.pass,message:()=>$.pass?``:[this.utils.matcherHint(`toMatchScreenshot`,`element`,``),``,$.message,$.reference?`\nReference screenshot:\n ${this.utils.EXPECTED_COLOR($.reference.path)}`:null,$.actual?`\nActual screenshot:\n ${this.utils.RECEIVED_COLOR($.actual.path)}`:null,$.diff?this.utils.DIM_COLOR(`\nDiff image:\n ${$.diff.path}`):null,``].filter(h=>h!==null).join(`
27
- `)}}const matchers={toBeDisabled,toBeEnabled,toBeEmptyDOMElement,toBeInTheDocument,toBeInViewport,toBeInvalid,toBeRequired,toBeValid,toBeVisible,toContainElement,toContainHTML,toHaveAccessibleDescription,toHaveAccessibleErrorMessage,toHaveAccessibleName,toHaveAttribute,toHaveClass,toHaveFocus,toHaveFormValues,toHaveStyle,toHaveTextContent,toHaveValue,toHaveDisplayValue,toBeChecked,toBePartiallyChecked,toHaveRole,toHaveSelection,toMatchScreenshot},kLocator=Symbol.for(`$$vitest:locator`);function element(h,q){if(h!=null&&!(h instanceof HTMLElement)&&!(h instanceof SVGElement)&&!(kLocator in h))throw Error(`Invalid element or locator: ${h}. Expected an instance of HTMLElement, SVGElement or Locator, received ${getType(h)}`);let J=expect.poll(function(){if(h instanceof Element||h==null)return h;let W=chai.util.flag(this,`negate`),K=chai.util.flag(this,`_name`);if(W&&K===`toBeInTheDocument`)return h.query();if(K===`toHaveLength`)return h.elements();if(K===`toMatchScreenshot`&&!chai.util.flag(this,`_poll.assert_once`)&&chai.util.flag(this,`_poll.assert_once`,!0),chai.util.flag(this,`_isLastPollAttempt`))return h.element();let q=h.query();if(!q)throw Error(`Cannot find element with locator: ${JSON.stringify(h)}`);return q},processTimeoutOptions(q));return chai.util.flag(J,`_poll.element`,!0),J}expect.extend(matchers),expect.element=element;
25
+ `)}}}function Xe(e){let t=X===`chrome`||X===`chromium`?document:document.implementation.createHTMLDocument(``),n=t.createElement(`div`);t.body.appendChild(n);let r=Object.keys(e);r.forEach(t=>{n.style[t]=e[t]});let i={},a=window.getComputedStyle(n);return r.forEach(e=>{let t=(Z.has(e)?n.style:a)[e];t!=null&&(i[e]=t)}),n.remove(),i}function Ze(e){let t=X===`chrome`||X===`chromium`||X===`webkit`?document:document.implementation.createHTMLDocument(``),n=t.createElement(`div`);n.setAttribute(`style`,e.replace(/\n/g,``)),t.body.appendChild(n);let r=window.getComputedStyle(n),i=Array.from(n.style).reduce((e,t)=>(e[t]=Z.has(t)?n.style.getPropertyValue(t):r.getPropertyValue(t),e),{});return n.remove(),i}function Qe(e){return Object.keys(e).sort().map(t=>`${t}: ${e[t]};`).join(`
26
+ `)}function $e(e,t,n,r){let i=Object.keys(e);return i.length?i.every(i=>{let a=e[i],o=i.startsWith(`--`),s=[i];return o||s.push(i.toLowerCase()),s.some(e=>{let o=r.has(i)&&Z.has(i)?t.style:n;return o[e]===a||o.getPropertyValue(e)===a})}):!1}function et(e,t,n={normalizeWhitespace:!0}){let r=le(e,et,this),i=n.normalizeWhitespace?be(r.textContent||``):(r.textContent||``).replace(/\u00A0/g,` `),a=i!==``&&t===``;return{pass:!a&&xe(i,t),message:()=>{let e=this.isNot?`not to`:`to`;return h(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveTextContent`,`element`,``),a?`Checking with empty string will always match, use .toBeEmptyDOMElement() instead`:`Expected element ${e} have text content`,t,`Received`,i)}}}function tt(e,t){let n=m(e,tt,this);if(b(n)&&[`checkbox`,`radio`].includes(n.type))throw Error(`input with type=checkbox or type=radio cannot be used with .toHaveValue(). Use .toBeChecked() for type=checkbox or .toHaveFormValues() instead`);let r=x(n),i=t!==void 0,a=t,o=r;return t==r&&t!==r&&(a=`${t} (${typeof t})`,o=`${r} (${typeof r})`),{pass:i?this.equals(r,t,[S,...this.customTesters]):!!r,message:()=>{let e=this.isNot?`not to`:`to`,n=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveValue`,`element`,t);return h(this,n,`Expected the element ${e} have value`,i?a:`(any)`,`Received`,o)}}}const $=new Map([]);async function nt(t,n,r=typeof n==`object`?n:{}){if(this.isNot)throw Error(`'toMatchScreenshot' cannot be used with "not"`);if(this.task===void 0||this.currentTestName===void 0)throw Error(`'toMatchScreenshot' cannot be used without test context`);let i=`${this.task.result?.repeatCount??0}${this.testPath}${this.currentTestName}`,a=$.get(i);a===void 0&&(a={current:0},$.set(i,a)),a.current+=1;let o=typeof n==`string`?n:`${this.currentTestName} ${a.current}`,[s,...c]=await Promise.all([d(t,r),...r.screenshotOptions&&`mask`in r.screenshotOptions?r.screenshotOptions.mask.map(e=>d(e,r)):[]]),l=r.screenshotOptions&&`mask`in r.screenshotOptions?{...r,screenshotOptions:{...r.screenshotOptions,mask:c}}:r,u=await f().commands.triggerCommand(`__vitest_screenshotMatcher`,[o,this.currentTestName,{element:s,...l}]);if(u.pass===!1){let t=[];u.reference&&t.push({name:`reference`,...u.reference}),u.actual&&t.push({name:`actual`,...u.actual}),u.diff&&t.push({name:`diff`,...u.diff}),t.length>0&&await e(this.task,{type:`internal:toMatchScreenshot`,kind:`visual-regression`,message:u.message,attachments:t})}return{pass:u.pass,message:()=>u.pass?``:[this.utils.matcherHint(`toMatchScreenshot`,`element`,``),``,u.message,u.reference?`\nReference screenshot:\n ${this.utils.EXPECTED_COLOR(u.reference.path)}`:null,u.actual?`\nActual screenshot:\n ${this.utils.RECEIVED_COLOR(u.actual.path)}`:null,u.diff?this.utils.DIM_COLOR(`\nDiff image:\n ${u.diff.path}`):null,``].filter(e=>e!==null).join(`
27
+ `)}}const rt={toBeDisabled:E,toBeEnabled:D,toBeEmptyDOMElement:T,toBeInTheDocument:k,toBeInViewport:M,toBeInvalid:j,toBeRequired:P,toBeValid:De,toBeVisible:Le,toContainElement:F,toContainHTML:I,toHaveAccessibleDescription:L,toHaveAccessibleErrorMessage:R,toHaveAccessibleName:z,toHaveAttribute:B,toHaveClass:H,toHaveFocus:K,toHaveFormValues:q,toHaveStyle:Q,toHaveTextContent:et,toHaveValue:tt,toHaveDisplayValue:G,toBeChecked:w,toBePartiallyChecked:N,toHaveRole:J,toHaveSelection:Y,toMatchScreenshot:nt},it=Symbol.for(`$$vitest:locator`);function at(e,i){if(e!=null&&!(e instanceof HTMLElement)&&!(e instanceof SVGElement)&&!(it in e))throw Error(`Invalid element or locator: ${e}. Expected an instance of HTMLElement, SVGElement or Locator, received ${r(e)}`);let a=t.poll(function(){if(e instanceof Element||e==null)return e;let t=n.util.flag(this,`negate`),r=n.util.flag(this,`_name`);if(t&&r===`toBeInTheDocument`)return e.query();if(r===`toHaveLength`)return e.elements();if(r===`toMatchScreenshot`&&!n.util.flag(this,`_poll.assert_once`)&&n.util.flag(this,`_poll.assert_once`,!0),n.util.flag(this,`_isLastPollAttempt`))return e.element();let i=e.query();if(!i)throw Error(`Cannot find element with locator: ${JSON.stringify(e)}`);return i},ae(i));n.util.flag(a,`_poll.element`,!0);let o=oe().current;if(o&&f().activeTraceTaskIds.has(o.id)){let t=Error(`__vitest_mark_trace__`);n.util.flag(a,`_poll.onSettled`,async r=>{let i=n.util.flag(r.assertion,`negate`),a=n.util.flag(r.assertion,`_name`)||`<unknown>`,o=`expect.element().${i?`not.`:``}${a}`,s=r.status===`fail`?`${o} [ERROR]`:o,c=!e||e instanceof Element?void 0:e.selector;await f().commands.triggerCommand(`__vitest_markTrace`,[{name:s,selector:c,stack:t.stack}],t)})}return a}t.extend(rt),t.element=at;