@burdenoff/ui-engine 2026.1127.1 → 2026.1127.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +68 -3
  2. package/dist/capture.js +3 -2
  3. package/dist/dom-runtime/actions.d.ts +65 -0
  4. package/dist/dom-runtime/iife.d.ts +1 -0
  5. package/dist/dom-runtime/index.d.ts +7 -0
  6. package/dist/dom-runtime/runtime.d.ts +79 -0
  7. package/dist/dom-runtime.d.ts +2 -0
  8. package/dist/dom-runtime.iife.js +1 -0
  9. package/dist/dom-runtime.js +535 -0
  10. package/dist/{index-05zgh18g.js → index-2kgsgn1c.js} +1 -1
  11. package/dist/{index-phd8yhyg.js → index-bnvmt4wf.js} +7 -5
  12. package/dist/{index-c6pmt2rg.js → index-cs6acyjn.js} +6 -59
  13. package/dist/index-mgztm37r.js +57 -0
  14. package/dist/index-q1b0j9yr.js +1349 -0
  15. package/dist/index-zwrxw3zp.js +1988 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +180 -6
  18. package/dist/recording.js +1 -1
  19. package/dist/replay.js +2 -2
  20. package/dist/script/adapters/browser-action-contract.d.ts +22 -0
  21. package/dist/script/adapters/from-browser-action.d.ts +7 -0
  22. package/dist/script/adapters/from-remote-browser.d.ts +7 -0
  23. package/dist/script/adapters/recording.d.ts +25 -0
  24. package/dist/script/adapters/to-browser-action.d.ts +8 -0
  25. package/dist/script/canonical.d.ts +6 -0
  26. package/dist/script/capabilities.d.ts +29 -0
  27. package/dist/script/describe.d.ts +83 -0
  28. package/dist/script/fingerprint.d.ts +9 -0
  29. package/dist/script/hash.d.ts +3 -0
  30. package/dist/script/index.d.ts +22 -0
  31. package/dist/script/json-schema.d.ts +4 -0
  32. package/dist/script/limits.d.ts +61 -0
  33. package/dist/script/parse.d.ts +31 -0
  34. package/dist/script/schema.d.ts +87 -0
  35. package/dist/script/types.d.ts +489 -0
  36. package/dist/script/walk.d.ts +29 -0
  37. package/dist/script.d.ts +2 -0
  38. package/dist/script.js +175 -0
  39. package/dist/target/aria.d.ts +31 -0
  40. package/dist/target/dom.d.ts +35 -0
  41. package/dist/target/index.d.ts +13 -0
  42. package/dist/target/markers.d.ts +18 -0
  43. package/dist/target/methods.d.ts +52 -0
  44. package/dist/target/resolve.d.ts +46 -0
  45. package/dist/target/snapshot.d.ts +57 -0
  46. package/dist/target/text.d.ts +23 -0
  47. package/dist/target/types.d.ts +88 -0
  48. package/dist/target.d.ts +2 -0
  49. package/dist/target.js +92 -0
  50. package/dist/testing/fixtures/ambiguous.d.ts +7 -0
  51. package/dist/testing/fixtures/iframe.d.ts +6 -0
  52. package/dist/testing/fixtures/index.d.ts +26 -0
  53. package/dist/testing/fixtures/invoices-v2.d.ts +8 -0
  54. package/dist/testing/fixtures/invoices-v3.d.ts +7 -0
  55. package/dist/testing/fixtures/invoices.d.ts +6 -0
  56. package/dist/testing/fixtures/login.d.ts +6 -0
  57. package/dist/testing/fixtures/shadow.d.ts +7 -0
  58. package/dist/testing/index.d.ts +6 -0
  59. package/dist/testing/mount.d.ts +18 -0
  60. package/dist/testing.d.ts +2 -0
  61. package/dist/testing.js +324 -0
  62. package/package.json +28 -5
  63. package/schema/ui-script-v1.schema.json +8199 -0
package/README.md CHANGED
@@ -14,7 +14,7 @@ bun add @burdenoff/ui-engine zod
14
14
 
15
15
  ## Modules
16
16
 
17
- Each module is a subpath export, and the root entry re-exports all of them.
17
+ Each module is a subpath export. The root entry re-exports the data and planning modules (`recording` to `script`); the DOM modules (`target`, `dom-runtime`, `testing`) are subpath-only, so a consumer without DOM types, such as a service, never loads them through the root.
18
18
 
19
19
  | Import | What it holds |
20
20
  |---|---|
@@ -22,6 +22,71 @@ Each module is a subpath export, and the root entry re-exports all of them.
22
22
  | `@burdenoff/ui-engine/capture` | `captureRecording` (turns recorder events into a masked recording), `maskUrl`, `redactCredentials`, `REDACTED` |
23
23
  | `@burdenoff/ui-engine/resolve` | `readSnapshotNodes` (array, `{ nodes }` or `{ elements }` snapshots), `resolveTarget` (exact role and label match, `nth` among equals) |
24
24
  | `@burdenoff/ui-engine/replay` | The pure replay planner: `replayStateFrom`, `planReplay`, `afterReplayCall`, `finishFallback`, `markFallbackAsked`, `replayReasons`, `readReplayState` |
