@vitest/browser 5.0.0-beta.2 → 5.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/context.d.ts +8 -0
  2. package/dist/client/.vite/manifest.json +8 -8
  3. package/dist/client/__vitest__/assets/index-B2jbgabi.js +139 -0
  4. package/dist/client/__vitest__/assets/index-CEyXAB_I.css +1 -0
  5. package/dist/client/__vitest__/index.html +2 -2
  6. package/dist/client/__vitest_browser__/defineProperty-C3k2g8Sk.js +267 -0
  7. package/dist/client/__vitest_browser__/orchestrator-B44yH1M4.js +343 -0
  8. package/dist/client/__vitest_browser__/rrweb-snapshot-iZCFA2to.js +4388 -0
  9. package/dist/client/__vitest_browser__/tester-kAU8uxhk.js +5086 -0
  10. package/dist/client/orchestrator.html +2 -2
  11. package/dist/client/tester/tester.html +2 -2
  12. package/dist/client/tester/trace.d.ts +9 -6
  13. package/dist/client.js +10 -1
  14. package/dist/context.js +53 -23
  15. package/dist/expect-element.js +30 -30
  16. package/dist/index.js +153 -33
  17. package/dist/locators-CPBpJv8y.js +5 -0
  18. package/dist/locators.js +1 -1
  19. package/dist/shared/screenshotMatcher/types.d.ts +2 -1
  20. package/dist/state.js +64 -14
  21. package/dist/types.d.ts +7 -2
  22. package/jest-dom.d.ts +26 -6
  23. package/matchers.d.ts +2 -1
  24. package/package.json +7 -7
  25. package/dist/client/__vitest__/assets/index-Cd6On2Pm.js +0 -136
  26. package/dist/client/__vitest__/assets/index-Dw9P28Qt.css +0 -1
  27. package/dist/client/__vitest_browser__/orchestrator-BfoS0x4w.js +0 -411
  28. package/dist/client/__vitest_browser__/rrweb-snapshot-xhvrgOHx.js +0 -5476
  29. package/dist/client/__vitest_browser__/tester-BJtW9QqZ.js +0 -5588
  30. package/dist/client/__vitest_browser__/utils-Nd8hqrhP.js +0 -189
  31. package/dist/locators-CesZ2RSY.js +0 -5
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import { PNG } from 'pngjs';
18
18
  import { diff } from '@blazediff/core';
19
19
  import { WebSocketServer } from 'ws';
20
20
 
21
- var version = "5.0.0-beta.2";
21
+ var version = "5.0.0-beta.4";
22
22
 
23
23
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
24
24
  function normalizeWindowsPath(input = "") {
@@ -702,7 +702,7 @@ async function resolveOrchestrator(globalServer, url, res) {
702
702
  __VITEST_TYPE__: "\"orchestrator\"",
703
703
  __VITEST_SESSION_ID__: JSON.stringify(sessionId),
704
704
  __VITEST_TESTER_ID__: "\"none\"",
705
- __VITEST_OTEL_CARRIER__: url.searchParams.get("otelCarrier") ?? "null",
705
+ __VITEST_OTEL_CARRIER__: JSON.stringify(session?.otelCarrier ?? null),
706
706
  __VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(browserProject.project.getProvidedContext())),
707
707
  __VITEST_API_TOKEN__: JSON.stringify(globalServer.vitest.config.api.token)
708
708
  });
@@ -714,7 +714,7 @@ async function resolveOrchestrator(globalServer, url, res) {
714
714
  for (const attr in script.attrs || {}) {
715
715
  html += `${attr}="${script.attrs[attr]}" `;
716
716
  }
717
- html += `>${script.children}<\/script>`;
717
+ html += `>${escapeInlineScript(typeof script.children === "string" ? script.children : "")}<\/script>`;
718
718
  return html;
719
719
  }).join("\n");
720
720
  }
@@ -735,11 +735,14 @@ async function resolveOrchestrator(globalServer, url, res) {
735
735
  __VITEST_FAVICON__: globalServer.faviconUrl,
736
736
  __VITEST_TITLE__: "Vitest Browser Runner",
737
737
  __VITEST_SCRIPTS__: globalServer.orchestratorScripts,
738
- __VITEST_INJECTOR__: `<script type="module">${injector}<\/script>`,
738
+ __VITEST_INJECTOR__: `<script type="module">${escapeInlineScript(injector)}<\/script>`,
739
739
  __VITEST_ERROR_CATCHER__: `<script type="module" src="${globalServer.errorCatcherUrl}"><\/script>`,
740
740
  __VITEST_SESSION_ID__: JSON.stringify(sessionId)
741
741
  });
742
742
  }
743
+ function escapeInlineScript(content) {
744
+ return content.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
745
+ }
743
746
 
