@vitest/browser 5.0.0-rc.1 → 5.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/context.d.ts CHANGED
@@ -447,6 +447,9 @@ export interface LocatorOptions {
447
447
  * regular expression. Note that exact match still trims whitespace.
448
448
  */
449
449
  exact?: boolean
450
+ }
451
+
452
+ export interface LocatorFilterOptions {
450
453
  hasText?: string | RegExp
451
454
  hasNotText?: string | RegExp
452
455
  has?: Locator
@@ -766,7 +769,7 @@ export interface Locator extends LocatorSelectors {
766
769
  * Narrows existing locator according to the options.
767
770
  * @see {@link https://vitest.dev/api/browser/locators#filter}
768
771
  */
769
- filter(options: LocatorOptions): Locator
772
+ filter(options: LocatorFilterOptions): Locator
770
773
  /**
771
774
  * This method returns an element matching the locator.
772
775
  * Unlike [`.element()`](https://vitest.dev/api/browser/locators#element),
@@ -1,33 +1,33 @@
1
1
  {
2
- "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js": {
3
- "file": "__vitest_browser__/rrweb-snapshot-g5vjbXoV.js",
2
+ "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=b66b30796877352a5f887f3f4115c4e7265ddc11772af2223da4bd92293716f6/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js": {
3
+ "file": "__vitest_browser__/rrweb-snapshot-JG8daYmg.js",
4
4
  "name": "rrweb-snapshot",
5
- "src": "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js",
5
+ "src": "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=b66b30796877352a5f887f3f4115c4e7265ddc11772af2223da4bd92293716f6/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js",
6
6
  "isDynamicEntry": true
7
7
  },
8
- "_defineProperty-BOtRrjRA.js": {
9
- "file": "__vitest_browser__/defineProperty-BOtRrjRA.js",
8
+ "_defineProperty-DgkPJYVE.js": {
9
+ "file": "__vitest_browser__/defineProperty-DgkPJYVE.js",
10
10
  "name": "defineProperty"
11
11
  },
12
12
  "orchestrator.html": {
13
- "file": "__vitest_browser__/orchestrator-DJgIeTMM.js",
13
+ "file": "__vitest_browser__/orchestrator-M9828UZ-.js",
14
14
  "name": "orchestrator",
15
15
  "src": "orchestrator.html",
16
16
  "isEntry": true,
17
17
  "imports": [
18
- "_defineProperty-BOtRrjRA.js"
18
+ "_defineProperty-DgkPJYVE.js"
19
+ ],
20
+ "dynamicImports": [
21
+ "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=b66b30796877352a5f887f3f4115c4e7265ddc11772af2223da4bd92293716f6/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js"
19
22
  ]
20
23
  },
21
24
  "tester/tester.html": {
22
- "file": "__vitest_browser__/tester-Ck66x6M6.js",
25
+ "file": "__vitest_browser__/tester-COH68OX9.js",
23
26
  "name": "tester",
24
27
  "src": "tester/tester.html",
25
28
  "isEntry": true,
26
29
  "imports": [
27
- "_defineProperty-BOtRrjRA.js"
28
- ],
29
- "dynamicImports": [
30
- "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js"
30
+ "_defineProperty-DgkPJYVE.js"
31
31
  ]
32
32
  }
33
33
  }
@@ -270,6 +270,10 @@ function getBrowserState() {
270
270
  return window.__vitest_browser_runner__;
271
271
  }
272
272
  /* @__NO_SIDE_EFFECTS__ */
273
+ function getOrchestratorState() {
274
+ return window.parent.__vitest_browser_runner__;
275
+ }
276
+ /* @__NO_SIDE_EFFECTS__ */
273
277
  function getWorkerState() {
274
278
  const state = window.__vitest_worker__;
275
279
  if (!state) throw new Error("Worker state is not found. This is an issue with Vitest. Please, open an issue.");
@@ -319,4 +323,4 @@ function _defineProperty(e, r, t) {
319
323
  }
320
324
 
321
325
  //#endregion
322
- export { moduleRunner as a, generateFileHash as c, relative as d, resolve as f, getWorkerState as i, getTestName as l, getBrowserState as n, now as o, getConfig as r, __vitePreload as s, _defineProperty as t, basename as u };
326
+ export { getWorkerState as a, __vitePreload as c, basename as d, relative as f, getOrchestratorState as i, generateFileHash as l, getBrowserState as n, moduleRunner as o, resolve as p, getConfig as r, now as s, _defineProperty as t, getTestName as u };
@@ -1,4 +1,4 @@
1
- import { c as generateFileHash, d as relative, n as getBrowserState, r as getConfig, t as _defineProperty } from "./defineProperty-BOtRrjRA.js";
1
+ import { c as __vitePreload, f as relative, l as generateFileHash, n as getBrowserState, r as getConfig, t as _defineProperty } from "./defineProperty-DgkPJYVE.js";
2
2
  import { channel, client, globalChannel } from "@vitest/browser/client";
3
3
  import { Traces } from "vitest/internal/traces";
4
4
 
@@ -24,6 +24,11 @@ var IframeOrchestrator = class {
24
24
  _defineProperty(this, "loggedIframe", /* @__PURE__ */ new WeakSet());
25
25
  _defineProperty(this, "iframeEvents", /* @__PURE__ */ new WeakMap());
26
26
  debug("init orchestrator", (/* @__PURE__ */ getBrowserState()).sessionId);
27
+ if (getConfig().browser.traceView.enabled) {
28
+ const domSnapshot = __vitePreload(() => import("./rrweb-snapshot-JG8daYmg.js"), []);
29
+ domSnapshot.catch(() => {});
30
+ (/* @__PURE__ */ getBrowserState()).browserTraceDomSnapshotPromise = domSnapshot;
31
+ }
27
32
  const otelConfig = (/* @__PURE__ */ getBrowserState()).config.experimental.openTelemetry;
28
33
  this.traces = new Traces({
29
34
  enabled: !!((otelConfig === null || otelConfig === void 0 ? void 0 : otelConfig.enabled) && otelConfig.browserSdkPath),
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js
1
+ //#region ../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=b66b30796877352a5f887f3f4115c4e7265ddc11772af2223da4bd92293716f6/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
4
4
  enumerable: true,
@@ -446,13 +446,24 @@ function genId() {
446
446
  return _id++;
447
447
  }
448
448
  function getValidTagName(element) {
449
- if (element instanceof HTMLFormElement) return "form";
449
+ if (Object.prototype.toString.call(element) === "[object HTMLFormElement]") return "form";
450
450
  const processedTagName = toLowerCase(element.tagName);
451
451
  if (tagNameRegex.test(processedTagName)) return "div";
452
452
  return processedTagName;
453
453
  }
454
- var canvasService;
455
- var canvasCtx;
454
+ var canvasServices = /* @__PURE__ */ new WeakMap();
455
+ function getCanvasService(doc) {
456
+ let service = canvasServices.get(doc);
457
+ if (!service) {
458
+ const canvas = doc.createElement("canvas");
459
+ service = {
460
+ canvas,
461
+ context: canvas.getContext("2d")
462
+ };
463
+ canvasServices.set(doc, service);
464
+ }
465
+ return service;
466
+ }
456
467
  var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
457
468
  var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
458
469
  function getAbsoluteSrcsetString(doc, attributeValue) {
@@ -772,10 +783,7 @@ function serializeElementNode(n, options) {
772
783
  }
773
784
  }
774
785
  if (tagName === "img" && inlineImages) {
775
- if (!canvasService) {
776
- canvasService = doc.createElement("canvas");
777
- canvasCtx = canvasService.getContext("2d");
778
- }
786
+ const { canvas: canvasService, context: canvasCtx } = getCanvasService(doc);
779
787
  const image = n;
780
788
  const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
781
789
  const priorCrossOrigin = image.crossOrigin;
@@ -1,4 +1,4 @@
1
- import { a as moduleRunner, f as resolve, i as getWorkerState, l as getTestName, n as getBrowserState, o as now$1, r as getConfig, s as __vitePreload, t as _defineProperty, u as basename } from "./defineProperty-BOtRrjRA.js";
1
+ import { a as getWorkerState, c as __vitePreload, d as basename, i as getOrchestratorState, n as getBrowserState, o as moduleRunner, p as resolve, r as getConfig, s as now$1, t as _defineProperty, u as getTestName } from "./defineProperty-DgkPJYVE.js";
2
2
  import { channel, client, globalChannel, onCancel, registerPageMarkHandler } from "@vitest/browser/client";
3
3
  import { Traces } from "vitest/internal/traces";
4
4
  import { page, server, userEvent } from "vitest/browser";
@@ -720,6 +720,9 @@ var VitestBrowserSnapshotEnvironment = class {
720
720
  readSnapshotFile(filepath) {
721
721
  return rpc$1().readSnapshotFile(filepath);
722
722
  }
723
+ readSnapshotFileData(filepath) {
724
+ return rpc$1().readSnapshotFileData(filepath);
725
+ }
723
726
  saveSnapshotFile(filepath, snapshot) {
724
727
  return rpc$1().saveSnapshotFile(filepath, snapshot);
725
728
  }
@@ -760,7 +763,8 @@ var PSEUDO_CLASS_NAMES = [
760
763
  ":active",
761
764
  ":focus",
762
765
  ":focus-visible",
763
- ":focus-within"
766
+ ":focus-within",
767
+ ":popover-open"
764
768
  ];
765
769
  function createBrowserTraceRangeId() {
766
770
  return Math.random().toString(36).slice(2);
@@ -1032,7 +1036,8 @@ function createBrowserRunner(mocker, state, coverageModule) {
1032
1036
  return;
1033
1037
  }
1034
1038
  if (shouldTraceView) {
1035
- (/* @__PURE__ */ getBrowserState()).browserTraceDomSnapshot = await __vitePreload(() => import("./rrweb-snapshot-g5vjbXoV.js"), []);
1039
+ var _getBrowserState;
1040
+ (_getBrowserState = /* @__PURE__ */ getBrowserState()).browserTraceDomSnapshot ?? (_getBrowserState.browserTraceDomSnapshot = await (/* @__PURE__ */ getOrchestratorState()).browserTraceDomSnapshotPromise);
1036
1041
  (/* @__PURE__ */ getBrowserState()).browserTraceAttempts.set(test.id, {
1037
1042
  retry,
1038
1043
  repeats,
@@ -26,8 +26,8 @@
26
26
  {__VITEST_INJECTOR__}
27
27
  {__VITEST_ERROR_CATCHER__}
28
28
  {__VITEST_SCRIPTS__}
29
- <script type="module" crossorigin src="/__vitest_browser__/orchestrator-DJgIeTMM.js"></script>
30
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-BOtRrjRA.js">
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-M9828UZ-.js"></script>
30
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-DgkPJYVE.js">
31
31
  </head>
32
32
  <body>
33
33
  <div id="vitest-tester"></div>
@@ -1,4 +1,4 @@
1
- import type { LocatorByRoleOptions, LocatorOptions, LocatorScreenshotOptions, MarkOptions, SelectorOptions, UserEventClearOptions, UserEventClickOptions, UserEventDragAndDropOptions, UserEventFillOptions, UserEventHoverOptions, UserEventSelectOptions, UserEventUploadOptions, UserEventWheelOptions } from "vitest/browser";
1
+ import type { LocatorByRoleOptions, LocatorFilterOptions, LocatorOptions, LocatorScreenshotOptions, MarkOptions, SelectorOptions, UserEventClearOptions, UserEventClickOptions, UserEventDragAndDropOptions, UserEventFillOptions, UserEventHoverOptions, UserEventSelectOptions, UserEventUploadOptions, UserEventWheelOptions } from "vitest/browser";
2
2
  import { Ivya } from "ivya";
3
3
  export { ensureAwaited } from "../utils.js";
4
4
  export { convertElementToCssSelector, getIframeScale, processTimeoutOptions } from "./tester-utils.js";
@@ -40,7 +40,7 @@ export declare abstract class Locator {
40
40
  getByTestId(testId: string | RegExp): Locator;
41
41
  getByText(text: string | RegExp, options?: LocatorOptions): Locator;
42
42
  getByTitle(title: string | RegExp, options?: LocatorOptions): Locator;
43
- filter(filter: LocatorOptions): Locator;
43
+ filter(filter: LocatorFilterOptions): Locator;
44
44
  and(locator: Locator): Locator;
45
45
  or(locator: Locator): Locator;
46
46
  query(): HTMLElement | SVGElement | null;
@@ -5,8 +5,8 @@
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-Ck66x6M6.js"></script>
9
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-BOtRrjRA.js">
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-COH68OX9.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-DgkPJYVE.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -45,7 +45,7 @@ interface TraceSnapshot {
45
45
  selectorError?: string;
46
46
  pseudoClassIds: Record<PseudoClassName, number[]>;
47
47
  }
48
- declare const PSEUDO_CLASS_NAMES: readonly [":hover", ":active", ":focus", ":focus-visible", ":focus-within"];
48
+ declare const PSEUDO_CLASS_NAMES: readonly [":hover", ":active", ":focus", ":focus-visible", ":focus-within", ":popover-open"];
49
49
  type PseudoClassName = (typeof PSEUDO_CLASS_NAMES)[number];
50
50
  export interface BrowserTraceAttempt {
51
51
  retry: number;
package/dist/client.js CHANGED
@@ -19,7 +19,7 @@ function nanoid(size = 21) {
19
19
  while (i--) id += urlAlphabet[random() * 64 | 0];
20
20
  return id;
21
21
  }
22
-
22
+ //#endregion
23
23
  //#region src/main.ts
24
24
  const DEFAULT_TIMEOUT = 6e4;
25
25
  const defaultSerialize = (i) => i;
package/dist/context.js CHANGED
@@ -50,21 +50,23 @@ function getWorkerState() {
50
50
  return state;
51
51
  }
52
52
 
53
- // rrweb-snapshot rewrites pseudo-class selectors in serialized styles so replay can
54
- // reproduce snapshot-time states. For example:
53
+ // Dynamic pseudo-class state isn't preserved in the serialized DOM. rrweb-snapshot
54
+ // rewrites user-action selectors in serialized styles. For example:
55
55
  // some-selector:hover { ... }
56
56
  // becomes:
57
57
  // some-selector:hover, some-selector.\:hover { ... }
58
58
  // Vitest side integration then adds matching pseudo-state classes in the replay DOM.
59
59
  // rrweb-snapshot only handles `:hover` upstream, so we patch it locally for the
60
- // other user-action pseudo-classes as well.
60
+ // other user-action pseudo-classes as well. Native states such as `:popover-open`
61
+ // are restored through their DOM API instead.
61
62
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-classes#user_action_pseudo-classes
62
63
  const PSEUDO_CLASS_NAMES = [
63
64
  ":hover",
64
65
  ":active",
65
66
  ":focus",
66
67
  ":focus-visible",
67
- ":focus-within"
68
+ ":focus-within",
69
+ ":popover-open"
68
70
  ];
69
71
  function createBrowserTraceRangeId() {
70
72
  return Math.random().toString(36).slice(2);
@@ -1,4 +1,4 @@
1
- import{Snapshots as e,recordArtifact as t,expect as n,chai as r}from"vitest";import{getType as i}from"vitest/internal/browser";import{i as a,g as o,n as s,a as c,k as l,b as u,c as d,d as f,e as ee,f as te,h as ne,j as re,l as ie,m as ae,o as oe,p as se,q as ce,r as p,_ as m,s as h,t as g,u as _,L as v,v as le,w as ue,x as de,y as fe,z as pe,A as me,B as he,C as ge,D as _e,E as ve}from"./locators-BTqFw5Up.js";import{server as ye}from"vitest/browser";var be=Object.defineProperty,xe=(e,t)=>{let n={};for(var r in e)be(n,r,{get:e[r],enumerable:!0});return be(n,Symbol.toStringTag,{value:`Module`}),n};function Se(e,t,n={}){let r=Ce(e,t,n);if(r.errors.length)throw Error(r.errors[0].message);return r.fragment}function Ce(e,t,n={}){let r=new e.LineCounter,i={keepSourceTokens:!0,lineCounter:r,...n},a=e.parseDocument(t,i),o=[],s=e=>[r.linePos(e[0]),r.linePos(e[1])],c=e=>{o.push({message:e.message,range:[r.linePos(e.pos[0]),r.linePos(e.pos[1])]})},l=(t,n)=>{for(let r of n.items){if(r instanceof e.Scalar&&typeof r.value==`string`){let e=Ee.parse(r,i,o);e&&(t.children=t.children||[],t.children.push(e));continue}if(r instanceof e.YAMLMap){u(t,r);continue}o.push({message:`Sequence items should be strings or maps`,range:s(r.range||n.range)})}},u=(t,n)=>{for(let r of n.items){if(t.children=t.children||[],!(r.key instanceof e.Scalar&&typeof r.key.value==`string`)){o.push({message:`Only string keys are supported`,range:s(r.key.range||n.range)});continue}let a=r.key,c=r.value;if(a.value===`text`){if(!(c instanceof e.Scalar&&typeof c.value==`string`)){o.push({message:`Text value should be a string`,range:s(r.value.range||n.range)});continue}t.children.push({kind:`text`,text:y(c.value)});continue}if(a.value===`/children`){if(!(c instanceof e.Scalar&&typeof c.value==`string`)||c.value!==`contain`&&c.value!==`equal`&&c.value!==`deep-equal`){o.push({message:`Strict value should be "contain", "equal" or "deep-equal"`,range:s(r.value.range||n.range)});continue}t.containerMode=c.value;continue}if(a.value.startsWith(`/`)){if(!(c instanceof e.Scalar&&typeof c.value==`string`)){o.push({message:`Property value should be a string`,range:s(r.value.range||n.range)});continue}t.props=t.props??{},t.props[a.value.slice(1)]=y(c.value);continue}let u=Ee.parse(a,i,o);if(u){if(c instanceof e.Scalar){let e=typeof c.value;if(e!==`string`&&e!==`number`&&e!==`boolean`){o.push({message:`Node value should be a string or a sequence`,range:s(r.value.range||n.range)});continue}t.children.push({...u,children:[{kind:`text`,text:y(String(c.value))}]});continue}if(c instanceof e.YAMLSeq){t.children.push(u),l(u,c);continue}o.push({message:`Map values should be strings or sequences`,range:s(r.value.range||n.range)})}}},d={kind:`role`,role:`fragment`};return a.errors.forEach(c),o.length?{errors:o,fragment:d}:a.contents?(a.contents instanceof e.YAMLSeq||o.push({message:`Aria snapshot must be a YAML sequence, elements starting with " -"`,range:s(a.contents.range)}),o.length?{errors:o,fragment:d}:(l(d,a.contents),o.length?{errors:o,fragment:we}:d.children?.length===1&&(!d.containerMode||d.containerMode===`contain`)?{fragment:d.children[0],errors:[]}:{fragment:d,errors:[]})):{fragment:d,errors:[]}}const we={kind:`role`,role:`fragment`};function Te(e){return e.replace(/[\u200b\u00ad]/g,``).replace(/[\r\n\s\t]+/g,` `).trim()}function y(e){return{raw:e,normalized:Te(e)}}var Ee=class e{static parse(t,n,r){try{return new e(t.value)._parse()}catch(e){if(e instanceof b){let i=n.prettyErrors===!1?e.message:`${e.message}:\n\n${t.value}\n${` `.repeat(e.pos)}^\n`;return r.push({message:i,range:[n.lineCounter.linePos(t.range[0]),n.lineCounter.linePos(t.range[0]+e.pos)]}),null}throw e}}constructor(e){m(this,`_input`,void 0),m(this,`_pos`,void 0),m(this,`_length`,void 0),this._input=e,this._pos=0,this._length=e.length}_peek(){return this._input[this._pos]||``}_next(){return this._pos<this._length?this._input[this._pos++]:null}_eof(){return this._pos>=this._length}_isWhitespace(){return!this._eof()&&/\s/.test(this._peek())}_skipWhitespace(){for(;this._isWhitespace();)this._pos++}_readIdentifier(e){this._eof()&&this._throwError(`Unexpected end of input when expecting ${e}`);let t=this._pos;for(;!this._eof()&&/[a-zA-Z]/.test(this._peek());)this._pos++;return this._input.slice(t,this._pos)}_readString(){let e=``,t=!1;for(;!this._eof();){let n=this._next();if(t)e+=n,t=!1;else if(n===`\\`)t=!0;else if(n===`"`)return e;else e+=n}this._throwError(`Unterminated string`)}_throwError(e,t=0){throw new b(e,t||this._pos)}_readRegex(){let e=``,t=!1,n=!1;for(;!this._eof();){let r=this._next();if(t)e+=r,t=!1;else if(r===`\\`)t=!0,e+=r;else if(r===`/`&&!n)return{pattern:e};else r===`[`?(n=!0,e+=r):r===`]`&&n?(e+=r,n=!1):e+=r}this._throwError(`Unterminated regex`)}_readStringOrRegex(){let e=this._peek();return e===`"`?(this._next(),Te(this._readString())):e===`/`?(this._next(),this._readRegex()):null}_readAttributes(e){let t=this._pos;for(;this._skipWhitespace(),this._peek()===`[`;){this._next(),this._skipWhitespace(),t=this._pos;let n=this._readIdentifier(`attribute`);this._skipWhitespace();let r=``;if(this._peek()===`=`)for(this._next(),this._skipWhitespace(),t=this._pos;this._peek()!==`]`&&!this._isWhitespace()&&!this._eof();)r+=this._next();this._skipWhitespace(),this._peek()!==`]`&&this._throwError(`Expected ]`),this._next(),this._applyAttribute(e,n,r||`true`,t)}}_parse(){this._skipWhitespace();let e=this._readIdentifier(`role`);e===`fragment`&&this._throwError(`Invalid role "fragment"`),this._skipWhitespace();let t={kind:`role`,role:e,name:this._readStringOrRegex()||void 0};return this._readAttributes(t),this._skipWhitespace(),this._eof()||this._throwError(`Unexpected input`),t}_applyAttribute(e,t,n,r){if(t===`checked`){this._assert(n===`true`||n===`false`||n===`mixed`,`Value of "checked" attribute must be a boolean or "mixed"`,r),e.checked=n===`true`||n!==`false`&&`mixed`;return}if(t===`disabled`){this._assert(n===`true`||n===`false`,`Value of "disabled" attribute must be a boolean`,r),e.disabled=n===`true`;return}if(t===`expanded`){this._assert(n===`true`||n===`false`,`Value of "expanded" attribute must be a boolean`,r),e.expanded=n===`true`;return}if(t===`active`){this._assert(n===`true`||n===`false`,`Value of "active" attribute must be a boolean`,r),e.active=n===`true`;return}if(t===`level`){this._assert(!Number.isNaN(Number(n)),`Value of "level" attribute must be a number`,r),e.level=Number(n);return}if(t===`pressed`){this._assert(n===`true`||n===`false`||n===`mixed`,`Value of "pressed" attribute must be a boolean or "mixed"`,r),e.pressed=n===`true`||n!==`false`&&`mixed`;return}if(t===`selected`){this._assert(n===`true`||n===`false`,`Value of "selected" attribute must be a boolean`,r),e.selected=n===`true`;return}this._assert(!1,`Unsupported attribute [${t}]`,r)}_assert(e,t,n){e||this._throwError(t||`Assertion error`,n)}},b=class extends Error{constructor(e,t){super(e),m(this,`pos`,void 0),this.pos=t}};function x(e,t){return t?e?typeof t==`string`?e===t:!!e.match(new RegExp(t.pattern)):!1:!0}function S(e,t){if(!t?.normalized)return!0;if(!e)return!1;if(e===t.normalized||e===t.raw)return!0;let n=w(t);return n?!!e.match(n):!1}const C=Symbol(`cachedRegex`);function w(e){if(e[C]!==void 0)return e[C];let{raw:t}=e,n=t.startsWith(`/`)&&t.endsWith(`/`)&&t.length>1,r;try{r=n?new RegExp(t.slice(1,-1)):null}catch{r=null}return e[C]=r,r}function T(e,t,n){if(typeof e==`string`&&t.kind===`text`)return S(e,t.text);if(typeof e!=`object`||!e||t.kind!==`role`||t.role!==`fragment`&&t.role!==e.role||t.checked!==void 0&&t.checked!==e.checked||t.disabled!==void 0&&t.disabled!==e.disabled||t.expanded!==void 0&&t.expanded!==e.expanded||t.level!==void 0&&t.level!==e.level||t.pressed!==void 0&&t.pressed!==e.pressed||t.selected!==void 0&&t.selected!==e.selected||!x(e.name,t.name))return!1;if(t.props){for(let[n,r]of Object.entries(t.props))if(!S(e.props[n]||``,r))return!1}return t.containerMode===`contain`?D(e.children||[],t.children||[]):t.containerMode===`equal`?E(e.children||[],t.children||[],!1):t.containerMode===`deep-equal`||n?E(e.children||[],t.children||[],!0):D(e.children||[],t.children||[])}function E(e,t,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(!T(e[r],t[r],n))return!1;return!0}function D(e,t){if(t.length>e.length)return!1;let n=e.slice(),r=t.slice();for(let e of r){let t=n.shift();for(;t&&!T(t,e,!1);)t=n.shift();if(!t)return!1}return!0}var De=xe({LineCounter:()=>Oe,Scalar:()=>O,YAMLError:()=>j,YAMLMap:()=>k,YAMLSeq:()=>A,parseDocument:()=>ke}),O=class{constructor(e,t=[0,0,0]){m(this,`value`,void 0),m(this,`range`,void 0),this.value=e,this.range=t}},k=class{constructor(e=[0,0,0]){m(this,`items`,void 0),m(this,`range`,void 0),this.items=[],this.range=e}},A=class{constructor(e=[0,0,0]){m(this,`items`,void 0),m(this,`range`,void 0),this.items=[],this.range=e}},Oe=class{constructor(){m(this,`lineStarts`,[0])}addNewLine(e){e>this.lineStarts[this.lineStarts.length-1]&&this.lineStarts.push(e)}linePos(e){let t=0,n=this.lineStarts.length-1;for(;t<n;){let r=t+n+1>>1;this.lineStarts[r]<=e?t=r:n=r-1}return{line:t+1,col:e-this.lineStarts[t]+1}}},j=class extends Error{constructor(e,t){super(e),m(this,`pos`,void 0),this.pos=t}};function ke(e,t={}){let n=t.lineCounter,r=[];if(n)for(let t=0;t<e.length;t++)e[t]===`
1
+ import{Snapshots as e,recordArtifact as t,expect as n,chai as r}from"vitest";import{getType as i}from"vitest/internal/browser";import{i as a,g as o,n as s,a as c,k as l,b as u,c as d,d as f,e as ee,f as te,h as ne,j as re,l as ie,m as ae,o as oe,p as se,q as ce,r as p,_ as m,s as h,t as g,u as _,L as v,v as le,w as ue,x as de,y as fe,z as pe,A as me,B as he,C as ge,D as _e,E as ve}from"./locators-CIWNuqVM.js";import{server as ye}from"vitest/browser";var be=Object.defineProperty,xe=(e,t)=>{let n={};for(var r in e)be(n,r,{get:e[r],enumerable:!0});return be(n,Symbol.toStringTag,{value:`Module`}),n};function Se(e,t,n={}){let r=Ce(e,t,n);if(r.errors.length)throw Error(r.errors[0].message);return r.fragment}function Ce(e,t,n={}){let r=new e.LineCounter,i={keepSourceTokens:!0,lineCounter:r,...n},a=e.parseDocument(t,i),o=[],s=e=>[r.linePos(e[0]),r.linePos(e[1])],c=e=>{o.push({message:e.message,range:[r.linePos(e.pos[0]),r.linePos(e.pos[1])]})},l=(t,n)=>{for(let r of n.items){if(r instanceof e.Scalar&&typeof r.value==`string`){let e=Ee.parse(r,i,o);e&&(t.children=t.children||[],t.children.push(e));continue}if(r instanceof e.YAMLMap){u(t,r);continue}o.push({message:`Sequence items should be strings or maps`,range:s(r.range||n.range)})}},u=(t,n)=>{for(let r of n.items){if(t.children=t.children||[],!(r.key instanceof e.Scalar&&typeof r.key.value==`string`)){o.push({message:`Only string keys are supported`,range:s(r.key.range||n.range)});continue}let a=r.key,c=r.value;if(a.value===`text`){if(!(c instanceof e.Scalar&&typeof c.value==`string`)){o.push({message:`Text value should be a string`,range:s(r.value.range||n.range)});continue}t.children.push({kind:`text`,text:y(c.value)});continue}if(a.value===`/children`){if(!(c instanceof e.Scalar&&typeof c.value==`string`)||c.value!==`contain`&&c.value!==`equal`&&c.value!==`deep-equal`){o.push({message:`Strict value should be "contain", "equal" or "deep-equal"`,range:s(r.value.range||n.range)});continue}t.containerMode=c.value;continue}if(a.value.startsWith(`/`)){if(!(c instanceof e.Scalar&&typeof c.value==`string`)){o.push({message:`Property value should be a string`,range:s(r.value.range||n.range)});continue}t.props=t.props??{},t.props[a.value.slice(1)]=y(c.value);continue}let u=Ee.parse(a,i,o);if(u){if(c instanceof e.Scalar){let e=typeof c.value;if(e!==`string`&&e!==`number`&&e!==`boolean`){o.push({message:`Node value should be a string or a sequence`,range:s(r.value.range||n.range)});continue}t.children.push({...u,children:[{kind:`text`,text:y(String(c.value))}]});continue}if(c instanceof e.YAMLSeq){t.children.push(u),l(u,c);continue}o.push({message:`Map values should be strings or sequences`,range:s(r.value.range||n.range)})}}},d={kind:`role`,role:`fragment`};return a.errors.forEach(c),o.length?{errors:o,fragment:d}:a.contents?(a.contents instanceof e.YAMLSeq||o.push({message:`Aria snapshot must be a YAML sequence, elements starting with " -"`,range:s(a.contents.range)}),o.length?{errors:o,fragment:d}:(l(d,a.contents),o.length?{errors:o,fragment:we}:d.children?.length===1&&(!d.containerMode||d.containerMode===`contain`)?{fragment:d.children[0],errors:[]}:{fragment:d,errors:[]})):{fragment:d,errors:[]}}const we={kind:`role`,role:`fragment`};function Te(e){return e.replace(/[\u200b\u00ad]/g,``).replace(/[\r\n\s\t]+/g,` `).trim()}function y(e){return{raw:e,normalized:Te(e)}}var Ee=class e{static parse(t,n,r){try{return new e(t.value)._parse()}catch(e){if(e instanceof b){let i=n.prettyErrors===!1?e.message:`${e.message}:\n\n${t.value}\n${` `.repeat(e.pos)}^\n`;return r.push({message:i,range:[n.lineCounter.linePos(t.range[0]),n.lineCounter.linePos(t.range[0]+e.pos)]}),null}throw e}}constructor(e){m(this,`_input`,void 0),m(this,`_pos`,void 0),m(this,`_length`,void 0),this._input=e,this._pos=0,this._length=e.length}_peek(){return this._input[this._pos]||``}_next(){return this._pos<this._length?this._input[this._pos++]:null}_eof(){return this._pos>=this._length}_isWhitespace(){return!this._eof()&&/\s/.test(this._peek())}_skipWhitespace(){for(;this._isWhitespace();)this._pos++}_readIdentifier(e){this._eof()&&this._throwError(`Unexpected end of input when expecting ${e}`);let t=this._pos;for(;!this._eof()&&/[a-zA-Z]/.test(this._peek());)this._pos++;return this._input.slice(t,this._pos)}_readString(){let e=``,t=!1;for(;!this._eof();){let n=this._next();if(t)e+=n,t=!1;else if(n===`\\`)t=!0;else if(n===`"`)return e;else e+=n}this._throwError(`Unterminated string`)}_throwError(e,t=0){throw new b(e,t||this._pos)}_readRegex(){let e=``,t=!1,n=!1;for(;!this._eof();){let r=this._next();if(t)e+=r,t=!1;else if(r===`\\`)t=!0,e+=r;else if(r===`/`&&!n)return{pattern:e};else r===`[`?(n=!0,e+=r):r===`]`&&n?(e+=r,n=!1):e+=r}this._throwError(`Unterminated regex`)}_readStringOrRegex(){let e=this._peek();return e===`"`?(this._next(),Te(this._readString())):e===`/`?(this._next(),this._readRegex()):null}_readAttributes(e){let t=this._pos;for(;this._skipWhitespace(),this._peek()===`[`;){this._next(),this._skipWhitespace(),t=this._pos;let n=this._readIdentifier(`attribute`);this._skipWhitespace();let r=``;if(this._peek()===`=`)for(this._next(),this._skipWhitespace(),t=this._pos;this._peek()!==`]`&&!this._isWhitespace()&&!this._eof();)r+=this._next();this._skipWhitespace(),this._peek()!==`]`&&this._throwError(`Expected ]`),this._next(),this._applyAttribute(e,n,r||`true`,t)}}_parse(){this._skipWhitespace();let e=this._readIdentifier(`role`);e===`fragment`&&this._throwError(`Invalid role "fragment"`),this._skipWhitespace();let t={kind:`role`,role:e,name:this._readStringOrRegex()||void 0};return this._readAttributes(t),this._skipWhitespace(),this._eof()||this._throwError(`Unexpected input`),t}_applyAttribute(e,t,n,r){if(t===`checked`){this._assert(n===`true`||n===`false`||n===`mixed`,`Value of "checked" attribute must be a boolean or "mixed"`,r),e.checked=n===`true`||n!==`false`&&`mixed`;return}if(t===`disabled`){this._assert(n===`true`||n===`false`,`Value of "disabled" attribute must be a boolean`,r),e.disabled=n===`true`;return}if(t===`expanded`){this._assert(n===`true`||n===`false`,`Value of "expanded" attribute must be a boolean`,r),e.expanded=n===`true`;return}if(t===`active`){this._assert(n===`true`||n===`false`,`Value of "active" attribute must be a boolean`,r),e.active=n===`true`;return}if(t===`level`){this._assert(!Number.isNaN(Number(n)),`Value of "level" attribute must be a number`,r),e.level=Number(n);return}if(t===`pressed`){this._assert(n===`true`||n===`false`||n===`mixed`,`Value of "pressed" attribute must be a boolean or "mixed"`,r),e.pressed=n===`true`||n!==`false`&&`mixed`;return}if(t===`selected`){this._assert(n===`true`||n===`false`,`Value of "selected" attribute must be a boolean`,r),e.selected=n===`true`;return}this._assert(!1,`Unsupported attribute [${t}]`,r)}_assert(e,t,n){e||this._throwError(t||`Assertion error`,n)}},b=class extends Error{constructor(e,t){super(e),m(this,`pos`,void 0),this.pos=t}};function x(e,t){return t?e?typeof t==`string`?e===t:!!e.match(new RegExp(t.pattern)):!1:!0}function S(e,t){if(!t?.normalized)return!0;if(!e)return!1;if(e===t.normalized||e===t.raw)return!0;let n=w(t);return n?!!e.match(n):!1}const C=Symbol(`cachedRegex`);function w(e){if(e[C]!==void 0)return e[C];let{raw:t}=e,n=t.startsWith(`/`)&&t.endsWith(`/`)&&t.length>1,r;try{r=n?new RegExp(t.slice(1,-1)):null}catch{r=null}return e[C]=r,r}function T(e,t,n){if(typeof e==`string`&&t.kind===`text`)return S(e,t.text);if(typeof e!=`object`||!e||t.kind!==`role`||t.role!==`fragment`&&t.role!==e.role||t.checked!==void 0&&t.checked!==e.checked||t.disabled!==void 0&&t.disabled!==e.disabled||t.expanded!==void 0&&t.expanded!==e.expanded||t.level!==void 0&&t.level!==e.level||t.pressed!==void 0&&t.pressed!==e.pressed||t.selected!==void 0&&t.selected!==e.selected||!x(e.name,t.name))return!1;if(t.props){for(let[n,r]of Object.entries(t.props))if(!S(e.props[n]||``,r))return!1}return t.containerMode===`contain`?D(e.children||[],t.children||[]):t.containerMode===`equal`?E(e.children||[],t.children||[],!1):t.containerMode===`deep-equal`||n?E(e.children||[],t.children||[],!0):D(e.children||[],t.children||[])}function E(e,t,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(!T(e[r],t[r],n))return!1;return!0}function D(e,t){if(t.length>e.length)return!1;let n=e.slice(),r=t.slice();for(let e of r){let t=n.shift();for(;t&&!T(t,e,!1);)t=n.shift();if(!t)return!1}return!0}var De=xe({LineCounter:()=>Oe,Scalar:()=>O,YAMLError:()=>j,YAMLMap:()=>k,YAMLSeq:()=>A,parseDocument:()=>ke}),O=class{constructor(e,t=[0,0,0]){m(this,`value`,void 0),m(this,`range`,void 0),this.value=e,this.range=t}},k=class{constructor(e=[0,0,0]){m(this,`items`,void 0),m(this,`range`,void 0),this.items=[],this.range=e}},A=class{constructor(e=[0,0,0]){m(this,`items`,void 0),m(this,`range`,void 0),this.items=[],this.range=e}},Oe=class{constructor(){m(this,`lineStarts`,[0])}addNewLine(e){e>this.lineStarts[this.lineStarts.length-1]&&this.lineStarts.push(e)}linePos(e){let t=0,n=this.lineStarts.length-1;for(;t<n;){let r=t+n+1>>1;this.lineStarts[r]<=e?t=r:n=r-1}return{line:t+1,col:e-this.lineStarts[t]+1}}},j=class extends Error{constructor(e,t){super(e),m(this,`pos`,void 0),this.pos=t}};function ke(e,t={}){let n=t.lineCounter,r=[];if(n)for(let t=0;t<e.length;t++)e[t]===`
2
2
  `&&n.addNewLine(t+1);try{return{contents:new Ae(e,r).parseRoot(),errors:r}}catch(e){if(e instanceof j)return r.push(e),{contents:null,errors:r};throw e}}var Ae=class{constructor(e,t){m(this,`lines`,void 0),m(this,`pos`,void 0),m(this,`text`,void 0),m(this,`errors`,void 0),this.text=e,this.errors=t,this.lines=[],this.pos=0;let n=0,r=e.split(`
3
3
  `);for(let e of r){let t=e.replace(/\r$/,``),r=t.replace(/^\s+/,``),i=t.length-r.length;this.lines.push({indent:i,content:r,offset:n+i,lineOffset:n,raw:t}),n+=e.length+1}for(;this.lines.length>0&&this.lines[this.lines.length-1].content===``;)this.lines.pop()}parseRoot(){if(this.lines.length===0)return null;let e=this.parseNode(0);if(this.skipEmpty(),this.pos<this.lines.length){let e=this.currentLine();this.addError(`Unexpected scalar at node end`,e.offset)}return e}currentLine(){return this.lines[this.pos]}parseNode(e){this.skipEmpty();let t=this.currentLine();return!t||t.indent<e?null:t.content.startsWith(`- `)||t.content===`-`?this.parseSequence(t.indent):this.isMapEntry(t.content)?this.parseMap(t.indent):(this.pos++,this.parseScalarValue(t.content,t.offset,t))}parseSequence(e){let t=this.currentLine(),n=new A([t.offset-t.indent,0,0]),r=t.offset;for(;this.pos<this.lines.length;){this.skipEmpty();let t=this.currentLine();if(!t||t.indent<e)break;if(t.indent>e){this.addError(`Bad indentation of a sequence entry`,t.offset);break}if(!t.content.startsWith(`- `)&&t.content!==`-`)break;let i=t.content===`-`?1:2,a=t.content.slice(i),o=t.offset+i;if(this.pos++,a===``||a.trim()===``){let t=this.parseNode(e+1);t&&(n.items.push(t),r=this.peekLastOffset())}else if(this.isMapEntry(a)){let s=this.parseInlineMap(a,o,e+i,t);n.items.push(s),r=s.range[2]}else{let e=this.parseScalarValue(a,o,t);n.items.push(e),r=e.range[2]}}return n.range[1]=r,n.range[2]=r,n}parseMap(e){let t=this.currentLine(),n=new k([t.offset-t.indent,0,0]),r=t.offset;for(;this.pos<this.lines.length;){this.skipEmpty();let t=this.currentLine();if(!t||t.indent<e)break;if(t.indent>e){this.addError(`Bad indentation of a mapping entry`,t.offset);break}if(!this.isMapEntry(t.content))break;let{key:i,valueStr:a,colonOffset:o,valueOffset:s}=this.splitMapEntry(t.content,t.offset),c=new O(i,[t.offset,t.offset+i.length,o]);this.pos++;let l;l=a===``?this.parseMapValue(e,o):this.parseScalarValue(a.trim(),s,t),n.items.push({key:c,value:l}),r=l?this.getNodeEnd(l):o+1}return n.range[1]=r,n.range[2]=r,n}parseInlineMap(e,t,n,r){let i=new k([t,0,0]),a=t,{key:o,valueStr:s,colonOffset:c,valueOffset:l}=this.splitMapEntry(e,t),u=new O(o,[t,t+o.length,c]),d;for(d=s===``?this.parseMapValue(n,c):this.parseScalarValue(s.trim(),l,r),i.items.push({key:u,value:d}),a=d?this.getNodeEnd(d):c+1;this.pos<this.lines.length;){this.skipEmpty();let e=this.currentLine();if(!e||e.indent<n||e.indent>n||!this.isMapEntry(e.content)||e.content.startsWith(`- `))break;let t=this.splitMapEntry(e.content,e.offset),r=new O(t.key,[e.offset,e.offset+t.key.length,t.colonOffset]);this.pos++;let o;o=t.valueStr===``?this.parseMapValue(n,t.colonOffset):this.parseScalarValue(t.valueStr.trim(),t.valueOffset,e),i.items.push({key:r,value:o}),a=o?this.getNodeEnd(o):t.colonOffset+1}return i.range[1]=a,i.range[2]=a,i}parseMapValue(e,t){this.skipEmpty();let n=this.currentLine();return!n||n.indent<e?new O(null,[t+1,t+1,t+1]):n.indent===e&&(n.content.startsWith(`- `)||n.content===`-`)?this.parseNode(e):n.indent>e?this.parseNode(e+1):new O(null,[t+1,t+1,t+1])}getNodeEnd(e){return e.range[2]}peekLastOffset(){if(this.pos>0&&this.pos<=this.lines.length){let e=this.lines[this.pos-1];return e.lineOffset+e.raw.length}return this.text.length}parseScalarValue(e,t,n){let r=e.trim(),i=t+e.indexOf(r),a=i+r.length,o=n.lineOffset+n.raw.length;return r.startsWith(`"`)?this.parseQuotedScalar(r,i,o):r===`true`||r===`false`?new O(r===`true`,[i,a,o]):r===`null`||r===`~`?new O(null,[i,a,o]):r!==``&&je(r)?new O(Number(r),[i,a,o]):new O(r,[i,a,o])}parseQuotedScalar(e,t,n){let r=``,i=1;for(;i<e.length;){let a=e[i];if(a===`\\`){if(i++,i>=e.length){this.addError(`Unterminated double-quoted string`,t+i);break}let n=e[i];switch(n){case`n`:r+=`
4
4
  `;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`"`:r+=`"`;break;case`\\`:r+=`\\`;break;case`/`:r+=`/`;break;default:r+=n}}else if(a===`"`){let e=t+i+1;return new O(r,[t,e,n])}else r+=a;i++}return this.addError(`Unterminated double-quoted string`,t),new O(r,[t,t+e.length,n])}skipEmpty(){for(;this.pos<this.lines.length&&this.lines[this.pos].content===``;)this.pos++}isMapEntry(e){return this.findMapColon(e)>=0}findMapColon(e){let t=!1,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){n=!1;continue}if(i===`\\`&&t){n=!0;continue}if(i===`"`){t=!t;continue}if(!t&&i===`:`&&(r+1>=e.length||e[r+1]===` `))return r}return-1}splitMapEntry(e,t){let n=this.findMapColon(e),r=e.slice(0,n).trim(),i=t+n,a=e.slice(n+1),o=a.trimStart(),s=i+1+(a.length-a.trimStart().length);return r.startsWith(`"`)&&r.endsWith(`"`)?{key:r.slice(1,-1),valueStr:o,colonOffset:i,valueOffset:s}:{key:r,valueStr:o,colonOffset:i,valueOffset:s}}addError(e,t){this.errors.push(new j(e,[t,t+1]))}};function je(e){return e===``||e===`-`||e===`+`?!1:/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(e)}function M(e){return Me(e)?`"`+e.replace(/[\\"\x00-\x1f\x7f-\x9f]/g,e=>{switch(e){case`\\`:return`\\\\`;case`"`:return`\\"`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { distClientRoot } from '@vitest/ui';
6
6
  import { slash as slash$1, deepMerge, cleanUrl as cleanUrl$1, toArray } from '@vitest/utils/helpers';
7
7
  import sirv from 'sirv';
8
8
  import c from 'tinyrainbow';
9
- import { isFileLoadingAllowed, createDebugger, isValidApiRequest, isCSSRequest, distDir, rolldownVersion, isFileServingAllowed } from 'vitest/node';
9
+ import { isFileLoadingAllowed, createDebugger, isValidApiRequest, BrowserConnectionError, isCSSRequest, distDir, rolldownVersion, isFileServingAllowed } from 'vitest/node';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import crypto from 'node:crypto';
12
12
  import MagicString from 'magic-string';
@@ -209,7 +209,7 @@ const basename = function(p, extension) {
209
209
  return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
210
210
  };
211
211
 
212
- var version = "5.0.0-rc.1";
212
+ var version = "5.0.0-rc.3";
213
213
 
214
214
  const pkgRoot = resolve(fileURLToPath(import.meta.url), "../..");
215
215
  const distRoot = resolve(pkgRoot, "dist");
@@ -2496,6 +2496,348 @@ class ParentBrowserProject {
2496
2496
  }
2497
2497
  }
2498
2498
 
2499
+ function _mergeNamespaces$1(n, m) {
2500
+ m.forEach(function(e) {
2501
+ e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
2502
+ if (k !== "default" && !(k in n)) {
2503
+ var d = Object.getOwnPropertyDescriptor(e, k);
2504
+ Object.defineProperty(n, k, d.get ? d : {
2505
+ enumerable: true,
2506
+ get: function() {
2507
+ return e[k];
2508
+ }
2509
+ });
2510
+ }
2511
+ });
2512
+ });
2513
+ return Object.freeze(n);
2514
+ }
2515
+ function getDefaultExportFromCjs(x) {
2516
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
2517
+ }
2518
+ var reactIs$1 = { exports: {} };
2519
+ var reactIs_production = {};
2520
+ /**
2521
+ * @license React
2522
+ * react-is.production.js
2523
+ *
2524
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2525
+ *
2526
+ * This source code is licensed under the MIT license found in the
2527
+ * LICENSE file in the root directory of this source tree.
2528
+ */
2529
+ var hasRequiredReactIs_production;
2530
+ function requireReactIs_production() {
2531
+ if (hasRequiredReactIs_production) return reactIs_production;
2532
+ hasRequiredReactIs_production = 1;
2533
+ 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");
2534
+ function typeOf(object) {
2535
+ if ("object" === typeof object && null !== object) {
2536
+ var $$typeof = object.$$typeof;
2537
+ switch ($$typeof) {
2538
+ case REACT_ELEMENT_TYPE: switch (object = object.type, object) {
2539
+ case REACT_FRAGMENT_TYPE:
2540
+ case REACT_PROFILER_TYPE:
2541
+ case REACT_STRICT_MODE_TYPE:
2542
+ case REACT_SUSPENSE_TYPE:
2543
+ case REACT_SUSPENSE_LIST_TYPE:
2544
+ case REACT_VIEW_TRANSITION_TYPE: return object;
2545
+ default: switch (object = object && object.$$typeof, object) {
2546
+ case REACT_CONTEXT_TYPE:
2547
+ case REACT_FORWARD_REF_TYPE:
2548
+ case REACT_LAZY_TYPE:
2549
+ case REACT_MEMO_TYPE: return object;
2550
+ case REACT_CONSUMER_TYPE: return object;
2551
+ default: return $$typeof;
2552
+ }
2553
+ }
2554
+ case REACT_PORTAL_TYPE: return $$typeof;
2555
+ }
2556
+ }
2557
+ }
2558
+ reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
2559
+ reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
2560
+ reactIs_production.Element = REACT_ELEMENT_TYPE;
2561
+ reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
2562
+ reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
2563
+ reactIs_production.Lazy = REACT_LAZY_TYPE;
2564
+ reactIs_production.Memo = REACT_MEMO_TYPE;
2565
+ reactIs_production.Portal = REACT_PORTAL_TYPE;
2566
+ reactIs_production.Profiler = REACT_PROFILER_TYPE;
2567
+ reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
2568
+ reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
2569
+ reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
2570
+ reactIs_production.isContextConsumer = function(object) {
2571
+ return typeOf(object) === REACT_CONSUMER_TYPE;
2572
+ };
2573
+ reactIs_production.isContextProvider = function(object) {
2574
+ return typeOf(object) === REACT_CONTEXT_TYPE;
2575
+ };
2576
+ reactIs_production.isElement = function(object) {
2577
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
2578
+ };
2579
+ reactIs_production.isForwardRef = function(object) {
2580
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
2581
+ };
2582
+ reactIs_production.isFragment = function(object) {
2583
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
2584
+ };
2585
+ reactIs_production.isLazy = function(object) {
2586
+ return typeOf(object) === REACT_LAZY_TYPE;
2587
+ };
2588
+ reactIs_production.isMemo = function(object) {
2589
+ return typeOf(object) === REACT_MEMO_TYPE;
2590
+ };
2591
+ reactIs_production.isPortal = function(object) {
2592
+ return typeOf(object) === REACT_PORTAL_TYPE;
2593
+ };
2594
+ reactIs_production.isProfiler = function(object) {
2595
+ return typeOf(object) === REACT_PROFILER_TYPE;
2596
+ };
2597
+ reactIs_production.isStrictMode = function(object) {
2598
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
2599
+ };
2600
+ reactIs_production.isSuspense = function(object) {
2601
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
2602
+ };
2603
+ reactIs_production.isSuspenseList = function(object) {
2604
+ return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
2605
+ };
2606
+ reactIs_production.isValidElementType = function(type) {
2607
+ 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;
2608
+ };
2609
+ reactIs_production.typeOf = typeOf;
2610
+ return reactIs_production;
2611
+ }
2612
+ var hasRequiredReactIs$1;
2613
+ function requireReactIs$1() {
2614
+ if (hasRequiredReactIs$1) return reactIs$1.exports;
2615
+ hasRequiredReactIs$1 = 1;
2616
+ {
2617
+ reactIs$1.exports = requireReactIs_production();
2618
+ }
2619
+ return reactIs$1.exports;
2620
+ }
2621
+ var reactIsExports$1 = requireReactIs$1();
2622
+ var index$1 = /*@__PURE__*/ getDefaultExportFromCjs(reactIsExports$1);
2623
+ var ReactIs19 = /*#__PURE__*/ _mergeNamespaces$1({
2624
+ __proto__: null,
2625
+ default: index$1
2626
+ }, [reactIsExports$1]);
2627
+ var reactIs = { exports: {} };
2628
+ var reactIs_production_min = {};
2629
+ /**
2630
+ * @license React
2631
+ * react-is.production.min.js
2632
+ *
2633
+ * Copyright (c) Facebook, Inc. and its affiliates.
2634
+ *
2635
+ * This source code is licensed under the MIT license found in the
2636
+ * LICENSE file in the root directory of this source tree.
2637
+ */
2638
+ var hasRequiredReactIs_production_min;
2639
+ function requireReactIs_production_min() {
2640
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
2641
+ hasRequiredReactIs_production_min = 1;
2642
+ 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;
2643
+ u = Symbol.for("react.module.reference");
2644
+ function v(a) {
2645
+ if ("object" === typeof a && null !== a) {
2646
+ var r = a.$$typeof;
2647
+ switch (r) {
2648
+ case b: switch (a = a.type, a) {
2649
+ case d:
2650
+ case f:
2651
+ case e:
2652
+ case m:
2653
+ case n: return a;
2654
+ default: switch (a = a && a.$$typeof, a) {
2655
+ case k:
2656
+ case h:
2657
+ case l:
2658
+ case q:
2659
+ case p:
2660
+ case g: return a;
2661
+ default: return r;
2662
+ }
2663
+ }
2664
+ case c: return r;
2665
+ }
2666
+ }
2667
+ }
2668
+ reactIs_production_min.ContextConsumer = h;
2669
+ reactIs_production_min.ContextProvider = g;
2670
+ reactIs_production_min.Element = b;
2671
+ reactIs_production_min.ForwardRef = l;
2672
+ reactIs_production_min.Fragment = d;
2673
+ reactIs_production_min.Lazy = q;
2674
+ reactIs_production_min.Memo = p;
2675
+ reactIs_production_min.Portal = c;
2676
+ reactIs_production_min.Profiler = f;
2677
+ reactIs_production_min.StrictMode = e;
2678
+ reactIs_production_min.Suspense = m;
2679
+ reactIs_production_min.SuspenseList = n;
2680
+ reactIs_production_min.isAsyncMode = function() {
2681
+ return false;
2682
+ };
2683
+ reactIs_production_min.isConcurrentMode = function() {
2684
+ return false;
2685
+ };
2686
+ reactIs_production_min.isContextConsumer = function(a) {
2687
+ return v(a) === h;
2688
+ };
2689
+ reactIs_production_min.isContextProvider = function(a) {
2690
+ return v(a) === g;
2691
+ };
2692
+ reactIs_production_min.isElement = function(a) {
2693
+ return "object" === typeof a && null !== a && a.$$typeof === b;
2694
+ };
2695
+ reactIs_production_min.isForwardRef = function(a) {
2696
+ return v(a) === l;
2697
+ };
2698
+ reactIs_production_min.isFragment = function(a) {
2699
+ return v(a) === d;
2700
+ };
2701
+ reactIs_production_min.isLazy = function(a) {
2702
+ return v(a) === q;
2703
+ };
2704
+ reactIs_production_min.isMemo = function(a) {
2705
+ return v(a) === p;
2706
+ };
2707
+ reactIs_production_min.isPortal = function(a) {
2708
+ return v(a) === c;
2709
+ };
2710
+ reactIs_production_min.isProfiler = function(a) {
2711
+ return v(a) === f;
2712
+ };
2713
+ reactIs_production_min.isStrictMode = function(a) {
2714
+ return v(a) === e;
2715
+ };
2716
+ reactIs_production_min.isSuspense = function(a) {
2717
+ return v(a) === m;
2718
+ };
2719
+ reactIs_production_min.isSuspenseList = function(a) {
2720
+ return v(a) === n;
2721
+ };
2722
+ reactIs_production_min.isValidElementType = function(a) {
2723
+ 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;
2724
+ };
2725
+ reactIs_production_min.typeOf = v;
2726
+ return reactIs_production_min;
2727
+ }
2728
+ var hasRequiredReactIs;
2729
+ function requireReactIs() {
2730
+ if (hasRequiredReactIs) return reactIs.exports;
2731
+ hasRequiredReactIs = 1;
2732
+ {
2733
+ reactIs.exports = requireReactIs_production_min();
2734
+ }
2735
+ return reactIs.exports;
2736
+ }
2737
+ var reactIsExports = requireReactIs();
2738
+ var index = /*@__PURE__*/ getDefaultExportFromCjs(reactIsExports);
2739
+ var ReactIs18 = /*#__PURE__*/ _mergeNamespaces$1({
2740
+ __proto__: null,
2741
+ default: index
2742
+ }, [reactIsExports]);
2743
+ const reactIsMethods = [
2744
+ "isAsyncMode",
2745
+ "isConcurrentMode",
2746
+ "isContextConsumer",
2747
+ "isContextProvider",
2748
+ "isElement",
2749
+ "isForwardRef",
2750
+ "isFragment",
2751
+ "isLazy",
2752
+ "isMemo",
2753
+ "isPortal",
2754
+ "isProfiler",
2755
+ "isStrictMode",
2756
+ "isSuspense",
2757
+ "isSuspenseList",
2758
+ "isValidElementType"
2759
+ ];
2760
+ Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
2761
+
2762
+ var naturalCompare = {exports: {}};
2763
+
2764
+ var hasRequiredNaturalCompare;
2765
+
2766
+ function requireNaturalCompare () {
2767
+ if (hasRequiredNaturalCompare) return naturalCompare.exports;
2768
+ hasRequiredNaturalCompare = 1;
2769
+ /*
2770
+ * @version 1.4.0
2771
+ * @date 2015-10-26
2772
+ * @stability 3 - Stable
2773
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
2774
+ * @license MIT License
2775
+ */
2776
+
2777
+
2778
+ var naturalCompare$1 = function(a, b) {
2779
+ var i, codeA
2780
+ , codeB = 1
2781
+ , posA = 0
2782
+ , posB = 0
2783
+ , alphabet = String.alphabet;
2784
+
2785
+ function getCode(str, pos, code) {
2786
+ if (code) {
2787
+ for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
2788
+ return +str.slice(pos - 1, i)
2789
+ }
2790
+ code = alphabet && alphabet.indexOf(str.charAt(pos));
2791
+ return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code
2792
+ : code < 46 ? 65 // -
2793
+ : code < 48 ? code - 1
2794
+ : code < 58 ? code + 18 // 0-9
2795
+ : code < 65 ? code - 11
2796
+ : code < 91 ? code + 11 // A-Z
2797
+ : code < 97 ? code - 37
2798
+ : code < 123 ? code + 5 // a-z
2799
+ : code - 63
2800
+ }
2801
+
2802
+
2803
+ if ((a+="") != (b+="")) for (;codeB;) {
2804
+ codeA = getCode(a, posA++);
2805
+ codeB = getCode(b, posB++);
2806
+
2807
+ if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
2808
+ codeA = getCode(a, posA, posA);
2809
+ codeB = getCode(b, posB, posA = i);
2810
+ posB = i;
2811
+ }
2812
+
2813
+ if (codeA != codeB) return (codeA < codeB) ? -1 : 1
2814
+ }
2815
+ return 0
2816
+ };
2817
+
2818
+ try {
2819
+ naturalCompare.exports = naturalCompare$1;
2820
+ } catch (e) {
2821
+ String.naturalCompare = naturalCompare$1;
2822
+ }
2823
+ return naturalCompare.exports;
2824
+ }
2825
+
2826
+ requireNaturalCompare();
2827
+
2828
+ // Evaluate a snapshot file's content into its snapshot key/value pairs.
2829
+ function evaluateSnapshotFile(filepath, content) {
2830
+ const data = Object.create(null);
2831
+ try {
2832
+ // eslint-disable-next-line no-new-func
2833
+ const populate = new Function("exports", content);
2834
+ populate(data);
2835
+ } catch (cause) {
2836
+ throw new Error(`Invalid snapshot file, please manually fix or delete it: ${filepath}`, { cause });
2837
+ }
2838
+ return data;
2839
+ }
2840
+
2499
2841
  //#region src/utils.ts
2500
2842
  function createPromiseWithResolvers() {
2501
2843
  let resolve;
@@ -2517,7 +2859,7 @@ function nanoid(size = 21) {
2517
2859
  while (i--) id += urlAlphabet[random() * 64 | 0];
2518
2860
  return id;
2519
2861
  }
2520
-
2862
+ //#endregion
2521
2863
  //#region src/main.ts
2522
2864
  const DEFAULT_TIMEOUT = 6e4;
2523
2865
  const defaultSerialize = (i) => i;
@@ -2697,6 +3039,24 @@ function createBirpc($functions, options) {
2697
3039
 
2698
3040
  const debug = createDebugger("vitest:browser:api");
2699
3041
  const BROWSER_API_PATH = "/__vitest_browser_api__";
3042
+ const DEFAULT_HEARTBEAT_INTERVAL = 15e3;
3043
+ const HEARTBEAT_MAX_MISSED = 2;
3044
+ let warnedInvalidHeartbeatInterval = false;
3045
+ function resolveHeartbeatInterval(vitest) {
3046
+ const rawInterval = process.env.VITEST_BROWSER_HEARTBEAT_INTERVAL;
3047
+ if (!rawInterval) {
3048
+ return DEFAULT_HEARTBEAT_INTERVAL;
3049
+ }
3050
+ const interval = Number(rawInterval);
3051
+ if (Number.isNaN(interval)) {
3052
+ if (!warnedInvalidHeartbeatInterval) {
3053
+ warnedInvalidHeartbeatInterval = true;
3054
+ vitest.logger.warn(`VITEST_BROWSER_HEARTBEAT_INTERVAL is expected to be a number, received "${rawInterval}". Using the default interval of ${DEFAULT_HEARTBEAT_INTERVAL}ms instead.`);
3055
+ }
3056
+ return DEFAULT_HEARTBEAT_INTERVAL;
3057
+ }
3058
+ return interval;
3059
+ }
2700
3060
  function setupBrowserRpc(globalServer, defaultMockerRegistry) {
2701
3061
  const vite = globalServer.vite;
2702
3062
  const vitest = globalServer.vitest;
@@ -2745,8 +3105,31 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
2745
3105
  const clients = type === "tester" ? state.testers : state.orchestrators;
2746
3106
  clients.set(rpcId, rpc);
2747
3107
  debug?.("[%s] Browser API connected to %s", rpcId, type);
3108
+ // if the browser stops answering pings, terminate the socket so the
3109
+ // "close" handler below rejects pending calls (like `createTesters`)
3110
+ // instead of the run hanging forever; timeouts that live in the browser
3111
+ // (`testTimeout`, iframe ack) cannot fire once its process is frozen
3112
+ const heartbeatInterval = resolveHeartbeatInterval(vitest);
3113
+ let missedPongs = 0;
3114
+ ws.on("pong", () => {
3115
+ missedPongs = 0;
3116
+ });
3117
+ const heartbeat = heartbeatInterval > 0 ? setInterval(() => {
3118
+ if (ws.readyState !== ws.OPEN) {
3119
+ return;
3120
+ }
3121
+ if (missedPongs >= HEARTBEAT_MAX_MISSED) {
3122
+ debug?.("[%s] %s did not respond to %s heartbeat pings, terminating the connection", rpcId, type, missedPongs);
3123
+ rpc.$close(new Error(`[vitest] The browser ${type} did not respond to a heartbeat ping for ${missedPongs * heartbeatInterval}ms. The browser process might be frozen or killed. Closing the connection.`));
3124
+ ws.terminate();
3125
+ return;
3126
+ }
3127
+ missedPongs++;
3128
+ ws.ping();
3129
+ }, heartbeatInterval).unref() : undefined;
2748
3130
  ws.on("close", () => {
2749
3131
  debug?.("[%s] Browser API disconnected from %s", rpcId, type);
3132
+ clearInterval(heartbeat);
2750
3133
  offCancel();
2751
3134
  clients.delete(rpcId);
2752
3135
  globalServer.removeCDPHandler(rpcId);
@@ -2754,7 +3137,7 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
2754
3137
  sessions.destroySession(sessionId);
2755
3138
  }
2756
3139
  // this will reject any hanging methods if there are any
2757
- rpc.$close(new Error(`[vitest] Browser connection was closed while running tests. Was the page closed unexpectedly?`));
3140
+ rpc.$close(new BrowserConnectionError(`[vitest] Browser connection was closed while running tests. Was the page closed unexpectedly?`));
2758
3141
  });
2759
3142
  });
2760
3143
  });
@@ -2771,8 +3154,11 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
2771
3154
  function canWrite(project) {
2772
3155
  return project.config.api.allowWrite && project.vitest.config.api.allowWrite;
2773
3156
  }
3157
+ function canExec(project) {
3158
+ return project.config.api.allowExec && project.vitest.config.api.allowExec;
3159
+ }
2774
3160
  function isCdpAllowed(project) {
2775
- return project.config.api.allowExec && project.vitest.config.api.allowExec && project.config.api.allowWrite && project.vitest.config.api.allowWrite;
3161
+ return canExec(project) && canWrite(project);
2776
3162
  }
2777
3163
  function assertCdpAllowed(project) {
2778
3164
  if (!isCdpAllowed(project)) {
@@ -2881,6 +3267,17 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
2881
3267
  }
2882
3268
  return promises.readFile(snapshotPath, "utf-8");
2883
3269
  },
3270
+ async readSnapshotFileData(snapshotPath) {
3271
+ checkFileAccess(snapshotPath);
3272
+ if (!existsSync(snapshotPath)) {
3273
+ return null;
3274
+ }
3275
+ if (!canExec(project)) {
3276
+ throw new Error(`Cannot read snapshot file because browser API exec operations are disabled. See https://vitest.dev/config/api.`);
3277
+ }
3278
+ const content = await promises.readFile(snapshotPath, "utf-8");
3279
+ return evaluateSnapshotFile(snapshotPath, content);
3280
+ },
2884
3281
  async saveSnapshotFile(id, content) {
2885
3282
  checkFileAccess(id);
2886
3283
  if (!canWrite(project)) {
@@ -2987,6 +3384,7 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
2987
3384
  if (module.type === "redirect") {
2988
3385
  const redirectUrl = new URL(module.redirect);
2989
3386
  module.redirect = join(vite.config.root, redirectUrl.pathname);
3387
+ checkFileAccess(module.redirect);
2990
3388
  }
2991
3389
  defaultMockerRegistry.register(module);
2992
3390
  }
@@ -3339,7 +3737,10 @@ body {
3339
3737
  };
3340
3738
  contribution.plugins = [
3341
3739
  ...BrowserPlugin(contribution),
3342
- interceptorPlugin({ registry: mockerRegistry }),
3740
+ interceptorPlugin({
3741
+ registry: mockerRegistry,
3742
+ registerWebSocketEvents: false
3743
+ }),
3343
3744
  {
3344
3745
  name: "vitest:browser:framework-sourcemaps",
3345
3746
  enforce: "post",
@@ -3420,6 +3821,7 @@ function resolveBrowserOptimizeDeps(projectConfigs, testFiles, harness) {
3420
3821
  "@vitest/browser/utils",
3421
3822
  "@vitest/browser/context",
3422
3823
  "@vitest/browser/locators",
3824
+ "@vitest/browser/client",
3423
3825
  "msw",
3424
3826
  "msw/browser"
3425
3827
  ];
@@ -3446,12 +3848,12 @@ function resolveBrowserOptimizeDeps(projectConfigs, testFiles, harness) {
3446
3848
  }
3447
3849
  // Pre-bundle the vitest runtime so the browser fetches a few optimized
3448
3850
  // chunks instead of ~20 separately-served dist chunks (faster startup).
3449
- // `vitest`, `vitest/internal/browser` and `@vitest/browser/client` are
3450
- // optimized together in a single pass, so esbuild dedupes their shared
3451
- // stateful chunks (the test collector, the runner, the RPC client) to a
3452
- // single instance — preserving module identity between the test files'
3453
- // `import 'vitest'` and the tester. Their transitive deps (@vitest/utils,
3454
- // @vitest/spy, pathe, tinyrainbow, …) are inlined into these bundles.
3851
+ // `vitest` and `vitest/internal/browser` are optimized together in a single
3852
+ // pass, so esbuild dedupes their shared stateful chunks (the test collector,
3853
+ // the runner) to a single instance, preserving module identity between the
3854
+ // test files' `import 'vitest'` and the tester. Their transitive deps
3855
+ // (@vitest/utils, @vitest/spy, pathe, tinyrainbow, …) are inlined into
3856
+ // these bundles.
3455
3857
  const include = [
3456
3858
  "vitest > expect-type",
3457
3859
  "vitest > magic-string",
@@ -3459,8 +3861,7 @@ function resolveBrowserOptimizeDeps(projectConfigs, testFiles, harness) {
3459
3861
  "vitest > vite/module-runner",
3460
3862
  "vitest",
3461
3863
  "vitest/internal/browser",
3462
- "vitest/internal/traces",
3463
- "@vitest/browser/client"
3864
+ "vitest/internal/traces"
3464
3865
  ];
3465
3866
  const provider = testConfig.browser?.provider;
3466
3867
  if (provider?.name === "preview") {
@@ -1,5 +1,5 @@
1
1
  import{server as e,page as t,utils as n}from"vitest/browser";import{__INTERNAL as r,getSafeTimers as i}from"vitest/internal/browser";const a=globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;function o(e){let t=c().current;if(!t||t.type!==`test`)return e();let n=!1,r=Error(`STACK_TRACE_ERROR`);t.onFinished??=[],t.onFinished.push(()=>{if(!n){let e=Error(`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`);throw e.stack=r.stack?.replace(r.message,e.message),e}});let i;return{then(t,a){return n=!0,(i||=e(r)).then(t,a)},catch(t){return n=!0,(i||=e(r)).catch(t)},finally(t){return n=!0,(i||=e(r)).finally(t)},[Symbol.toStringTag]:`Promise`}}function s(){return window.__vitest_browser_runner__}function c(){let e=window.__vitest_worker__;if(!e)throw Error(`Worker state is not found. This is an issue with Vitest. Please, open an issue.`);return e}function l(e){"@babel/helpers - typeof";return l=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const p=function(e,t,n){return e>=t&&e<=n};function m(e){return p(e,48,57)}function h(e){return m(e)||p(e,65,70)||p(e,97,102)}function g(e){return p(e,65,90)}function ee(e){return p(e,97,122)}function _(e){return g(e)||ee(e)}function v(e){return e>=128}function y(e){return _(e)||v(e)||e===95}function te(e){return y(e)||m(e)||e===45}function ne(e){return p(e,0,8)||e===11||p(e,14,31)||e===127}function b(e){return e===10}function x(e){return b(e)||e===9||e===32}var S=class extends Error{constructor(e){super(e),this.name=`InvalidCharacterError`}};function re(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===13&&e.charCodeAt(n+1)===10&&(r=10,n++),(r===13||r===12)&&(r=10),r===0&&(r=65533),p(r,55296,56319)&&p(e.charCodeAt(n+1),56320,57343)){let t=r-55296,i=e.charCodeAt(n+1)-56320;r=2**16+t*2**10+i,n++}t.push(r)}return t}function C(e){if(e<=65535)return String.fromCharCode(e);e-=2**16;let t=Math.floor(e/2**10)+55296,n=e%2**10+56320;return String.fromCharCode(t)+String.fromCharCode(n)}function w(e){let t=re(e),n=-1,r=[],i,a=function(e){return e>=t.length?-1:t[e]},o=function(e){if(e===void 0&&(e=1),e>3)throw`Spec Error: no more than three codepoints of lookahead.`;return a(n+e)},s=function(e){return e===void 0&&(e=1),n+=e,i=a(n),!0},c=function(){return--n,!0},l=function(e){return e===void 0&&(e=i),e===-1},u=function(){if(d(),s(),x(i)){for(;x(o());)s();return new oe}else if(i===34)return g();else if(i===35)if(te(o())||v(o(1),o(2))){let e=new Oe(``);return w(o(1),o(2),o(3))&&(e.type=`id`),e.value=k(),e}else return new D(i);else if(i===36)return o()===61?(s(),new xe):new D(i);else if(i===39)return g();else if(i===40)return new ge;else if(i===41)return new _e;else if(i===42)return o()===61?(s(),new Se):new D(i);else if(i===43)return O()?(c(),f()):new D(i);else if(i===44)return new de;else if(i===45)return O()?(c(),f()):o(1)===45&&o(2)===62?(s(2),new ce):T()?(c(),p()):new D(i);else if(i===46)return O()?(c(),f()):new D(i);else if(i===58)return new le;else if(i===59)return new ue;else if(i===60)return o(1)===33&&o(2)===45&&o(3)===45?(s(3),new se):new D(i);else if(i===64)return w(o(1),o(2),o(3))?new De(k()):new D(i);else if(i===91)return new me;else if(i===92)return S()?(c(),p()):new D(i);else if(i===93)return new he;else if(i===94)return o()===61?(s(),new be):new D(i);else if(i===123)return new fe;else if(i===124)return o()===61?(s(),new ye):o()===124?(s(),new Ce):new D(i);else if(i===125)return new pe;else if(i===126)return o()===61?(s(),new ve):new D(i);else if(m(i))return c(),f();else if(y(i))return c(),p();else if(l())return new we;else return new D(i)},d=function(){for(;o(1)===47&&o(2)===42;)for(s(2);;)if(s(),i===42&&o()===47){s();break}else if(l())return},f=function(){let e=Pe();if(w(o(1),o(2),o(3))){let t=new Ne;return t.value=e.value,t.repr=e.repr,t.type=e.type,t.unit=k(),t}else if(o()===37){s();let t=new Me;return t.value=e.value,t.repr=e.repr,t}else{let t=new je;return t.value=e.value,t.repr=e.repr,t.type=e.type,t}},p=function(){let e=k();if(e.toLowerCase()===`url`&&o()===40){for(s();x(o(1))&&x(o(2));)s();return o()===34||o()===39||x(o())&&(o(2)===34||o(2)===39)?new Ee(e):ee()}else if(o()===40)return s(),new Ee(e);else return new Te(e)},g=function(e){e===void 0&&(e=i);let t=``;for(;s();)if(i===e||l())return new ke(t);else if(b(i))return c(),new ie;else i===92?l(o())||(b(o())?s():t+=C(_())):t+=C(i);throw Error(`Internal error`)},ee=function(){let e=new Ae(``);for(;x(o());)s();if(l(o()))return e;for(;s();)if(i===41||l())return e;else if(x(i)){for(;x(o());)s();return o()===41||l(o())?(s(),e):(A(),new ae)}else if(i===34||i===39||i===40||ne(i))return A(),new ae;else if(i===92)if(S())e.value+=C(_());else return A(),new ae;else e.value+=C(i);throw Error(`Internal error`)},_=function(){if(s(),h(i)){let e=[i];for(let t=0;t<5&&h(o());t++)s(),e.push(i);x(o())&&s();let t=Number.parseInt(e.map(e=>String.fromCharCode(e)).join(``),16);return t>1114111&&(t=65533),t}else if(l())return 65533;else return i},v=function(e,t){return!(e!==92||b(t))},S=function(){return v(i,o())},w=function(e,t,n){return e===45?y(t)||t===45||v(t,n):y(e)?!0:e===92&&v(e,t)},T=function(){return w(i,o(1),o(2))},E=function(e,t,n){return e===43||e===45?!!(m(t)||t===46&&m(n)):e===46?!!m(t):!!m(e)},O=function(){return E(i,o(1),o(2))},k=function(){let e=``;for(;s();)if(te(i))e+=C(i);else if(S())e+=C(_());else return c(),e;throw Error(`Internal parse error`)},Pe=function(){let e=``,t=`integer`;for((o()===43||o()===45)&&(s(),e+=C(i));m(o());)s(),e+=C(i);if(o(1)===46&&m(o(2)))for(s(),e+=C(i),s(),e+=C(i),t=`number`;m(o());)s(),e+=C(i);let n=o(1),r=o(2),a=o(3);if((n===69||n===101)&&m(r))for(s(),e+=C(i),s(),e+=C(i),t=`number`;m(o());)s(),e+=C(i);else if((n===69||n===101)&&(r===43||r===45)&&m(a))for(s(),e+=C(i),s(),e+=C(i),s(),e+=C(i),t=`number`;m(o());)s(),e+=C(i);let c=Fe(e);return{type:t,value:c,repr:e}},Fe=function(e){return+e},A=function(){for(;s();)if(i===41||l())return;else S()&&_()},Ie=0;for(;!l(o());)if(r.push(u()),Ie++,Ie>t.length*2)throw Error(`I'm infinite-looping!`);return r}var T=class{constructor(){f(this,`tokenType`,``),f(this,`value`,void 0)}toJSON(){return{token:this.tokenType}}toString(){return this.tokenType}toSource(){return`${this}`}},ie=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`BADSTRING`)}},ae=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`BADURL`)}},oe=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`WHITESPACE`)}toString(){return`WS`}toSource(){return` `}},se=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`CDO`)}toSource(){return`<!--`}},ce=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`CDC`)}toSource(){return`-->`}},le=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`:`)}},ue=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`;`)}},de=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`,`)}},E=class extends T{constructor(...e){super(...e),f(this,`value`,``),f(this,`mirror`,``)}},fe=class extends E{constructor(){super(),f(this,`tokenType`,`{`),this.value=`{`,this.mirror=`}`}},pe=class extends E{constructor(){super(),f(this,`tokenType`,`}`),this.value=`}`,this.mirror=`{`}},me=class extends E{constructor(){super(),f(this,`tokenType`,`[`),this.value=`[`,this.mirror=`]`}},he=class extends E{constructor(){super(),f(this,`tokenType`,`]`),this.value=`]`,this.mirror=`[`}},ge=class extends E{constructor(){super(),f(this,`tokenType`,`(`),this.value=`(`,this.mirror=`)`}},_e=class extends E{constructor(){super(),f(this,`tokenType`,`)`),this.value=`)`,this.mirror=`(`}},ve=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`~=`)}},ye=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`|=`)}},be=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`^=`)}},xe=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`$=`)}},Se=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`*=`)}},Ce=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`||`)}},we=class extends T{constructor(...e){super(...e),f(this,`tokenType`,`EOF`)}toSource(){return``}},D=class extends T{constructor(e){super(),f(this,`tokenType`,`DELIM`),f(this,`value`,``),this.value=C(e)}toString(){return`DELIM(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}toSource(){return this.value===`\\`?`\\
2
2
  `:this.value}},O=class extends T{constructor(...e){super(...e),f(this,`value`,``)}ASCIIMatch(e){return this.value.toLowerCase()===e.toLowerCase()}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}},Te=class extends O{constructor(e){super(),f(this,`tokenType`,`IDENT`),this.value=e}toString(){return`IDENT(${this.value})`}toSource(){return k(this.value)}},Ee=class extends O{constructor(e){super(),f(this,`tokenType`,`FUNCTION`),f(this,`mirror`,void 0),this.value=e,this.mirror=`)`}toString(){return`FUNCTION(${this.value})`}toSource(){return`${k(this.value)}(`}},De=class extends O{constructor(e){super(),f(this,`tokenType`,`AT-KEYWORD`),this.value=e}toString(){return`AT(${this.value})`}toSource(){return`@${k(this.value)}`}},Oe=class extends O{constructor(e){super(),f(this,`tokenType`,`HASH`),f(this,`type`,void 0),this.value=e,this.type=`unrestricted`}toString(){return`HASH(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e}toSource(){return this.type===`id`?`#${k(this.value)}`:`#${Pe(this.value)}`}},ke=class extends O{constructor(e){super(),f(this,`tokenType`,`STRING`),this.value=e}toString(){return`"${Fe(this.value)}"`}},Ae=class extends O{constructor(e){super(),f(this,`tokenType`,`URL`),this.value=e}toString(){return`URL(${this.value})`}toSource(){return`url("${Fe(this.value)}")`}},je=class extends T{constructor(){super(),f(this,`tokenType`,`NUMBER`),f(this,`type`,void 0),f(this,`repr`,void 0),this.type=`integer`,this.repr=``}toString(){return this.type===`integer`?`INT(${this.value})`:`NUMBER(${this.value})`}toJSON(){let e=super.toJSON();return e.value=this.value,e.type=this.type,e.repr=this.repr,e}toSource(){return this.repr}},Me=class extends T{constructor(){super(),f(this,`tokenType`,`PERCENTAGE`),f(this,`repr`,void 0),this.repr=``}toString(){return`PERCENTAGE(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.repr=this.repr,e}toSource(){return`${this.repr}%`}},Ne=class extends T{constructor(){super(),f(this,`tokenType`,`DIMENSION`),f(this,`type`,void 0),f(this,`repr`,void 0),f(this,`unit`,void 0),this.type=`integer`,this.repr=``,this.unit=``}toString(){return`DIM(${this.value},${this.unit})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e.repr=this.repr,e.unit=this.unit,e}toSource(){let e=this.repr,t=k(this.unit);return t[0].toLowerCase()===`e`&&(t[1]===`-`||p(t.charCodeAt(1),48,57))&&(t=`\\65 ${t.slice(1,t.length)}`),e+t}};function k(e){e=`${e}`;let t=``,n=e.charCodeAt(0);for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i===0)throw new S(`Invalid character: the input contains U+0000.`);p(i,1,31)||i===127||r===0&&p(i,48,57)||r===1&&p(i,48,57)&&n===45?t+=`\\${i.toString(16)} `:i>=128||i===45||i===95||p(i,48,57)||p(i,65,90)||p(i,97,122)?t+=e[r]:t+=`\\${e[r]}`}return t}function Pe(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new S(`Invalid character: the input contains U+0000.`);r>=128||r===45||r===95||p(r,48,57)||p(r,65,90)||p(r,97,122)?t+=e[n]:t+=`\\${r.toString(16)} `}return t}function Fe(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new S(`Invalid character: the input contains U+0000.`);p(r,1,31)||r===127?t+=`\\${r.toString(16)} `:t+=r===34||r===92?`\\${e[n]}`:e[n]}return t}var A=class extends Error{};function Ie(e,t){let n;try{n=w(e),n[n.length-1]instanceof we||n.push(new we)}catch(t){let n=`${t.message} while parsing selector "${e}"`,r=(t.stack||``).indexOf(t.message);throw r!==-1&&(t.stack=t.stack.substring(0,r)+n+t.stack.substring(r+t.message.length)),t.message=n,t}let r=n.find(e=>e instanceof De||e instanceof ie||e instanceof ae||e instanceof Ce||e instanceof se||e instanceof ce||e instanceof ue||e instanceof fe||e instanceof pe||e instanceof Ae||e instanceof Me);if(r)throw new A(`Unsupported token "${r.toSource()}" while parsing selector "${e}"`);let i=0,a=new Set;function o(){return new A(`Unexpected token "${n[i].toSource()}" while parsing selector "${e}"`)}function s(){for(;n[i]instanceof oe;)i++}function c(e=i){return n[e]instanceof Te}function l(e=i){return n[e]instanceof ke}function u(e=i){return n[e]instanceof je}function d(e=i){return n[e]instanceof de}function f(e=i){return n[e]instanceof ge}function p(e=i){return n[e]instanceof _e}function m(e=i){return n[e]instanceof Ee}function h(e=i){return n[e]instanceof D&&n[e].value===`*`}function g(e=i){return n[e]instanceof we}function ee(e=i){return n[e]instanceof D&&[`>`,`+`,`~`].includes(n[e].value)}function _(e=i){return d(e)||p(e)||g(e)||ee(e)||n[e]instanceof oe}function v(){let e=[y()];for(;s(),d();)i++,e.push(y());return e}function y(){return s(),u()||l()?n[i++].value:te()}function te(){let e={simples:[]};for(s(),ee()?e.simples.push({selector:{functions:[{name:`scope`,args:[]}]},combinator:``}):e.simples.push({selector:ne(),combinator:``});;){if(s(),ee())e.simples[e.simples.length-1].combinator=n[i++].value,s();else if(_())break;e.simples.push({combinator:``,selector:ne()})}return e}function ne(){let e=``,r=[];for(;!_();)if(c()||h())e+=n[i++].toSource();else if(n[i]instanceof Oe)e+=n[i++].toSource();else if(n[i]instanceof D&&n[i].value===`.`)if(i++,c())e+=`.${n[i++].toSource()}`;else throw o();else if(n[i]instanceof le)if(i++,c())if(!t.has(n[i].value.toLowerCase()))e+=`:${n[i++].toSource()}`;else{let e=n[i++].value.toLowerCase();r.push({name:e,args:[]}),a.add(e)}else if(m()){let c=n[i++].value.toLowerCase();if(t.has(c)?(r.push({name:c,args:v()}),a.add(c)):e+=`:${c}(${b()})`,s(),!p())throw o();i++}else throw o();else if(n[i]instanceof me){for(e+=`[`,i++;!(n[i]instanceof he)&&!g();)e+=n[i++].toSource();if(!(n[i]instanceof he))throw o();e+=`]`,i++}else throw o();if(!e&&!r.length)throw o();return{css:e||void 0,functions:r}}function b(){let e=``,t=1;for(;!g()&&((f()||m())&&t++,p()&&t--,t);)e+=n[i++].toSource();return e}let x=v();if(!g())throw o();if(x.some(e=>typeof e!=`object`||!(`simples`in e)))throw new A(`Error while parsing selector "${e}"`);return{selector:x,names:Array.from(a)}}const Le=new Set([`internal:has`,`internal:has-not`,`internal:and`,`internal:or`,`internal:chain`,`left-of`,`right-of`,`above`,`below`,`near`]),Re=new Set([`left-of`,`right-of`,`above`,`below`,`near`]),ze=new Set([`not`,`is`,`where`,`has`,`scope`,`light`,`visible`,`text`,`text-matches`,`text-is`,`has-text`,`above`,`below`,`right-of`,`left-of`,`near`,`nth-match`]);function Be(e){let t=Ue(e),n=[];for(let e of t.parts){if(e.name===`css`||e.name===`css:light`){e.name===`css:light`&&(e.body=`:light(${e.body})`);let t=Ie(e.body,ze);n.push({name:`css`,body:t.selector,source:e.body});continue}if(Le.has(e.name)){let t,r;try{let n=JSON.parse(`[${e.body}]`);if(!Array.isArray(n)||n.length<1||n.length>2||typeof n[0]!=`string`)throw new A(`Malformed selector: ${e.name}=${e.body}`);if(t=n[0],n.length===2){if(typeof n[1]!=`number`||!Re.has(e.name))throw new A(`Malformed selector: ${e.name}=${e.body}`);r=n[1]}}catch{throw new A(`Malformed selector: ${e.name}=${e.body}`)}let i={name:e.name,source:e.body,body:{parsed:Be(t),distance:r}},a=[...i.body.parsed.parts].reverse().find(e=>e.name===`internal:control`&&e.body===`enter-frame`),o=a?i.body.parsed.parts.indexOf(a):-1;o!==-1&&Ve(i.body.parsed.parts.slice(0,o+1),n.slice(0,o+1))&&i.body.parsed.parts.splice(0,o+1),n.push(i);continue}n.push({...e,source:e.body})}if(Le.has(n[0].name))throw new A(`"${n[0].name}" selector cannot be first`);return{capture:t.capture,parts:n}}function Ve(e,t){return j({parts:e})===j({parts:t})}function j(e,t){return typeof e==`string`?e:e.parts.map((n,r)=>{let i=!0;!t&&r!==e.capture&&(n.name===`css`||n.name===`xpath`&&n.source.startsWith(`//`)||n.source.startsWith(`..`))&&(i=!1);let a=i?`${n.name}=`:``;return`${r===e.capture?`*`:``}${a}${n.source}`}).join(` >> `)}function He(e,t){let n=(e,r)=>{for(let i of e.parts)t(i,r),Le.has(i.name)&&n(i.body.parsed,!0)};n(e,!1)}function Ue(e){let t=0,n,r=0,i={parts:[]},a=()=>{let n=e.substring(r,t).trim(),a=n.indexOf(`=`),o,s;a!==-1&&n.substring(0,a).trim().match(/^[\w\-+:*]+$/)?(o=n.substring(0,a).trim(),s=n.substring(a+1)):n.length>1&&n[0]===`"`&&n[n.length-1]===`"`||n.length>1&&n[0]===`'`&&n[n.length-1]===`'`?(o=`text`,s=n):/^\(*\/\//.test(n)||n.startsWith(`..`)?(o=`xpath`,s=n):(o=`css`,s=n);let c=!1;if(o[0]===`*`&&(c=!0,o=o.substring(1)),i.parts.push({name:o,body:s}),c){if(i.capture!==void 0)throw new A(`Only one of the selectors can capture using * modifier`);i.capture=i.parts.length-1}};if(!e.includes(`>>`))return t=e.length,a(),i;let o=()=>{let n=e.substring(r,t).match(/^\s*text\s*=(.*)$/);return!!n&&!!n[1]};for(;t<e.length;){let i=e[t];i===`\\`&&t+1<e.length?t+=2:i===n?(n=void 0,t++):!n&&(i===`"`||i===`'`||i==="`")&&!o()?(n=i,t++):!n&&i===`>`&&e[t+1]===`>`?(a(),t+=2,r=t):t++}return a(),i}function M(e,t){let n=0,r=e.length===0,i=()=>e[n]||``,a=()=>{let t=i();return++n,r=n>=e.length,t},o=t=>{throw r?new A(`Unexpected end of selector while parsing selector \`${e}\``):new A(`Error while parsing selector \`${e}\` - unexpected symbol "${i()}" at position ${n}${t?` during ${t}`:``}`)};function s(){for(;!r&&/\s/.test(i());)a()}function c(e){return e>=`€`||e>=`0`&&e<=`9`||e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`_`||e===`-`}function l(){let e=``;for(s();!r&&c(i());)e+=a();return e}function u(e){let t=a();for(t!==e&&o(`parsing quoted string`);!r&&i()!==e;)i()===`\\`&&a(),t+=a();return i()!==e&&o(`parsing quoted string`),t+=a(),t}function d(){a()!==`/`&&o(`parsing regular expression`);let t=``,n=!1;for(;!r;){if(i()===`\\`)t+=a(),r&&o(`parsing regular expression`);else if(n&&i()===`]`)n=!1;else if(!n&&i()===`[`)n=!0;else if(!n&&i()===`/`)break;t+=a()}a()!==`/`&&o(`parsing regular expression`);let s=``;for(;!r&&i().match(/[dgimsuy]/);)s+=a();try{return new RegExp(t,s)}catch(t){throw new A(`Error while parsing selector \`${e}\`: ${t.message}`)}}function f(){let e=``;return s(),e=i()===`'`||i()===`"`?u(i()).slice(1,-1):l(),e||o(`parsing property path`),e}function p(){s();let e=``;return r||(e+=a()),!r&&e!==`=`&&(e+=a()),[`=`,`*=`,`^=`,`$=`,`|=`,`~=`].includes(e)||o(`parsing operator`),e}function m(){a();let t=[];for(t.push(f()),s();i()===`.`;)a(),t.push(f()),s();if(i()===`]`)return a(),{name:t.join(`.`),jsonPath:t,op:`<truthy>`,value:null,caseSensitive:!1};let n=p(),l,m=!0;if(s(),i()===`/`){if(n!==`=`)throw new A(`Error while parsing selector \`${e}\` - cannot use ${n} in attribute with regular expression`);l=d()}else if(i()===`'`||i()===`"`)l=u(i()).slice(1,-1),s(),i()===`i`||i()===`I`?(m=!1,a()):(i()===`s`||i()===`S`)&&(m=!0,a());else{for(l=``;!r&&(c(i())||i()===`+`||i()===`.`);)l+=a();l===`true`?l=!0:l===`false`&&(l=!1)}if(s(),i()!==`]`&&o(`parsing attribute value`),a(),n!==`=`&&typeof l!=`string`)throw new A(`Error while parsing selector \`${e}\` - cannot use ${n} in attribute with non-string matching value - ${l}`);return{name:t.join(`.`),jsonPath:t,op:n,value:l,caseSensitive:m}}let h={name:``,attributes:[]};for(h.name=l(),s();i()===`[`;)h.attributes.push(m()),s();if(r||o(void 0),!h.name&&!h.attributes.length)throw new A(`Error while parsing selector \`${e}\` - selector cannot be empty`);return h}function We(e,t=`'`){let n=JSON.stringify(e),r=n.substring(1,n.length-1).replace(/\\"/g,`"`);if(t===`'`)return t+r.replace(/'/g,`\\'`)+t;if(t===`"`)return t+r.replace(/"/g,`\\"`)+t;if(t==="`")return t+r.replace(/`/g,"`")+t;throw Error(`Invalid escape char`)}function N(e){let t=``;for(let n=0;n<e.length;n++)t+=Ke(e,n);return t}function Ge(e){return`"${N(e).replace(/\\ /g,` `)}"`}function Ke(e,t){let n=e.charCodeAt(t);return n===0?`�`:n>=1&&n<=31||n>=48&&n<=57&&(t===0||t===1&&e.charCodeAt(0)===45)?`\\${n.toString(16)} `:t===0&&n===45&&e.length===1?`\\${e.charAt(t)}`:n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?e.charAt(t):`\\${e.charAt(t)}`}function P(e){return e.replace(/[\u200b\u00ad]/g,``).trim().replace(/\s+/g,` `)}function qe(e){return e.replace(/(^|[^\\])(\\\\)*\\(['"`])/g,`$1$2$3`)}function Je(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function F(e,t){return typeof e==`string`?`${JSON.stringify(e)}${t?`s`:`i`}`:Je(e)}function I(e,t){return typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"${t?`s`:`i`}`:Je(e)}function Ye(e,t,n=``){if(e.length<=t)return e;let r=[...e];return r.length>t?r.slice(0,t-n.length).join(``)+n:r.join(``)}function Xe(e,t){return Ye(e,t,`…`)}function Ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function L(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function Qe(e){let t=e;for(;t.parentNode;)t=t.parentNode;if(t.nodeType===11||t.nodeType===9)return t}function $e(e){for(;e.parentElement;)e=e.parentElement;return L(e)}function et(e,t){for(;e;){let n=e.closest(t);if(n)return n;e=$e(e)}}function R(e,t){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,t):void 0}function tt(e,t){if(t??=R(e),!t)return!0;if(Element.prototype.checkVisibility&&Q.options.browser!==`webkit`){if(!e.checkVisibility())return!1}else{let t=e.closest(`details,summary`);if(t!==e&&t?.nodeName===`DETAILS`&&!t.open)return!1}return t.visibility===`visible`}function nt(e){let t=R(e);if(!t)return!0;if(t.display===`contents`){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&nt(t)||t.nodeType===3&&rt(t))return!0;return!1}if(!tt(e,t))return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0}function rt(e){let t=e.ownerDocument.createRange();t.selectNode(e);let n=t.getBoundingClientRect();return n.width>0&&n.height>0}function z(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function it(e){return e.hasAttribute(`aria-label`)||e.hasAttribute(`aria-labelledby`)}const at=`article:not([role]), aside:not([role]), main:not([role]), nav:not([role]), section:not([role]), [role=article], [role=complementary], [role=main], [role=navigation], [role=region]`,ot=new Map([[`aria-atomic`,void 0],[`aria-busy`,void 0],[`aria-controls`,void 0],[`aria-current`,void 0],[`aria-describedby`,void 0],[`aria-details`,void 0],[`aria-dropeffect`,void 0],[`aria-flowto`,void 0],[`aria-grabbed`,void 0],[`aria-hidden`,void 0],[`aria-keyshortcuts`,void 0],[`aria-label`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-labelledby`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-live`,void 0],[`aria-owns`,void 0],[`aria-relevant`,void 0],[`aria-roledescription`,new Set([`generic`])]]);function st(e,t){return[...ot].some(([n,r])=>!r?.has(t||``)&&e.hasAttribute(n))}function ct(e){return!Number.isNaN(Number(String(e.getAttribute(`tabindex`))))}function lt(e){return!qt(e)&&(ut(e)||ct(e))}function ut(e){let t=z(e);return[`BUTTON`,`DETAILS`,`SELECT`,`TEXTAREA`].includes(t)?!0:t===`A`||t===`AREA`?e.hasAttribute(`href`):t===`INPUT`&&!e.hidden}const dt={A:e=>e.hasAttribute(`href`)?`link`:null,AREA:e=>e.hasAttribute(`href`)?`link`:null,ARTICLE:()=>`article`,ASIDE:()=>`complementary`,BLOCKQUOTE:()=>`blockquote`,BUTTON:()=>`button`,CAPTION:()=>`caption`,CODE:()=>`code`,DATALIST:()=>`listbox`,DD:()=>`definition`,DEL:()=>`deletion`,DETAILS:()=>`group`,DFN:()=>`term`,DIALOG:()=>`dialog`,DT:()=>`term`,EM:()=>`emphasis`,FIELDSET:()=>`group`,FIGURE:()=>`figure`,FOOTER:e=>et(e,at)?null:`contentinfo`,FORM:e=>it(e)?`form`:null,H1:()=>`heading`,H2:()=>`heading`,H3:()=>`heading`,H4:()=>`heading`,H5:()=>`heading`,H6:()=>`heading`,HEADER:e=>et(e,at)?null:`banner`,HR:()=>`separator`,HTML:()=>`document`,IMG:e=>e.getAttribute(`alt`)===``&&!e.getAttribute(`title`)&&!st(e)&&!ct(e)?`presentation`:`img`,INPUT:e=>{let t=e.type.toLowerCase();if(t===`search`)return e.hasAttribute(`list`)?`combobox`:`searchbox`;if([`email`,`tel`,`text`,`url`,``].includes(t)){let t=H(e,e.getAttribute(`list`))[0];return t&&z(t)===`DATALIST`?`combobox`:`textbox`}return t===`hidden`?``:t===`file`?`button`:{button:`button`,checkbox:`checkbox`,image:`button`,number:`spinbutton`,radio:`radio`,range:`slider`,reset:`button`,submit:`button`}[t]||`textbox`},INS:()=>`insertion`,LI:()=>`listitem`,MAIN:()=>`main`,MARK:()=>`mark`,MATH:()=>`math`,MENU:()=>`list`,METER:()=>`meter`,NAV:()=>`navigation`,OL:()=>`list`,OPTGROUP:()=>`group`,OPTION:()=>`option`,OUTPUT:()=>`status`,P:()=>`paragraph`,PROGRESS:()=>`progressbar`,SECTION:e=>it(e)?`region`:null,SELECT:e=>e.hasAttribute(`multiple`)||e.size>1?`listbox`:`combobox`,STRONG:()=>`strong`,SUB:()=>`subscript`,SUP:()=>`superscript`,SVG:()=>`img`,TABLE:()=>`table`,TBODY:()=>`rowgroup`,TD:e=>{let t=et(e,`table`),n=t?_t(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},TEXTAREA:()=>`textbox`,TFOOT:()=>`rowgroup`,TH:e=>{if(e.getAttribute(`scope`)===`col`)return`columnheader`;if(e.getAttribute(`scope`)===`row`)return`rowheader`;let t=et(e,`table`),n=t?_t(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},THEAD:()=>`rowgroup`,TIME:()=>`time`,TR:()=>`row`,UL:()=>`list`},ft={DD:[`DL`,`DIV`],DIV:[`DL`],DT:[`DL`,`DIV`],LI:[`OL`,`UL`],TBODY:[`TABLE`],TD:[`TR`],TFOOT:[`TABLE`],TH:[`TR`],THEAD:[`TABLE`],TR:[`THEAD`,`TBODY`,`TFOOT`,`TABLE`]};function pt(e){let t=dt[z(e)]?.call(dt,e)||``;if(!t)return null;let n=e;for(;n;){let e=L(n),t=ft[z(n)];if(!t||!e||!t.includes(z(e)))break;let r=_t(e);if((r===`none`||r===`presentation`)&&!vt(e,r))return r;n=e}return t}const mt=`alert.alertdialog.application.article.banner.blockquote.button.caption.cell.checkbox.code.columnheader.combobox.command.complementary.composite.contentinfo.definition.deletion.dialog.directory.document.emphasis.feed.figure.form.generic.grid.gridcell.group.heading.img.input.insertion.landmark.link.list.listbox.listitem.log.main.marquee.math.meter.menu.menubar.menuitem.menuitemcheckbox.menuitemradio.navigation.none.note.option.paragraph.presentation.progressbar.radio.radiogroup.range.region.roletype.row.rowgroup.rowheader.scrollbar.search.searchbox.section.sectionhead.select.separator.slider.spinbutton.status.strong.structure.subscript.superscript.switch.tab.table.tablist.tabpanel.term.textbox.time.timer.toolbar.tooltip.tree.treegrid.treeitem.widget.window`.split(`.`),ht=[`command`,`composite`,`input`,`landmark`,`range`,`roletype`,`section`,`sectionhead`,`select`,`structure`,`widget`,`window`],gt=mt.filter(e=>!ht.includes(e));function _t(e){return(e.getAttribute(`role`)||``).split(` `).map(e=>e.trim()).find(e=>gt.includes(e))||null}function vt(e,t){return st(e,t)||lt(e)}function B(e){let t=_t(e);if(!t)return pt(e);if(t===`none`||t===`presentation`){let t=pt(e);if(vt(e,t))return t}return t}function yt(e){return e===null?void 0:e.toLowerCase()===`true`}function bt(e){return[`STYLE`,`SCRIPT`,`NOSCRIPT`,`TEMPLATE`].includes(z(e))}function V(e){if(bt(e))return!0;let t=R(e),n=e.nodeName===`SLOT`;if(t?.display===`contents`&&!n){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&!V(t)||t.nodeType===3&&rt(t))return!1;return!0}return!(e.nodeName===`OPTION`&&e.closest(`select`))&&!n&&!tt(e,t)||xt(e)}function xt(e){let t=tn?.get(e);if(t===void 0){if(t=!1,e.parentElement&&e.parentElement.shadowRoot&&!e.assignedSlot&&(t=!0),!t){let n=R(e);t=!n||n.display===`none`||yt(e.getAttribute(`aria-hidden`))===!0}if(!t){let n=L(e);n&&(t=xt(n))}tn?.set(e,t)}return t}function H(e,t){if(!t)return[];let n=Qe(e);if(!n)return[];try{let e=t.split(` `).filter(e=>!!e),r=new Set;for(let t of e){let e=n.querySelector(`#${CSS.escape(t)}`);e&&r.add(e)}return[...r]}catch{return[]}}function U(e){return e.trim()}function W(e){return e.split(`\xA0`).map(e=>e.replace(/\r\n/g,`
3
3
  `).replace(/[\u200b\u00ad]/g,``).replace(/\s\s*/g,` `)).join(`\xA0`).trim()}function St(e,t){let n=[...e.querySelectorAll(t)];for(let r of H(e,e.getAttribute(`aria-owns`)))r.matches(t)&&n.push(r),n.push(...r.querySelectorAll(t));return n}function Ct(e,t){let n=t===`::before`?nn:rn;if(n?.has(e))return n?.get(e)||``;let r=wt(R(e,t));return n&&n.set(e,r),r}function wt(e){if(!e)return``;let t=e.content;if(t[0]===`'`&&t[t.length-1]===`'`||t[0]===`"`&&t[t.length-1]===`"`){let n=t.substring(1,t.length-1);return(e.display||`inline`)===`inline`?n:` ${n} `}return``}function Tt(e){let t=e.getAttribute(`aria-labelledby`);return t===null?null:H(e,t)}function Et(e,t){let n=[`button`,`cell`,`checkbox`,`columnheader`,`gridcell`,`heading`,`link`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`radio`,`row`,`rowheader`,`switch`,`tab`,`tooltip`,`treeitem`].includes(e),r=t&&[``,`caption`,`code`,`contentinfo`,`definition`,`deletion`,`emphasis`,`insertion`,`list`,`listitem`,`mark`,`none`,`paragraph`,`presentation`,`region`,`row`,`rowgroup`,`section`,`strong`,`subscript`,`superscript`,`table`,`term`,`time`].includes(e);return n||r}function Dt(e,t){let n=t?Qt:Zt,r=n?.get(e);return r===void 0&&(r=``,[`caption`,`code`,`definition`,`deletion`,`emphasis`,`generic`,`insertion`,`mark`,`paragraph`,`presentation`,`strong`,`subscript`,`suggestion`,`superscript`,`term`,`time`].includes(B(e)||``)||(r=W(G(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:void 0,embeddedInLabelledBy:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0,embeddedInTargetElement:`self`}))),n?.set(e,r)),r}function Ot(e,t){let n=en,r=n?.get(e);return r===void 0&&(r=``,r=e.hasAttribute(`aria-describedby`)?W(H(e,e.getAttribute(`aria-describedby`)).map(e=>G(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:V(e)}})).join(` `)):e.hasAttribute(`aria-description`)?W(e.getAttribute(`aria-description`)||``):W(e.getAttribute(`title`)||``),n?.set(e,r)),r}const kt=[`application`,`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`slider`,`spinbutton`,`textbox`,`tree`,`columnheader`,`rowheader`,`searchbox`,`switch`,`treegrid`];function At(e){let t=B(e)||``;if(!t||!kt.includes(t))return`false`;let n=e.getAttribute(`aria-invalid`);return!n||n.trim()===``||n.toLocaleLowerCase()===`false`?`false`:n===`true`||n===`grammar`||n===`spelling`?n:`true`}function jt(e){return`validity`in e&&e.validity?.valid===!1}function Mt(e){let t=$t,n=$t?.get(e);if(n===void 0){n=``;let r=At(e)!==`false`,i=jt(e);(r||i)&&(n=H(e,e.getAttribute(`aria-errormessage`)).map(e=>W(G(e,{visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:V(e)}}))).join(` `).trim()),t?.set(e,n)}return n}function G(e,t){if(t.visitedElements.has(e))return``;let n={...t,embeddedInTargetElement:t.embeddedInTargetElement===`self`?`descendant`:t.embeddedInTargetElement};if(!t.includeHidden){let n=!!t.embeddedInLabelledBy?.hidden||!!t.embeddedInDescribedBy?.hidden||!!t.embeddedInNativeTextAlternative?.hidden||!!t.embeddedInLabel?.hidden;if(bt(e)||!n&&V(e))return t.visitedElements.add(e),``}let r=Tt(e);if(!t.embeddedInLabelledBy){let e=(r||[]).map(e=>G(e,{...t,embeddedInLabelledBy:{element:e,hidden:V(e)},embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0})).join(` `);if(e)return e}let i=B(e)||``,a=z(e);if(t.embeddedInLabel||t.embeddedInLabelledBy||t.embeddedInTargetElement===`descendant`){let o=[...e.labels||[]].includes(e),s=(r||[]).includes(e);if(!o&&!s){if(i===`textbox`)return t.visitedElements.add(e),a===`INPUT`||a===`TEXTAREA`?e.value:e.textContent||``;if([`combobox`,`listbox`].includes(i)){t.visitedElements.add(e);let r;if(a===`SELECT`)r=[...e.selectedOptions],!r.length&&e.options.length&&r.push(e.options[0]);else{let t=i===`combobox`?St(e,`*`).find(e=>B(e)===`listbox`):e;r=t?St(t,`[aria-selected="true"]`).filter(e=>B(e)===`option`):[]}return!r.length&&a===`INPUT`?e.value:r.map(e=>G(e,n)).join(` `)}if([`progressbar`,`scrollbar`,`slider`,`spinbutton`,`meter`].includes(i))return t.visitedElements.add(e),e.hasAttribute(`aria-valuetext`)?e.getAttribute(`aria-valuetext`)||``:e.hasAttribute(`aria-valuenow`)?e.getAttribute(`aria-valuenow`)||``:e.getAttribute(`value`)||``;if([`menu`].includes(i))return t.visitedElements.add(e),``}}let o=e.getAttribute(`aria-label`)||``;if(U(o))return t.visitedElements.add(e),o;if(![`presentation`,`none`].includes(i)){if(a===`INPUT`&&[`button`,`submit`,`reset`].includes(e.type)){t.visitedElements.add(e);let n=e.value||``;return U(n)?n:e.type===`submit`?`Submit`:e.type===`reset`?`Reset`:e.getAttribute(`title`)||``}if(a===`INPUT`&&e.type===`image`){t.visitedElements.add(e);let n=e.labels||[];if(n.length&&!t.embeddedInLabelledBy)return Xt(n,t);let r=e.getAttribute(`alt`)||``;if(U(r))return r;let i=e.getAttribute(`title`)||``;return U(i)?i:`Submit`}if(!r&&a===`BUTTON`){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return Xt(n,t)}if(!r&&a===`OUTPUT`){t.visitedElements.add(e);let n=e.labels||[];return n.length?Xt(n,t):e.getAttribute(`title`)||``}if(!r&&(a===`TEXTAREA`||a===`SELECT`||a===`INPUT`)){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return Xt(n,t);let r=a===`INPUT`&&[`text`,`password`,`search`,`tel`,`email`,`url`].includes(e.type)||a===`TEXTAREA`,i=e.getAttribute(`placeholder`)||``,o=e.getAttribute(`title`)||``;return!r||o?o:i}if(!r&&a===`FIELDSET`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`LEGEND`)return G(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:V(t)}});return e.getAttribute(`title`)||``}if(!r&&a===`FIGURE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`FIGCAPTION`)return G(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:V(t)}});return e.getAttribute(`title`)||``}if(a===`IMG`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return U(n)?n:e.getAttribute(`title`)||``}if(a===`TABLE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`CAPTION`)return G(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:V(t)}});let r=e.getAttribute(`summary`)||``;if(r)return r}if(a===`AREA`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return U(n)?n:e.getAttribute(`title`)||``}if(a===`SVG`||e.ownerSVGElement){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`TITLE`&&t.ownerSVGElement)return G(t,{...n,embeddedInLabelledBy:{element:t,hidden:V(t)}})}if(e.ownerSVGElement&&a===`A`){let n=e.getAttribute(`xlink:title`)||``;if(U(n))return t.visitedElements.add(e),n}}let s=a===`SUMMARY`&&![`presentation`,`none`].includes(i);if(Et(i,t.embeddedInTargetElement===`descendant`)||s||t.embeddedInLabelledBy||t.embeddedInDescribedBy||t.embeddedInLabel||t.embeddedInNativeTextAlternative){t.visitedElements.add(e);let r=Nt(e,n);if(t.embeddedInTargetElement===`self`?U(r):r)return r}if(![`presentation`,`none`].includes(i)||a===`IFRAME`){t.visitedElements.add(e);let n=e.getAttribute(`title`)||``;if(U(n))return n}return t.visitedElements.add(e),``}function Nt(e,t){let n=[],r=(e,r)=>{if(!(r&&e.assignedSlot))if(e.nodeType===1){let r=R(e)?.display||`inline`,i=G(e,t);(r!==`inline`||e.nodeName===`BR`)&&(i=` `+i+` `),n.push(i)}else e.nodeType===3&&n.push(e.textContent||``)};n.push(Ct(e,`::before`));let i=e.nodeName===`SLOT`?e.assignedNodes():[];if(i.length)for(let e of i)r(e,!1);else{for(let t=e.firstChild;t;t=t.nextSibling)r(t,!0);if(e.shadowRoot)for(let t=e.shadowRoot.firstChild;t;t=t.nextSibling)r(t,!0);for(let t of H(e,e.getAttribute(`aria-owns`)))r(t,!0)}return n.push(Ct(e,`::after`)),n.join(``)}const Pt=[`gridcell`,`option`,`row`,`tab`,`rowheader`,`columnheader`,`treeitem`];function Ft(e){return z(e)===`OPTION`?e.selected:Pt.includes(B(e)||``)?yt(e.getAttribute(`aria-selected`))===!0:!1}const It=[`checkbox`,`menuitemcheckbox`,`option`,`radio`,`switch`,`menuitemradio`,`treeitem`];function Lt(e){let t=Rt(e);return t!==`error`&&t}function Rt(e,t){let n=z(e);if(n===`INPUT`&&e.indeterminate)return`mixed`;if(n===`INPUT`&&[`checkbox`,`radio`].includes(e.type))return e.checked;if(It.includes(B(e)||``)){let t=e.getAttribute(`aria-checked`);return t===`true`||t===`mixed`&&`mixed`}return`error`}const zt=[`button`];function Bt(e){if(zt.includes(B(e)||``)){let t=e.getAttribute(`aria-pressed`);if(t===`true`)return!0;if(t===`mixed`)return`mixed`}return!1}const Vt=[`application`,`button`,`checkbox`,`combobox`,`gridcell`,`link`,`listbox`,`menuitem`,`row`,`rowheader`,`tab`,`treeitem`,`columnheader`,`menuitemcheckbox`,`menuitemradio`,`rowheader`,`switch`];function Ht(e){if(z(e)===`DETAILS`)return e.open;if(Vt.includes(B(e)||``)){let t=e.getAttribute(`aria-expanded`);return t===null?`none`:t===`true`}return`none`}const Ut=[`heading`,`listitem`,`row`,`treeitem`];function Wt(e){let t={H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[z(e)];if(t)return t;if(Ut.includes(B(e)||``)){let t=e.getAttribute(`aria-level`),n=t===null?NaN:Number(t);if(Number.isInteger(n)&&n>=1)return n}return 0}const Gt=`application.button.composite.gridcell.group.input.link.menuitem.scrollbar.separator.tab.checkbox.columnheader.combobox.grid.listbox.menu.menubar.menuitemcheckbox.menuitemradio.option.radio.radiogroup.row.rowheader.searchbox.select.slider.spinbutton.switch.tablist.textbox.toolbar.tree.treegrid.treeitem`.split(`.`);function Kt(e){return qt(e)||Yt(e)}function qt(e){return[`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`OPTION`,`OPTGROUP`].includes(e.tagName)&&(e.hasAttribute(`disabled`)||Jt(e))}function Jt(e){let t=e?.closest(`FIELDSET[DISABLED]`);if(!t)return!1;let n=t.querySelector(`:scope > LEGEND`);return!n||!n.contains(e)}function Yt(e){if(!e)return!1;if(Gt.includes(B(e)||``)){let t=(e.getAttribute(`aria-disabled`)||``).toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}return Yt(L(e))}function Xt(e,t){return[...e].map(e=>G(e,{...t,embeddedInLabel:{element:e,hidden:V(e)},embeddedInNativeTextAlternative:void 0,embeddedInLabelledBy:void 0,embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0})).filter(e=>!!e).join(` `)}let Zt,Qt,$t,en,tn,nn,rn,an=0;function on(){++an,Zt??=new Map,Qt??=new Map,en??=new Map,$t??=new Map,tn??=new Map,nn??=new Map,rn??=new Map}function sn(){--an||(Zt=void 0,Qt=void 0,en=void 0,$t=void 0,tn=void 0,nn=void 0,rn=void 0)}function cn(e,t){let n=typeof e==`string`&&!t.caseSensitive?e.toUpperCase():e,r=typeof t.value==`string`&&!t.caseSensitive?t.value.toUpperCase():t.value;return t.op===`<truthy>`?!!n:t.op===`=`?r instanceof RegExp?typeof n==`string`&&!!n.match(r):n===r:typeof n!=`string`||typeof r!=`string`?!1:t.op===`*=`?n.includes(r):t.op===`^=`?n.startsWith(r):t.op===`$=`?n.endsWith(r):t.op===`|=`?n===r||n.startsWith(`${r}-`):t.op===`~=`&&n.split(` `).includes(r)}function ln(e){let t=e.ownerDocument;return e.nodeName===`SCRIPT`||e.nodeName===`NOSCRIPT`||e.nodeName===`STYLE`||t.head&&t.head.contains(e)}function K(e,t){let n=e.get(t);if(n===void 0){if(n={full:``,normalized:``,immediate:[]},!ln(t)){let r=``;if(t instanceof HTMLInputElement&&(t.type===`submit`||t.type===`button`))n={full:t.value,normalized:P(t.value),immediate:[t.value]};else{for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.TEXT_NODE?(n.full+=i.nodeValue||``,r+=i.nodeValue||``):(r&&n.immediate.push(r),r=``,i.nodeType===Node.ELEMENT_NODE&&(n.full+=K(e,i).full));r&&n.immediate.push(r),t.shadowRoot&&(n.full+=K(e,t.shadowRoot).full),n.full&&(n.normalized=P(n.full))}}e.set(t,n)}return n}function un(e,t,n){if(ln(t)||!n(K(e,t)))return`none`;for(let r=t.firstChild;r;r=r.nextSibling)if(r.nodeType===Node.ELEMENT_NODE&&n(K(e,r)))return`selfAndChildren`;return t.shadowRoot&&n(K(e,t.shadowRoot))?`selfAndChildren`:`self`}function dn(e,t){let n=Tt(t);if(n)return n.map(t=>K(e,t));let r=t.getAttribute(`aria-label`);if(r!==null&&r.trim())return[{full:r,normalized:P(r),immediate:[r]}];let i=t.nodeName===`INPUT`&&t.type!==`hidden`;if([`BUTTON`,`METER`,`OUTPUT`,`PROGRESS`,`SELECT`,`TEXTAREA`].includes(t.nodeName)||i){let n=t.labels;if(n)return[...n].map(t=>K(e,t))}return[]}const fn=[`selected`,`checked`,`pressed`,`expanded`,`level`,`disabled`,`name`,`include-hidden`];fn.sort();function pn(e,t,n){if(!t.includes(n))throw Error(`"${e}" attribute is only supported for roles: ${t.slice().sort().map(e=>`"${e}"`).join(`, `)}`)}function q(e,t){if(e.op!==`<truthy>`&&!t.includes(e.value))throw Error(`"${e.name}" must be one of ${t.map(e=>JSON.stringify(e)).join(`, `)}`)}function J(e,t){if(!t.includes(e.op))throw Error(`"${e.name}" does not support "${e.op}" matcher`)}function mn(e,t){let n={role:t};for(let r of e)switch(r.name){case`checked`:pn(r.name,It,t),q(r,[!0,!1,`mixed`]),J(r,[`<truthy>`,`=`]),n.checked=r.op===`<truthy>`||r.value;break;case`pressed`:pn(r.name,zt,t),q(r,[!0,!1,`mixed`]),J(r,[`<truthy>`,`=`]),n.pressed=r.op===`<truthy>`||r.value;break;case`selected`:pn(r.name,Pt,t),q(r,[!0,!1]),J(r,[`<truthy>`,`=`]),n.selected=r.op===`<truthy>`||r.value;break;case`expanded`:pn(r.name,Vt,t),q(r,[!0,!1]),J(r,[`<truthy>`,`=`]),n.expanded=r.op===`<truthy>`||r.value;break;case`level`:if(pn(r.name,Ut,t),typeof r.value==`string`&&(r.value=+r.value),r.op!==`=`||typeof r.value!=`number`||Number.isNaN(r.value))throw Error(`"level" attribute must be compared to a number`);n.level=r.value;break;case`disabled`:q(r,[!0,!1]),J(r,[`<truthy>`,`=`]),n.disabled=r.op===`<truthy>`||r.value;break;case`name`:if(r.op===`<truthy>`)throw Error(`"name" attribute must have a value`);if(typeof r.value!=`string`&&!(r.value instanceof RegExp))throw TypeError(`"name" attribute must be a string or a regular expression`);n.name=r.value,n.nameOp=r.op,n.exact=r.caseSensitive;break;case`include-hidden`:q(r,[!0,!1]),J(r,[`<truthy>`,`=`]),n.includeHidden=r.op===`<truthy>`||r.value;break;default:throw Error(`Unknown attribute "${r.name}", must be one of ${fn.map(e=>`"${e}"`).join(`, `)}.`)}return n}function hn(e,t,n){let r=[],i=e=>{if(B(e)===t.role&&(t.selected===void 0||Ft(e)===t.selected)&&(t.checked===void 0||Lt(e)===t.checked)&&(t.pressed===void 0||Bt(e)===t.pressed)&&(t.expanded===void 0||Ht(e)===t.expanded)&&(t.level===void 0||Wt(e)===t.level)&&(t.disabled===void 0||Kt(e)===t.disabled)&&!(!t.includeHidden&&V(e))){if(t.name!==void 0){let r=P(Dt(e,!!t.includeHidden));if(typeof t.name==`string`&&(t.name=P(t.name)),n&&!t.exact&&t.nameOp===`=`&&(t.nameOp=`*=`),!cn(r,{op:t.nameOp||`=`,value:t.name,caseSensitive:!!t.exact}))return}r.push(e)}},a=e=>{let t=[];e.shadowRoot&&t.push(e.shadowRoot);for(let n of e.querySelectorAll(`*`))i(n),n.shadowRoot&&t.push(n.shadowRoot);t.forEach(a)};return a(e),r}function gn(e){return{queryAll:(t,n)=>{let r=M(n),i=r.name.toLowerCase();if(!i)throw Error(`Role must not be empty`);let a=mn(r.attributes,i);on();try{return hn(t,a,e)}finally{sn()}}}}function _n(e,t,n=!1){return vn(e,t,n)[0]}function vn(e,t,n=!1,r=20,i){try{return Y(new xn[e](i),Be(t),n,r)}catch{return[t]}}function Y(e,t,n=!1,r=20){let i=[...t.parts];for(let e=0;e<i.length-1;e++)if(i[e].name===`nth`&&i[e+1].name===`internal:control`&&i[e+1].body===`enter-frame`){let[t]=i.splice(e,1);i.splice(e+1,0,t)}let a=[],o=n?`frame-locator`:`page`;for(let t=0;t<i.length;t++){let n=i[t],s=o;if(o=`locator`,n.name===`nth`){n.body===`0`?a.push([e.generateLocator(s,`first`,``),e.generateLocator(s,`nth`,`0`)]):n.body===`-1`?a.push([e.generateLocator(s,`last`,``),e.generateLocator(s,`nth`,`-1`)]):a.push([e.generateLocator(s,`nth`,n.body)]);continue}if(n.name===`internal:text`){let{exact:t,text:r}=bn(n.body);a.push([e.generateLocator(s,`text`,r,{exact:t})]);continue}if(n.name===`internal:has-text`){let{exact:t,text:r}=bn(n.body);if(!t){a.push([e.generateLocator(s,`has-text`,r,{exact:t})]);continue}}if(n.name===`internal:has-not-text`){let{exact:t,text:r}=bn(n.body);if(!t){a.push([e.generateLocator(s,`has-not-text`,r,{exact:t})]);continue}}if(n.name===`internal:has`){let t=Y(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`has`,t)));continue}if(n.name===`internal:has-not`){let t=Y(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`hasNot`,t)));continue}if(n.name===`internal:and`){let t=Y(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`and`,t)));continue}if(n.name===`internal:or`){let t=Y(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`or`,t)));continue}if(n.name===`internal:chain`){let t=Y(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`chain`,t)));continue}if(n.name===`internal:label`){let{exact:t,text:r}=bn(n.body);a.push([e.generateLocator(s,`label`,r,{exact:t})]);continue}if(n.name===`internal:role`){let t=M(n.body),r={attrs:[]};for(let e of t.attributes)e.name===`name`?(r.exact=e.caseSensitive,r.name=e.value):(e.name===`level`&&typeof e.value==`string`&&(e.value=+e.value),r.attrs.push({name:e.name===`include-hidden`?`includeHidden`:e.name,value:e.value}));a.push([e.generateLocator(s,`role`,t.name,r)]);continue}if(n.name===`internal:testid`){let{value:t}=M(n.body).attributes[0];a.push([e.generateLocator(s,`test-id`,t)]);continue}if(n.name===`internal:attr`){let{name:t,value:r,caseSensitive:i}=M(n.body).attributes[0],o=r,c=!!i;if(t===`placeholder`){a.push([e.generateLocator(s,`placeholder`,o,{exact:c})]);continue}if(t===`alt`){a.push([e.generateLocator(s,`alt`,o,{exact:c})]);continue}if(t===`title`){a.push([e.generateLocator(s,`title`,o,{exact:c})]);continue}}let c=`default`,l=i[t+1];l&&l.name===`internal:control`&&l.body===`enter-frame`&&(c=`frame`,o=`frame-locator`,t++);let u=j({parts:[n]}),d=e.generateLocator(s,c,u);if(c==="default"&&l&&[`internal:has-text`,`internal:has-not-text`].includes(l.name)){let{exact:n,text:r}=bn(l.body);if(!n){let i=e.generateLocator(`locator`,l.name===`internal:has-text`?`has-text`:`has-not-text`,r,{exact:n}),o={};l.name===`internal:has-text`?o.hasText=r:o.hasNotText=r;let c=e.generateLocator(s,`default`,u,o);a.push([e.chainLocators([d,i]),c]),t++;continue}}let f;if([`xpath`,`css`].includes(n.name)){let t=j({parts:[n]},!0);f=e.generateLocator(s,c,t)}a.push([d,f].filter(Boolean))}return yn(e,a,r)}function yn(e,t,n){let r=t.map(()=>``),i=[],a=o=>{if(o===t.length)return i.push(e.chainLocators(r)),r.length<n;for(let e of t[o])if(r[o]=e,!a(o+1))return!1;return!0};return a(0),i}function bn(e){let t=!1,n=e.match(/^\/(.*)\/([igm]*)$/);return n?{text:new RegExp(n[1],n[2])}:(e.endsWith(`"`)?(e=JSON.parse(e),t=!0):e.endsWith(`"s`)?(e=JSON.parse(e.substring(0,e.length-1)),t=!0):e.endsWith(`"i`)&&(e=JSON.parse(e.substring(0,e.length-1)),t=!1),{exact:t,text:e})}const xn={javascript:class{constructor(e){this.preferredQuote=e}generateLocator(e,t,n,r={}){switch(t){case`default`:return r.hasText===void 0?r.hasNotText===void 0?`locator(${this.quote(n)})`:`locator(${this.quote(n)}, { hasNotText: ${this.toHasText(r.hasNotText)} })`:`locator(${this.quote(n)}, { hasText: ${this.toHasText(r.hasText)} })`;case`frame`:return`frameLocator(${this.quote(n)})`;case`nth`:return`nth(${n})`;case`first`:return`first()`;case`last`:return`last()`;case`role`:{let e=[];Sn(r.name)?e.push(`name: ${this.regexToSourceString(r.name)}`):typeof r.name==`string`&&(e.push(`name: ${this.quote(r.name)}`),r.exact!=null&&Q.options.exact!==r.exact&&e.push(`exact: ${r.exact}`));for(let{name:t,value:n}of r.attrs)e.push(`${t}: ${typeof n==`string`?this.quote(n):n}`);let t=e.length?`, { ${e.join(`, `)} }`:``;return`getByRole(${this.quote(n)}${t})`}case`has-text`:return`filter({ hasText: ${this.toHasText(n)} })`;case`has-not-text`:return`filter({ hasNotText: ${this.toHasText(n)} })`;case`has`:return`filter({ has: ${n} })`;case`hasNot`:return`filter({ hasNot: ${n} })`;case`and`:return`and(${n})`;case`or`:return`or(${n})`;case`chain`:return`locator(${n})`;case`test-id`:{let e=this.toTestIdValue(n);return e.startsWith(`'__vitest_`)&&e.endsWith(`__'`)?`page`:`getByTestId(${e})`}case`text`:return this.toCallWithExact(`getByText`,n,!!r.exact);case`alt`:return this.toCallWithExact(`getByAltText`,n,!!r.exact);case`placeholder`:return this.toCallWithExact(`getByPlaceholder`,n,!!r.exact);case`label`:return this.toCallWithExact(`getByLabel`,n,!!r.exact);case`title`:return this.toCallWithExact(`getByTitle`,n,!!r.exact);default:throw Error(`Unknown selector kind ${t}`)}}chainLocators(e){return e.join(`.`)}regexToSourceString(e){return qe(String(e))}toCallWithExact(e,t,n){return Sn(t)?`${e}(${this.regexToSourceString(t)})`:n!=null&&Q.options.exact!==n?`${e}(${this.quote(t)}, { exact: ${n} })`:`${e}(${this.quote(t)})`}toHasText(e){return Sn(e)?this.regexToSourceString(e):this.quote(e)}toTestIdValue(e){return Sn(e)?this.regexToSourceString(e):this.quote(e)}quote(e){return We(e,this.preferredQuote??`'`)}}};function Sn(e){return e instanceof RegExp}const Cn=new Map,wn=new Map,Tn=1e4;function En(e,t,n){e._evaluator.begin(),on();try{return Pn(On(e,t,n)||Mn(e,t,n))}finally{Cn.clear(),wn.clear(),sn(),e._evaluator.end()}}function Dn(e){return e.filter(e=>e[0].selector[0]!==`/`)}function On(e,t,n){if(t.ownerDocument.documentElement===t)return[{engine:`css`,selector:`html`,score:1}];let r=(r,a)=>{let o=r===t,s=a?An(e,r,r===t):[];r!==t&&(s=Dn(s));let c=kn(e,r,n).map(e=>[e]),l=Fn(e,t.ownerDocument,r,[...s,...c],o);s=Dn(s);let u=t=>{let n=a&&!t.length,s=[...t,...c].filter(e=>!l||X(e)<X(l)),u=s[0];if(u)for(let t=L(r);t;t=L(t)){let a=i(t,n);if(!a||l&&X([...a,...u])>=X(l))continue;if(u=Fn(e,t,r,s,o),!u)return;let c=[...a,...u];(!l||X(c)<X(l))&&(l=c)}};return u(s),r===t&&s.length&&u([]),l},i=(e,t)=>{let n=t?Cn:wn,i=n.get(e);return i===void 0&&(i=r(e,t),n.set(e,i)),i};return r(t,!n.noText)}function kn(e,t,n){let r=[];for(let e of[`data-testid`,`data-test-id`,`data-test`])e!==n.testIdAttributeName&&t.getAttribute(e)&&r.push({engine:`css`,selector:`[${e}=${Ge(t.getAttribute(e))}]`,score:2});if(!n.noCSSId){let e=t.getAttribute(`id`);e&&!In(e)&&r.push({engine:`css`,selector:jn(e),score:500})}if(r.push({engine:`css`,selector:N(t.nodeName.toLowerCase()),score:530}),t.nodeName===`IFRAME`){for(let e of[`name`,`title`])t.getAttribute(e)&&r.push({engine:`css`,selector:`${N(t.nodeName.toLowerCase())}[${e}=${Ge(t.getAttribute(e))}]`,score:10});return t.getAttribute(n.testIdAttributeName)&&r.push({engine:`css`,selector:`[${n.testIdAttributeName}=${Ge(t.getAttribute(n.testIdAttributeName))}]`,score:1}),Nn([r]),r}if(t.getAttribute(n.testIdAttributeName)&&r.push({engine:`internal:testid`,selector:`[${n.testIdAttributeName}=${I(t.getAttribute(n.testIdAttributeName),!0)}]`,score:1}),t.nodeName===`INPUT`||t.nodeName===`TEXTAREA`){let e=t;if(e.placeholder){r.push({engine:`internal:attr`,selector:`[placeholder=${I(e.placeholder,!0)}]`,score:105});for(let t of Z(e.placeholder))r.push({engine:`internal:attr`,selector:`[placeholder=${I(t.text,!1)}]`,score:100-t.scoreBouns})}}let i=dn(e._evaluator._cacheText,t);for(let e of i){let t=e.normalized;r.push({engine:`internal:label`,selector:F(t,!0),score:125});for(let e of Z(t))r.push({engine:`internal:label`,selector:F(e.text,!1),score:120-e.scoreBouns})}let a=B(t);return a&&![`none`,`presentation`].includes(a)&&r.push({engine:`internal:role`,selector:a,score:510}),t.getAttribute(`name`)&&[`BUTTON`,`FORM`,`FIELDSET`,`FRAME`,`IFRAME`,`INPUT`,`KEYGEN`,`OBJECT`,`OUTPUT`,`SELECT`,`TEXTAREA`,`MAP`,`META`,`PARAM`].includes(t.nodeName)&&r.push({engine:`css`,selector:`${N(t.nodeName.toLowerCase())}[name=${Ge(t.getAttribute(`name`))}]`,score:520}),[`INPUT`,`TEXTAREA`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&t.getAttribute(`type`)&&r.push({engine:`css`,selector:`${N(t.nodeName.toLowerCase())}[type=${Ge(t.getAttribute(`type`))}]`,score:520}),[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&r.push({engine:`css`,selector:N(t.nodeName.toLowerCase()),score:521}),Nn([r]),r}function An(e,t,n){if(t.nodeName===`SELECT`)return[];let r=[],i=t.getAttribute(`title`);if(i){r.push([{engine:`internal:attr`,selector:`[title=${I(i,!0)}]`,score:205}]);for(let e of Z(i))r.push([{engine:`internal:attr`,selector:`[title=${I(e.text,!1)}]`,score:200-e.scoreBouns}])}let a=t.getAttribute(`alt`);if(a&&[`APPLET`,`AREA`,`IMG`,`INPUT`].includes(t.nodeName)){r.push([{engine:`internal:attr`,selector:`[alt=${I(a,!0)}]`,score:165}]);for(let e of Z(a))r.push([{engine:`internal:attr`,selector:`[alt=${I(e.text,!1)}]`,score:160-e.scoreBouns}])}let o=K(e._evaluator._cacheText,t).normalized;if(o){let e=Z(o);if(n){o.length<=80&&r.push([{engine:`internal:text`,selector:F(o,!0),score:185}]);for(let t of e)r.push([{engine:`internal:text`,selector:F(t.text,!1),score:180-t.scoreBouns}])}let i={engine:`css`,selector:N(t.nodeName.toLowerCase()),score:530};for(let t of e)r.push([i,{engine:`internal:has-text`,selector:F(t.text,!1),score:180-t.scoreBouns}]);if(o.length<=80){let e=RegExp(`^${Ze(o)}$`);r.push([i,{engine:`internal:has-text`,selector:F(e,!1),score:250}])}}let s=B(t);if(s&&![`none`,`presentation`].includes(s)){let e=Dt(t,!1);if(e){r.push([{engine:`internal:role`,selector:`${s}[name=${I(e,!0)}]`,score:145}]);for(let t of Z(e))r.push([{engine:`internal:role`,selector:`${s}[name=${I(t.text,!1)}]`,score:140-t.scoreBouns}])}}return Nn(r),r}function jn(e){return/^[a-z][\w\-]+$/i.test(e)?`#${e}`:`[id="${N(e)}"]`}function Mn(e,t,n){let r=t.ownerDocument,i=[];function a(n){let a=i.slice();n&&a.unshift(n);let o=a.join(` > `),s=e.parseSelector(o);return e.querySelector(s,r,!1)===t?o:void 0}function o(n){let i={engine:`css`,selector:n,score:1e7},a=e.parseSelector(n),o=e.querySelectorAll(a,r);return o.length===1?[i]:[i,{engine:`nth`,selector:String(o.indexOf(t)),score:Tn}]}for(let e=t;e&&e!==r;e=L(e)){let t=e.nodeName.toLowerCase(),r=``;if(e.id&&!n.noCSSId){let t=jn(e.id),n=a(t);if(n)return o(n);r=t}let s=e.parentNode,c=[...e.classList];for(let e=0;e<c.length;++e){let t=`.${N(c.slice(0,e+1).join(`.`))}`,n=a(t);if(n)return o(n);!r&&s&&s.querySelectorAll(t).length===1&&(r=t)}if(s){let n=[...s.children],i=n.filter(e=>e.nodeName.toLowerCase()===t).indexOf(e)===0?N(t):`${N(t)}:nth-child(${1+n.indexOf(e)})`,c=a(i);if(c)return o(c);r||=i}else r||=N(t);i.unshift(r)}return o(a())}function Nn(e){for(let t of e)for(let e of t)e.score>50&&e.score<300&&(e.score+=Math.min(10,e.selector.length/10|0))}function Pn(e){let t=[],n=``;for(let{engine:r,selector:i}of e)t.length&&(n!==`css`||r!==`css`||i.startsWith(`:nth-match(`))&&t.push(`>>`),n=r,r===`css`?t.push(i):t.push(`${r}=${i}`);return t.join(` `)}function X(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].score*(e.length-n);return t}function Fn(e,t,n,r,i){let a=r.map(e=>({tokens:e,score:X(e)}));a.sort((e,t)=>e.score-t.score);let o=null;for(let{tokens:r}of a){let a=e.parseSelector(Pn(r)),s=e.querySelectorAll(a,t);if(s[0]===n&&s.length===1)return r;let c=s.indexOf(n);if(!i||o||c===-1||s.length>5)continue;let l={engine:`nth`,selector:String(c),score:Tn};o=[...r,l]}return o}function In(e){let t,n=0;for(let r=0;r<e.length;++r){let i=e[r],a;if(i!==`-`&&i!==`_`){if(a=i>=`a`&&i<=`z`?`lower`:i>=`A`&&i<=`Z`?`upper`:i>=`0`&&i<=`9`?`digit`:`other`,a===`lower`&&t===`upper`){t=a;continue}t&&t!==a&&++n,t=a}}return n>=e.length/4}function Ln(e,t){if(e.length<=t)return e;e=e.substring(0,t);let n=e.match(/^(.*)\b(.+)$/);return n?n[1].trimEnd():``}function Z(e){let t=[];{let n=e.match(/^([\d.,]+)[^.,\w]/),r=n?n[1].length:0;if(r){let n=Ln(e.substring(r).trimStart(),80);t.push({text:n,scoreBouns:n.length<=30?2:1})}}{let n=e.match(/[^.,\w]([\d.,]+)$/),r=n?n[1].length:0;if(r){let n=Ln(e.substring(0,e.length-r).trimEnd(),80);t.push({text:n,scoreBouns:n.length<=30?2:1})}}return e.length<=30?t.push({text:e,scoreBouns:0}):(t.push({text:Ln(e,80),scoreBouns:0}),t.push({text:Ln(e,30),scoreBouns:1})),t=t.filter(e=>e.text),t.length||t.push({text:e.substring(0,80),scoreBouns:0}),t}function Rn(e,t,n){let r=e.left-t.right;if(!(r<0||n!==void 0&&r>n))return r+Math.max(t.bottom-e.bottom,0)+Math.max(e.top-t.top,0)}function zn(e,t,n){let r=t.left-e.right;if(!(r<0||n!==void 0&&r>n))return r+Math.max(t.bottom-e.bottom,0)+Math.max(e.top-t.top,0)}function Bn(e,t,n){let r=t.top-e.bottom;if(!(r<0||n!==void 0&&r>n))return r+Math.max(e.left-t.left,0)+Math.max(t.right-e.right,0)}function Vn(e,t,n){let r=e.top-t.bottom;if(!(r<0||n!==void 0&&r>n))return r+Math.max(e.left-t.left,0)+Math.max(t.right-e.right,0)}function Hn(e,t,n){let r=n===void 0?50:n,i=0;return e.left-t.right>=0&&(i+=e.left-t.right),t.left-e.right>=0&&(i+=t.left-e.right),t.top-e.bottom>=0&&(i+=t.top-e.bottom),e.top-t.bottom>=0&&(i+=e.top-t.bottom),i>r?void 0:i}const Un=[`left-of`,`right-of`,`above`,`below`,`near`];function Wn(e,t,n,r){let i=t.getBoundingClientRect(),a={"left-of":zn,"right-of":Rn,above:Bn,below:Vn,near:Hn}[e],o;for(let e of n){if(e===t)continue;let n=a(i,e.getBoundingClientRect(),r);n!==void 0&&(o===void 0||n<o)&&(o=n)}return o}var Gn=class{constructor(e){f(this,`_engines`,new Map),f(this,`_cacheQueryCSS`,new Map),f(this,`_cacheMatches`,new Map),f(this,`_cacheQuery`,new Map),f(this,`_cacheMatchesSimple`,new Map),f(this,`_cacheMatchesParents`,new Map),f(this,`_cacheCallMatches`,new Map),f(this,`_cacheCallQuery`,new Map),f(this,`_cacheQuerySimple`,new Map),f(this,`_cacheText`,new Map),f(this,`_scoreMap`,void 0),f(this,`_retainCacheCounter`,0);for(let[t,n]of e)this._engines.set(t,n);this._engines.set(`not`,Yn),this._engines.set(`is`,Kn),this._engines.set(`where`,Kn),this._engines.set(`has`,qn),this._engines.set(`scope`,Jn),this._engines.set(`light`,Xn),this._engines.set(`visible`,Zn),this._engines.set(`text`,Qn),this._engines.set(`text-is`,$n),this._engines.set(`text-matches`,er),this._engines.set(`has-text`,tr),this._engines.set(`right-of`,nr(`right-of`)),this._engines.set(`left-of`,nr(`left-of`)),this._engines.set(`above`,nr(`above`)),this._engines.set(`below`,nr(`below`)),this._engines.set(`near`,nr(`near`)),this._engines.set(`nth-match`,rr);let t=[...this._engines.keys()];t.sort();let n=[...ze];if(n.sort(),t.join(`|`)!==n.join(`|`))throw Error(`Please keep customCSSNames in sync with evaluator engines: ${t.join(`|`)} vs ${n.join(`|`)}`)}begin(){++this._retainCacheCounter}end(){--this._retainCacheCounter,this._retainCacheCounter||(this._cacheQueryCSS.clear(),this._cacheMatches.clear(),this._cacheQuery.clear(),this._cacheMatchesSimple.clear(),this._cacheMatchesParents.clear(),this._cacheCallMatches.clear(),this._cacheCallQuery.clear(),this._cacheQuerySimple.clear(),this._cacheText.clear())}_cached(e,t,n,r){e.has(t)||e.set(t,[]);let i=e.get(t),a=i.find(e=>n.every((t,n)=>e.rest[n]===t));if(a)return a.result;let o=r();return i.push({rest:n,result:o}),o}_checkSelector(e){if(!(typeof e==`object`&&e&&(Array.isArray(e)||`simples`in e&&e.simples.length)))throw Error(`Malformed selector "${e}"`);return e}matches(e,t,n){let r=this._checkSelector(t);this.begin();try{return this._cached(this._cacheMatches,e,[r,n.scope,n.pierceShadow,n.originalScope],()=>Array.isArray(r)?this._matchesEngine(Kn,e,r,n):(this._hasScopeClause(r)&&(n=this._expandContextForScopeMatching(n)),this._matchesSimple(e,r.simples[r.simples.length-1].selector,n)?this._matchesParents(e,r,r.simples.length-2,n):!1))}finally{this.end()}}query(e,t){let n=this._checkSelector(t);this.begin();try{return this._cached(this._cacheQuery,n,[e.scope,e.pierceShadow,e.originalScope],()=>{if(Array.isArray(n))return this._queryEngine(Kn,e,n);this._hasScopeClause(n)&&(e=this._expandContextForScopeMatching(e));let t=this._scoreMap;this._scoreMap=new Map;let r=this._querySimple(e,n.simples[n.simples.length-1].selector);return r=r.filter(t=>this._matchesParents(t,n,n.simples.length-2,e)),this._scoreMap.size&&r.sort((e,t)=>{let n=this._scoreMap.get(e),r=this._scoreMap.get(t);return n===r?0:n===void 0?1:r===void 0?-1:n-r}),this._scoreMap=t,r})}finally{this.end()}}_markScore(e,t){this._scoreMap&&this._scoreMap.set(e,t)}_hasScopeClause(e){return e.simples.some(e=>e.selector.functions.some(e=>e.name===`scope`))}_expandContextForScopeMatching(e){if(e.scope.nodeType!==1)return e;let t=L(e.scope);return t?{...e,scope:t,originalScope:e.originalScope||e.scope}:e}_matchesSimple(e,t,n){return this._cached(this._cacheMatchesSimple,e,[t,n.scope,n.pierceShadow,n.originalScope],()=>{if(e===n.scope||t.css&&!this._matchesCSS(e,t.css))return!1;for(let r of t.functions)if(!this._matchesEngine(this._getEngine(r.name),e,r.args,n))return!1;return!0})}_querySimple(e,t){return t.functions.length?this._cached(this._cacheQuerySimple,t,[e.scope,e.pierceShadow,e.originalScope],()=>{let n=t.css,r=t.functions;n===`*`&&r.length&&(n=void 0);let i,a=-1;n===void 0?(a=r.findIndex(e=>this._getEngine(e.name).query!==void 0),a===-1&&(a=0),i=this._queryEngine(this._getEngine(r[a].name),e,r[a].args)):i=this._queryCSS(e,n);for(let t=0;t<r.length;t++){if(t===a)continue;let n=this._getEngine(r[t].name);n.matches!==void 0&&(i=i.filter(i=>this._matchesEngine(n,i,r[t].args,e)))}for(let t=0;t<r.length;t++){if(t===a)continue;let n=this._getEngine(r[t].name);n.matches===void 0&&(i=i.filter(i=>this._matchesEngine(n,i,r[t].args,e)))}return i}):this._queryCSS(e,t.css||`*`)}_matchesParents(e,t,n,r){return n<0||this._cached(this._cacheMatchesParents,e,[t,n,r.scope,r.pierceShadow,r.originalScope],()=>{let{selector:i,combinator:a}=t.simples[n];if(a===`>`){let a=ir(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===`+`){let a=ar(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===``){let a=ir(e,r);for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===``)break}a=ir(a,r)}return!1}if(a===`~`){let a=ar(e,r);for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===`~`)break}a=ar(a,r)}return!1}if(a===`>=`){let a=e;for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===``)break}a=ir(a,r)}return!1}throw Error(`Unsupported combinator "${a}"`)})}_matchesEngine(e,t,n,r){if(e.matches)return this._callMatches(e,t,n,r);if(e.query)return this._callQuery(e,n,r).includes(t);throw Error(`Selector engine should implement "matches" or "query"`)}_queryEngine(e,t,n){if(e.query)return this._callQuery(e,n,t);if(e.matches)return this._queryCSS(t,`*`).filter(r=>this._callMatches(e,r,n,t));throw Error(`Selector engine should implement "matches" or "query"`)}_callMatches(e,t,n,r){return this._cached(this._cacheCallMatches,t,[e,r.scope,r.pierceShadow,r.originalScope,...n],()=>e.matches(t,n,r,this))}_callQuery(e,t,n){return this._cached(this._cacheCallQuery,e,[n.scope,n.pierceShadow,n.originalScope,...t],()=>e.query(n,t,this))}_matchesCSS(e,t){return e.matches(t)}_queryCSS(e,t){return this._cached(this._cacheQueryCSS,t,[e.scope,e.pierceShadow,e.originalScope],()=>{let n=[];function r(i){if(n=n.concat([...i.querySelectorAll(t)]),e.pierceShadow){i.shadowRoot&&r(i.shadowRoot);for(let e of i.querySelectorAll(`*`))e.shadowRoot&&r(e.shadowRoot)}}return r(e.scope),n})}_getEngine(e){let t=this._engines.get(e);if(!t)throw Error(`Unknown selector engine "${e}"`);return t}};const Kn={matches(e,t,n,r){if(t.length===0)throw Error(`"is" engine expects non-empty selector list`);return t.some(t=>r.matches(e,t,n))},query(e,t,n){if(t.length===0)throw Error(`"is" engine expects non-empty selector list`);let r=[];for(let i of t)r=r.concat(n.query(e,i));return t.length===1?r:or(r)}},qn={matches(e,t,n,r){if(t.length===0)throw Error(`"has" engine expects non-empty selector list`);return r.query({...n,scope:e},t).length>0}},Jn={matches(e,t,n,r){if(t.length!==0)throw Error(`"scope" engine expects no arguments`);let i=n.originalScope||n.scope;return i.nodeType===9?e===i.documentElement:e===i},query(e,t,n){if(t.length!==0)throw Error(`"scope" engine expects no arguments`);let r=e.originalScope||e.scope;if(r.nodeType===9){let e=r.documentElement;return e?[e]:[]}return r.nodeType===1?[r]:[]}},Yn={matches(e,t,n,r){if(t.length===0)throw Error(`"not" engine expects non-empty selector list`);return!r.matches(e,t,n)}},Xn={query(e,t,n){return n.query({...e,pierceShadow:!1},t)},matches(e,t,n,r){return r.matches(e,t,{...n,pierceShadow:!1})}},Zn={matches(e,t,n,r){if(t.length)throw Error(`"visible" engine expects no arguments`);return nt(e)}},Qn={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text" engine expects a single string`);let i=P(t[0]).toLowerCase();return un(r._cacheText,e,e=>e.normalized.toLowerCase().includes(i))===`self`}},$n={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text-is" engine expects a single string`);let i=P(t[0]);return un(r._cacheText,e,e=>!i&&!e.immediate.length||e.immediate.some(e=>P(e)===i))!==`none`}},er={matches(e,t,n,r){if(t.length===0||typeof t[0]!=`string`||t.length>2||t.length===2&&typeof t[1]!=`string`)throw Error(`"text-matches" engine expects a regexp body and optional regexp flags`);let i=new RegExp(t[0],t.length===2?t[1]:void 0);return un(r._cacheText,e,e=>i.test(e.full))===`self`}},tr={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"has-text" engine expects a single string`);if(ln(e))return!1;let i=P(t[0]).toLowerCase();return(e=>e.normalized.toLowerCase().includes(i))(K(r._cacheText,e))}};function nr(e){return{matches(t,n,r,i){let a=n.length&&typeof n[n.length-1]==`number`?n[n.length-1]:void 0,o=a===void 0?n:n.slice(0,n.length-1);if(n.length<1+(a===void 0?0:1))throw Error(`"${e}" engine expects a selector list and optional maximum distance in pixels`);let s=Wn(e,t,i.query(r,o),a);return s===void 0?!1:(i._markScore(t,s),!0)}}}const rr={query(e,t,n){let r=t[t.length-1];if(t.length<2)throw Error(`"nth-match" engine expects non-empty selector list and an index argument`);if(typeof r!=`number`||r<1)throw Error(`"nth-match" engine expects a one-based index as the last argument`);let i=Kn.query(e,t.slice(0,t.length-1),n);return r--,r<i.length?[i[r]]:[]}};function ir(e,t){if(e!==t.scope)return t.pierceShadow?L(e):e.parentElement||void 0}function ar(e,t){if(e!==t.scope)return e.previousElementSibling||void 0}function or(e){let t=new Map,n=[],r=[];function i(e){let r=t.get(e);if(r)return r;let a=L(e);return a?i(a).children.push(e):n.push(e),r={children:[],taken:!1},t.set(e,r),r}for(let t of e)i(t).taken=!0;function a(e){let n=t.get(e);if(n.taken&&r.push(e),n.children.length>1){let t=new Set(n.children);n.children=[];let r=e.firstElementChild;for(;r&&n.children.length<t.size;)t.has(r)&&n.children.push(r),r=r.nextElementSibling;for(r=e.shadowRoot?e.shadowRoot.firstElementChild:null;r&&n.children.length<t.size;)t.has(r)&&n.children.push(r),r=r.nextElementSibling}n.children.forEach(a)}return n.forEach(a),r}function sr(e,t,n){return`internal:attr=[${e}=${I(t,n?.exact??Q.options.exact)}]`}function cr(e,t){return`internal:testid=[${e}=${I(t,!0)}]`}function lr(e,t){return`internal:label=${F(e,t?.exact??Q.options.exact)}`}function ur(e,t){return sr(`alt`,e,t)}function dr(e,t){return sr(`title`,e,t)}function fr(e,t){return sr(`placeholder`,e,t)}function pr(e,t){return`internal:text=${F(e,t?.exact??Q.options.exact)}`}function mr(e,t={}){let n=[];return t.checked!==void 0&&n.push([`checked`,String(t.checked)]),t.disabled!==void 0&&n.push([`disabled`,String(t.disabled)]),t.selected!==void 0&&n.push([`selected`,String(t.selected)]),t.expanded!==void 0&&n.push([`expanded`,String(t.expanded)]),t.includeHidden!==void 0&&n.push([`include-hidden`,String(t.includeHidden)]),t.level!==void 0&&n.push([`level`,String(t.level)]),t.name!==void 0&&n.push([`name`,I(t.name,t.exact??Q.options.exact)]),t.pressed!==void 0&&n.push([`pressed`,String(t.pressed)]),`internal:role=${e}${n.map(([e,t])=>`[${e}=${t}]`).join(``)}`}var Q=class e{static create(t){return Object.assign(e.options,t),e.singleton||=new e}constructor(){f(this,`_engines`,void 0),f(this,`_evaluator`,void 0),this._evaluator=new Gn(new Map),this._engines=new Map,this._engines.set(`xpath`,br),this._engines.set(`xpath:light`,br),this._engines.set(`role`,gn(!1)),this._engines.set(`text`,this._createTextEngine(!0,!1)),this._engines.set(`text:light`,this._createTextEngine(!1,!1)),this._engines.set(`id`,this._createAttributeEngine(`id`,!0)),this._engines.set(`id:light`,this._createAttributeEngine(`id`,!1)),this._engines.set(`data-testid`,this._createAttributeEngine(`data-testid`,!0)),this._engines.set(`data-testid:light`,this._createAttributeEngine(`data-testid`,!1)),this._engines.set(`data-test-id`,this._createAttributeEngine(`data-test-id`,!0)),this._engines.set(`data-test-id:light`,this._createAttributeEngine(`data-test-id`,!1)),this._engines.set(`data-test`,this._createAttributeEngine(`data-test`,!0)),this._engines.set(`data-test:light`,this._createAttributeEngine(`data-test`,!1)),this._engines.set(`css`,this._createCSSEngine()),this._engines.set(`nth`,{queryAll:()=>[]}),this._engines.set(`visible`,this._createVisibleEngine()),this._engines.set(`internal:control`,this._createControlEngine()),this._engines.set(`internal:has`,this._createHasEngine()),this._engines.set(`internal:has-not`,this._createHasNotEngine()),this._engines.set(`internal:and`,{queryAll:()=>[]}),this._engines.set(`internal:or`,{queryAll:()=>[]}),this._engines.set(`internal:chain`,this._createInternalChainEngine()),this._engines.set(`internal:label`,this._createInternalLabelEngine()),this._engines.set(`internal:text`,this._createTextEngine(!0,!0)),this._engines.set(`internal:has-text`,this._createInternalHasTextEngine()),this._engines.set(`internal:has-not-text`,this._createInternalHasNotTextEngine()),this._engines.set(`internal:attr`,this._createNamedAttributeEngine()),this._engines.set(`internal:testid`,this._createNamedAttributeEngine()),this._engines.set(`internal:role`,gn(!0))}queryLocatorSelector(e,t=document.documentElement,n=!0){return this.querySelector(this.parseSelector(e),t,n)}queryLocatorSelectorAll(e,t=document.documentElement){return this.querySelectorAll(this.parseSelector(e),t)}querySelector(e,t,n=!0){let r=this.querySelectorAll(e,t);if(n&&r.length>1)throw this.strictModeViolationError(e,r);return r[0]||null}queryAllByRole(e,t,n=document.documentElement){let r=this.parseSelector(mr(e,t));return this.querySelectorAll(r,n)}queryAllByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(lr(e,t));return this.querySelectorAll(r,n)}queryAllByTestId(t,n=document.documentElement){let r=this.parseSelector(cr(e.options.testIdAttribute,t));return this.querySelectorAll(r,n)}queryAllByText(e,t,n=document.documentElement){let r=this.parseSelector(pr(e,t));return this.querySelectorAll(r,n)}queryAllByTitle(e,t,n=document.documentElement){let r=this.parseSelector(dr(e,t));return this.querySelectorAll(r,n)}queryAllByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(fr(e,t));return this.querySelectorAll(r,n)}queryAllByAltText(e,t,n=document.documentElement){let r=this.parseSelector(ur(e,t));return this.querySelectorAll(r,n)}queryByRole(e,t,n=document.documentElement){let r=this.parseSelector(mr(e,t));return this.querySelector(r,n,!1)}queryByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(lr(e,t));return this.querySelector(r,n,!1)}queryByTestId(t,n=document.documentElement){let r=this.parseSelector(cr(e.options.testIdAttribute,t));return this.querySelector(r,n,!1)}queryByText(e,t,n=document.documentElement){let r=this.parseSelector(pr(e,t));return this.querySelector(r,n,!1)}queryByTitle(e,t,n=document.documentElement){let r=this.parseSelector(dr(e,t));return this.querySelector(r,n,!1)}queryByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(fr(e,t));return this.querySelector(r,n,!1)}queryByAltText(e,t,n=document.documentElement){let r=this.parseSelector(ur(e,t));return this.querySelector(r,n,!1)}strictModeViolationError(e,t){let n=t.slice(0,10).map(e=>({preview:this.previewNode(e),selector:this.generateSelectorSimple(e)})),r=n.map((e,t)=>`\n ${t+1}) ${e.preview} aka ${_n(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
4
- ...`),this.createStacklessError(`strict mode violation: ${_n(`javascript`,j(e))} resolved to ${t.length} elements:${r.join(``)}\n`)}generateSelectorSimple(t,n){return En(this,t,{...n,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let t=Be(e);return He(t,t=>{if(!this._engines.has(t.name))throw this.createStacklessError(`Unknown engine "${t.name}" while parsing selector ${e}`)}),t}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return hr(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return hr(`<${e.nodeName.toLowerCase()} />`);let t=e,n=[];for(let e=0;e<t.attributes.length;e++){let{name:r,value:i}=t.attributes[e];r!==`style`&&(!i&&gr.has(r)?n.push(` ${r}`):n.push(` ${r}="${i}"`))}n.sort((e,t)=>e.length-t.length);let r=Xe(n.join(``),500);if(_r.has(t.nodeName))return hr(`<${t.nodeName.toLowerCase()}${r}/>`);let i=t.childNodes,a=!1;if(i.length<=5){a=!0;for(let e=0;e<i.length;e++)a&&=i[e].nodeType===Node.TEXT_NODE}let o=a?t.textContent||``:i.length?`…`:``;return hr(`<${t.nodeName.toLowerCase()}${r}>${Xe(o,50)}</${t.nodeName.toLowerCase()}>`)}querySelectorAll(e,t){if(e.capture!==void 0){if(e.parts.some(e=>e.name===`nth`))throw this.createStacklessError(`Can't query n-th element in a request with the capture.`);let n={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let t={parts:e.parts.slice(e.capture+1)},r={name:`internal:has`,body:{parsed:t},source:j(t)};n.parts.push(r)}return this.querySelectorAll(n,t)}if(!t.querySelectorAll)throw this.createStacklessError(`Node is not queryable.`);if(e.capture!==void 0)throw this.createStacklessError(`Internal error: there should not be a capture in the selector.`);if(t.nodeType===11&&e.parts.length===1&&e.parts[0].name===`css`&&e.parts[0].source===`:scope`)return[t];this._evaluator.begin();try{let n=new Set([t]);for(let r of e.parts)if(r.name===`nth`)n=this._queryNth(n,r);else if(r.name===`internal:and`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(e.filter(e=>n.has(e)))}else if(r.name===`internal:or`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(or(new Set([...n,...e])))}else if(Un.includes(r.name))n=this._queryLayoutSelector(n,r,t);else{let e=new Set;for(let t of n){let n=this._queryEngineAll(r,t);for(let t of n)e.add(t)}n=e}return[...n]}finally{this._evaluator.end()}}_queryEngineAll(e,t){let n=this._engines.get(e.name).queryAll(t,e.body);for(let e of n)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return n}_queryNth(e,t){let n=[...e],r=+t.body;return r===-1&&(r=n.length-1),new Set(n.slice(r,r+1))}_queryLayoutSelector(e,t,n){let r=t.name,i=t.body,a=[],o=this.querySelectorAll(i.parsed,n);for(let t of e){let e=Wn(r,t,o,i.distance);e!==void 0&&a.push({element:t,score:e})}return a.sort((e,t)=>e.score-t.score),new Set(a.map(e=>e.element))}createStacklessError(t){if(e.options.browser===`firefox`){let e=Error(`Error: ${t}`);return e.stack=``,e}let n=Error(t);return delete n.stack,n}_createTextEngine(e,t){return{queryAll:(n,r)=>{let{matcher:i,kind:a}=yr(r,t),o=[],s=null,c=e=>{if(a===`lax`&&s&&s.contains(e))return!1;let n=un(this._evaluator._cacheText,e,i);n===`none`&&(s=e),(n===`self`||n===`selfAndChildren`&&a===`strict`&&!t)&&o.push(e)};n.nodeType===Node.ELEMENT_NODE&&c(n);let l=this._evaluator._queryCSS({scope:n,pierceShadow:e},`*`);for(let e of l)c(e);return o}}}_createAttributeEngine(e,t){let n=t=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(t)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,r)=>this._evaluator.query({scope:e,pierceShadow:t},n(r))}}_createCSSEngine(){return{queryAll:(e,t)=>this._evaluator.query({scope:e,pierceShadow:!0},t)}}_createNamedAttributeEngine(){return{queryAll:(e,t)=>{let n=M(t);if(n.name||n.attributes.length!==1)throw Error(`Malformed attribute selector: ${t}`);let{name:r,value:i,caseSensitive:a}=n.attributes[0],o=a?null:i.toLowerCase(),s;return s=i instanceof RegExp?e=>!!e.match(i):a?e=>e===i:e=>e.toLowerCase().includes(o),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${r}]`).filter(e=>s(e.getAttribute(r)))}}}_createVisibleEngine(){return{queryAll:(e,t)=>e.nodeType===1&&nt(e)===!!t?[e]:[]}}_createControlEngine(){return{queryAll:(e,t)=>{if(t===`enter-frame`&&e instanceof HTMLIFrameElement){let t=e.contentDocument?.documentElement;return t?[t]:[]}return[]}}}_createHasEngine(){return{queryAll:(e,t)=>e.nodeType===1&&this.querySelector(t.parsed,e,!1)?[e]:[]}}_createHasNotEngine(){return{queryAll:(e,t)=>e.nodeType===1?this.querySelector(t.parsed,e,!1)?[]:[e]:[]}}_createInternalChainEngine(){return{queryAll:(e,t)=>this.querySelectorAll(t.parsed,e)}}_createInternalLabelEngine(){return{queryAll:(e,t)=>{let{matcher:n}=yr(t,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>dn(this._evaluator._cacheText,e).some(e=>n(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=K(this._evaluator._cacheText,n),{matcher:i}=yr(t,!0);return i(r)?[n]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=K(this._evaluator._cacheText,n),{matcher:i}=yr(t,!0);return i(r)?[]:[n]}}}};f(Q,`options`,{testIdAttribute:`data-testid`,browser:`chromium`,exact:!1}),f(Q,`singleton`,null);function hr(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}const gr=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),_r=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function vr(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let t=[],n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length&&n++,t.push(e[n++]);return t.join(``)}function yr(e,t){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let t=e.lastIndexOf(`/`),n=new RegExp(e.substring(1,t),e.substring(t+1));return{matcher:e=>n.test(e.full),kind:`regex`}}let n=t?JSON.parse.bind(JSON):vr,r=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=n(e),r=!0):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=n(e.substring(0,e.length-1)),r=!1):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=n(e.substring(0,e.length-1)),r=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=n(e),r=!0),e=P(e),r?t?{kind:`strict`,matcher:t=>t.normalized===e}:{matcher:t=>!e&&!t.immediate.length||t.immediate.some(t=>P(t)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:t=>t.normalized.toLowerCase().includes(e)})}const br={queryAll(e,t){t.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(t=`.${t}`);let n=[],r=e.ownerDocument||e;if(!r)return n;let i=r.evaluate(t,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=i.iterateNext();e;e=i.iterateNext())e.nodeType===Node.ELEMENT_NODE&&n.push(e);return n}},xr=[`:hover`,`:active`,`:focus`,`:focus-visible`,`:focus-within`];function Sr(){return Math.random().toString(36).slice(2)}async function Cr(e,t){let n=s().browserTraceAttempts.get(e.id),r=a()-n.startTime,i=wr(t.element),o={...t,startTime:r,snapshot:i},{retry:l,repeats:u}=n,{recordCanvas:d}=s().config.browser.traceView,f={retry:l,repeats:u,recordCanvas:d,entries:[o]};await c().rpc.triggerCommand(s().sessionId,`__vitest_recordBrowserTrace`,void 0,[{testId:e.id,data:f}])}function wr(e){let{snapshot:t,createMirror:n}=s().browserTraceDomSnapshot,r=s().config.browser.traceView,i=s().selectorEngine,a=n(),o={serialized:t(document,{mirror:a,inlineImages:r.inlineImages,recordCanvas:r.recordCanvas}),viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},pseudoClassIds:{}};for(let e of xr){let t=document.querySelectorAll(e),n=Array.from(t,e=>a.getId(e)).filter(e=>e!==-1);o.pseudoClassIds[e]=n}if(e)try{let t=i.querySelector(i.parseSelector(e._pwSelector??e.selector),document.documentElement,!1);if(!t)o.selectorResolution=`missing`;else{let e=a.getId(t);e===-1?o.selectorResolution=`missing`:(o.selectorId=e,o.selectorResolution=`matched`)}}catch(e){o.selectorResolution=`error`,o.selectorError=e instanceof Error?e.message:String(e)}return o}function Tr(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return Dr(e)}function Er(e){return e.split(``).map(e=>{let t=e.charCodeAt(0);return e===` `||e===`#`||e===`.`||e===`:`||e===`[`||e===`]`||e===`>`||e===`+`||e===`~`||e===`\\`?`\\${e}`:t>=65536?`\\${t.toString(16).toUpperCase().padStart(6,`0`)} `:t<32||t===127||t>=128?`\\${t.toString(16).toUpperCase().padStart(2,`0`)} `:e}).join(``)}function Dr(e){let t=[],n,r=!1;for(;n=Or(e);){n.shadowRoot&&(r=!0);let i=e.tagName;if(e.id)t.push(`#${Er(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)t.push(i.toLowerCase());else{let r=0,a=0,o=0;for(let t of n.children)r++,t.tagName===i&&a++,t===e&&(o=r);a>1?t.push(`${i.toLowerCase()}:nth-child(${o})`):t.push(i.toLowerCase())}e=n}return`${s().provider===`webdriverio`&&r?`>>>`:``}${t.reverse().join(` > `)}`}function Or(e){let t=e.parentNode;return t instanceof ShadowRoot?t.host:t}function kr(e){if(e&&e.timeout!=null||c().config.browser.providerOptions.actionTimeout!=null)return e;let t=s().runner,n=t._currentTaskStartTime;if(!n)return e;let r=t._currentTaskTimeout;if(r===0||r==null||r===1/0)return e;e||={};let i=a(),o=n+r,l=Math.floor(o-i);return e.timeout=Math.max(l-250,1),e}function Ar(){let e=window.frameElement;if(!e)throw Error(`Cannot find iframe element. This is a bug in Vitest. Please, open a new issue with reproduction.`);return new DOMMatrix(getComputedStyle(e).transform).a}function jr(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function Mr(e,t){return typeof e==`string`?`${JSON.stringify(e)}i`:jr(e)}const Nr=s().provider,Pr=Symbol.for(`$$vitest:locator-resolved`);async function Fr(e,t){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element){let t=Tr(e);return{selector:t,locator:r._asLocator(`javascript`,t)}}if(Lr(e)){if(Nr===`playwright`||Pr in e)return e.serialize();let n=Tr(await e.findElement(t));return{selector:n,locator:r._asLocator(`javascript`,n)}}throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const Ir=Symbol.for(`$$vitest:locator`);function Lr(e){return!!e&&typeof e==`object`&&Ir in e}function Rr(e){let t;if(e.delta)t=e.delta;else switch(e.direction){case`up`:t={y:-100};break;case`down`:t={y:100};break;case`left`:t={x:-100};break;case`right`:t={x:100}}return{delta:t,times:e.times}}r._asLocator=_n;const zr=Date.now,Br=[0,20,50,100,100,500];function Vr(e){let{setTimeout:t}=i();return new Promise(n=>t(n,e))}const $=Q.create({exact:e.config.browser.locators.exact,browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(e.config.browser.name),testIdAttribute:e.config.browser.locators.testIdAttribute});s().selectorEngine=$;const Hr=Symbol.for(`$$vitest:locator`);class Ur{_parsedSelector;_container;_pwSelector;_pwLocator;_errorSource;constructor(){Object.defineProperty(this,Hr,{enumerable:!1,writable:!1,configurable:!1,value:Hr})}click(e){return this.triggerCommand(`__vitest_click`,this.serialize(),e)}dblClick(e){return this.triggerCommand(`__vitest_dblClick`,this.serialize(),e)}tripleClick(e){return this.triggerCommand(`__vitest_tripleClick`,this.serialize(),e)}wheel(e){return o(async t=>{await s().commands.triggerCommand(`__vitest_wheel`,[this.serialize(),Rr(e)],t);let n=s().config.browser.name;if(n===`chromium`||n===`chrome`)return new Promise(e=>{requestAnimationFrame(()=>{e()})})})}clear(e){return this.triggerCommand(`__vitest_clear`,this.serialize(),e)}hover(e){return this.triggerCommand(`__vitest_hover`,this.serialize(),e)}unhover(e){return this.triggerCommand(`__vitest_hover`,{selector:`html > body`,locator:`locator('body')`},e)}fill(e,t){return this.triggerCommand(`__vitest_fill`,this.serialize(),e,t)}upload(e,t){return o(async n=>{let r=(Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(Error(`Failed to read file: ${e.name}`)),r.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:t.slice(t.indexOf(`,`)+1)}});return s().commands.triggerCommand(`__vitest_upload`,[this.serialize(),await Promise.all(r),t],n)})}dropTo(e,t={}){return this.triggerCommand(`__vitest_dragAndDrop`,this.toJSON(),e.toJSON(),t)}selectOptions(e,t){let n=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:Lr(e)?e.serialize():{selector:Tr(e),locator:r._asLocator(`javascript`,$.generateSelectorSimple(e))}});return this.triggerCommand(`__vitest_selectOptions`,this.serialize(),n,t)}screenshot(e){return t.screenshot({...e,element:this})}mark(e,t){let n=c().current,r=!!n&&s().activeTraceTaskIds.has(n.id),i=!!n&&s().browserTraceAttempts.has(n.id);return!n||!r&&!i?Promise.resolve():o(async a=>(i&&await Cr(n,{name:e,kind:t?.kind??`mark`,element:this.serialize(),stack:t?.stack??a?.stack}),r?s().commands.triggerCommand(`__vitest_markTrace`,[{name:e,element:this.serialize(),stack:t?.stack??a?.stack}],a):Promise.resolve()))}getByRole(e,t){return this.locator(mr(e,t))}getByAltText(e,t){return this.locator(ur(e,t))}getByLabelText(e,t){return this.locator(lr(e,t))}getByPlaceholder(e,t){return this.locator(fr(e,t))}getByTestId(t){return this.locator(cr(e.config.browser.locators.testIdAttribute,t))}getByText(e,t){return this.locator(pr(e,t))}getByTitle(e,t){return this.locator(dr(e,t))}filter(e){let t=[];if(e?.hasText&&t.push(`internal:has-text=${Mr(e.hasText)}`),e?.hasNotText&&t.push(`internal:has-not-text=${Mr(e.hasNotText)}`),e?.has){let n=e.has;t.push(`internal:has=${JSON.stringify(n._pwSelector||n.selector)}`)}if(e?.hasNot){let n=e.hasNot;t.push(`internal:has-not=${JSON.stringify(n._pwSelector||n.selector)}`)}if(!t.length)throw Error(`Locator.filter expects at least one filter. None provided.`);return this.locator(t.join(` >> `))}and(e){return this.locator(`internal:and=${JSON.stringify(e._pwSelector||e.selector)}`)}or(e){return this.locator(`internal:or=${JSON.stringify(e._pwSelector||e.selector)}`)}query(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw n.getElementError(this,this._container||document.body);return e}elements(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.querySelectorAll(e,document.documentElement)}get length(){return this.elements().length}all(){return this.elements().map(e=>this.elementLocator(e))}nth(e){return this.locator(`nth=${e}`)}first(){return this.nth(0)}last(){return this.nth(-1)}toString(){return this.selector}serialize(){return{selector:this.selector,locator:this.asLocator(),_pwSelector:this._pwSelector}}asLocator(){return this._pwLocator||=_n(`javascript`,this._pwSelector||this.selector)}toJSON(){return this.serialize()}async findElement(e={}){let t=kr(e),r=t?.timeout,i=t?.strict??!0,a=zr(),o=0;for(;;){let e=this.elements();if(e.length===1)return e[0];if(e.length>1){if(i)throw Gr(this,e);return e[0]}let t=zr()-a;if(r!=null&&t>=r)throw n.getElementError(this,this._container||document.body);let s=Br[Math.min(o++,Br.length-1)];await Vr(r==null?s:Math.min(s,r-t))}}triggerCommand(e,...t){return this._errorSource?Wr({name:e,arguments:t,errorSource:this._errorSource}):o(n=>Wr({name:e,arguments:t,errorSource:n}))}}function Wr(e){return s().commands.triggerCommand(e.name,e.arguments,e.errorSource)}function Gr(e,t){let n=t.slice(0,10).map(e=>({preview:$.previewNode(e),selector:$.generateSelectorSimple(e)})),r=n.map((e,t)=>`\n ${t+1}) ${e.preview} aka ${_n(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
4
+ ...`),this.createStacklessError(`strict mode violation: ${_n(`javascript`,j(e))} resolved to ${t.length} elements:${r.join(``)}\n`)}generateSelectorSimple(t,n){return En(this,t,{...n,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let t=Be(e);return He(t,t=>{if(!this._engines.has(t.name))throw this.createStacklessError(`Unknown engine "${t.name}" while parsing selector ${e}`)}),t}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return hr(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return hr(`<${e.nodeName.toLowerCase()} />`);let t=e,n=[];for(let e=0;e<t.attributes.length;e++){let{name:r,value:i}=t.attributes[e];r!==`style`&&(!i&&gr.has(r)?n.push(` ${r}`):n.push(` ${r}="${i}"`))}n.sort((e,t)=>e.length-t.length);let r=Xe(n.join(``),500);if(_r.has(t.nodeName))return hr(`<${t.nodeName.toLowerCase()}${r}/>`);let i=t.childNodes,a=!1;if(i.length<=5){a=!0;for(let e=0;e<i.length;e++)a&&=i[e].nodeType===Node.TEXT_NODE}let o=a?t.textContent||``:i.length?`…`:``;return hr(`<${t.nodeName.toLowerCase()}${r}>${Xe(o,50)}</${t.nodeName.toLowerCase()}>`)}querySelectorAll(e,t){if(e.capture!==void 0){if(e.parts.some(e=>e.name===`nth`))throw this.createStacklessError(`Can't query n-th element in a request with the capture.`);let n={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let t={parts:e.parts.slice(e.capture+1)},r={name:`internal:has`,body:{parsed:t},source:j(t)};n.parts.push(r)}return this.querySelectorAll(n,t)}if(!t.querySelectorAll)throw this.createStacklessError(`Node is not queryable.`);if(e.capture!==void 0)throw this.createStacklessError(`Internal error: there should not be a capture in the selector.`);if(t.nodeType===11&&e.parts.length===1&&e.parts[0].name===`css`&&e.parts[0].source===`:scope`)return[t];this._evaluator.begin();try{let n=new Set([t]);for(let r of e.parts)if(r.name===`nth`)n=this._queryNth(n,r);else if(r.name===`internal:and`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(e.filter(e=>n.has(e)))}else if(r.name===`internal:or`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(or(new Set([...n,...e])))}else if(Un.includes(r.name))n=this._queryLayoutSelector(n,r,t);else{let e=new Set;for(let t of n){let n=this._queryEngineAll(r,t);for(let t of n)e.add(t)}n=e}return[...n]}finally{this._evaluator.end()}}_queryEngineAll(e,t){let n=this._engines.get(e.name).queryAll(t,e.body);for(let e of n)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return n}_queryNth(e,t){let n=[...e],r=+t.body;return r===-1&&(r=n.length-1),new Set(n.slice(r,r+1))}_queryLayoutSelector(e,t,n){let r=t.name,i=t.body,a=[],o=this.querySelectorAll(i.parsed,n);for(let t of e){let e=Wn(r,t,o,i.distance);e!==void 0&&a.push({element:t,score:e})}return a.sort((e,t)=>e.score-t.score),new Set(a.map(e=>e.element))}createStacklessError(t){if(e.options.browser===`firefox`){let e=Error(`Error: ${t}`);return e.stack=``,e}let n=Error(t);return delete n.stack,n}_createTextEngine(e,t){return{queryAll:(n,r)=>{let{matcher:i,kind:a}=yr(r,t),o=[],s=null,c=e=>{if(a===`lax`&&s&&s.contains(e))return!1;let n=un(this._evaluator._cacheText,e,i);n===`none`&&(s=e),(n===`self`||n===`selfAndChildren`&&a===`strict`&&!t)&&o.push(e)};n.nodeType===Node.ELEMENT_NODE&&c(n);let l=this._evaluator._queryCSS({scope:n,pierceShadow:e},`*`);for(let e of l)c(e);return o}}}_createAttributeEngine(e,t){let n=t=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(t)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,r)=>this._evaluator.query({scope:e,pierceShadow:t},n(r))}}_createCSSEngine(){return{queryAll:(e,t)=>this._evaluator.query({scope:e,pierceShadow:!0},t)}}_createNamedAttributeEngine(){return{queryAll:(e,t)=>{let n=M(t);if(n.name||n.attributes.length!==1)throw Error(`Malformed attribute selector: ${t}`);let{name:r,value:i,caseSensitive:a}=n.attributes[0],o=a?null:i.toLowerCase(),s;return s=i instanceof RegExp?e=>!!e.match(i):a?e=>e===i:e=>e.toLowerCase().includes(o),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${r}]`).filter(e=>s(e.getAttribute(r)))}}}_createVisibleEngine(){return{queryAll:(e,t)=>e.nodeType===1&&nt(e)===!!t?[e]:[]}}_createControlEngine(){return{queryAll:(e,t)=>{if(t===`enter-frame`&&e instanceof HTMLIFrameElement){let t=e.contentDocument?.documentElement;return t?[t]:[]}return[]}}}_createHasEngine(){return{queryAll:(e,t)=>e.nodeType===1&&this.querySelector(t.parsed,e,!1)?[e]:[]}}_createHasNotEngine(){return{queryAll:(e,t)=>e.nodeType===1?this.querySelector(t.parsed,e,!1)?[]:[e]:[]}}_createInternalChainEngine(){return{queryAll:(e,t)=>this.querySelectorAll(t.parsed,e)}}_createInternalLabelEngine(){return{queryAll:(e,t)=>{let{matcher:n}=yr(t,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>dn(this._evaluator._cacheText,e).some(e=>n(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=K(this._evaluator._cacheText,n),{matcher:i}=yr(t,!0);return i(r)?[n]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=K(this._evaluator._cacheText,n),{matcher:i}=yr(t,!0);return i(r)?[]:[n]}}}};f(Q,`options`,{testIdAttribute:`data-testid`,browser:`chromium`,exact:!1}),f(Q,`singleton`,null);function hr(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}const gr=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),_r=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function vr(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let t=[],n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length&&n++,t.push(e[n++]);return t.join(``)}function yr(e,t){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let t=e.lastIndexOf(`/`),n=new RegExp(e.substring(1,t),e.substring(t+1));return{matcher:e=>n.test(e.full),kind:`regex`}}let n=t?JSON.parse.bind(JSON):vr,r=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=n(e),r=!0):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=n(e.substring(0,e.length-1)),r=!1):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=n(e.substring(0,e.length-1)),r=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=n(e),r=!0),e=P(e),r?t?{kind:`strict`,matcher:t=>t.normalized===e}:{matcher:t=>!e&&!t.immediate.length||t.immediate.some(t=>P(t)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:t=>t.normalized.toLowerCase().includes(e)})}const br={queryAll(e,t){t.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(t=`.${t}`);let n=[],r=e.ownerDocument||e;if(!r)return n;let i=r.evaluate(t,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=i.iterateNext();e;e=i.iterateNext())e.nodeType===Node.ELEMENT_NODE&&n.push(e);return n}},xr=[`:hover`,`:active`,`:focus`,`:focus-visible`,`:focus-within`,`:popover-open`];function Sr(){return Math.random().toString(36).slice(2)}async function Cr(e,t){let n=s().browserTraceAttempts.get(e.id),r=a()-n.startTime,i=wr(t.element),o={...t,startTime:r,snapshot:i},{retry:l,repeats:u}=n,{recordCanvas:d}=s().config.browser.traceView,f={retry:l,repeats:u,recordCanvas:d,entries:[o]};await c().rpc.triggerCommand(s().sessionId,`__vitest_recordBrowserTrace`,void 0,[{testId:e.id,data:f}])}function wr(e){let{snapshot:t,createMirror:n}=s().browserTraceDomSnapshot,r=s().config.browser.traceView,i=s().selectorEngine,a=n(),o={serialized:t(document,{mirror:a,inlineImages:r.inlineImages,recordCanvas:r.recordCanvas}),viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},pseudoClassIds:{}};for(let e of xr){let t=document.querySelectorAll(e),n=Array.from(t,e=>a.getId(e)).filter(e=>e!==-1);o.pseudoClassIds[e]=n}if(e)try{let t=i.querySelector(i.parseSelector(e._pwSelector??e.selector),document.documentElement,!1);if(!t)o.selectorResolution=`missing`;else{let e=a.getId(t);e===-1?o.selectorResolution=`missing`:(o.selectorId=e,o.selectorResolution=`matched`)}}catch(e){o.selectorResolution=`error`,o.selectorError=e instanceof Error?e.message:String(e)}return o}function Tr(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return Dr(e)}function Er(e){return e.split(``).map(e=>{let t=e.charCodeAt(0);return e===` `||e===`#`||e===`.`||e===`:`||e===`[`||e===`]`||e===`>`||e===`+`||e===`~`||e===`\\`?`\\${e}`:t>=65536?`\\${t.toString(16).toUpperCase().padStart(6,`0`)} `:t<32||t===127||t>=128?`\\${t.toString(16).toUpperCase().padStart(2,`0`)} `:e}).join(``)}function Dr(e){let t=[],n,r=!1;for(;n=Or(e);){n.shadowRoot&&(r=!0);let i=e.tagName;if(e.id)t.push(`#${Er(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)t.push(i.toLowerCase());else{let r=0,a=0,o=0;for(let t of n.children)r++,t.tagName===i&&a++,t===e&&(o=r);a>1?t.push(`${i.toLowerCase()}:nth-child(${o})`):t.push(i.toLowerCase())}e=n}return`${s().provider===`webdriverio`&&r?`>>>`:``}${t.reverse().join(` > `)}`}function Or(e){let t=e.parentNode;return t instanceof ShadowRoot?t.host:t}function kr(e){if(e&&e.timeout!=null||c().config.browser.providerOptions.actionTimeout!=null)return e;let t=s().runner,n=t._currentTaskStartTime;if(!n)return e;let r=t._currentTaskTimeout;if(r===0||r==null||r===1/0)return e;e||={};let i=a(),o=n+r,l=Math.floor(o-i);return e.timeout=Math.max(l-250,1),e}function Ar(){let e=window.frameElement;if(!e)throw Error(`Cannot find iframe element. This is a bug in Vitest. Please, open a new issue with reproduction.`);return new DOMMatrix(getComputedStyle(e).transform).a}function jr(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function Mr(e,t){return typeof e==`string`?`${JSON.stringify(e)}i`:jr(e)}const Nr=s().provider,Pr=Symbol.for(`$$vitest:locator-resolved`);async function Fr(e,t){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element){let t=Tr(e);return{selector:t,locator:r._asLocator(`javascript`,t)}}if(Lr(e)){if(Nr===`playwright`||Pr in e)return e.serialize();let n=Tr(await e.findElement(t));return{selector:n,locator:r._asLocator(`javascript`,n)}}throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const Ir=Symbol.for(`$$vitest:locator`);function Lr(e){return!!e&&typeof e==`object`&&Ir in e}function Rr(e){let t;if(e.delta)t=e.delta;else switch(e.direction){case`up`:t={y:-100};break;case`down`:t={y:100};break;case`left`:t={x:-100};break;case`right`:t={x:100}}return{delta:t,times:e.times}}r._asLocator=_n;const zr=Date.now,Br=[0,20,50,100,100,500];function Vr(e){let{setTimeout:t}=i();return new Promise(n=>t(n,e))}const $=Q.create({exact:e.config.browser.locators.exact,browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(e.config.browser.name),testIdAttribute:e.config.browser.locators.testIdAttribute});s().selectorEngine=$;const Hr=Symbol.for(`$$vitest:locator`);class Ur{_parsedSelector;_container;_pwSelector;_pwLocator;_errorSource;constructor(){Object.defineProperty(this,Hr,{enumerable:!1,writable:!1,configurable:!1,value:Hr})}click(e){return this.triggerCommand(`__vitest_click`,this.serialize(),e)}dblClick(e){return this.triggerCommand(`__vitest_dblClick`,this.serialize(),e)}tripleClick(e){return this.triggerCommand(`__vitest_tripleClick`,this.serialize(),e)}wheel(e){return o(async t=>{await s().commands.triggerCommand(`__vitest_wheel`,[this.serialize(),Rr(e)],t);let n=s().config.browser.name;if(n===`chromium`||n===`chrome`)return new Promise(e=>{requestAnimationFrame(()=>{e()})})})}clear(e){return this.triggerCommand(`__vitest_clear`,this.serialize(),e)}hover(e){return this.triggerCommand(`__vitest_hover`,this.serialize(),e)}unhover(e){return this.triggerCommand(`__vitest_hover`,{selector:`html > body`,locator:`locator('body')`},e)}fill(e,t){return this.triggerCommand(`__vitest_fill`,this.serialize(),e,t)}upload(e,t){return o(async n=>{let r=(Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(Error(`Failed to read file: ${e.name}`)),r.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:t.slice(t.indexOf(`,`)+1)}});return s().commands.triggerCommand(`__vitest_upload`,[this.serialize(),await Promise.all(r),t],n)})}dropTo(e,t={}){return this.triggerCommand(`__vitest_dragAndDrop`,this.toJSON(),e.toJSON(),t)}selectOptions(e,t){let n=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:Lr(e)?e.serialize():{selector:Tr(e),locator:r._asLocator(`javascript`,$.generateSelectorSimple(e))}});return this.triggerCommand(`__vitest_selectOptions`,this.serialize(),n,t)}screenshot(e){return t.screenshot({...e,element:this})}mark(e,t){let n=c().current,r=!!n&&s().activeTraceTaskIds.has(n.id),i=!!n&&s().browserTraceAttempts.has(n.id);return!n||!r&&!i?Promise.resolve():o(async a=>(i&&await Cr(n,{name:e,kind:t?.kind??`mark`,element:this.serialize(),stack:t?.stack??a?.stack}),r?s().commands.triggerCommand(`__vitest_markTrace`,[{name:e,element:this.serialize(),stack:t?.stack??a?.stack}],a):Promise.resolve()))}getByRole(e,t){return this.locator(mr(e,t))}getByAltText(e,t){return this.locator(ur(e,t))}getByLabelText(e,t){return this.locator(lr(e,t))}getByPlaceholder(e,t){return this.locator(fr(e,t))}getByTestId(t){return this.locator(cr(e.config.browser.locators.testIdAttribute,t))}getByText(e,t){return this.locator(pr(e,t))}getByTitle(e,t){return this.locator(dr(e,t))}filter(e){let t=[];if(e?.hasText&&t.push(`internal:has-text=${Mr(e.hasText)}`),e?.hasNotText&&t.push(`internal:has-not-text=${Mr(e.hasNotText)}`),e?.has){let n=e.has;t.push(`internal:has=${JSON.stringify(n._pwSelector||n.selector)}`)}if(e?.hasNot){let n=e.hasNot;t.push(`internal:has-not=${JSON.stringify(n._pwSelector||n.selector)}`)}if(!t.length)throw Error(`Locator.filter expects at least one filter. None provided.`);return this.locator(t.join(` >> `))}and(e){return this.locator(`internal:and=${JSON.stringify(e._pwSelector||e.selector)}`)}or(e){return this.locator(`internal:or=${JSON.stringify(e._pwSelector||e.selector)}`)}query(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw n.getElementError(this,this._container||document.body);return e}elements(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.querySelectorAll(e,document.documentElement)}get length(){return this.elements().length}all(){return this.elements().map(e=>this.elementLocator(e))}nth(e){return this.locator(`nth=${e}`)}first(){return this.nth(0)}last(){return this.nth(-1)}toString(){return this.selector}serialize(){return{selector:this.selector,locator:this.asLocator(),_pwSelector:this._pwSelector}}asLocator(){return this._pwLocator||=_n(`javascript`,this._pwSelector||this.selector)}toJSON(){return this.serialize()}async findElement(e={}){let t=kr(e),r=t?.timeout,i=t?.strict??!0,a=zr(),o=0;for(;;){let e=this.elements();if(e.length===1)return e[0];if(e.length>1){if(i)throw Gr(this,e);return e[0]}let t=zr()-a;if(r!=null&&t>=r)throw n.getElementError(this,this._container||document.body);let s=Br[Math.min(o++,Br.length-1)];await Vr(r==null?s:Math.min(s,r-t))}}triggerCommand(e,...t){return this._errorSource?Wr({name:e,arguments:t,errorSource:this._errorSource}):o(n=>Wr({name:e,arguments:t,errorSource:n}))}}function Wr(e){return s().commands.triggerCommand(e.name,e.arguments,e.errorSource)}function Gr(e,t){let n=t.slice(0,10).map(e=>({preview:$.previewNode(e),selector:$.generateSelectorSimple(e)})),r=n.map((e,t)=>`\n ${t+1}) ${e.preview} aka ${_n(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
5
5
  ...`),Error(`strict mode violation: ${e.asLocator()} resolved to ${t.length} elements:${r.join(``)}\n`)}export{kr as A,a as B,c as C,Sr as D,Cr as E,Tr as F,o as G,ur as H,lr as I,fr as J,mr as K,Ur as L,cr as M,pr as N,dr as O,Ar as P,$ as Q,Wr as R,f as _,Dt as a,Lt as b,Gt as c,Kt as d,Vt as e,Ht as f,B as g,Ut as h,V as i,Wt as j,It as k,zt as l,Bt as m,P as n,Pt as o,Ft as p,R as q,Ct as r,on as s,sn as t,s as u,nt as v,Ot as w,Mt as x,N as y,Fr as z};
@@ -1,4 +1,4 @@
1
- import { UserEventClickOptions, UserEventWheelOptions, UserEventClearOptions, UserEventHoverOptions, UserEventFillOptions, UserEventUploadOptions, UserEventDragAndDropOptions, UserEventSelectOptions, LocatorScreenshotOptions, MarkOptions, LocatorByRoleOptions, LocatorOptions, SelectorOptions } from 'vitest/browser';
1
+ import { UserEventClickOptions, UserEventWheelOptions, UserEventClearOptions, UserEventHoverOptions, UserEventFillOptions, UserEventUploadOptions, UserEventDragAndDropOptions, UserEventSelectOptions, LocatorScreenshotOptions, MarkOptions, LocatorByRoleOptions, LocatorOptions, LocatorFilterOptions, SelectorOptions } from 'vitest/browser';
2
2
 
3
3
  //#region src/cssParser.d.ts
4
4
  type ClauseCombinator = '' | '>' | '+' | '~' | '>=';
@@ -270,7 +270,7 @@ declare abstract class Locator {
270
270
  getByTestId(testId: string | RegExp): Locator;
271
271
  getByText(text: string | RegExp, options?: LocatorOptions): Locator;
272
272
  getByTitle(title: string | RegExp, options?: LocatorOptions): Locator;
273
- filter(filter: LocatorOptions): Locator;
273
+ filter(filter: LocatorFilterOptions): Locator;
274
274
  and(locator: Locator): Locator;
275
275
  or(locator: Locator): Locator;
276
276
  query(): HTMLElement | SVGElement | null;
package/dist/locators.js CHANGED
@@ -1 +1 @@
1
- export{L as Locator,F as convertElementToCssSelector,G as ensureAwaited,H as getByAltTextSelector,I as getByLabelSelector,J as getByPlaceholderSelector,K as getByRoleSelector,M as getByTestIdSelector,N as getByTextSelector,O as getByTitleSelector,P as getIframeScale,A as processTimeoutOptions,Q as selectorEngine,R as triggerCommandWithTrace}from"./locators-BTqFw5Up.js";import"vitest/browser";import"vitest/internal/browser";
1
+ export{L as Locator,F as convertElementToCssSelector,G as ensureAwaited,H as getByAltTextSelector,I as getByLabelSelector,J as getByPlaceholderSelector,K as getByRoleSelector,M as getByTestIdSelector,N as getByTextSelector,O as getByTitleSelector,P as getIframeScale,A as processTimeoutOptions,Q as selectorEngine,R as triggerCommandWithTrace}from"./locators-CIWNuqVM.js";import"vitest/browser";import"vitest/internal/browser";
package/dist/types.d.ts CHANGED
@@ -18,6 +18,7 @@ export interface WebSocketBrowserHandlers {
18
18
  cancelCurrentRun: (reason: CancelReason) => void;
19
19
  getCountOfFailedTests: () => number;
20
20
  readSnapshotFile: (id: string) => Promise<string | null>;
21
+ readSnapshotFileData: (id: string) => Promise<Record<string, string> | null>;
21
22
  saveSnapshotFile: (id: string, content: string) => Promise<void>;
22
23
  removeSnapshotFile: (id: string) => Promise<void>;
23
24
  sendLog: (method: TestExecutionMethod, log: UserConsoleLog) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "5.0.0-rc.1",
4
+ "version": "5.0.0-rc.3",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -63,32 +63,33 @@
63
63
  "providers"
64
64
  ],
65
65
  "peerDependencies": {
66
- "vitest": "5.0.0-rc.1"
66
+ "vitest": "5.0.0-rc.3"
67
67
  },
68
68
  "dependencies": {
69
69
  "@blazediff/core": "1.10.0",
70
- "magic-string": "^1.1.0",
70
+ "@vitest/mocker": "5.0.0-rc.3",
71
+ "@vitest/ui": "5.0.0-rc.3",
72
+ "@vitest/utils": "5.0.0-rc.3",
73
+ "magic-string": "^1.2.2",
71
74
  "pngjs": "^7.0.0",
72
75
  "sirv": "^3.0.2",
73
76
  "tinyrainbow": "^3.1.1",
74
- "ws": "^8.21.3",
75
- "@vitest/mocker": "5.0.0-rc.1",
76
- "@vitest/utils": "5.0.0-rc.1",
77
- "@vitest/ui": "5.0.0-rc.1"
77
+ "ws": "^8.21.3"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@opentelemetry/api": "^1.9.1",
81
- "@testing-library/user-event": "^14.6.3",
81
+ "@testing-library/user-event": "^14.6.6",
82
82
  "@types/node": "24.13.3",
83
83
  "@types/pngjs": "^6.0.5",
84
84
  "@types/ws": "^8.18.1",
85
- "birpc": "^4.1.0",
85
+ "@vitest/snapshot": "5.0.0-rc.3",
86
+ "birpc": "^4.2.0",
86
87
  "flatted": "^3.4.4",
87
88
  "ivya": "^1.8.2",
88
89
  "mime": "^4.1.0",
89
90
  "pathe": "^2.0.3",
90
91
  "rrweb-snapshot": "2.1.1",
91
- "vitest": "5.0.0-rc.1"
92
+ "vitest": "5.0.0-rc.3"
92
93
  },
93
94
  "scripts": {
94
95
  "typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",