25
+ | `@burdenoff/ui-engine/script` | UI script v1: types, `uiScriptSchema`, `parseUiScript`, `UI_SCRIPT_SCHEMA_HASH`, `requiredCapabilities`, the adapters and `describeStep` (see below) |
26
+ | `@burdenoff/ui-engine/schema/ui-script-v1.schema.json` | The JSON Schema (draft 2020-12) of UI script v1 |
27
+ | `@burdenoff/ui-engine/target` | The multi-method web target resolver (`resolveWebTarget`), accessible role and name helpers, and value-free tree snapshots (`serializeTreeSnapshot`, `hydrateTreeSnapshot`) |
28
+ | `@burdenoff/ui-engine/dom-runtime` | The DOM runtime a desk injects into a page (`createDomRuntime`, `installDomRuntime`): resolve, act, highlight, snapshot |
29
+ | `@burdenoff/ui-engine/dom-runtime.iife.js` | The same runtime as one self-contained script (at most 60 KB minified) that installs itself on `globalThis.__burdenoffUiRuntime` |
30
+ | `@burdenoff/ui-engine/testing` | Copies of the RPA playground fixture pages (`RPA_FIXTURES`) and `mountFixture` for test DOMs |
31
+
32
+ ## UI script v1
33
+
34
+ A UI script is the portable form of a UI sequence that a desk runs: a paired browser (the FluidGrids extension), a remote browser driven over CDP by the workers, and later a robot. It is the contract FluidGrids RPA builds on (spec `fluidgrids-specs/product/specs/rpa/03-ARCHITECTURE.md` section 5 and `05-UI_AUTOMATION.md`; plan package P0-04, BOFF-17115).
35
+
36
+ **Shape.** `{ scriptVersion: 1, name?, application?, settings?, inputs?, outputs?, variables?, elements?, steps, cleanup? }`.
37
+
38
+ - A **target** is an ordered list of methods: `role` (accessible role and name, the n-th match; a superset of the Stewards saved-step target), `css`, `testId`, `xpath`, `fuzzy`, `anchor` and `text`, each with an on or off switch, plus an optional frame and shadow-root chain. A step names an inline target or a pinned library element (`{ element: key }`).
39
+ - **Steps** carry an `id` (unique across the script), an action and its fields, and the common options: `intent`, `note`, `saveAs`, `disabled`, `breakpoint`, `timeoutMs`, `retry`, `onError`, `verify`, `screenshot`, `inputMethod`, `safeToRepeat`, `screenshotRef` and `fingerprint`.
40
+ - **Actions.** Web: `navigate`, `goBack`, `reload`, `closeTab`, `click`, `doubleClick`, `hover`, `type`, `typeSecret`, `clear`, `select`, `check`, `pressKey`, `scroll`, `waitFor`, `extract`, `extractList`, `getText`, `getValue`, `getAttribute`, `elementExists`, `getPageText`, `getPageHtml`, `screenshot`, `login`. Desktop (from Stewards recordings): `focusWindow`. Flow: `if`, `forEach`, `while` (a limit is mandatory), `retryScope`, `set`, `log`, `call` (a shared sequence pinned by version; inlined when the worker compiles the script).
41
+ - **Expressions** are JSON trees, never text to evaluate: literals, `{ input }`, `{ var }` (each with an optional `path`), `{ list }`, `{ object }` and `{ op, args }` over a fixed operator list (`UI_EXPRESSION_OPS`, arities in `UI_EXPRESSION_ARITY`).
42
+ - **Secrets** never appear in a script: `typeSecret` holds a reference, and `parseUiScript` refuses credential-shaped text in values, intents, notes, URLs, target texts and selectors, window names, element names and script descriptions.
43
+ - **Fingerprints** cover every target a step holds. A step a Stewards saved step can express is fingerprinted exactly as Stewards does.
44
+ - Optional fields have no zod defaults, so a parsed script is exactly the stored one; each type documents the default an interpreter applies.
45
+
46
+ **Limits** (`limits.ts`): 500 steps including nested and clean-up steps, 1 MiB serialised, flow blocks 8 deep, expressions 16 deep, 8 methods per target, 500 pinned elements, 100 inputs, outputs and variables each.
47
+
48
+ **Parsing.** `parseUiScript(value, { resolved? })` accepts an object or its JSON text and throws `UiScriptError` with a `code` (`INVALID_SCRIPT`, `SCRIPT_TOO_LARGE`, `TOO_MANY_STEPS`, `DUPLICATE_STEP_ID`, `UNKNOWN_ELEMENT`, `UNKNOWN_INPUT`, `FINGERPRINT_MISMATCH`, `CREDENTIAL_IN_SCRIPT`, `UNRESOLVED`) and a `path`. `resolved: true` also requires every pinned element to carry its target and every `call` to be inlined. `safeParseUiScript` returns the result instead of throwing.
49
+
50
+ **Schema hash.** `UI_SCRIPT_SCHEMA_HASH` is the SHA-256 of the canonical JSON of `schema/ui-script-v1.schema.json`. The service returns the hashes it accepts, and a worker refuses to park a script whose hash the service does not accept. After changing `src/script/schema.ts`, run `bun run schema:write` and copy the printed hash into `src/script/hash.ts`; a test fails until both match.
51
+
52
+ **Capabilities.** `requiredCapabilities(script)` returns the sorted ids a desk must support (`script:1`, `action:<action>`, `target:<kind>`, `target:frame`, `step:verify`, `step:retry`, `step:breakpoint`, `input:direct`, `input:hardware`); `CAPABILITY_IDS` lists them all and `missingCapabilities(script, supported)` reports the gap.
53
+
54
+ **Adapters.**
55
+
56
+ | Function | From and to | Notes |
57
+ |---|---|---|
58
+ | `fromRecording`, `toRecording` | Stewards saved-step recording v1 | Lossless both ways, fingerprints included; `toRecording` returns null for a script a recording cannot express |
59
+ | `fromBrowserActionSteps` | Run in Browser steps (`internal:browser-action`) | Keeps every field a 0.3.0 extension reads |
60
+ | `toBrowserActionSteps` | Lowering to Run in Browser steps | Null unless the script fits the legacy contract: at most 100 steps and 256 KB, only the 14 legacy actions, one CSS selector per target (or one text for click and wait), literal or supplied input values, no script wait or screenshot settings beyond the defaults, and no flow steps, verification, retries or breakpoints |
61
+ | `fromRemoteBrowserSteps` | Remote Browser `runSteps` (`store/remotebrowser` 1.0.0) | Playwright `css=`, `text=`, `xpath=`, `id=` and `data-testid=` selectors; other engines are refused |
62
+
63
+ **Descriptions.** `describeStep(step, elements)` returns `{ key, vars, fallback }`, with keys under `fluidgrids.uiScript.step.*` for `tr(key, vars)` and an English fallback; `UI_SCRIPT_STEP_MESSAGES` holds every English template.
64
+
65
+ ## Web targets and the DOM runtime
66
+
67
+ The resolver and the runtime implement spec 05 section 3 for web pages (plan P1-01, BOFF-17144). They read no globals, so the same code runs in a content script, a CDP isolated world, a test DOM and a document rebuilt from a snapshot.
68
+
69
+ **Resolution.** `resolveWebTarget(root, target, { state })` follows the frame and shadow-root chain (`target.frame`: each CSS selector names one same-origin iframe or one open shadow host), then tries the methods in order and uses the first that finds exactly one element in the required state (`interactable`, the default: visible and enabled; `visible`; or `attached`). It returns the element with the method that found it, `fallback: true` when that was not the first enabled method, the element's report form (`candidate`) and one attempt per method (`found`, `none`, `ambiguous`, `notInteractable`, `invalid`, `unsupported`, `disabled`, `notTried`).
70
+
71
+ **Never the first of several.** Several matches are settled only by a rule the target states: an explicit `nth` on `role` and `text`, or a clearly best score for `fuzzy` (the best similarity must lead the next by 0.05) and the spatial `anchor` relations (the nearest element must lead the next by 4 px). Otherwise the method is ambiguous and the next one is tried. When no method finds exactly one element the result is a failure with `code`:
72
+
73
+ | Code | When | Candidates |
74
+ |---|---|---|
75
+ | `ELEMENT_NOT_FOUND` | No method matched, or the frame chain failed (`frame.reason`: `notFound`, `ambiguous`, `invalid`, `notAFrame`, `inaccessible`) | none |
76
+ | `ELEMENT_AMBIGUOUS` | A method matched several elements and no later method found one | up to 5, from the first ambiguous method |
77
+ | `ELEMENT_NOT_INTERACTABLE` | Elements matched but none is visible and enabled (disabled, inside a disabled control or fieldset, `inert`, `aria-disabled`, hidden, or in a hidden or inert frame); for a pointer action also `reason` `covered`, `offscreen` (still outside the viewport after scrolling into view) or `noPointerEvents` | up to 5 |
78
+
79
+ A candidate carries `role`, `name` (cut to 200 characters; empty for sensitive elements; for typed content, an editor or a text area or anything inside one, only the name its labels give), `bounds` (CSS pixels in the top viewport) and the matching `method` and `methodIndex`. The interpreter (P1-02) maps the codes to node error families.
80
+
81
+ **Methods on the web.** `role` compares the computed role and accessible name (a compact accname subset; form fields never take a name from their value) after NFKC, whitespace and case normalisation; `app` and `window` are desktop fields and are ignored. `css` and `xpath` use the page's engines (`xpath` is `unsupported` where the DOM has none). `testId` compares an attribute (default `data-testid`). `fuzzy` scores the edit-distance similarity of names (threshold 0.8 by default, never below 0.5). `anchor` finds a text or role anchor, then the element `inside` it (or inside the heading's container) or the nearest element `leftOf`, `rightOf`, `above`, `below` or on the `sameRow`, from element bounds. `text` matches the innermost element whose visible text contains (or, with `exact`, equals) the text.
82
+
83
+ **The runtime.** `createDomRuntime(document)` returns `{ version, resolve, act, highlight, clearHighlight, snapshot }`; every result is plain JSON. `act(target, action)` resolves first and acts only on exactly one element: `click` (left, middle, right), `doubleClick`, `hover`, `focus`, `type` (through the value setter, with `input` and `change`; `append` optional), `clear`, `select` (by value, effective label or index), `check` (confirmed afterwards), `pressKey` (with the browser's defaults: Enter activates a button, link or summary or performs implicit submission through the default button; Space activates a button, checkbox, radio or summary), `scroll`, `scrollIntoView`, `getText`, `getValue`, `getAttribute` and `exists`. Pointer events follow a real mouse: entry events on every element entered, the held button in `buttons` on press, the click count in `detail`, the element centre as coordinates, focus moved to the nearest focusable element, and cancelled `pointerdown` or `mousedown` honoured. Action problems are `INVALID_ACTION`, `NOT_EDITABLE`, `NOT_SELECTABLE`, `NOT_CHECKABLE`, `OPTION_NOT_FOUND`, `STATE_NOT_CHANGED` (a handler cancelled a `check`) and `SENSITIVE_ELEMENT` (reads of password, one-time-code, card and secret-named fields, of content inside them, and of elements under `data-sensitive`, `data-private` or `data-fg-sensitive`, across shadow roots, slots and frames, are refused). Typed text and read values never appear in a result's report fields. `highlight` outlines the element, or numbers the candidates of an ambiguous target, in a closed shadow root using the system `Highlight` colour; the overlay is removed before every resolve, act or snapshot.
84
+
85
+ The runtime must be injected into an isolated world (a content script, or a CDP world from `Page.createIsolatedWorld`), never the page's main world. `dist/dom-runtime.iife.js` has no imports, needs no `eval`, and keeps an installed runtime of the same protocol version (`DOM_RUNTIME_VERSION`) when it is injected again after a navigation. `bun run check:runtime-size` (a `boff sanity` step) and a unit test hold it to 60 KB minified.
86
+
87
+ **Tree snapshots.** `serializeTreeSnapshot(document)` keeps tag names, an allow-list of attributes, visible text, bounds and a hidden flag, across open shadow roots and same-origin frames, up to 5,000 nodes. It never keeps form-field values (input, text-area and select values, editable-region text, checked and selected state), any text of a sensitive element, scripts, styles, event handlers, or URL queries and fragments, and all kept text passes through `redactCredentials` (threat review R7). `hydrateTreeSnapshot(document, snapshot)` rebuilds the tree into an empty, inert document and returns the probe (`rectOf`, `isVisible`) that makes `resolveWebTarget` see the recorded bounds and visibility; frames are rebuilt where the DOM gives a `srcdoc` frame a document synchronously (a server-side DOM such as happy-dom).
88
+
89
+ **Fixtures.** `@burdenoff/ui-engine/testing` holds copies of the playground pages (`invoices`, `invoices-v2` with renamed ids and moved elements, `invoices-v3` with slightly changed wording, `ambiguous` with two identical Save buttons and a counter, `iframe`, `shadow`, `login`) for the same pages the live suites use (plan P0-08); `mountFixture(document, name)` loads one into a test DOM, attaching declarative shadow roots and filling `srcdoc` frames where the DOM does not.
25
90
 
26
91
  ## Compatibility with Stewards
27
92
 
@@ -43,13 +108,13 @@ Recordings that capture produces, in either copy, still parse here, and the gold
43
108
 
44
109
  ## Browser safety
45
110
 
46
- Nothing under `src/` may import a Node built-in. ESLint enforces this, `tests/browser-safe.test.ts` checks every source file, and `bun run check:browser-safe` (a `boff sanity` extra step) checks the built `dist/` for Node built-ins and for any bare import other than `zod` and `@noble/hashes`.
111
+ Nothing under `src/` may import a Node built-in. ESLint enforces this, `tests/browser-safe.test.ts` checks every source file, and `bun run check:browser-safe` (a `boff sanity` extra step) checks the built `dist/` for Node built-ins and for any bare import other than `zod` and `@noble/hashes`. `bun run check:runtime-size` checks that `dist/dom-runtime.iife.js` is self-contained and within its budget.
47
112
 
48
113
  ## Development
49
114
 
50
115
  ```bash
51
116
  bun install
52
- bun run sanity # format, lint, typecheck, build, tests with the coverage gate, browser-safety check
117
+ bun run sanity # format, lint, typecheck, build, tests with the coverage gate, browser-safety and runtime-size checks
53
118
  bun test # unit tests only
54
119
  bun run build # dist/ (ESM, browser target) and .d.ts files
55
120
  ```
package/dist/capture.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  maskUrl2,
3
3
  captureRecording2
4
- } from "./index-phd8yhyg.js";
4
+ } from "./index-bnvmt4wf.js";
5
+ import"./index-cs6acyjn.js";
5
6
  import {
6
7
  REDACTED2,
7
8
  redactCredentials2
8
- } from "./index-c6pmt2rg.js";
9
+ } from "./index-mgztm37r.js";
9
10
  export {
10
11
  REDACTED2 as REDACTED,
11
12
  captureRecording2 as captureRecording,
@@ -0,0 +1,65 @@
1
+ /** Longest text a read returns. */
2
+ export declare const MAX_READ_TEXT = 65536;
3
+ /** Longest text a `type` action accepts. */
4
+ export declare const MAX_TYPED_TEXT = 65536;
5
+ /** The actions the runtime performs on a resolved element. */
6
+ export type DomAction = {
7
+ kind: 'click';
8
+ button?: 'left' | 'middle' | 'right';
9
+ } | {
10
+ kind: 'doubleClick';
11
+ } | {
12
+ kind: 'hover';
13
+ } | {
14
+ kind: 'focus';
15
+ } | {
16
+ kind: 'type';
17
+ text: string;
18
+ append?: boolean;
19
+ } | {
20
+ kind: 'clear';
21
+ } | {
22
+ kind: 'select';
23
+ value?: string;
24
+ label?: string;
25
+ index?: number;
26
+ } | {
27
+ kind: 'check';
28
+ checked: boolean;
29
+ } | {
30
+ kind: 'pressKey';
31
+ key: string;
32
+ } | {
33
+ kind: 'scroll';
34
+ dx?: number;
35
+ dy?: number;
36
+ } | {
37
+ kind: 'scrollIntoView';
38
+ } | {
39
+ kind: 'getText';
40
+ } | {
41
+ kind: 'getValue';
42
+ } | {
43
+ kind: 'getAttribute';
44
+ name: string;
45
+ } | {
46
+ kind: 'exists';
47
+ };
48
+ export type DomActionKind = DomAction['kind'];
49
+ /** Actions that only read; they need the element visible, not enabled. */
50
+ export declare const READ_ACTIONS: ReadonlySet<DomActionKind>;
51
+ /** Actions a pointer performs (`check` toggles by clicking); the runtime checks that nothing covers the element first. */
52
+ export declare const POINTER_ACTIONS: ReadonlySet<DomActionKind>;
53
+ /** Why an action could not be performed on the element it resolved to. */
54
+ export type DomActionProblem = 'INVALID_ACTION' | 'NOT_EDITABLE' | 'NOT_SELECTABLE' | 'NOT_CHECKABLE' | 'OPTION_NOT_FOUND' | 'SENSITIVE_ELEMENT'
55
+ /** The control was activated but did not reach the requested state (a handler cancelled it). */
56
+ | 'STATE_NOT_CHANGED';
57
+ export type DomActionOutcome = {
58
+ ok: true;
59
+ value?: string | boolean | null;
60
+ } | {
61
+ ok: false;
62
+ problem: DomActionProblem;
63
+ };
64
+ /** Perform one action on a resolved element. */
65
+ export declare function performDomAction(element: Element, action: DomAction): DomActionOutcome;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `@burdenoff/ui-engine/dom-runtime`: the DOM runtime for bundling into a
3
+ * content script or an isolated-world script. The same code ships prebuilt as
4
+ * `@burdenoff/ui-engine/dom-runtime.iife.js` (see `iife.ts`).
5
+ */
6
+ export { type CreateDomRuntimeOptions, DOM_RUNTIME_GLOBAL, DOM_RUNTIME_VERSION, type DomActResult, type DomHighlightOptions, type DomResolution, type DomResolutionFound, type DomResolveOptions, type DomRuntime, HIGHLIGHT_HOST_TAG, MAX_HIGHLIGHT_MS, createDomRuntime, installDomRuntime, isRuntimeTarget, } from './runtime.js';
7
+ export { type DomAction, type DomActionKind, type DomActionOutcome, type DomActionProblem, MAX_READ_TEXT, MAX_TYPED_TEXT, POINTER_ACTIONS, READ_ACTIONS, performDomAction, } from './actions.js';
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The DOM runtime (plan P1-01): what a desk injects into a page to resolve
3
+ * targets, highlight them, act on them and take tree snapshots. The paired
4
+ * browser (the FluidGrids extension, P1-09) and the remote-browser executor
5
+ * (P1-07) load the same code, either bundled (`createDomRuntime`) or as the
6
+ * self-contained script `dist/dom-runtime.iife.js`, which installs itself on
7
+ * `globalThis[DOM_RUNTIME_GLOBAL]`.
8
+ *
9
+ * It must be injected into an isolated world (a content script, or a CDP world
10
+ * from `Page.createIsolatedWorld`), never into the page's main world, where
11
+ * page scripts could replace it (threat review S2, C4).
12
+ *
13
+ * Every result is plain JSON. `act` resolves the target first and acts only
14
+ * when exactly one element was found in the required state: an ambiguous,
15
+ * missing or non-interactable target is reported and nothing happens to the
16
+ * page.
17
+ */
18
+ import type { UiTarget } from '../script/types.js';
19
+ import type { WebSearchRoot } from '../target/dom.js';
20
+ import { type ResolveWebTargetOptions } from '../target/resolve.js';
21
+ import { type SerializeTreeSnapshotOptions, type UiTreeSnapshot } from '../target/snapshot.js';
22
+ import type { WebElementState, WebTargetErrorCode, WebTargetFailed, WebTargetFound } from '../target/types.js';
23
+ import { type DomAction, type DomActionProblem } from './actions.js';
24
+ /** The protocol version of the runtime object. A host checks it before calling. */
25
+ export declare const DOM_RUNTIME_VERSION = 1;
26
+ /** The global the IIFE build installs the runtime on. */
27
+ export declare const DOM_RUNTIME_GLOBAL = "__burdenoffUiRuntime";
28
+ /** Longest a highlight stays without being cleared. */
29
+ export declare const MAX_HIGHLIGHT_MS = 60000;
30
+ /** The tag of the highlight overlay host; its boxes live in a closed shadow root. */
31
+ export declare const HIGHLIGHT_HOST_TAG = "fg-ui-highlight";
32
+ /** A found resolution without the element reference: what crosses the world boundary. */
33
+ export type DomResolutionFound = Omit<WebTargetFound<never>, 'element'>;
34
+ export type DomResolution = DomResolutionFound | WebTargetFailed;
35
+ /**
36
+ * The result of `act`. On success `resolution` is the found resolution, or the
37
+ * not-found one for `exists` (whose `value` is then false). On failure `code`
38
+ * is a resolution error code or an action problem, and nothing was done.
39
+ */
40
+ export type DomActResult = {
41
+ ok: true;
42
+ resolution: DomResolution;
43
+ value?: string | boolean | null;
44
+ } | {
45
+ ok: false;
46
+ code: WebTargetErrorCode | DomActionProblem;
47
+ resolution?: DomResolution;
48
+ reason?: 'covered' | 'noPointerEvents' | 'offscreen';
49
+ };
50
+ export interface DomResolveOptions {
51
+ state?: WebElementState;
52
+ }
53
+ export interface DomHighlightOptions extends DomResolveOptions {
54
+ /** A short caption shown under the box (text only). */
55
+ label?: string;
56
+ /** Clear the highlight after this many milliseconds (at most `MAX_HIGHLIGHT_MS`). Absent means until cleared. */
57
+ durationMs?: number;
58
+ }
59
+ export interface DomRuntime {
60
+ version: number;
61
+ resolve(target: UiTarget, options?: DomResolveOptions): DomResolution;
62
+ act(target: UiTarget, action: DomAction, options?: DomResolveOptions): DomActResult;
63
+ highlight(target: UiTarget, options?: DomHighlightOptions): DomResolution;
64
+ clearHighlight(): void;
65
+ snapshot(options?: Pick<SerializeTreeSnapshotOptions, 'maxNodes'>): UiTreeSnapshot;
66
+ }
67
+ export interface CreateDomRuntimeOptions extends Pick<ResolveWebTargetOptions, 'rectOf' | 'isVisible'> {
68
+ /** Where targets are searched. Absent means the document itself. */
69
+ root?: WebSearchRoot;
70
+ }
71
+ /** A light structural check of a target from the host; the host has already parsed the script. */
72
+ export declare function isRuntimeTarget(value: unknown): value is UiTarget;
73
+ /** Create a runtime over a document. */
74
+ export declare function createDomRuntime(document: Document, options?: CreateDomRuntimeOptions): DomRuntime;
75
+ /**
76
+ * Install a runtime on a global object, unless one of the same or a newer
77
+ * protocol version is already there. Returns the installed runtime.
78
+ */
79
+ export declare function installDomRuntime(scope: object, document: Document): DomRuntime;
@@ -0,0 +1,2 @@
1
+ /** `@burdenoff/ui-engine/dom-runtime`: the DOM runtime a desk injects into a page. */
2
+ export * from './dom-runtime/index.js';
@@ -0,0 +1 @@
1
+ (()=>{var U=["data-fg-sensitive","data-sensitive","data-private"];function Z(e){return U.some((t)=>e.hasAttribute(t))}function D(e){let t=e.assignedSlot;if(t!==void 0)return t;let n=e.parentElement?.shadowRoot;if(!n)return null;for(let o of Array.from(n.querySelectorAll("slot")))if((typeof o.assignedNodes==="function"?o.assignedNodes():[]).includes(e))return o;return null}function x(e){let t=D(e);if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();if(n&&"host"in n)return n.host;try{return e.ownerDocument.defaultView?.frameElement??null}catch{return null}}function y(e){for(let t=e;t;t=x(t))if(Z(t))return!0;return!1}var Y=256;function g(e){return(e??"").normalize("NFKC").replace(/\s+/g," ").trim().toLowerCase()}function P(e,t){return g(e)===g(t)}function fe(e,t){let n=g(t);return n.length>0&&g(e).includes(n)}function qe(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o+=1){let r=[o];for(let i=1;i<=t.length;i+=1){let s=e[o-1]===t[i-1]?0:1;r[i]=Math.min((n[i]??0)+1,(r[i-1]??0)+1,(n[i-1]??0)+s)}n=r}return n[t.length]??0}function me(e,t){let n=g(e).slice(0,256),o=g(t).slice(0,256),r=Math.max(n.length,o.length);if(r===0)return 0;return 1-qe(n,o)/r}function _(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}var Q=512,Ze=65536,Ye={button:"button",submit:"button",reset:"button",image:"button",checkbox:"checkbox",radio:"radio",range:"slider",number:"spinbutton",search:"searchbox",email:"textbox",tel:"textbox",text:"textbox",url:"textbox",password:"textbox",date:"textbox","datetime-local":"textbox",month:"textbox",time:"textbox",week:"textbox",color:"textbox",file:"button"},Je={article:"article",aside:"complementary",button:"button",datalist:"listbox",dd:"definition",details:"group",dialog:"dialog",dt:"term",fieldset:"group",figure:"figure",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",hr:"separator",li:"listitem",main:"main",menu:"list",meter:"meter",nav:"navigation",ol:"list",optgroup:"group",option:"option",output:"status",p:"paragraph",progress:"progressbar",summary:"button",table:"table",tbody:"rowgroup",td:"cell",textarea:"textbox",tfoot:"rowgroup",thead:"rowgroup",tr:"row",ul:"list"},Qe=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"]),et=new Set(["button","input","meter","output","progress","select","textarea"]),tt=new Set(["script","style","noscript","template","head","title","meta","link"]);function A(e){return e.localName.toLowerCase()}function be(e){return e.parentElement?.closest("article, aside, main, nav, section")!=null}function nt(e){let t=A(e);switch(t){case"a":case"area":return e.hasAttribute("href")?"link":"";case"input":{let n=(e.getAttribute("type")??"text").toLowerCase();if(n==="hidden")return"";if(e.hasAttribute("list")&&["text","search","email","tel","url"].includes(n))return"combobox";return Ye[n]??"textbox"}case"select":{let n=Number(e.getAttribute("size")??"0");return e.hasAttribute("multiple")||n>1?"listbox":"combobox"}case"img":return e.getAttribute("alt")===""?"presentation":"img";case"th":return e.getAttribute("scope")==="row"?"rowheader":"columnheader";case"header":return be(e)?"":"banner";case"footer":return be(e)?"":"contentinfo";case"section":case"form":return e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")?t==="form"?"form":"region":"";default:return Je[t]??""}}function R(e){let t=e.getAttribute("role")?.trim().split(/\s+/)[0];return t?t.toLowerCase():nt(e)}function ot(e,t){let n=e.getRootNode();return typeof n.getElementById==="function"?n.getElementById(t):null}function rt(e){return e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true"}function it(e){let t=e.ownerDocument.defaultView;if(!t)return"none";let n=t.getComputedStyle(e);if(n.display==="none")return"subtree";return n.visibility==="hidden"||n.visibility==="collapse"?"self":"none"}function I(e){let t=e.getAttribute("contenteditable");if(t===null)return!1;let n=t.trim().toLowerCase();return n===""||n==="true"||n==="plaintext-only"}function st(e){if(e.shadowRoot)return Array.from(e.shadowRoot.childNodes);if(A(e)==="slot"){let t=e,n=typeof t.assignedNodes==="function"?t.assignedNodes({flatten:!0}):[];if(n.length>0)return n}return Array.from(e.childNodes)}var at=/^(div|p|li|tr|td|th|br|h[1-6]|section|article|header|footer)$/;function O(e,t){if(e.remaining<=0||t.length===0)return;let n=t.slice(0,e.remaining);e.parts.push(n),e.remaining-=n.length}function pe(e,t,n,o,r,i=!1){if(t>32||n.remaining<=0)return;if(e.nodeType===3){if(!i)O(n,e.textContent??"");return}if(e.nodeType!==1)return;let s=e,a=A(s);if(tt.has(a)||Z(s))return;if(!r&&rt(s))return;let l=!1;if(t>0&&!r){let d=o?.isVisible?.(s);if(d===!1)l=!0;else if(d===void 0){let c=it(s);if(c==="subtree")return;l=c==="self"}}let u=s.getAttribute("aria-label")?.trim();if(u&&t>0&&!l){O(n,` ${u} `);return}if(a==="img"||a==="input"&&s.getAttribute("type")==="image"){if(!l)O(n,` ${s.getAttribute("alt")??""} `);return}if(a==="input"||a==="textarea"||a==="select")return;if(t>0&&I(s))return;let f=t>0&&at.test(a);if(f)O(n," ");for(let d of st(s))pe(d,t+1,n,o,r,l);if(f)O(n," ")}function he(e){if(A(e)==="textarea"||I(e))return!0;for(let n=x(e);n;n=x(n))if(A(n)==="textarea"||I(n))return!0;return!1}function Ee(e){for(let t=x(e);t;t=x(t)){let n=A(t);if(n==="textarea"||n==="select"||I(t))return!0}return!1}function H(e,t,n=!1){let o=A(e);if(o==="textarea"||o==="select"||I(e)||Ee(e)||y(e))return"";return E(e.getAttribute("aria-label")??"")||V(e,t,Q,n)}function V(e,t,n=Q,o=!1){if(e.nodeType===1&&y(e))return"";let r={parts:[],remaining:n*2+64};return pe(e,0,r,t,o),E(r.parts.join(""),n)}function E(e,t=Q){return e.replace(/\s+/g," ").trim().slice(0,t)}function lt(e,t){let n=[],o=e.getAttribute("id");if(o){let i=e.getRootNode();for(let s of Array.from(i.querySelectorAll("label")))if(s.getAttribute("for")===o)n.push(H(s,t,!0))}let r=e.closest("label");if(r&&!r.hasAttribute("for"))n.push(H(r,t,!0));return E(n.join(" "))}function J(e,t,n){let o=Array.from(e.children).find((r)=>A(r)===t);return o?H(o,n):""}function k(e,t){return Te(e,t,!0)}function ge(e,t){return Te(e,t,!1)}function ut(e,t){let n=Array.from(e.children).find((o)=>A(o)==="title");if(!n||y(n)||Ee(n))return"";return E(Array.from(n.childNodes).map((o)=>V(o,t)).join(" "))}function Te(e,t,n){let o=e.getAttribute("aria-labelledby");if(o){let l=o.split(/\s+/).filter(Boolean).map((u)=>ot(e,u)).filter((u)=>u!==null).map((u)=>H(u,t,!0)).join(" ");if(E(l))return E(l)}let r=e.getAttribute("aria-label");if(r&&E(r))return E(r);let i=A(e);if(et.has(i)){let l=lt(e,t);if(l)return l}if(i==="input"){let l=(e.getAttribute("type")??"text").toLowerCase();if(l==="button"||l==="submit"||l==="reset"){let u=e.getAttribute("value");if(u!==null)return E(u);return l==="submit"?"Submit":l==="reset"?"Reset":""}if(l==="image")return E(e.getAttribute("alt")??"")}if(i==="img"||i==="area"){let l=e.getAttribute("alt");if(l)return E(l)}if(i==="svg"){let l=ut(e,t);if(l)return l}if(i==="fieldset"){let l=J(e,"legend",t);if(l)return l}if(i==="table"){let l=J(e,"caption",t);if(l)return l}if(i==="option"){let l=E(e.getAttribute("label")??"");if(l)return l}if(i==="figure"){let l=J(e,"figcaption",t);if(l)return l}if(n&&Qe.has(R(e))){let l=V(e,t);if(l)return l}let s=e.getAttribute("title");if(s&&E(s))return E(s);let a=e.getAttribute("placeholder");if(a&&E(a))return E(a);return""}function F(e,t){if(A(e)==="input"){let o=(e.getAttribute("type")??"text").toLowerCase();return o==="button"||o==="submit"||o==="reset"?k(e,t):""}return V(e,t,Ze)}function ee(e,t,n,o){return R(e)===t.trim().toLowerCase()&&g(k(e,o))===g(n)}function ct(e){return e.ownerDocument.defaultView}function B(e){let t=D(e);if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return n&&"host"in n?n.host:null}function N(e,t){let n=t?.isVisible?.(e);if(n!==void 0)return n;if(!e.isConnected)return!1;let o=ct(e),r=e;while(r){if(r.hasAttribute("hidden"))return!1;if(r.localName==="input"&&r.getAttribute("type")?.toLowerCase()==="hidden")return!1;if(o&&o.getComputedStyle(r).display==="none")return!1;r=B(r)}if(o){let s=o.getComputedStyle(e);if(s.visibility==="hidden"||s.visibility==="collapse")return!1;if(s.display==="contents")return!0}let i=e.checkVisibility;return typeof i==="function"?i.call(e):!0}function w(e){for(let n=e;n;n=x(n))if(n.getAttribute("aria-disabled")==="true"||n.hasAttribute("inert"))return!1;if(!dt.has(e.localName)){let n=e.parentElement?.closest("button, select, option, optgroup, textarea");return n?w(n):!0}if(e.hasAttribute("disabled"))return!1;let t=e.parentElement?.closest("fieldset[disabled]");if(t){if(!Array.from(t.children).find((o)=>o.localName==="legend")?.contains(e))return!1}try{return!e.matches(":disabled")}catch{return!0}}var dt=new Set(["button","input","select","textarea","optgroup","option","fieldset"]);function v(e,t,n){let r=t?.rectOf?.(e)??e.getBoundingClientRect();return{x:Math.round(r.x+(n?.x??0)),y:Math.round(r.y+(n?.y??0)),width:Math.round(r.width),height:Math.round(r.height)}}function C(e){let t=Array.from(e.querySelectorAll("*"));return e.nodeType===1?[e,...t]:t}var ft=/password|passcode|passwd|\bpin\b|otp|one[\s-]?time|verification|security code|auth(?:entication)? code|\bcvv\b|\bcvc\b|card number|secret|token|recovery/i,mt=/password|one-time-code|^cc-/i;function bt(e){return ft.test(e)}function S(e){if(y(e))return!0;if(xe(e))return!0;for(let t=x(e);t;t=x(t))if(xe(t))return!0;return!1}function xe(e){let t=e.localName,n=e.getAttribute("contenteditable"),o=n!==null&&n.trim().toLowerCase()!=="false";if(t!=="input"&&t!=="textarea"&&t!=="select"&&!o)return!1;if(e.getAttribute("type")?.toLowerCase()==="password")return!0;if((e.getAttribute("autocomplete")??"").trim().split(/\s+/).filter(Boolean).some((i)=>mt.test(i)))return!0;return pt(e).some((i)=>i.length>0&&bt(i.replace(/[-_]/g," ")))}function pt(e){let t=(a)=>(a??"").slice(0,512),n=[k(e),t(e.getAttribute("aria-label")),t(e.getAttribute("placeholder")),t(e.getAttribute("title")),t(e.getAttribute("name")),t(e.getAttribute("id"))],o=e.getRootNode(),r=(a)=>typeof o.getElementById==="function"?o.getElementById(a):null;for(let a of(e.getAttribute("aria-labelledby")??"").split(/\s+/).filter(Boolean)){let l=r(a);if(l)n.push(t(l.getAttribute("aria-label")),t(l.textContent))}let i=e.getAttribute("id"),s=Array.from(o.querySelectorAll("label")).filter((a)=>i!==null&&a.getAttribute("for")===i||!a.hasAttribute("for")&&a.contains(e));for(let a of s)n.push(t(a.getAttribute("aria-label")),t(a.textContent));return n}var ht=0.8,Et=0.05,gt=4,Ae=1000,z=2,Tt=new Set(["button","checkbox","combobox","link","listbox","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]),xt=/^[A-Za-z_][\w:.-]{0,127}$/;function At(e){return e.nodeType===9?e:e.ownerDocument}function yt(e,t){return{kind:"list",elements:C(t.root).filter((o)=>ee(o,e.role,e.name,t.probe)),...e.nth!==void 0?{nth:e.nth}:{}}}function St(e,t){try{return{kind:"list",elements:Array.from(t.root.querySelectorAll(e))}}catch{return{kind:"invalid"}}}function Mt(e,t){let n=e.attribute??"data-testid";if(!xt.test(n))return{kind:"invalid"};return{kind:"list",elements:C(t.root).filter((r)=>r.getAttribute(n)===e.value)}}function Rt(e,t){if(e.nodeType===9)return t.ownerDocument===e&&t.getRootNode()===e;return e===t||e.contains(t)}function kt(e,t){let n=At(t.root);if(typeof n.evaluate!=="function")return{kind:"unsupported"};let o;try{o=n.evaluate(e.xpath,t.root,null,7,null)}catch{return{kind:"invalid"}}let r=[],i=Math.min(o.snapshotLength,Ae);for(let s=0;s<i;s+=1){let a=o.snapshotItem(s);if(a&&a.nodeType===1&&Rt(t.root,a))r.push(a)}return{kind:"list",elements:r,...o.snapshotLength>Ae?{overflow:!0}:{}}}function Nt(e,t,n){let o=Math.min(g(e).length,Y),r=Math.max(o,t);return r>0&&Math.abs(o-t)<=(1-n)*r}function wt(e,t){let n=Math.min(1,Math.max(0.5,e.threshold??ht)),o=e.role?.trim().toLowerCase(),r=Math.min(g(e.name).length,Y),i=[];for(let s of C(t.root)){let a=R(s);if(o?a!==o:a==="")continue;let l=k(s,t.probe);if(!Nt(l,r,n))continue;let u=me(l,e.name);if(u>=n)i.push({element:s,score:u})}return{kind:"ranked",scored:i,margin:Et}}function Me(e,t){let n=C(e.root).filter((i)=>t(F(i,e.probe))),o=e.keep??(()=>!0),r=n.filter(o);return n.filter((i)=>!r.some((s)=>s!==i&&i.contains(s)))}function Ct(e,t){let n=e.exact?(o)=>P(o,e.text):(o)=>fe(o,e.text);if(g(e.text).length===0)return{kind:"list",elements:[]};return{kind:"list",elements:Me(t,n),...e.nth!==void 0?{nth:e.nth}:{}}}function te(e){return g(e).replace(/[\s:*]+$/u,"")}function vt(e,t){return(e.kind==="role"?C(t.root).filter((o)=>ee(o,e.role,e.name,t.probe)):Me(t,(o)=>te(o)===te(e.text)&&te(o)!=="")).filter((o)=>N(o,t.probe))}function Re(e,t,n){let o=e.role?.trim().toLowerCase();return C(t.root).filter((r)=>{let i=R(r);if(o?i!==o:!Tt.has(i))return!1;return!n.some((s)=>s===r||r.contains(s))})}var Dt=new Set(["h1","h2","h3","h4","h5","h6","legend","caption","figcaption","summary","dt"]);function _t(e){return Dt.has(e.localName)||R(e)==="heading"}function Ot(e){for(let t=e;t;t=t.parentElement)if(_t(t))return t;return null}function It(e,t,n){let o=Re(e,t,n),r=new Set;for(let i of n){let a=Ot(i)?.parentElement??i;for(let l of o)if(a.contains(l))r.add(l)}return{kind:"list",elements:o.filter((i)=>r.has(i))}}function ye(e,t,n,o){return e<o&&n<t}function Lt(e,t,n){let o=t.x+t.width,r=t.y+t.height,i=n.x+n.width,s=n.y+n.height,a=ye(t.y,r,n.y,s),l=ye(t.x,o,n.x,i);switch(e){case"rightOf":return a&&n.x>=o-z?Math.max(0,n.x-o):null;case"leftOf":return a&&i<=t.x+z?Math.max(0,t.x-i):null;case"below":return l&&n.y>=r-z?Math.max(0,n.y-r):null;case"above":return l&&s<=t.y+z?Math.max(0,t.y-s):null;case"sameRow":return a?Math.abs(n.x+n.width/2-(t.x+t.width/2)):null;default:return null}}function Se(e){return e.width>0&&e.height>0}function Wt(e,t){let n=vt(e.anchor,t);if(n.length===0)return{kind:"list",elements:[]};if(e.relation==="inside")return It(e,t,n);let o=n.map((i)=>v(i,t.probe)).filter(Se);if(o.length===0)return{kind:"unsupported"};let r=[];for(let i of Re(e,t,n)){let s=v(i,t.probe);if(!Se(s))continue;let a=null;for(let l of o){let u=Lt(e.relation,l,s);if(u!==null&&(a===null||u<a))a=u}if(a!==null)r.push({element:i,score:-a})}return{kind:"ranked",scored:r,margin:gt}}function ke(e,t){switch(e.kind){case"role":return yt(e,t);case"css":return St(e.selector,t);case"testId":return Mt(e,t);case"xpath":return kt(e,t);case"fuzzy":return wt(e,t);case"anchor":return Wt(e,t);case"text":return Ct(e,t);default:return{kind:"unsupported"}}}var Ne=5,we=200;var Ut={x:0,y:0,width:0,height:0};function Pt(e,t,n){let o={root:e,offset:Ut,hidden:!1,disabled:!1};for(let[r,i]of(t??[]).entries()){let s;try{s=Array.from(o.root.querySelectorAll(i))}catch{return{index:r,reason:"invalid"}}if(s.length===0)return{index:r,reason:"notFound"};if(s.length>1)return{index:r,reason:"ambiguous"};let a=s[0],l=a.localName;if(l==="iframe"||l==="frame"){let u=a,f=null;try{f=u.contentDocument}catch{f=null}if(!f)return{index:r,reason:"inaccessible"};let d=v(a,n,o.offset);o={root:f,offset:{x:d.x+u.clientLeft,y:d.y+u.clientTop,width:0,height:0},hidden:o.hidden||!N(a,n),disabled:o.disabled||!w(a)}}else if(a.shadowRoot)o={root:a.shadowRoot,offset:o.offset,hidden:o.hidden,disabled:o.disabled};else return{index:r,reason:"notAFrame"}}return o}function Ht(e,t,n,o){if(t==="attached")return!0;if(n.hidden||!N(e,o))return!1;return t==="visible"||!n.disabled&&w(e)}function Ce(e,t,n,o,r){return{role:R(e),name:S(e)?"":_(he(e)?ge(e,r):k(e,r),we),bounds:v(e,r,o),method:t.kind,methodIndex:n}}function Vt(e,t,n,o=!1){if(t.length===0)return e.length>0?{outcome:"notInteractable",elements:e,matches:0}:{outcome:"none",elements:[],matches:0};if(o)return{outcome:"ambiguous",elements:t,matches:t.length};if(n!==void 0){let r=t[n];return r?{outcome:"found",element:r,matches:t.length}:{outcome:"none",elements:[],matches:t.length}}return t.length===1?{outcome:"found",element:t[0],matches:1}:{outcome:"ambiguous",elements:t,matches:t.length}}function Ft(e,t,n){if(t.length===0)return e.length>0?{outcome:"notInteractable",elements:e.map((a)=>a.element),matches:0}:{outcome:"none",elements:[],matches:0};let o=[...t].sort((a,l)=>l.score-a.score),r=o[0],i=o[1];if(!i||r.score-i.score>=n)return{outcome:"found",element:r.element,matches:t.length};let s=o.filter((a)=>r.score-a.score<n).map((a)=>a.element);return{outcome:"ambiguous",elements:s,matches:s.length}}function Bt(e,t){switch(e.kind){case"invalid":case"unsupported":return e.kind;case"list":return Vt(e.elements,e.elements.filter(t),e.nth,e.overflow);case"ranked":return Ft(e.scored,e.scored.filter((n)=>t(n.element)),e.margin)}}function X(e,t,n=[],o=0,r){return{status:"failed",code:e,candidates:n,candidateCount:o,attempts:t,...r?{frame:r}:{}}}function ve(e,t,n={}){let o=n.state??"interactable",r=Pt(e,t.frame,n);if(!("root"in r)){let d=t.methods.map((c,b)=>({index:b,method:c.kind,outcome:"notTried",matches:0}));return X("ELEMENT_NOT_FOUND",d,[],0,r)}let i=[],s=t.methods.findIndex((d)=>d.enabled!==!1),a,l,u;for(let[d,c]of t.methods.entries()){if(u){i.push({index:d,method:c.kind,outcome:"notTried",matches:0});continue}if(c.enabled===!1){i.push({index:d,method:c.kind,outcome:"disabled",matches:0});continue}let b=(p)=>Ht(p,o,r,n),m=Bt(ke(c,{root:r.root,probe:n,keep:b}),b);if(m==="invalid"||m==="unsupported"){i.push({index:d,method:c.kind,outcome:m,matches:0});continue}if(i.push({index:d,method:c.kind,outcome:m.outcome,matches:m.matches}),m.outcome==="found")u={element:m.element,method:c,index:d};else if(m.outcome==="ambiguous"&&!a)a={elements:m.elements,method:c,index:d,count:m.matches};else if(m.outcome==="notInteractable"&&!l)l={elements:m.elements,method:c,index:d}}if(u)return{status:"found",element:u.element,method:u.method.kind,methodIndex:u.index,fallback:u.index!==s,candidate:Ce(u.element,u.method,u.index,r.offset,n),attempts:i};let f=(d)=>d.elements.slice(0,Ne).map((c)=>Ce(c,d.method,d.index,r.offset,n));if(a)return X("ELEMENT_AMBIGUOUS",i,f(a),a.count);if(l)return X("ELEMENT_NOT_INTERACTABLE",i,f(l),l.elements.length);return X("ELEMENT_NOT_FOUND",i)}var ne="[REDACTED]",zt=[/\b(?:Bearer|Basic)\s+[^\s"'`,;)\]}]+/gi,/\b(?:sk|pk|rk|xai)-[^\s"'`,;)\]}]+/gi,/\b(?:gsk|hf|ghp|gho|ghs|ghu|glpat)_[^\s"'`,;)\]}]+/gi,/\bAIza[\w-]{10,}/g,/\b(?:AKIA|ASIA)[0-9A-Z]{12,}/g],Xt=/([\s"'`,;:=()[\]{}]+)/,Kt=/^(?:api[_-]?key|access[_-]?key|secret|secret[_-]?key|client[_-]?secret|token|password)$/i;function jt(e){let t=e.indexOf("…");return e.includes("***")||t!==-1&&t<e.length-1}function $t(e){let t=e.split(Xt);for(let n=0;n<t.length;n+=2){let o=t[n]??"";if(o&&o!=="[REDACTED]"&&jt(o))t[n]="[REDACTED]";let r=t[n+1]??"";if(t[n+2]&&Kt.test(o)&&/[:=]/.test(r))t[n+2]="[REDACTED]"}return t.join("")}function oe(e){if(!e)return e;let t=e;for(let n of zt)t=t.replace(n,"[REDACTED]");return t=$t(t),t.replace(/(?:\[REDACTED\]){2,}/g,"[REDACTED]")}var De="";function K(e){if(!e)return!1;let t=e.replaceAll("[REDACTED]",De);return oe(t).replaceAll(De,"[REDACTED]")!==e}function re(e){try{return decodeURIComponent(e.replaceAll("+"," "))}catch{return e}}function _e(e){return K(re(e).replace(/[/?&#]/g," "))}var Gt=1,qt=5000,Zt=64,Ie=500,Yt=new Set(["script","style","noscript","template","link","meta","base","head","object","embed"]),Jt=new Set(["textarea"]),Qt=new Set(["id","class","role","name","type","for","title","alt","placeholder","label","autocomplete","tabindex","disabled","readonly","hidden","inert","contenteditable","list","multiple","size","scope","slot","part","lang","dir","data-testid","data-test","data-test-id","data-qa","data-cy","data-automation-id",...U]),en=new Set(["aria-valuenow","aria-valuetext","aria-checked","aria-selected","aria-pressed"]),tn=new Set(["button","submit","reset"]),Le=/reset|recover|verify|verification|magic|confirm|activate|invite|unsubscribe/i,nn=/^[a-z][a-z0-9-]{0,63}$/;var on=/^[a-z][a-z0-9_:.-]{0,127}$/;function We(e){let t=e.getAttribute("contenteditable");return t!==null&&t.trim().toLowerCase()!=="false"}function Ue(e){for(let t=x(e);t;t=x(t))if(t.localName==="textarea"||We(t))return!0;return!1}function rn(e){if(!e.parentElement?.shadowRoot)return!1;let t=D(e);return t!==null&&(S(t)||Ue(t))}function j(e){return _(oe(e),Ie)}function sn(e){let t=e;for(let n=0;n<3;n+=1){let o=re(t);if(o===t)break;t=o}return t}function an(e){let t=e.split(/[/?#;]/),n=t.findIndex((r)=>Le.test(r));return t.slice(0,n+1).map((r)=>K(r)?ne:r).join("/")}function Pe(e){let t=e.trim();if(t==="")return null;let n=/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith("//"),o="",r;if(n){let f;try{f=new URL(t.startsWith("//")?`https:${t}`:t)}catch{return null}if(f.protocol!=="http:"&&f.protocol!=="https:")return null;o=t.startsWith("//")?`//${f.host}`:f.origin,r=f.pathname}else r=t.split(/[?#]/)[0]??"";let i=r.split("/"),s=i.map(sn),a=s.findIndex((f)=>Le.test(f)),u=(a>=0?i.slice(0,a+1):i).map((f,d)=>{let c=s[d]??f;if(d===a)return an(c);return K(c)||_e(f)?ne:f}).join("/");return _(`${o}${u}`,Ie)}var ln=new Set(["alt","label","title","placeholder","value","aria-label","aria-description","aria-roledescription","aria-placeholder"]),un=new Set(["aria-hidden","aria-disabled","aria-expanded","aria-haspopup","aria-controls","aria-owns","aria-labelledby","aria-describedby","aria-level","aria-current","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-readonly","aria-required","aria-invalid","aria-busy","aria-live","aria-atomic","aria-posinset","aria-setsize","aria-colcount","aria-colindex","aria-colspan","aria-rowcount","aria-rowindex","aria-rowspan","aria-sort"]);function cn(e,t){let n={},o=e.localName;for(let r of Array.from(e.attributes)){let i=r.name.toLowerCase();if(i.startsWith("on")||!on.test(i))continue;if(t&&(ln.has(i)||i==="href"||i.startsWith("aria-")&&!un.has(i)))continue;if(Qt.has(i)||i.startsWith("aria-")&&!en.has(i))n[i]=j(r.value);else if(i==="href"&&(o==="a"||o==="area")){let s=Pe(r.value);if(s!==null)n[i]=s}else if(i==="value"&&o==="input"&&tn.has((e.getAttribute("type")??"").toLowerCase()))n[i]=j(r.value)}return Object.keys(n).length>0?n:void 0}function dn(e,t){let n=t?.rectOf?.(e)??e.getBoundingClientRect(),o=[Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height)];return o[2]>0||o[3]>0?o:void 0}function Oe(e,t,n,o,r){let i=[];for(let s of Array.from(e.childNodes)){if(t.count>=t.max){t.truncated=!0;break}if(s.nodeType===3){if(!o||rn(s))continue;let a=s.textContent??"";if(a.length===0)continue;let l=a.trim()===""?" ":j(a);t.count+=1,i.push(l)}else if(s.nodeType===1){let a=G(s,t,n+1,o,r);if(a)i.push(a)}}return i}function G(e,t,n,o,r){let i=e.localName.toLowerCase();if(Yt.has(i)||!nn.test(i))return null;if(n>Zt)return t.truncated=!0,null;t.count+=1;let s={t:i},a=Ue(e),l=r||a||y(e),u=cn(e,l);if(u)s.a=u;if(N(e,t.probe)){let p=dn(e,t.probe);if(p)s.r=p}else s.h=1;let f=S(e),d=o&&!a&&!f&&!Jt.has(i)&&!We(e),c=l||!d;if(i==="svg"){let p=Array.from(e.children).find((T)=>T.localName==="title"),h=p?G(p,t,n+1,d,c):null;if(h)s.c=[h];return s}if(i==="iframe"||i==="frame"){let p=null;try{p=e.contentDocument}catch{p=null}let h=p?.documentElement;if(h){let T=G(h,t,n+1,d,c);if(T)s.f=T}return s}let b=Oe(e,t,n,d,c);if(b.length>0)s.c=b;let m=e.shadowRoot;if(m){let p=Oe(m,t,n,d,c);if(p.length>0)s.s=p}return s}function fn(e){let t=e.querySelector("title");if(t&&y(t))return"";return j(e.title??"")}function He(e,t={}){let n={count:0,max:Math.max(1,t.maxNodes??qt),truncated:!1,probe:t},o=G(e.documentElement,n,0,!0,!1)??{t:"html"},r=e.defaultView;return{snapshotVersion:Gt,url:Pe(e.URL)??"",title:fn(e),viewport:{width:Math.round(r?.innerWidth??0),height:Math.round(r?.innerHeight??0)},root:o,nodeCount:n.count,truncated:n.truncated}}var ie=65536,mn=65536,Fe=new Set(["getText","getValue","getAttribute","exists"]),Be=new Set(["click","doubleClick","hover","check"]);function bn(e){return e.ownerDocument.defaultView}var pn={left:0,middle:1,right:2},hn={left:1,middle:4,right:2};function se(e,t,n){let o=e.getBoundingClientRect();return{bubbles:!0,cancelable:!0,composed:!0,view:t,button:pn[n],buttons:0,clientX:o.x+o.width/2,clientY:o.y+o.height/2,pointerId:1,pointerType:"mouse",isPrimary:!0}}function ze(e,t,n){let o=typeof t.PointerEvent==="function"?t.PointerEvent:t.MouseEvent,r=[];for(let s=e;s;s=B(s))r.unshift(s);let i={...n,bubbles:!1};e.dispatchEvent(new o("pointerover",n));for(let s of r)s.dispatchEvent(new o("pointerenter",i));e.dispatchEvent(new t.MouseEvent("mouseover",n));for(let s of r)s.dispatchEvent(new t.MouseEvent("mouseenter",i))}var En='a[href], area[href], button, input, select, textarea, iframe, summary, [tabindex], [contenteditable]:not([contenteditable="false"])';function gn(e,t){for(let o=e;o;o=B(o))if(o.matches(En)&&w(o)&&o instanceof t.HTMLElement){o.focus();return}let n=e.ownerDocument.activeElement;if(n instanceof t.HTMLElement&&n!==e.ownerDocument.body)n.blur()}function Tn(e,t,n,o,r){let i=typeof t.PointerEvent==="function"?t.PointerEvent:t.MouseEvent,s={...n,buttons:hn[o],detail:r},a={...n,detail:r};ze(e,t,n);let l=e.dispatchEvent(new i("pointerdown",s));if(l&&e.dispatchEvent(new t.MouseEvent("mousedown",s)))gn(e,t);if(e.dispatchEvent(new i("pointerup",a)),l)e.dispatchEvent(new t.MouseEvent("mouseup",a))}function L(e,t,n,o=1){let r=se(e,t,n);Tn(e,t,r,n,o);let i=n==="left"?"click":n==="right"?"contextmenu":"auxclick";e.dispatchEvent(new t.MouseEvent(i,{...r,detail:o}))}function Xe(e,t){if(e instanceof t.HTMLTextAreaElement)return!0;if(!(e instanceof t.HTMLInputElement))return!1;return!["button","submit","reset","image","checkbox","radio","file","range","color","hidden"].includes(e.type)}function xn(e,t,n){let o=e instanceof t.HTMLTextAreaElement?t.HTMLTextAreaElement.prototype:t.HTMLInputElement.prototype,r=Object.getOwnPropertyDescriptor(o,"value")?.set;if(r)r.call(e,n);else e.value=n;e.dispatchEvent(new t.Event("input",{bubbles:!0,composed:!0})),e.dispatchEvent(new t.Event("change",{bubbles:!0}))}function An(e,t){if(!(e instanceof t.HTMLElement))return!1;if(e.isContentEditable)return!0;let n=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return n===""||n==="true"||n==="plaintext-only"}function Ve(e,t,n,o){if(n.length>mn)return{ok:!1,problem:"INVALID_ACTION"};if(Xe(e,t)){if(e.readOnly)return{ok:!1,problem:"NOT_EDITABLE"};return e.focus(),xn(e,t,o?`${e.value}${n}`:n),{ok:!0}}if(An(e,t))return e.focus(),e.textContent=o?`${e.textContent??""}${n}`:n,e.dispatchEvent(new t.Event("input",{bubbles:!0,composed:!0})),{ok:!0};return{ok:!1,problem:"NOT_EDITABLE"}}function yn(e){let t=e.getAttribute("label");return t!==null&&t.trim()!==""?t:e.textContent??""}function Sn(e,t,n){if(!(e instanceof t.HTMLSelectElement))return{ok:!1,problem:"NOT_SELECTABLE"};let o=Array.from(e.options),r=n.value!==void 0?o.find((i)=>i.value===n.value):n.label!==void 0?o.find((i)=>P(yn(i),n.label)):n.index!==void 0?o[n.index]:void 0;if(!r||r.disabled||r.closest("optgroup")?.hasAttribute("disabled"))return{ok:!1,problem:"OPTION_NOT_FOUND"};return e.focus(),r.selected=!0,e.dispatchEvent(new t.Event("input",{bubbles:!0,composed:!0})),e.dispatchEvent(new t.Event("change",{bubbles:!0})),{ok:!0}}function Mn(e,t,n){if(e instanceof t.HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")){if(e.checked!==n){if(e.type==="radio"&&!n)return{ok:!1,problem:"NOT_CHECKABLE"};L(e,t,"left")}return e.checked===n?{ok:!0}:{ok:!1,problem:"STATE_NOT_CHANGED"}}let o=e.getAttribute("role");if(o==="checkbox"||o==="switch"||o==="radio"||o==="menuitemcheckbox"){let r=()=>e.getAttribute("aria-checked")==="true";if(r()!==n)L(e,t,"left");return r()===n?{ok:!0}:{ok:!1,problem:"STATE_NOT_CHANGED"}}return{ok:!1,problem:"NOT_CHECKABLE"}}var Rn=/^(?:[\s\S]|[A-Z][A-Za-z0-9]{1,23})$/u;function kn(e,t){if(e instanceof t.HTMLButtonElement)return!0;if(e instanceof t.HTMLInputElement)return["submit","button","reset","image"].includes(e.type);let n=e.localName;return n==="a"&&e.hasAttribute("href")||n==="summary"}function Nn(e,t){if(e instanceof t.HTMLButtonElement)return!0;if(e instanceof t.HTMLInputElement)return["submit","button","reset","image","checkbox","radio"].includes(e.type);return e.localName==="summary"}function ae(e,t){e.dispatchEvent(new t.MouseEvent("click",{bubbles:!0,cancelable:!0,composed:!0,view:t,detail:0}))}function wn(e,t,n){if(!Rn.test(n))return{ok:!1,problem:"INVALID_ACTION"};let o=n==="Space"?" ":n;if(e instanceof t.HTMLElement)e.focus();let r={key:o,bubbles:!0,cancelable:!0,composed:!0},i=e.dispatchEvent(new t.KeyboardEvent("keydown",r));if(o==="Enter"&&i){if(kn(e,t))ae(e,t);else if(e instanceof t.HTMLInputElement&&Xe(e,t)&&e.form)Dn(e.form,t)}let s=e.dispatchEvent(new t.KeyboardEvent("keyup",r));if(o===" "&&i&&s&&Nn(e,t))ae(e,t);return{ok:!0}}var Cn=new Set(["submit","image"]),vn=new Set(["text","search","url","tel","email","password","date","month","week","time","datetime-local","number"]);function Dn(e,t){let n=Array.from(e.elements),o=e.getRootNode(),r=Array.from(o.querySelectorAll("button, input")).find((s)=>(s instanceof t.HTMLButtonElement&&s.type==="submit"||s instanceof t.HTMLInputElement&&Cn.has(s.type))&&s.form===e);if(r){if(w(r))ae(r,t);return}if(n.filter((s)=>s instanceof t.HTMLInputElement&&vn.has(s.type)).length===1)e.requestSubmit()}function _n(e,t){if(e instanceof t.HTMLInputElement&&(e.type==="checkbox"||e.type==="radio"))return e.checked;if(e instanceof t.HTMLInputElement||e instanceof t.HTMLTextAreaElement||e instanceof t.HTMLSelectElement)return e.value.slice(0,ie);let n=e.getAttribute("aria-checked");if(n==="true"||n==="false")return n==="true";return e.getAttribute("aria-valuenow")??e.getAttribute("aria-valuetext")}var On=/^[A-Za-z_][\w:.-]{0,127}$/;function Ke(e,t){let n=bn(e);if(!n)return{ok:!1,problem:"INVALID_ACTION"};switch(t.kind){case"click":return L(e,n,t.button??"left"),{ok:!0};case"doubleClick":return L(e,n,"left",1),L(e,n,"left",2),e.dispatchEvent(new n.MouseEvent("dblclick",{...se(e,n,"left"),detail:2})),{ok:!0};case"hover":{let o=se(e,n,"left"),r=typeof n.PointerEvent==="function"?n.PointerEvent:n.MouseEvent;return ze(e,n,o),e.dispatchEvent(new r("pointermove",o)),e.dispatchEvent(new n.MouseEvent("mousemove",o)),{ok:!0}}case"focus":if(e instanceof n.HTMLElement)e.focus();return{ok:!0};case"type":return typeof t.text==="string"?Ve(e,n,t.text,t.append===!0):{ok:!1,problem:"INVALID_ACTION"};case"clear":return Ve(e,n,"",!1);case"select":return Sn(e,n,t);case"check":return Mn(e,n,t.checked===!0);case"pressKey":return typeof t.key==="string"?wn(e,n,t.key):{ok:!1,problem:"INVALID_ACTION"};case"scroll":return e.scrollBy?.({left:Number(t.dx??0)||0,top:Number(t.dy??0)||0}),{ok:!0};case"scrollIntoView":return e.scrollIntoView?.({block:"center",inline:"nearest"}),{ok:!0};case"getText":if(S(e))return{ok:!1,problem:"SENSITIVE_ELEMENT"};return{ok:!0,value:F(e).slice(0,ie)};case"getValue":if(S(e))return{ok:!1,problem:"SENSITIVE_ELEMENT"};return{ok:!0,value:_n(e,n)};case"getAttribute":{if(typeof t.name!=="string"||!On.test(t.name))return{ok:!1,problem:"INVALID_ACTION"};let o=t.name.toLowerCase();if(S(e))return{ok:!1,problem:"SENSITIVE_ELEMENT"};return{ok:!0,value:e.getAttribute(o)?.slice(0,ie)??null}}case"exists":return{ok:!0,value:!0};default:return{ok:!1,problem:"INVALID_ACTION"}}}var $e=1,je="__burdenoffUiRuntime",In=60000,Ln="fg-ui-highlight",Wn=new Set(["role","css","testId","xpath","fuzzy","anchor","text"]);function le(e){if(!e||typeof e!=="object")return!1;let t=e;if(!Array.isArray(t.methods)||t.methods.length===0||t.methods.length>8)return!1;if(t.frame!==void 0&&!(Array.isArray(t.frame)&&t.frame.every((n)=>typeof n==="string")))return!1;return t.methods.every((n)=>!!n&&typeof n==="object"&&Wn.has(String(n.kind)))}function ue(){return{status:"failed",code:"ELEMENT_NOT_FOUND",candidates:[],candidateCount:0,attempts:[]}}function ce(e){return{status:e.status,method:e.method,methodIndex:e.methodIndex,fallback:e.fallback,candidate:e.candidate,attempts:e.attempts}}function Un(e){try{return e.defaultView?.frameElement??null}catch{return null}}function Pn(e,t,n,o){let r=e.getRootNode();if(typeof r.elementFromPoint!=="function")return null;let i=r.elementFromPoint(t,n);if(!i)return"offscreen";if(i===e||e.contains(i))return null;return o.some((s)=>s.contains(i))?null:"covered"}function Hn(e,t){let n=t.x+t.width/2,o=t.y+t.height/2,r=Array.from(e.labels??[]),i=e;for(let s=0;s<32;s+=1){let a=Pn(i,n,o,s===0?r:[]);if(a)return a;let l=i.getRootNode();if(l&&"host"in l){i=l.host;continue}let u=Un(i.ownerDocument);if(!u)return null;let f=u.getBoundingClientRect();n+=f.x+u.clientLeft,o+=f.y+u.clientTop,i=u}return null}function Vn(e,t){let n=e.ownerDocument.defaultView;if(!n)return!1;let o=t.x+t.width/2,r=t.y+t.height/2;return o<0||r<0||o>=n.innerWidth||r>=n.innerHeight}function Fn(e){let t=e.ownerDocument.defaultView;if(t&&t.getComputedStyle(e).pointerEvents==="none")return"noPointerEvents";let n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;if(Vn(e,n)&&typeof e.scrollIntoView==="function")e.scrollIntoView({block:"center",inline:"center"}),n=e.getBoundingClientRect();return Hn(e,n)}function Bn(e,t={}){let n=t.root??e,o={...t.rectOf?{rectOf:t.rectOf}:{},...t.isVisible?{isVisible:t.isVisible}:{}},r=null,i=null,s=()=>{if(i!==null)clearTimeout(i),i=null;r?.remove(),r=null},a=(c,b)=>(s(),ve(n,c,{...o,...b?{state:b}:{}})),l=(c,b={})=>{if(!le(c))return ue();let m=a(c,b.state);return m.status==="found"?ce(m):m},u=(c,b,m={})=>{if(!b||typeof b!=="object"||typeof b.kind!=="string")return{ok:!1,code:"INVALID_ACTION"};if(!le(c))return{ok:!1,code:"ELEMENT_NOT_FOUND",resolution:ue()};let p=m.state??(Fe.has(b.kind)?"visible":"interactable"),h=a(c,p);if(h.status!=="found"){if(b.kind==="exists"&&h.code==="ELEMENT_NOT_FOUND")return{ok:!0,value:!1,resolution:h};return{ok:!1,code:h.code,resolution:h}}let T=ce(h),W=Be.has(b.kind)?Fn(h.element):null;if(W)return{ok:!1,code:"ELEMENT_NOT_INTERACTABLE",reason:W,resolution:{status:"failed",code:"ELEMENT_NOT_INTERACTABLE",candidates:[h.candidate],candidateCount:1,attempts:h.attempts}};let M=Ke(h.element,b);if(!M.ok)return{ok:!1,code:M.problem,resolution:T};return M.value===void 0?{ok:!0,resolution:T}:{ok:!0,resolution:T,value:M.value}},f=(c,b,m)=>{let p=e.createElement(Ln);p.setAttribute("aria-hidden","true"),p.setAttribute("style","all: initial; position: fixed; inset: 0; pointer-events: none; z-index: 2147483647;");let h=p.attachShadow({mode:"closed"});c.forEach((T,W)=>{let M=e.createElement("div");M.setAttribute("style",`position: fixed; left: ${T.bounds.x-3}px; top: ${T.bounds.y-3}px; width: ${T.bounds.width+6}px; height: ${T.bounds.height+6}px; outline: 3px solid Highlight; border-radius: 4px; box-sizing: border-box;`);let de=m?`${W+1}${b?` ${b}`:""}`:b;if(de){let q=e.createElement("span");q.textContent=de.slice(0,120),q.setAttribute("style","position: absolute; left: 0; top: 100%; margin-top: 4px; padding: 2px 6px; font: 600 11px system-ui, sans-serif; background: Highlight; color: HighlightText; border-radius: 3px; white-space: nowrap;"),M.appendChild(q)}h.appendChild(M)}),e.documentElement.appendChild(p),r=p};return{version:$e,resolve:l,act:u,highlight:(c,b={})=>{if(!le(c))return ue();let m=a(c,b.state??"visible");if(m.status==="found")f([m.candidate],b.label,!1);else if(m.candidates.length>0)f(m.candidates,b.label,!0);let p=Math.min(In,Math.max(0,Number(b.durationMs??0)||0));if(r&&p>0)i=setTimeout(s,p);return m.status==="found"?ce(m):m},clearHighlight:s,snapshot:(c={})=>(s(),He(e,{...o,...c.maxNodes?{maxNodes:c.maxNodes}:{}}))}}function Ge(e,t){let n=Reflect.get(e,je);if(n&&typeof n==="object"&&typeof n.version==="number"&&n.version>=$e)return n;let o=Object.freeze(Bn(t));return Object.defineProperty(e,je,{value:o,configurable:!0,enumerable:!1,writable:!1}),o}Ge(globalThis,globalThis.document);})();