744
747
  function disableCache(res) {
745
748
  res.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate");
@@ -1026,7 +1029,14 @@ var BrowserPlugin = (parentServer, base = "/") => {
1026
1029
  // this plugin can be used in different projects, but all of them
1027
1030
  // have the same `include` pattern, so it doesn't matter which project we use
1028
1031
  const project = parentServer.project;
1029
- const { testFiles: browserTestFiles } = await project.globTestFiles();
1032
+ // only glob benchmarks when a browser-enabled bench project exists in
1033
+ // the workspace — keeps the optimizeDeps entries symmetrical across
1034
+ // the test/bench project clones so the optimizer doesn't re-scan when
1035
+ // the user switches modes
1036
+ const hasBrowserBenchProject = parentServer.vitest.projects.some((p) => p.config.browser.enabled && p.config.benchmark.enabled);
1037
+ const benchInclude = hasBrowserBenchProject ? project.config.benchmark.include : [];
1038
+ const dir = project.config.dir || project.config.root;
1039
+ const [{ testFiles: browserTestFiles }, browserBenchFiles] = await Promise.all([project.globTestFiles(), benchInclude.length > 0 ? project.globFiles(benchInclude, project.config.benchmark.exclude ?? project.config.exclude, dir) : []]);
1030
1040
  const setupFiles = toArray(project.config.setupFiles);
1031
1041
  // replace env values - cannot be reassign at runtime
1032
1042
  const define = {};
@@ -1035,7 +1045,7 @@ var BrowserPlugin = (parentServer, base = "/") => {
1035
1045
  define[`import.meta.env.${env}`] = stringValue;
1036
1046
  }
1037
1047
  const entries = [
1038
- ...browserTestFiles,
1048
+ ...new Set([...browserTestFiles, ...browserBenchFiles]),
1039
1049
  ...setupFiles,
1040
1050
  resolve(distDir, "index.js"),
1041
1051
  resolve(distDir, "browser.js"),
@@ -1170,7 +1180,10 @@ var BrowserPlugin = (parentServer, base = "/") => {
1170
1180
  BrowserContext(parentServer),
1171
1181
  dynamicImportPlugin({
1172
1182
  globalThisAccessor: "\"__vitest_browser_runner__\"",
1173
- filter(id) {
1183
+ filter(id, environment) {
1184
+ if (environment.name !== "client") {
1185
+ return false;
1186
+ }
1174
1187
  if (id.includes(distRoot)) {
1175
1188
  return false;
1176
1189
  }
@@ -1431,6 +1444,19 @@ class BrowserServerCDPHandler {
1431
1444
  }
1432
1445
  }
1433
1446
 
1447
+ const _startV8Coverage = async (context) => {
1448
+ const session = await context.__ensureCDPHandler();
1449
+ await session.send("Profiler.enable");
1450
+ await session.send("Profiler.startPreciseCoverage", {
1451
+ callCount: true,
1452
+ detailed: true
1453
+ });
1454
+ };
1455
+ const _takeV8Coverage = async (context) => {
1456
+ const session = await context.__ensureCDPHandler();
1457
+ return session.send("Profiler.takePreciseCoverage");
1458
+ };
1459
+
1434
1460
  const types = {
1435
1461
  'application/andrew-inset': ['ez'],
1436
1462
  'application/appinstaller': ['appinstaller'],
@@ -2169,12 +2195,16 @@ function sanitizeArg(input) {
2169
2195
  *
2170
2196
  * @returns `Promise` resolving to the decoded screenshot data
2171
2197
  */
2172
- function takeDecodedScreenshot({ codec, context, element, name, screenshotOptions }) {
2198
+ function takeScreenshotBuffer({ context, element, name, screenshotOptions, target }) {
2173
2199
  return context.triggerCommand("__vitest_takeScreenshot", name, {
2174
2200
  ...screenshotOptions,
2175
2201
  save: false,
2176
- element
2177
- }).then(({ buffer }) => codec.decode(buffer, {}));
2202
+ element,
2203
+ target
2204
+ }).then(({ buffer }) => buffer);
2205
+ }
2206
+ function takeDecodedScreenshot({ codec, ...options }) {
2207
+ return takeScreenshotBuffer(options).then((buffer) => codec.decode(buffer, {}));
2178
2208
  }
2179
2209
  /**
2180
2210
  * Creates a promise that resolves to `null` after the specified timeout.
@@ -2208,28 +2238,54 @@ const screenshotMatcher = async (context, name, testName, options) => {
2208
2238
  if (!context.testPath) {
2209
2239
  throw new Error("Cannot compare screenshots without a test path");
2210
2240
  }
2211
- const { element } = options;
2212
- const { codec, comparator, paths, resolvedOptions: { comparatorOptions, screenshotOptions, timeout } } = resolveOptions({
2241
+ const { element, target } = options;
2242
+ const { codec, comparator, paths, resolvedOptions: { comparatorName, comparatorOptions, screenshotOptions, timeout } } = resolveOptions({
2213
2243
  context,
2214
2244
  name,
2215
2245
  testName,
2216
2246
  options
2217
2247
  });
2248
+ const screenshotName = `${Date.now()}-${basename(paths.reference)}`;
2249
+ const screenshotCaptureOptions = {
2250
+ context,
2251
+ element,
2252
+ name: screenshotName,
2253
+ screenshotOptions,
2254
+ target
2255
+ };
2218
2256
  const referenceFile = await readFile$1(paths.reference).catch(() => null);
2219
- const reference = referenceFile && await codec.decode(referenceFile, {});
2257
+ let reference = null;
2258
+ let initialScreenshot = null;
2259
+ if (referenceFile) {
2260
+ // Reuse this capture in the stability loop so the byte fast path doesn't add another screenshot.
2261
+ const initialScreenshotBuffer = await takeScreenshotBuffer(screenshotCaptureOptions);
2262
+ // Keep custom comparator semantics intact: only the built-in pixelmatch
2263
+ // comparator is known to pass byte-identical PNGs without side effects.
2264
+ if (comparatorName === "pixelmatch" && Buffer.compare(referenceFile, initialScreenshotBuffer) === 0) {
2265
+ return buildOutput({ type: "matched-immediately" }, timeout);
2266
+ }
2267
+ [reference, initialScreenshot] = await Promise.all([codec.decode(referenceFile, {}), takeScreenshotData({
2268
+ ...screenshotCaptureOptions,
2269
+ buffer: initialScreenshotBuffer,
2270
+ codec
2271
+ })]);
2272
+ }
2220
2273
  const screenshotResult = await waitForStableScreenshot({
2221
2274
  codec,
2222
2275
  comparator,
2223
2276
  comparatorOptions,
2224
2277
  context,
2225
2278
  element,
2226
- name: `${Date.now()}-${basename(paths.reference)}`,
2279
+ initialScreenshot,
2280
+ name: screenshotName,
2227
2281
  reference,
2228
- screenshotOptions
2282
+ screenshotOptions,
2283
+ target
2229
2284
  }, timeout);
2230
2285
  const outcome = await determineOutcome({
2231
2286
  reference,
2232
2287
  screenshot: screenshotResult && screenshotResult.actual,
2288
+ screenshotBuffer: screenshotResult?.buffer,
2233
2289
  retries: screenshotResult?.retries ?? 0,
2234
2290
  updateSnapshot: context.project.serializedConfig.snapshotOptions.updateSnapshot,
2235
2291
  paths,
@@ -2246,7 +2302,7 @@ const screenshotMatcher = async (context, name, testName, options) => {
2246
2302
  *
2247
2303
  * The outcome carries all data needed by {@linkcode performSideEffects} and {@linkcode buildOutput}.
2248
2304
  */
2249
- async function determineOutcome({ comparator, comparatorOptions, paths, reference, retries, screenshot, updateSnapshot }) {
2305
+ async function determineOutcome({ comparator, comparatorOptions, paths, reference, retries, screenshot, screenshotBuffer, updateSnapshot }) {
2250
2306
  if (screenshot === null) {
2251
2307
  return {
2252
2308
  type: "unstable-screenshot",
@@ -2263,7 +2319,8 @@ async function determineOutcome({ comparator, comparatorOptions, paths, referenc
2263
2319
  type: "update-reference",
2264
2320
  reference: {
2265
2321
  image: screenshot,
2266
- path: paths.reference
2322
+ path: paths.reference,
2323
+ buffer: screenshotBuffer
2267
2324
  }
2268
2325
  };
2269
2326
  }
@@ -2273,7 +2330,8 @@ async function determineOutcome({ comparator, comparatorOptions, paths, referenc
2273
2330
  location,
2274
2331
  reference: {
2275
2332
  image: screenshot,
2276
- path: location === "reference" ? paths.reference : paths.diffs.reference
2333
+ path: location === "reference" ? paths.reference : paths.diffs.reference,
2334
+ buffer: screenshotBuffer
2277
2335
  }
2278
2336
  };
2279
2337
  }
@@ -2293,7 +2351,8 @@ async function determineOutcome({ comparator, comparatorOptions, paths, referenc
2293
2351
  type: "update-reference",
2294
2352
  reference: {
2295
2353
  image: screenshot,
2296
- path: paths.reference
2354
+ path: paths.reference,
2355
+ buffer: screenshotBuffer
2297
2356
  }
2298
2357
  };
2299
2358
  }
@@ -2305,7 +2364,8 @@ async function determineOutcome({ comparator, comparatorOptions, paths, referenc
2305
2364
  },
2306
2365
  actual: {
2307
2366
  image: screenshot,
2308
- path: paths.diffs.actual
2367
+ path: paths.diffs.actual,
2368
+ buffer: screenshotBuffer
2309
2369
  },
2310
2370
  diff: comparisonResult.diff && {
2311
2371
  image: {
@@ -2326,11 +2386,11 @@ async function performSideEffects(outcome, codec) {
2326
2386
  switch (outcome.type) {
2327
2387
  case "missing-reference":
2328
2388
  case "update-reference": {
2329
- await writeScreenshot(outcome.reference.path, await codec.encode(outcome.reference.image, {}));
2389
+ await writeScreenshot(outcome.reference.path, await encodeScreenshot(outcome.reference, codec));
2330
2390
  break;
2331
2391
  }
2332
2392
  case "mismatch": {
2333
- await writeScreenshot(outcome.actual.path, await codec.encode(outcome.actual.image, {}));
2393
+ await writeScreenshot(outcome.actual.path, await encodeScreenshot(outcome.actual, codec));
2334
2394
  if (outcome.diff) {
2335
2395
  await writeScreenshot(outcome.diff.path, await codec.encode(outcome.diff.image, {}));
2336
2396
  }
@@ -2338,6 +2398,9 @@ async function performSideEffects(outcome, codec) {
2338
2398
  }
2339
2399
  }
2340
2400
  }
2401
+ function encodeScreenshot(screenshot, codec) {
2402
+ return screenshot.buffer ?? codec.encode(screenshot.image, {});
2403
+ }
2341
2404
  /**
2342
2405
  * Transforms a {@linkcode MatchOutcome} into the output format expected by the test runner.
2343
2406
  *
@@ -2435,34 +2498,59 @@ async function waitForStableScreenshot(options, timeout) {
2435
2498
  *
2436
2499
  * @returns `Promise` resolving to an object containing the retry count and final screenshot
2437
2500
  */
2438
- async function getStableScreenshot({ codec, context, comparator, comparatorOptions, element, name, reference, screenshotOptions }, signal) {
2501
+ async function getStableScreenshot({ codec, context, comparator, comparatorOptions, element, initialScreenshot, name, reference, screenshotOptions, target }, signal) {
2439
2502
  const screenshotArgument = {
2440
2503
  codec,
2441
2504
  context,
2442
2505
  element,
2443
2506
  name,
2444
- screenshotOptions
2507
+ screenshotOptions,
2508
+ target
2445
2509
  };
2446
2510
  let retries = 0;
2447
2511
  let decodedBaseline = reference;
2512
+ let nextScreenshot = initialScreenshot;
2513
+ let lastCapturedScreenshot = null;
2448
2514
  while (signal.aborted === false) {
2449
2515
  if (decodedBaseline === null) {
2450
2516
  decodedBaseline = takeDecodedScreenshot(screenshotArgument);
2451
2517
  }
2452
- const [image1, image2] = await Promise.all([decodedBaseline, takeDecodedScreenshot(screenshotArgument)]);
2518
+ const [image1, capturedScreenshot] = await Promise.all([decodedBaseline, nextScreenshot ?? takeScreenshotData(screenshotArgument)]);
2519
+ const { image: image2 } = capturedScreenshot;
2520
+ lastCapturedScreenshot = capturedScreenshot;
2453
2521
  const isStable = (await comparator(image1, image2, {
2454
2522
  ...comparatorOptions,
2455
2523
  createDiff: false
2456
2524
  })).pass;
2457
2525
  decodedBaseline = image2;
2526
+ nextScreenshot = null;
2458
2527
  if (isStable) {
2459
- break;
2528
+ return {
2529
+ retries,
2530
+ actual: image2,
2531
+ buffer: capturedScreenshot.buffer
2532
+ };
2460
2533
  }
2461
2534
  retries += 1;
2462
2535
  }
2536
+ lastCapturedScreenshot ??= await takeScreenshotData(screenshotArgument);
2463
2537
  return {
2464
2538
  retries,
2465
- actual: await decodedBaseline
2539
+ actual: lastCapturedScreenshot.image,
2540
+ buffer: lastCapturedScreenshot.buffer
2541
+ };
2542
+ }
2543
+ async function takeScreenshotData({ buffer, codec, context, element, name, screenshotOptions, target }) {
2544
+ const screenshot = buffer ?? await takeScreenshotBuffer({
2545
+ context,
2546
+ element,
2547
+ name,
2548
+ screenshotOptions,
2549
+ target
2550
+ });
2551
+ return {
2552
+ buffer: screenshot,
2553
+ image: await codec.decode(screenshot, {})
2466
2554
  };
2467
2555
  }
2468
2556
  /** Writes encoded images to disk, creating parent directories as needed. */
@@ -2515,6 +2603,8 @@ var builtinCommands = {
2515
2603
  readFile,
2516
2604
  removeFile,
2517
2605
  writeFile,
2606
+ __vitest_startV8Coverage: _startV8Coverage,
2607
+ __vitest_takeV8Coverage: _takeV8Coverage,
2518
2608
  __vitest_markTrace: _markTrace,
2519
2609
  __vitest_groupTraceStart: _groupTraceStart,
2520
2610
  __vitest_groupTraceEnd: _groupTraceEnd,
@@ -2652,7 +2742,6 @@ class ParentBrowserProject {
2652
2742
  this.sourceMapCache.set(id, extracted?.map);
2653
2743
  return extracted?.map;
2654
2744
  }
2655
- this.sourceMapCache.set(id, result?.map);
2656
2745
  return result?.map;
2657
2746
  },
2658
2747
  getUrlId: (id) => {
@@ -3070,6 +3159,14 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3070
3159
  function canWrite(project) {
3071
3160
  return project.config.browser.api.allowWrite && project.vitest.config.browser.api.allowWrite && project.config.api.allowWrite && project.vitest.config.api.allowWrite;
3072
3161
  }
3162
+ function isCdpAllowed(project) {
3163
+ return project.config.api.allowExec && project.config.browser.api.allowExec && project.vitest.config.api.allowExec && project.vitest.config.browser.api.allowExec && project.config.api.allowWrite && project.config.browser.api.allowWrite && project.vitest.config.api.allowWrite && project.vitest.config.browser.api.allowWrite;
3164
+ }
3165
+ function assertCdpAllowed(project) {
3166
+ if (!isCdpAllowed(project)) {
3167
+ throw new Error(`Cannot use CDP because browser API write or exec operations are disabled. See https://vitest.dev/config/browser/api.`);
3168
+ }
3169
+ }
3073
3170
  function setupClient(project, rpcId, ws) {
3074
3171
  const mockResolver = new ServerMockResolver(globalServer.vite, { moduleDirectories: project.config?.deps?.moduleDirectories });
3075
3172
  const mocker = project.browser?.provider.mocker;
@@ -3110,6 +3207,21 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3110
3207
  }
3111
3208
  return vitest._testRun.recordArtifact(id, artifact);
3112
3209
  },
3210
+ async onTestBenchmark(testId, benchmark) {
3211
+ return vitest._testRun.recordBenchmark(testId, benchmark);
3212
+ },
3213
+ async readBenchmarkResult(relativePath) {
3214
+ checkFileAccess(project.benchmark.resolve(relativePath));
3215
+ return project.benchmark.readResult(relativePath);
3216
+ },
3217
+ async writeBenchmarkResult(relativePath, data) {
3218
+ if (!canWrite(project)) {
3219
+ vitest.logger.error(`[vitest] Cannot write benchmark artifact "${relativePath}" because file writing is disabled. See https://vitest.dev/config/browser/api.`);
3220
+ return;
3221
+ }
3222
+ checkFileAccess(project.benchmark.resolve(relativePath));
3223
+ return project.benchmark.writeResult(relativePath, data);
3224
+ },
3113
3225
  async onTaskUpdate(method, packs, events) {
3114
3226
  if (method === "collect") {
3115
3227
  vitest.state.updateTasks(packs);
@@ -3212,9 +3324,14 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3212
3324
  provider,
3213
3325
  contextId: sessionId,
3214
3326
  sessionId,
3327
+ mark: async (name, options) => {
3328
+ const tester = project.browser.state.testers.get(rpcId);
3329
+ await tester?.pageMark(name, options);
3330
+ },
3215
3331
  triggerCommand: (name, ...args) => {
3216
3332
  return project.browser.triggerCommand(name, context, ...args);
3217
- }
3333
+ },
3334
+ __ensureCDPHandler: () => globalServer.ensureCDPHandler(sessionId, rpcId)
3218
3335
  }, provider.getCommandsContext(sessionId));
3219
3336
  return await project.browser.triggerCommand(command, context, ...payload);
3220
3337
  },
@@ -3276,10 +3393,12 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3276
3393
  return mocker.delete(sessionId, id);
3277
3394
  },
3278
3395
  async sendCdpEvent(sessionId, event, payload) {
3396
+ assertCdpAllowed(project);
3279
3397
  const cdp = await globalServer.ensureCDPHandler(sessionId, rpcId);
3280
3398
  return cdp.send(event, payload);
3281
3399
  },
3282
3400
  async trackCdpEvent(sessionId, type, event, listenerId) {
3401
+ assertCdpAllowed(project);
3283
3402
  const cdp = await globalServer.ensureCDPHandler(sessionId, rpcId);
3284
3403
  cdp[type](event, listenerId);
3285
3404
  }
@@ -3302,10 +3421,11 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
3302
3421
  function cloneByOwnProperties(value) {
3303
3422
  // Clones the value's properties into a new Object. The simpler approach of
3304
3423
  // Object.assign() won't work in the case that properties are not enumerable.
3305
- return Object.getOwnPropertyNames(value).reduce((clone, prop) => ({
3306
- ...clone,
3307
- [prop]: value[prop]
3308
- }), {});
3424
+ const clone = {};
3425
+ for (const prop of Object.getOwnPropertyNames(value)) {
3426
+ clone[prop] = value[prop];
3427
+ }
3428
+ return clone;
3309
3429
  }
3310
3430
  /**
3311
3431
  * Replacer function for serialization methods such as JS.stringify() or
@@ -0,0 +1,5 @@
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";function a(e){"@babel/helpers - typeof";return a=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},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const l=function(e,t,n){return e>=t&&e<=n};function u(e){return l(e,48,57)}function d(e){return u(e)||l(e,65,70)||l(e,97,102)}function f(e){return l(e,65,90)}function p(e){return l(e,97,122)}function m(e){return f(e)||p(e)}function h(e){return e>=128}function g(e){return m(e)||h(e)||e===95}function _(e){return g(e)||u(e)||e===45}function ee(e){return l(e,0,8)||e===11||l(e,14,31)||e===127}function v(e){return e===10}function y(e){return v(e)||e===9||e===32}var b=class extends Error{constructor(e){super(e),this.name=`InvalidCharacterError`}};function te(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),l(r,55296,56319)&&l(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 x(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 ne(e){let t=te(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},f=function(){if(p(),s(),y(i)){for(;y(o());)s();return new ae}else if(i===34)return b();else if(i===35)if(_(o())||C(o(1),o(2))){let e=new De(``);return E(o(1),o(2),o(3))&&(e.type=`id`),e.value=Fe(),e}else return new w(i);else if(i===36)return o()===61?(s(),new be):new w(i);else if(i===39)return b();else if(i===40)return new he;else if(i===41)return new ge;else if(i===42)return o()===61?(s(),new xe):new w(i);else if(i===43)return D()?(c(),m()):new w(i);else if(i===44)return new ue;else if(i===45)return D()?(c(),m()):o(1)===45&&o(2)===62?(s(2),new se):Ne()?(c(),h()):new w(i);else if(i===46)return D()?(c(),m()):new w(i);else if(i===58)return new ce;else if(i===59)return new le;else if(i===60)return o(1)===33&&o(2)===45&&o(3)===45?(s(3),new oe):new w(i);else if(i===64)return E(o(1),o(2),o(3))?new Ee(Fe()):new w(i);else if(i===91)return new pe;else if(i===92)return T()?(c(),h()):new w(i);else if(i===93)return new me;else if(i===94)return o()===61?(s(),new ye):new w(i);else if(i===123)return new de;else if(i===124)return o()===61?(s(),new ve):o()===124?(s(),new Se):new w(i);else if(i===125)return new fe;else if(i===126)return o()===61?(s(),new _e):new w(i);else if(u(i))return c(),m();else if(g(i))return c(),h();else if(l())return new Ce;else return new w(i)},p=function(){for(;o(1)===47&&o(2)===42;)for(s(2);;)if(s(),i===42&&o()===47){s();break}else if(l())return},m=function(){let e=Ie();if(E(o(1),o(2),o(3))){let t=new Me;return t.value=e.value,t.repr=e.repr,t.type=e.type,t.unit=Fe(),t}else if(o()===37){s();let t=new je;return t.value=e.value,t.repr=e.repr,t}else{let t=new Ae;return t.value=e.value,t.repr=e.repr,t.type=e.type,t}},h=function(){let e=Fe();if(e.toLowerCase()===`url`&&o()===40){for(s();y(o(1))&&y(o(2));)s();return o()===34||o()===39||y(o())&&(o(2)===34||o(2)===39)?new Te(e):ne()}else if(o()===40)return s(),new Te(e);else return new we(e)},b=function(e){e===void 0&&(e=i);let t=``;for(;s();)if(i===e||l())return new Oe(t);else if(v(i))return c(),new re;else i===92?l(o())||(v(o())?s():t+=x(S())):t+=x(i);throw Error(`Internal error`)},ne=function(){let e=new ke(``);for(;y(o());)s();if(l(o()))return e;for(;s();)if(i===41||l())return e;else if(y(i)){for(;y(o());)s();return o()===41||l(o())?(s(),e):(O(),new ie)}else if(i===34||i===39||i===40||ee(i))return O(),new ie;else if(i===92)if(T())e.value+=x(S());else return O(),new ie;else e.value+=x(i);throw Error(`Internal error`)},S=function(){if(s(),d(i)){let e=[i];for(let t=0;t<5&&d(o());t++)s(),e.push(i);y(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},C=function(e,t){return!(e!==92||v(t))},T=function(){return C(i,o())},E=function(e,t,n){return e===45?g(t)||t===45||C(t,n):g(e)?!0:e===92?C(e,t):!1},Ne=function(){return E(i,o(1),o(2))},Pe=function(e,t,n){return e===43||e===45?!!(u(t)||t===46&&u(n)):e===46?!!u(t):!!u(e)},D=function(){return Pe(i,o(1),o(2))},Fe=function(){let e=``;for(;s();)if(_(i))e+=x(i);else if(T())e+=x(S());else return c(),e;throw Error(`Internal parse error`)},Ie=function(){let e=``,t=`integer`;for((o()===43||o()===45)&&(s(),e+=x(i));u(o());)s(),e+=x(i);if(o(1)===46&&u(o(2)))for(s(),e+=x(i),s(),e+=x(i),t=`number`;u(o());)s(),e+=x(i);let n=o(1),r=o(2),a=o(3);if((n===69||n===101)&&u(r))for(s(),e+=x(i),s(),e+=x(i),t=`number`;u(o());)s(),e+=x(i);else if((n===69||n===101)&&(r===43||r===45)&&u(a))for(s(),e+=x(i),s(),e+=x(i),s(),e+=x(i),t=`number`;u(o());)s(),e+=x(i);let c=Le(e);return{type:t,value:c,repr:e}},Le=function(e){return+e},O=function(){for(;s();)if(i===41||l())return;else T()&&S()},k=0;for(;!l(o());)if(r.push(f()),k++,k>t.length*2)throw Error(`I'm infinite-looping!`);return r}var S=class{constructor(){c(this,`tokenType`,``),c(this,`value`,void 0)}toJSON(){return{token:this.tokenType}}toString(){return this.tokenType}toSource(){return`${this}`}},re=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`BADSTRING`)}},ie=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`BADURL`)}},ae=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`WHITESPACE`)}toString(){return`WS`}toSource(){return` `}},oe=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`CDO`)}toSource(){return`<!--`}},se=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`CDC`)}toSource(){return`-->`}},ce=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`:`)}},le=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`;`)}},ue=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`,`)}},C=class extends S{constructor(...e){super(...e),c(this,`value`,``),c(this,`mirror`,``)}},de=class extends C{constructor(){super(),c(this,`tokenType`,`{`),this.value=`{`,this.mirror=`}`}},fe=class extends C{constructor(){super(),c(this,`tokenType`,`}`),this.value=`}`,this.mirror=`{`}},pe=class extends C{constructor(){super(),c(this,`tokenType`,`[`),this.value=`[`,this.mirror=`]`}},me=class extends C{constructor(){super(),c(this,`tokenType`,`]`),this.value=`]`,this.mirror=`[`}},he=class extends C{constructor(){super(),c(this,`tokenType`,`(`),this.value=`(`,this.mirror=`)`}},ge=class extends C{constructor(){super(),c(this,`tokenType`,`)`),this.value=`)`,this.mirror=`(`}},_e=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`~=`)}},ve=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`|=`)}},ye=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`^=`)}},be=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`$=`)}},xe=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`*=`)}},Se=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`||`)}},Ce=class extends S{constructor(...e){super(...e),c(this,`tokenType`,`EOF`)}toSource(){return``}},w=class extends S{constructor(e){super(),c(this,`tokenType`,`DELIM`),c(this,`value`,``),this.value=x(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
+ `:this.value}},T=class extends S{constructor(...e){super(...e),c(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}},we=class extends T{constructor(e){super(),c(this,`tokenType`,`IDENT`),this.value=e}toString(){return`IDENT(${this.value})`}toSource(){return E(this.value)}},Te=class extends T{constructor(e){super(),c(this,`tokenType`,`FUNCTION`),c(this,`mirror`,void 0),this.value=e,this.mirror=`)`}toString(){return`FUNCTION(${this.value})`}toSource(){return`${E(this.value)}(`}},Ee=class extends T{constructor(e){super(),c(this,`tokenType`,`AT-KEYWORD`),this.value=e}toString(){return`AT(${this.value})`}toSource(){return`@${E(this.value)}`}},De=class extends T{constructor(e){super(),c(this,`tokenType`,`HASH`),c(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`?`#${E(this.value)}`:`#${Ne(this.value)}`}},Oe=class extends T{constructor(e){super(),c(this,`tokenType`,`STRING`),this.value=e}toString(){return`"${Pe(this.value)}"`}},ke=class extends T{constructor(e){super(),c(this,`tokenType`,`URL`),this.value=e}toString(){return`URL(${this.value})`}toSource(){return`url("${Pe(this.value)}")`}},Ae=class extends S{constructor(){super(),c(this,`tokenType`,`NUMBER`),c(this,`type`,void 0),c(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}},je=class extends S{constructor(){super(),c(this,`tokenType`,`PERCENTAGE`),c(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}%`}},Me=class extends S{constructor(){super(),c(this,`tokenType`,`DIMENSION`),c(this,`type`,void 0),c(this,`repr`,void 0),c(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=E(this.unit);return t[0].toLowerCase()===`e`&&(t[1]===`-`||l(t.charCodeAt(1),48,57))&&(t=`\\65 ${t.slice(1,t.length)}`),e+t}};function E(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 b(`Invalid character: the input contains U+0000.`);l(i,1,31)||i===127||r===0&&l(i,48,57)||r===1&&l(i,48,57)&&n===45?t+=`\\${i.toString(16)} `:i>=128||i===45||i===95||l(i,48,57)||l(i,65,90)||l(i,97,122)?t+=e[r]:t+=`\\${e[r]}`}return t}function Ne(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new b(`Invalid character: the input contains U+0000.`);r>=128||r===45||r===95||l(r,48,57)||l(r,65,90)||l(r,97,122)?t+=e[n]:t+=`\\${r.toString(16)} `}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 b(`Invalid character: the input contains U+0000.`);l(r,1,31)||r===127?t+=`\\${r.toString(16)} `:r===34||r===92?t+=`\\${e[n]}`:t+=e[n]}return t}var D=class extends Error{};function Fe(e,t){let n;try{n=ne(e),n[n.length-1]instanceof Ce||n.push(new Ce)}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 Ee||e instanceof re||e instanceof ie||e instanceof Se||e instanceof oe||e instanceof se||e instanceof le||e instanceof de||e instanceof fe||e instanceof ke||e instanceof je);if(r)throw new D(`Unsupported token "${r.toSource()}" while parsing selector "${e}"`);let i=0,a=new Set;function o(){return new D(`Unexpected token "${n[i].toSource()}" while parsing selector "${e}"`)}function s(){for(;n[i]instanceof ae;)i++}function c(e=i){return n[e]instanceof we}function l(e=i){return n[e]instanceof Oe}function u(e=i){return n[e]instanceof Ae}function d(e=i){return n[e]instanceof ue}function f(e=i){return n[e]instanceof he}function p(e=i){return n[e]instanceof ge}function m(e=i){return n[e]instanceof Te}function h(e=i){return n[e]instanceof w&&n[e].value===`*`}function g(e=i){return n[e]instanceof Ce}function _(e=i){return n[e]instanceof w&&[`>`,`+`,`~`].includes(n[e].value)}function ee(e=i){return d(e)||p(e)||g(e)||_(e)||n[e]instanceof ae}function v(){let e=[y()];for(;s(),d();)i++,e.push(y());return e}function y(){return s(),u()||l()?n[i++].value:b()}function b(){let e={simples:[]};for(s(),_()?e.simples.push({selector:{functions:[{name:`scope`,args:[]}]},combinator:``}):e.simples.push({selector:te(),combinator:``});;){if(s(),_())e.simples[e.simples.length-1].combinator=n[i++].value,s();else if(ee())break;e.simples.push({combinator:``,selector:te()})}return e}function te(){let e=``,r=[];for(;!ee();)if(c()||h())e+=n[i++].toSource();else if(n[i]instanceof De)e+=n[i++].toSource();else if(n[i]instanceof w&&n[i].value===`.`)if(i++,c())e+=`.${n[i++].toSource()}`;else throw o();else if(n[i]instanceof ce)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}(${x()})`,s(),!p())throw o();i++}else throw o();else if(n[i]instanceof pe){for(e+=`[`,i++;!(n[i]instanceof me)&&!g();)e+=n[i++].toSource();if(!(n[i]instanceof me))throw o();e+=`]`,i++}else throw o();if(!e&&!r.length)throw o();return{css:e||void 0,functions:r}}function x(){let e=``,t=1;for(;!g()&&((f()||m())&&t++,p()&&t--,t);)e+=n[i++].toSource();return e}let S=v();if(!g())throw o();if(S.some(e=>typeof e!=`object`||!(`simples`in e)))throw new D(`Error while parsing selector "${e}"`);return{selector:S,names:Array.from(a)}}const Ie=new Set([`internal:has`,`internal:has-not`,`internal:and`,`internal:or`,`internal:chain`,`left-of`,`right-of`,`above`,`below`,`near`]),Le=new Set([`left-of`,`right-of`,`above`,`below`,`near`]),O=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 k(e){let t=Be(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=Fe(e.body,O);n.push({name:`css`,body:t.selector,source:e.body});continue}if(Ie.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 D(`Malformed selector: ${e.name}=${e.body}`);if(t=n[0],n.length===2){if(typeof n[1]!=`number`||!Le.has(e.name))throw new D(`Malformed selector: ${e.name}=${e.body}`);r=n[1]}}catch{throw new D(`Malformed selector: ${e.name}=${e.body}`)}let i={name:e.name,source:e.body,body:{parsed:k(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&&Re(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(Ie.has(n[0].name))throw new D(`"${n[0].name}" selector cannot be first`);return{capture:t.capture,parts:n}}function Re(e,t){return A({parts:e})===A({parts:t})}function A(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 ze(e,t){let n=(e,r)=>{for(let i of e.parts)t(i,r),Ie.has(i.name)&&n(i.body.parsed,!0)};n(e,!1)}function Be(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 D(`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 j(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 D(`Unexpected end of selector while parsing selector \`${e}\``):new D(`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 D(`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 D(`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 D(`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 D(`Error while parsing selector \`${e}\` - selector cannot be empty`);return h}function Ve(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 M(e){let t=``;for(let n=0;n<e.length;n++)t+=Ue(e,n);return t}function He(e){return`"${M(e).replace(/\\ /g,` `)}"`}function Ue(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 N(e){return e.replace(/[\u200b\u00ad]/g,``).trim().replace(/\s+/g,` `)}function We(e){return e.replace(/(^|[^\\])(\\\\)*\\(['"`])/g,`$1$2$3`)}function Ge(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function P(e,t){return typeof e==`string`?`${JSON.stringify(e)}${t?`s`:`i`}`:Ge(e)}function F(e,t){return typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"${t?`s`:`i`}`:Ge(e)}function Ke(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 qe(e,t){return Ke(e,t,`…`)}function Je(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function I(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function Ye(e){let t=e;for(;t.parentNode;)t=t.parentNode;if(t.nodeType===11||t.nodeType===9)return t}function Xe(e){for(;e.parentElement;)e=e.parentElement;return I(e)}function Ze(e,t){for(;e;){let n=e.closest(t);if(n)return n;e=Xe(e)}}function L(e,t){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,t):void 0}function Qe(e,t){if(t??=L(e),!t)return!0;if(Element.prototype.checkVisibility&&Z.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 $e(e){let t=L(e);if(!t)return!0;if(t.display===`contents`){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&$e(t)||t.nodeType===3&&et(t))return!0;return!1}if(!Qe(e,t))return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0}function et(e){let t=e.ownerDocument.createRange();t.selectNode(e);let n=t.getBoundingClientRect();return n.width>0&&n.height>0}function R(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function tt(e){return e.hasAttribute(`aria-label`)||e.hasAttribute(`aria-labelledby`)}const nt=`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]`,rt=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 it(e,t){return[...rt].some(([n,r])=>!r?.has(t||``)&&e.hasAttribute(n))}function at(e){return!Number.isNaN(Number(String(e.getAttribute(`tabindex`))))}function ot(e){return!Wt(e)&&(st(e)||at(e))}function st(e){let t=R(e);return[`BUTTON`,`DETAILS`,`SELECT`,`TEXTAREA`].includes(t)?!0:t===`A`||t===`AREA`?e.hasAttribute(`href`):t===`INPUT`?!e.hidden:!1}const ct={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=>Ze(e,nt)?null:`contentinfo`,FORM:e=>tt(e)?`form`:null,H1:()=>`heading`,H2:()=>`heading`,H3:()=>`heading`,H4:()=>`heading`,H5:()=>`heading`,H6:()=>`heading`,HEADER:e=>Ze(e,nt)?null:`banner`,HR:()=>`separator`,HTML:()=>`document`,IMG:e=>e.getAttribute(`alt`)===``&&!e.getAttribute(`title`)&&!it(e)&&!at(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=V(e,e.getAttribute(`list`))[0];return t&&R(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=>tt(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=Ze(e,`table`),n=t?mt(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=Ze(e,`table`),n=t?mt(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},THEAD:()=>`rowgroup`,TIME:()=>`time`,TR:()=>`row`,UL:()=>`list`},lt={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 ut(e){let t=ct[R(e)]?.call(ct,e)||``;if(!t)return null;let n=e;for(;n;){let e=I(n),t=lt[R(n)];if(!t||!e||!t.includes(R(e)))break;let r=mt(e);if((r===`none`||r===`presentation`)&&!ht(e,r))return r;n=e}return t}const dt=`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(`.`),ft=[`command`,`composite`,`input`,`landmark`,`range`,`roletype`,`section`,`sectionhead`,`select`,`structure`,`widget`,`window`],pt=dt.filter(e=>!ft.includes(e));function mt(e){return(e.getAttribute(`role`)||``).split(` `).map(e=>e.trim()).find(e=>pt.includes(e))||null}function ht(e,t){return it(e,t)||ot(e)}function z(e){let t=mt(e);if(!t)return ut(e);if(t===`none`||t===`presentation`){let t=ut(e);if(ht(e,t))return t}return t}function gt(e){return e===null?void 0:e.toLowerCase()===`true`}function _t(e){return[`STYLE`,`SCRIPT`,`NOSCRIPT`,`TEMPLATE`].includes(R(e))}function B(e){if(_t(e))return!0;let t=L(e),n=e.nodeName===`SLOT`;if(t?.display===`contents`&&!n){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&!B(t)||t.nodeType===3&&et(t))return!1;return!0}return!(e.nodeName===`OPTION`&&e.closest(`select`))&&!n&&!Qe(e,t)?!0:vt(e)}function vt(e){let t=Qt?.get(e);if(t===void 0){if(t=!1,e.parentElement&&e.parentElement.shadowRoot&&!e.assignedSlot&&(t=!0),!t){let n=L(e);t=!n||n.display===`none`||gt(e.getAttribute(`aria-hidden`))===!0}if(!t){let n=I(e);n&&(t=vt(n))}Qt?.set(e,t)}return t}function V(e,t){if(!t)return[];let n=Ye(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 H(e){return e.trim()}function U(e){return e.split(`\xA0`).map(e=>e.replace(/\r\n/g,`
3
+ `).replace(/[\u200b\u00ad]/g,``).replace(/\s\s*/g,` `)).join(`\xA0`).trim()}function yt(e,t){let n=[...e.querySelectorAll(t)];for(let r of V(e,e.getAttribute(`aria-owns`)))r.matches(t)&&n.push(r),n.push(...r.querySelectorAll(t));return n}function bt(e,t){let n=t===`::before`?$t:en;if(n?.has(e))return n?.get(e)||``;let r=xt(L(e,t));return n&&n.set(e,r),r}function xt(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 St(e){let t=e.getAttribute(`aria-labelledby`);return t===null?null:V(e,t)}function Ct(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 wt(e,t){let n=t?Yt:Jt,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(z(e)||``)||(r=U(W(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 Tt(e,t){let n=Zt,r=n?.get(e);return r===void 0&&(r=``,r=e.hasAttribute(`aria-describedby`)?U(V(e,e.getAttribute(`aria-describedby`)).map(e=>W(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:B(e)}})).join(` `)):e.hasAttribute(`aria-description`)?U(e.getAttribute(`aria-description`)||``):U(e.getAttribute(`title`)||``),n?.set(e,r)),r}const Et=[`application`,`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`slider`,`spinbutton`,`textbox`,`tree`,`columnheader`,`rowheader`,`searchbox`,`switch`,`treegrid`];function Dt(e){let t=z(e)||``;if(!t||!Et.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 Ot(e){return`validity`in e?e.validity?.valid===!1:!1}function kt(e){let t=Xt,n=Xt?.get(e);if(n===void 0){n=``;let r=Dt(e)!==`false`,i=Ot(e);(r||i)&&(n=V(e,e.getAttribute(`aria-errormessage`)).map(e=>U(W(e,{visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:B(e)}}))).join(` `).trim()),t?.set(e,n)}return n}function W(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(_t(e)||!n&&B(e))return t.visitedElements.add(e),``}let r=St(e);if(!t.embeddedInLabelledBy){let e=(r||[]).map(e=>W(e,{...t,embeddedInLabelledBy:{element:e,hidden:B(e)},embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0})).join(` `);if(e)return e}let i=z(e)||``,a=R(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`?yt(e,`*`).find(e=>z(e)===`listbox`):e;r=t?yt(t,`[aria-selected="true"]`).filter(e=>z(e)===`option`):[]}return!r.length&&a===`INPUT`?e.value:r.map(e=>W(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(H(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 H(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 qt(n,t);let r=e.getAttribute(`alt`)||``;if(H(r))return r;let i=e.getAttribute(`title`)||``;return H(i)?i:`Submit`}if(!r&&a===`BUTTON`){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return qt(n,t)}if(!r&&a===`OUTPUT`){t.visitedElements.add(e);let n=e.labels||[];return n.length?qt(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 qt(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(R(t)===`LEGEND`)return W(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:B(t)}});return e.getAttribute(`title`)||``}if(!r&&a===`FIGURE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(R(t)===`FIGCAPTION`)return W(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:B(t)}});return e.getAttribute(`title`)||``}if(a===`IMG`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return H(n)?n:e.getAttribute(`title`)||``}if(a===`TABLE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(R(t)===`CAPTION`)return W(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:B(t)}});let r=e.getAttribute(`summary`)||``;if(r)return r}if(a===`AREA`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return H(n)?n:e.getAttribute(`title`)||``}if(a===`SVG`||e.ownerSVGElement){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(R(t)===`TITLE`&&t.ownerSVGElement)return W(t,{...n,embeddedInLabelledBy:{element:t,hidden:B(t)}})}if(e.ownerSVGElement&&a===`A`){let n=e.getAttribute(`xlink:title`)||``;if(H(n))return t.visitedElements.add(e),n}}let s=a===`SUMMARY`&&![`presentation`,`none`].includes(i);if(Ct(i,t.embeddedInTargetElement===`descendant`)||s||t.embeddedInLabelledBy||t.embeddedInDescribedBy||t.embeddedInLabel||t.embeddedInNativeTextAlternative){t.visitedElements.add(e);let r=At(e,n);if(t.embeddedInTargetElement===`self`?H(r):r)return r}if(![`presentation`,`none`].includes(i)||a===`IFRAME`){t.visitedElements.add(e);let n=e.getAttribute(`title`)||``;if(H(n))return n}return t.visitedElements.add(e),``}function At(e,t){let n=[],r=(e,r)=>{if(!(r&&e.assignedSlot))if(e.nodeType===1){let r=L(e)?.display||`inline`,i=W(e,t);(r!==`inline`||e.nodeName===`BR`)&&(i=` `+i+` `),n.push(i)}else e.nodeType===3&&n.push(e.textContent||``)};n.push(bt(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 V(e,e.getAttribute(`aria-owns`)))r(t,!0)}return n.push(bt(e,`::after`)),n.join(``)}const jt=[`gridcell`,`option`,`row`,`tab`,`rowheader`,`columnheader`,`treeitem`];function Mt(e){return R(e)===`OPTION`?e.selected:jt.includes(z(e)||``)?gt(e.getAttribute(`aria-selected`))===!0:!1}const Nt=[`checkbox`,`menuitemcheckbox`,`option`,`radio`,`switch`,`menuitemradio`,`treeitem`];function Pt(e){let t=Ft(e);return t===`error`?!1:t}function Ft(e,t){let n=R(e);if(n===`INPUT`&&e.indeterminate)return`mixed`;if(n===`INPUT`&&[`checkbox`,`radio`].includes(e.type))return e.checked;if(Nt.includes(z(e)||``)){let t=e.getAttribute(`aria-checked`);return t===`true`?!0:t===`mixed`?`mixed`:!1}return`error`}const It=[`button`];function Lt(e){if(It.includes(z(e)||``)){let t=e.getAttribute(`aria-pressed`);if(t===`true`)return!0;if(t===`mixed`)return`mixed`}return!1}const Rt=[`application`,`button`,`checkbox`,`combobox`,`gridcell`,`link`,`listbox`,`menuitem`,`row`,`rowheader`,`tab`,`treeitem`,`columnheader`,`menuitemcheckbox`,`menuitemradio`,`rowheader`,`switch`];function zt(e){if(R(e)===`DETAILS`)return e.open;if(Rt.includes(z(e)||``)){let t=e.getAttribute(`aria-expanded`);return t===null?`none`:t===`true`}return`none`}const Bt=[`heading`,`listitem`,`row`,`treeitem`];function Vt(e){let t={H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[R(e)];if(t)return t;if(Bt.includes(z(e)||``)){let t=e.getAttribute(`aria-level`),n=t===null?NaN:Number(t);if(Number.isInteger(n)&&n>=1)return n}return 0}const Ht=`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 Ut(e){return Wt(e)||Kt(e)}function Wt(e){return[`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`OPTION`,`OPTGROUP`].includes(e.tagName)&&(e.hasAttribute(`disabled`)||Gt(e))}function Gt(e){let t=e?.closest(`FIELDSET[DISABLED]`);if(!t)return!1;let n=t.querySelector(`:scope > LEGEND`);return!n||!n.contains(e)}function Kt(e){if(!e)return!1;if(Ht.includes(z(e)||``)){let t=(e.getAttribute(`aria-disabled`)||``).toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}return Kt(I(e))}function qt(e,t){return[...e].map(e=>W(e,{...t,embeddedInLabel:{element:e,hidden:B(e)},embeddedInNativeTextAlternative:void 0,embeddedInLabelledBy:void 0,embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0})).filter(e=>!!e).join(` `)}let Jt,Yt,Xt,Zt,Qt,$t,en,tn=0;function nn(){++tn,Jt??=new Map,Yt??=new Map,Zt??=new Map,Xt??=new Map,Qt??=new Map,$t??=new Map,en??=new Map}function rn(){--tn||(Jt=void 0,Yt=void 0,Zt=void 0,Xt=void 0,Qt=void 0,$t=void 0,en=void 0)}function an(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):!1}function on(e){let t=e.ownerDocument;return e.nodeName===`SCRIPT`||e.nodeName===`NOSCRIPT`||e.nodeName===`STYLE`||t.head&&t.head.contains(e)}function G(e,t){let n=e.get(t);if(n===void 0){if(n={full:``,normalized:``,immediate:[]},!on(t)){let r=``;if(t instanceof HTMLInputElement&&(t.type===`submit`||t.type===`button`))n={full:t.value,normalized:N(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+=G(e,i).full));r&&n.immediate.push(r),t.shadowRoot&&(n.full+=G(e,t.shadowRoot).full),n.full&&(n.normalized=N(n.full))}}e.set(t,n)}return n}function sn(e,t,n){if(on(t)||!n(G(e,t)))return`none`;for(let r=t.firstChild;r;r=r.nextSibling)if(r.nodeType===Node.ELEMENT_NODE&&n(G(e,r)))return`selfAndChildren`;return t.shadowRoot&&n(G(e,t.shadowRoot))?`selfAndChildren`:`self`}function cn(e,t){let n=St(t);if(n)return n.map(t=>G(e,t));let r=t.getAttribute(`aria-label`);if(r!==null&&r.trim())return[{full:r,normalized:N(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=>G(e,t))}return[]}const ln=[`selected`,`checked`,`pressed`,`expanded`,`level`,`disabled`,`name`,`include-hidden`];ln.sort();function un(e,t,n){if(!t.includes(n))throw Error(`"${e}" attribute is only supported for roles: ${t.slice().sort().map(e=>`"${e}"`).join(`, `)}`)}function K(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 q(e,t){if(!t.includes(e.op))throw Error(`"${e.name}" does not support "${e.op}" matcher`)}function dn(e,t){let n={role:t};for(let r of e)switch(r.name){case`checked`:un(r.name,Nt,t),K(r,[!0,!1,`mixed`]),q(r,[`<truthy>`,`=`]),n.checked=r.op===`<truthy>`?!0:r.value;break;case`pressed`:un(r.name,It,t),K(r,[!0,!1,`mixed`]),q(r,[`<truthy>`,`=`]),n.pressed=r.op===`<truthy>`?!0:r.value;break;case`selected`:un(r.name,jt,t),K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.selected=r.op===`<truthy>`?!0:r.value;break;case`expanded`:un(r.name,Rt,t),K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.expanded=r.op===`<truthy>`?!0:r.value;break;case`level`:if(un(r.name,Bt,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`:K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.disabled=r.op===`<truthy>`?!0: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`:K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.includeHidden=r.op===`<truthy>`?!0:r.value;break;default:throw Error(`Unknown attribute "${r.name}", must be one of ${ln.map(e=>`"${e}"`).join(`, `)}.`)}return n}function fn(e,t,n){let r=[],i=e=>{if(z(e)===t.role&&!(t.selected!==void 0&&Mt(e)!==t.selected)&&!(t.checked!==void 0&&Pt(e)!==t.checked)&&!(t.pressed!==void 0&&Lt(e)!==t.pressed)&&!(t.expanded!==void 0&&zt(e)!==t.expanded)&&!(t.level!==void 0&&Vt(e)!==t.level)&&!(t.disabled!==void 0&&Ut(e)!==t.disabled)&&!(!t.includeHidden&&B(e))){if(t.name!==void 0){let r=N(wt(e,!!t.includeHidden));if(typeof t.name==`string`&&(t.name=N(t.name)),n&&!t.exact&&t.nameOp===`=`&&(t.nameOp=`*=`),!an(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 pn(e){return{queryAll:(t,n)=>{let r=j(n),i=r.name.toLowerCase();if(!i)throw Error(`Role must not be empty`);let a=dn(r.attributes,i);nn();try{return fn(t,a,e)}finally{rn()}}}}function mn(e,t,n=!1){return hn(e,t,n)[0]}function hn(e,t,n=!1,r=20,i){try{return J(new vn[e](i),k(t),n,r)}catch{return[t]}}function J(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}=_n(n.body);a.push([e.generateLocator(s,`text`,r,{exact:t})]);continue}if(n.name===`internal:has-text`){let{exact:t,text:r}=_n(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}=_n(n.body);if(!t){a.push([e.generateLocator(s,`has-not-text`,r,{exact:t})]);continue}}if(n.name===`internal:has`){let t=J(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=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`hasNot`,t)));continue}if(n.name===`internal:and`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`and`,t)));continue}if(n.name===`internal:or`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`or`,t)));continue}if(n.name===`internal:chain`){let t=J(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}=_n(n.body);a.push([e.generateLocator(s,`label`,r,{exact:t})]);continue}if(n.name===`internal:role`){let t=j(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}=j(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}=j(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=A({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}=_n(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=A({parts:[n]},!0);f=e.generateLocator(s,c,t)}a.push([d,f].filter(Boolean))}return gn(e,a,r)}function gn(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 _n(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 vn={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=[];yn(r.name)?e.push(`name: ${this.regexToSourceString(r.name)}`):typeof r.name==`string`&&(e.push(`name: ${this.quote(r.name)}`),r.exact!=null&&Z.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 We(String(e))}toCallWithExact(e,t,n){return yn(t)?`${e}(${this.regexToSourceString(t)})`:n!=null&&Z.options.exact!==n?`${e}(${this.quote(t)}, { exact: ${n} })`:`${e}(${this.quote(t)})`}toHasText(e){return yn(e)?this.regexToSourceString(e):this.quote(e)}toTestIdValue(e){return yn(e)?this.regexToSourceString(e):this.quote(e)}quote(e){return Ve(e,this.preferredQuote??`'`)}}};function yn(e){return e instanceof RegExp}const bn=new Map,xn=new Map,Sn=1e4;function Cn(e,t,n){e._evaluator.begin(),nn();try{return jn(Tn(e,t,n)||kn(e,t,n))}finally{bn.clear(),xn.clear(),rn(),e._evaluator.end()}}function wn(e){return e.filter(e=>e[0].selector[0]!==`/`)}function Tn(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?Dn(e,r,r===t):[];r!==t&&(s=wn(s));let c=En(e,r,n).map(e=>[e]),l=Mn(e,t.ownerDocument,r,[...s,...c],o);s=wn(s);let u=t=>{let n=a&&!t.length,s=[...t,...c].filter(e=>l?Y(e)<Y(l):!0),u=s[0];if(u)for(let t=I(r);t;t=I(t)){let a=i(t,n);if(!a||l&&Y([...a,...u])>=Y(l))continue;if(u=Mn(e,t,r,s,o),!u)return;let c=[...a,...u];(!l||Y(c)<Y(l))&&(l=c)}};return u(s),r===t&&s.length&&u([]),l},i=(e,t)=>{let n=t?bn:xn,i=n.get(e);return i===void 0&&(i=r(e,t),n.set(e,i)),i};return r(t,!n.noText)}function En(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}=${He(t.getAttribute(e))}]`,score:2});if(!n.noCSSId){let e=t.getAttribute(`id`);e&&!Nn(e)&&r.push({engine:`css`,selector:On(e),score:500})}if(r.push({engine:`css`,selector:M(t.nodeName.toLowerCase()),score:530}),t.nodeName===`IFRAME`){for(let e of[`name`,`title`])t.getAttribute(e)&&r.push({engine:`css`,selector:`${M(t.nodeName.toLowerCase())}[${e}=${He(t.getAttribute(e))}]`,score:10});return t.getAttribute(n.testIdAttributeName)&&r.push({engine:`css`,selector:`[${n.testIdAttributeName}=${He(t.getAttribute(n.testIdAttributeName))}]`,score:1}),An([r]),r}if(t.getAttribute(n.testIdAttributeName)&&r.push({engine:`internal:testid`,selector:`[${n.testIdAttributeName}=${F(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=${F(e.placeholder,!0)}]`,score:105});for(let t of X(e.placeholder))r.push({engine:`internal:attr`,selector:`[placeholder=${F(t.text,!1)}]`,score:100-t.scoreBouns})}}let i=cn(e._evaluator._cacheText,t);for(let e of i){let t=e.normalized;r.push({engine:`internal:label`,selector:P(t,!0),score:125});for(let e of X(t))r.push({engine:`internal:label`,selector:P(e.text,!1),score:120-e.scoreBouns})}let a=z(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:`${M(t.nodeName.toLowerCase())}[name=${He(t.getAttribute(`name`))}]`,score:520}),[`INPUT`,`TEXTAREA`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&t.getAttribute(`type`)&&r.push({engine:`css`,selector:`${M(t.nodeName.toLowerCase())}[type=${He(t.getAttribute(`type`))}]`,score:520}),[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&r.push({engine:`css`,selector:M(t.nodeName.toLowerCase()),score:521}),An([r]),r}function Dn(e,t,n){if(t.nodeName===`SELECT`)return[];let r=[],i=t.getAttribute(`title`);if(i){r.push([{engine:`internal:attr`,selector:`[title=${F(i,!0)}]`,score:205}]);for(let e of X(i))r.push([{engine:`internal:attr`,selector:`[title=${F(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=${F(a,!0)}]`,score:165}]);for(let e of X(a))r.push([{engine:`internal:attr`,selector:`[alt=${F(e.text,!1)}]`,score:160-e.scoreBouns}])}let o=G(e._evaluator._cacheText,t).normalized;if(o){let e=X(o);if(n){o.length<=80&&r.push([{engine:`internal:text`,selector:P(o,!0),score:185}]);for(let t of e)r.push([{engine:`internal:text`,selector:P(t.text,!1),score:180-t.scoreBouns}])}let i={engine:`css`,selector:M(t.nodeName.toLowerCase()),score:530};for(let t of e)r.push([i,{engine:`internal:has-text`,selector:P(t.text,!1),score:180-t.scoreBouns}]);if(o.length<=80){let e=RegExp(`^${Je(o)}$`);r.push([i,{engine:`internal:has-text`,selector:P(e,!1),score:250}])}}let s=z(t);if(s&&![`none`,`presentation`].includes(s)){let e=wt(t,!1);if(e){r.push([{engine:`internal:role`,selector:`${s}[name=${F(e,!0)}]`,score:145}]);for(let t of X(e))r.push([{engine:`internal:role`,selector:`${s}[name=${F(t.text,!1)}]`,score:140-t.scoreBouns}])}}return An(r),r}function On(e){return/^[a-z][\w\-]+$/i.test(e)?`#${e}`:`[id="${M(e)}"]`}function kn(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:Sn}]}for(let e=t;e&&e!==r;e=I(e)){let t=e.nodeName.toLowerCase(),r=``;if(e.id&&!n.noCSSId){let t=On(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=`.${M(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?M(t):`${M(t)}:nth-child(${1+n.indexOf(e)})`,c=a(i);if(c)return o(c);r||=i}else r||=M(t);i.unshift(r)}return o(a())}function An(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 jn(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 Y(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].score*(e.length-n);return t}function Mn(e,t,n,r,i){let a=r.map(e=>({tokens:e,score:Y(e)}));a.sort((e,t)=>e.score-t.score);let o=null;for(let{tokens:r}of a){let a=e.parseSelector(jn(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:Sn};o=[...r,l]}return o}function Nn(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 Pn(e,t){if(e.length<=t)return e;e=e.substring(0,t);let n=e.match(/^(.*)\b(.+)$/);return n?n[1].trimEnd():``}function X(e){let t=[];{let n=e.match(/^([\d.,]+)[^.,\w]/),r=n?n[1].length:0;if(r){let n=Pn(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=Pn(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:Pn(e,80),scoreBouns:0}),t.push({text:Pn(e,30),scoreBouns:1})),t=t.filter(e=>e.text),t.length||t.push({text:e.substring(0,80),scoreBouns:0}),t}function Fn(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 In(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 Ln(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 Rn(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 zn(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 Bn=[`left-of`,`right-of`,`above`,`below`,`near`];function Vn(e,t,n,r){let i=t.getBoundingClientRect(),a={"left-of":In,"right-of":Fn,above:Ln,below:Rn,near:zn}[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 Hn=class{constructor(e){c(this,`_engines`,new Map),c(this,`_cacheQueryCSS`,new Map),c(this,`_cacheMatches`,new Map),c(this,`_cacheQuery`,new Map),c(this,`_cacheMatchesSimple`,new Map),c(this,`_cacheMatchesParents`,new Map),c(this,`_cacheCallMatches`,new Map),c(this,`_cacheCallQuery`,new Map),c(this,`_cacheQuerySimple`,new Map),c(this,`_cacheText`,new Map),c(this,`_scoreMap`,void 0),c(this,`_retainCacheCounter`,0);for(let[t,n]of e)this._engines.set(t,n);this._engines.set(`not`,Kn),this._engines.set(`is`,Un),this._engines.set(`where`,Un),this._engines.set(`has`,Wn),this._engines.set(`scope`,Gn),this._engines.set(`light`,qn),this._engines.set(`visible`,Jn),this._engines.set(`text`,Yn),this._engines.set(`text-is`,Xn),this._engines.set(`text-matches`,Zn),this._engines.set(`has-text`,Qn),this._engines.set(`right-of`,$n(`right-of`)),this._engines.set(`left-of`,$n(`left-of`)),this._engines.set(`above`,$n(`above`)),this._engines.set(`below`,$n(`below`)),this._engines.set(`near`,$n(`near`)),this._engines.set(`nth-match`,er);let t=[...this._engines.keys()];t.sort();let n=[...O];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(Un,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(Un,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=I(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?!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=tr(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===`+`){let a=nr(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===``){let a=tr(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=tr(a,r)}return!1}if(a===`~`){let a=nr(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=nr(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=tr(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 Un={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:rr(r)}},Wn={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}},Gn={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]:[]}},Kn={matches(e,t,n,r){if(t.length===0)throw Error(`"not" engine expects non-empty selector list`);return!r.matches(e,t,n)}},qn={query(e,t,n){return n.query({...e,pierceShadow:!1},t)},matches(e,t,n,r){return r.matches(e,t,{...n,pierceShadow:!1})}},Jn={matches(e,t,n,r){if(t.length)throw Error(`"visible" engine expects no arguments`);return $e(e)}},Yn={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text" engine expects a single string`);let i=N(t[0]).toLowerCase();return sn(r._cacheText,e,e=>e.normalized.toLowerCase().includes(i))===`self`}},Xn={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text-is" engine expects a single string`);let i=N(t[0]);return sn(r._cacheText,e,e=>!i&&!e.immediate.length?!0:e.immediate.some(e=>N(e)===i))!==`none`}},Zn={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 sn(r._cacheText,e,e=>i.test(e.full))===`self`}},Qn={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"has-text" engine expects a single string`);if(on(e))return!1;let i=N(t[0]).toLowerCase();return(e=>e.normalized.toLowerCase().includes(i))(G(r._cacheText,e))}};function $n(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=Vn(e,t,i.query(r,o),a);return s===void 0?!1:(i._markScore(t,s),!0)}}}const er={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=Un.query(e,t.slice(0,t.length-1),n);return r--,r<i.length?[i[r]]:[]}};function tr(e,t){if(e!==t.scope)return t.pierceShadow?I(e):e.parentElement||void 0}function nr(e,t){if(e!==t.scope)return e.previousElementSibling||void 0}function rr(e){let t=new Map,n=[],r=[];function i(e){let r=t.get(e);if(r)return r;let a=I(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 ir(e,t,n){return`internal:attr=[${e}=${F(t,n?.exact??Z.options.exact)}]`}function ar(e,t){return`internal:testid=[${e}=${F(t,!0)}]`}function or(e,t){return`internal:label=${P(e,t?.exact??Z.options.exact)}`}function sr(e,t){return ir(`alt`,e,t)}function cr(e,t){return ir(`title`,e,t)}function lr(e,t){return ir(`placeholder`,e,t)}function ur(e,t){return`internal:text=${P(e,t?.exact??Z.options.exact)}`}function dr(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`,F(t.name,t.exact??Z.options.exact)]),t.pressed!==void 0&&n.push([`pressed`,String(t.pressed)]),`internal:role=${e}${n.map(([e,t])=>`[${e}=${t}]`).join(``)}`}var Z=class e{static create(t){return Object.assign(e.options,t),e.singleton||=new e}constructor(){c(this,`_engines`,void 0),c(this,`_evaluator`,void 0),this._evaluator=new Hn(new Map),this._engines=new Map,this._engines.set(`xpath`,_r),this._engines.set(`xpath:light`,_r),this._engines.set(`role`,pn(!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`,pn(!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(dr(e,t));return this.querySelectorAll(r,n)}queryAllByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(or(e,t));return this.querySelectorAll(r,n)}queryAllByTestId(t,n=document.documentElement){let r=this.parseSelector(ar(e.options.testIdAttribute,t));return this.querySelectorAll(r,n)}queryAllByText(e,t,n=document.documentElement){let r=this.parseSelector(ur(e,t));return this.querySelectorAll(r,n)}queryAllByTitle(e,t,n=document.documentElement){let r=this.parseSelector(cr(e,t));return this.querySelectorAll(r,n)}queryAllByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(lr(e,t));return this.querySelectorAll(r,n)}queryAllByAltText(e,t,n=document.documentElement){let r=this.parseSelector(sr(e,t));return this.querySelectorAll(r,n)}queryByRole(e,t,n=document.documentElement){let r=this.parseSelector(dr(e,t));return this.querySelector(r,n,!1)}queryByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(or(e,t));return this.querySelector(r,n,!1)}queryByTestId(t,n=document.documentElement){let r=this.parseSelector(ar(e.options.testIdAttribute,t));return this.querySelector(r,n,!1)}queryByText(e,t,n=document.documentElement){let r=this.parseSelector(ur(e,t));return this.querySelector(r,n,!1)}queryByTitle(e,t,n=document.documentElement){let r=this.parseSelector(cr(e,t));return this.querySelector(r,n,!1)}queryByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(lr(e,t));return this.querySelector(r,n,!1)}queryByAltText(e,t,n=document.documentElement){let r=this.parseSelector(sr(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 ${mn(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
4
+ ...`),this.createStacklessError(`strict mode violation: ${mn(`javascript`,A(e))} resolved to ${t.length} elements:${r.join(``)}\n`)}generateSelectorSimple(t,n){return Cn(this,t,{...n,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let t=k(e);return ze(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 fr(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return fr(`<${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&&pr.has(r)?n.push(` ${r}`):n.push(` ${r}="${i}"`))}n.sort((e,t)=>e.length-t.length);let r=qe(n.join(``),500);if(mr.has(t.nodeName))return fr(`<${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 fr(`<${t.nodeName.toLowerCase()}${r}>${qe(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:A(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(rr(new Set([...n,...e])))}else if(Bn.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=Vn(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}=gr(r,t),o=[],s=null,c=e=>{if(a===`lax`&&s&&s.contains(e))return!1;let n=sn(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=j(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&&$e(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}=gr(t,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>cn(this._evaluator._cacheText,e).some(e=>n(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=G(this._evaluator._cacheText,n),{matcher:i}=gr(t,!0);return i(r)?[n]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=G(this._evaluator._cacheText,n),{matcher:i}=gr(t,!0);return i(r)?[]:[n]}}}};c(Z,`options`,{testIdAttribute:`data-testid`,browser:`chromium`,exact:!1}),c(Z,`singleton`,null);function fr(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}const pr=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),mr=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function hr(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 gr(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):hr,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=N(e),r?t?{kind:`strict`,matcher:t=>t.normalized===e}:{matcher:t=>!e&&!t.immediate.length?!0:t.immediate.some(t=>N(t)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:t=>t.normalized.toLowerCase().includes(e)})}const _r={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}},vr=globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;function yr(e){let t=br().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 Q(){return window.__vitest_browser_runner__}function br(){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}const xr=[`:hover`,`:active`,`:focus`,`:focus-visible`,`:focus-within`];function Sr(){return Math.random().toString(36).slice(2)}async function Cr(e,t){let n=Q().browserTraceAttempts.get(e.id),r=vr()-n.startTime,i=wr(t.element),a={...t,startTime:r,snapshot:i},{retry:o,repeats:s}=n,{recordCanvas:c}=Q().config.browser.traceView,l={retry:o,repeats:s,recordCanvas:c,entries:[a]};await br().rpc.triggerCommand(Q().sessionId,`__vitest_recordBrowserTrace`,void 0,[{testId:e.id,data:l}])}function wr(e){let{snapshot:t,createMirror:n}=Q().browserTraceDomSnapshot,r=Q().config.browser.traceView,i=Q().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`${Q().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||br().config.browser.providerOptions.actionTimeout!=null)return e;let t=Q().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=vr(),a=n+r,o=Math.floor(a-i);return o<=0||(e.timeout=o-100),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=Q().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};break}return{delta:t,times:e.times}}r._asLocator=mn;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 $=Z.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});Q().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 yr(async t=>{await Q().commands.triggerCommand(`__vitest_wheel`,[this.serialize(),Rr(e)],t);let n=Q().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 yr(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 Q().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=br().current,r=!!n&&Q().activeTraceTaskIds.has(n.id),i=!!n&&Q().browserTraceAttempts.has(n.id);return!n||!r&&!i?Promise.resolve():yr(async a=>(i&&await Cr(n,{name:e,kind:t?.kind??`mark`,element:this.serialize(),stack:t?.stack??a?.stack}),r?Q().commands.triggerCommand(`__vitest_markTrace`,[{name:e,element:this.serialize(),stack:t?.stack??a?.stack}],a):Promise.resolve()))}getByRole(e,t){return this.locator(dr(e,t))}getByAltText(e,t){return this.locator(sr(e,t))}getByLabelText(e,t){return this.locator(or(e,t))}getByPlaceholder(e,t){return this.locator(lr(e,t))}getByTestId(t){return this.locator(ar(e.config.browser.locators.testIdAttribute,t))}getByText(e,t){return this.locator(ur(e,t))}getByTitle(e,t){return this.locator(cr(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||=mn(`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}):yr(n=>Wr({name:e,arguments:t,errorSource:n}))}}function Wr(e){return Q().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 ${mn(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
5
+ ...`),Error(`strict mode violation: ${e.asLocator()} resolved to ${t.length} elements:${r.join(``)}\n`)}export{kr as A,vr as B,br as C,Sr as D,Cr as E,Tr as F,yr as G,sr as H,or as I,lr as J,dr as K,Ur as L,ar as M,ur as N,cr as O,Ar as P,$ as Q,Wr as R,c as _,wt as a,nn as b,Pt as c,Ht as d,rn as e,Ut as f,z as g,Rt as h,B as i,zt as j,Nt as k,Bt as l,Vt as m,N as n,It as o,Lt as p,jt as q,Mt as r,L as s,bt as t,Q as u,$e as v,Tt as w,kt as x,M as y,Fr as z};
package/dist/locators.js CHANGED
@@ -1 +1 @@
1
- export{L as Locator,E as convertElementToCssSelector,F as ensureAwaited,G as getByAltTextSelector,H as getByLabelSelector,I as getByPlaceholderSelector,J as getByRoleSelector,K as getByTestIdSelector,M as getByTextSelector,N as getByTitleSelector,O as getIframeScale,A as processTimeoutOptions,P as selectorEngine,Q as triggerCommandWithTrace}from"./locators-CesZ2RSY.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-CPBpJv8y.js";import"vitest/browser";import"vitest/internal/browser";
@@ -1,6 +1,7 @@
1
1
  import type { ScreenshotComparatorRegistry, ScreenshotMatcherOptions, SerializedLocator } from "../../../context.js";
2
2
  export type ScreenshotMatcherArguments<ComparatorName extends keyof ScreenshotComparatorRegistry = keyof ScreenshotComparatorRegistry> = [name: string, testName: string, options: ScreenshotMatcherOptions<ComparatorName> & {
3
- element: SerializedLocator;
3
+ element?: SerializedLocator;
4
+ target?: "element" | "page";
4
5
  screenshotOptions?: ScreenshotMatcherOptions<ComparatorName>["screenshotOptions"] & {
5
6
  mask?: readonly SerializedLocator[];
6
7
  };