@xpert-ai/chatkit-host-automation 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +405 -405
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { safeRandomUUID as ge } from "@xpert-ai/chatkit-web-shared";
|
|
2
|
+
const te = [
|
|
2
3
|
"host_page_snapshot",
|
|
3
4
|
"host_page_click",
|
|
4
5
|
"host_page_fill",
|
|
@@ -12,27 +13,27 @@ const Qt = [
|
|
|
12
13
|
"host_page_screenshot",
|
|
13
14
|
"host_page_read",
|
|
14
15
|
"host_page_wait_for"
|
|
15
|
-
];
|
|
16
|
-
function
|
|
16
|
+
], ee = 80, me = 12, Z = 2, ye = 4e3, kt = 600, ne = 80, be = 80, ve = 12;
|
|
17
|
+
function oe(e) {
|
|
17
18
|
return (e ?? "").replace(/\s+/g, " ").trim();
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function Dt(e, t = kt) {
|
|
20
21
|
return e.length > t ? `${e.slice(0, t)}... [truncated ${e.length - t} chars]` : e;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
return e ?
|
|
23
|
+
function we(e, t = kt) {
|
|
24
|
+
return e ? Dt(e, t) : void 0;
|
|
24
25
|
}
|
|
25
26
|
function $(e) {
|
|
26
|
-
const t =
|
|
27
|
-
return t ?
|
|
27
|
+
const t = oe(e.textContent);
|
|
28
|
+
return t ? Dt(t) : void 0;
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
const t =
|
|
30
|
+
function ie(e) {
|
|
31
|
+
const t = oe(
|
|
31
32
|
Array.from(e.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent ?? "").join(" ")
|
|
32
33
|
);
|
|
33
|
-
return t ?
|
|
34
|
+
return t ? Dt(t) : void 0;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function pt(e) {
|
|
36
37
|
var o;
|
|
37
38
|
if (!(e instanceof HTMLElement || e instanceof SVGElement) || e instanceof HTMLElement && e.hidden)
|
|
38
39
|
return !1;
|
|
@@ -42,7 +43,7 @@ function ft(e) {
|
|
|
42
43
|
const n = e.getBoundingClientRect();
|
|
43
44
|
return n.width > 0 && n.height > 0;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function ot(e) {
|
|
46
47
|
const t = e.getBoundingClientRect();
|
|
47
48
|
return {
|
|
48
49
|
x: t.left,
|
|
@@ -51,10 +52,10 @@ function nt(e) {
|
|
|
51
52
|
height: t.height
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function Se(e) {
|
|
55
56
|
return e instanceof Document ? e : e.ownerDocument;
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function Pt(e) {
|
|
58
59
|
let t = e;
|
|
59
60
|
for (; t; ) {
|
|
60
61
|
let n = t.previousElementSibling;
|
|
@@ -71,29 +72,29 @@ function Mt(e) {
|
|
|
71
72
|
t = t.parentElement;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
const t = Array.from(e.children).map((n) =>
|
|
76
|
-
return t.length > 1 ? t : e.children.length === 1 ?
|
|
75
|
+
function _t(e) {
|
|
76
|
+
const t = Array.from(e.children).map((n) => ie(n) ?? $(n)).filter((n) => !!n);
|
|
77
|
+
return t.length > 1 ? t : e.children.length === 1 ? _t(e.children[0]) : t;
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function Ee(e) {
|
|
79
80
|
if (Array.from(e.children).some(
|
|
80
|
-
(i) =>
|
|
81
|
+
(i) => _t(i).length === 2
|
|
81
82
|
))
|
|
82
83
|
return;
|
|
83
|
-
const t =
|
|
84
|
+
const t = _t(e);
|
|
84
85
|
if (t.length !== 2)
|
|
85
86
|
return;
|
|
86
87
|
const [n, o] = t;
|
|
87
88
|
if (!(!n || !o || n === o || n.length > 120))
|
|
88
89
|
return { name: n, value: o };
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
return e.fields ? e.fields.slice(0,
|
|
91
|
+
function _e(e) {
|
|
92
|
+
return e.fields ? e.fields.slice(0, Z).map((t) => `${t.name}: ${t.value}`) : e.items ? e.items.slice(0, Z) : e.rows ? e.rows.slice(0, Z).map((t) => t.join(" | ")) : e.text ? [e.text] : [];
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function xe(e) {
|
|
94
95
|
return e.fields ? e.fields.length : e.items ? e.items.length : e.rows ? e.rows.length : e.text ? 1 : 0;
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
+
function Re(e) {
|
|
97
98
|
return [
|
|
98
99
|
e.heading,
|
|
99
100
|
e.text,
|
|
@@ -103,16 +104,16 @@ function me(e) {
|
|
|
103
104
|
...(e.rows ?? []).flat()
|
|
104
105
|
].reduce((t, n) => t + ((n == null ? void 0 : n.length) ?? 0), 0);
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
-
return e.slice(0,
|
|
108
|
-
const o =
|
|
107
|
+
function Te(e) {
|
|
108
|
+
return e.slice(0, ee).map((t, n) => {
|
|
109
|
+
const o = Re(t), i = `b${n + 1}`;
|
|
109
110
|
return {
|
|
110
111
|
...t,
|
|
111
112
|
blockId: i,
|
|
112
|
-
preview:
|
|
113
|
-
itemCount:
|
|
113
|
+
preview: _e(t),
|
|
114
|
+
itemCount: xe(t),
|
|
114
115
|
chars: o,
|
|
115
|
-
truncated: o >
|
|
116
|
+
truncated: o > ye,
|
|
116
117
|
readHint: {
|
|
117
118
|
tool: "host_page_read",
|
|
118
119
|
args: { blockId: i }
|
|
@@ -120,7 +121,7 @@ function ye(e) {
|
|
|
120
121
|
};
|
|
121
122
|
});
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
+
function Ae(e) {
|
|
124
125
|
return e.map((t, n) => ({
|
|
125
126
|
index: n,
|
|
126
127
|
blockId: t.blockId,
|
|
@@ -132,32 +133,32 @@ function be(e) {
|
|
|
132
133
|
truncated: t.truncated
|
|
133
134
|
}));
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
return e.truncated ? "block_truncated" : e.type === "keyValueList" ? "structured_fields" : e.type === "table" ? "structured_table" : e.itemCount >
|
|
136
|
+
function Ce(e) {
|
|
137
|
+
return e.truncated ? "block_truncated" : e.type === "keyValueList" ? "structured_fields" : e.type === "table" ? "structured_table" : e.itemCount > Z ? "preview_incomplete" : "long_readable_block";
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
+
function Ie(e) {
|
|
139
140
|
return (e.type === "keyValueList" ? 100 : e.type === "table" ? 90 : e.type === "list" ? 80 : e.type === "paragraph" ? 50 : 10) + (e.truncated ? 40 : 0) + Math.min(e.itemCount, 20) + Math.min(Math.floor(e.chars / 400), 20);
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function ke(e) {
|
|
142
143
|
return e.filter(
|
|
143
|
-
(t) => t.type !== "heading" && (t.truncated || t.itemCount >
|
|
144
|
+
(t) => t.type !== "heading" && (t.truncated || t.itemCount > Z || t.chars > kt)
|
|
144
145
|
).map((t, n) => ({
|
|
145
146
|
block: t,
|
|
146
147
|
index: n,
|
|
147
|
-
score:
|
|
148
|
-
})).sort((t, n) => n.score - t.score || t.index - n.index).slice(0,
|
|
148
|
+
score: Ie(t)
|
|
149
|
+
})).sort((t, n) => n.score - t.score || t.index - n.index).slice(0, me).sort((t, n) => t.index - n.index).map(({ block: t }) => ({
|
|
149
150
|
blockId: t.blockId,
|
|
150
151
|
type: t.type,
|
|
151
152
|
heading: t.heading,
|
|
152
|
-
reason:
|
|
153
|
+
reason: Ce(t),
|
|
153
154
|
args: {
|
|
154
155
|
blockId: t.blockId,
|
|
155
156
|
pageSize: t.fields || t.items || t.rows ? Math.min(20, Math.max(1, t.itemCount)) : void 0
|
|
156
157
|
}
|
|
157
158
|
}));
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
-
const t =
|
|
160
|
+
function De(e) {
|
|
161
|
+
const t = Ae(e.blocks), n = ke(e.blocks);
|
|
161
162
|
return {
|
|
162
163
|
...e,
|
|
163
164
|
outline: t,
|
|
@@ -176,16 +177,16 @@ function Ee(e) {
|
|
|
176
177
|
}))
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
-
const o = [], i =
|
|
180
|
+
function Pe(e, t, n) {
|
|
181
|
+
const o = [], i = Se(e).createTreeWalker(
|
|
181
182
|
e,
|
|
182
183
|
NodeFilter.SHOW_ELEMENT
|
|
183
184
|
);
|
|
184
185
|
let r = i.nextNode();
|
|
185
186
|
for (; r; ) {
|
|
186
187
|
const a = r;
|
|
187
|
-
if (
|
|
188
|
-
const s =
|
|
188
|
+
if (pt(a)) {
|
|
189
|
+
const s = Ee(a);
|
|
189
190
|
s && o.push({ ...s, element: a });
|
|
190
191
|
}
|
|
191
192
|
r = i.nextNode();
|
|
@@ -193,59 +194,59 @@ function _e(e, t, n) {
|
|
|
193
194
|
if (o.length !== 0) {
|
|
194
195
|
t.push({
|
|
195
196
|
type: "keyValueList",
|
|
196
|
-
heading:
|
|
197
|
-
fields: o.slice(0,
|
|
198
|
-
rect:
|
|
197
|
+
heading: Pt(o[0].element),
|
|
198
|
+
fields: o.slice(0, ne).map(({ name: a, value: s }) => ({ name: a, value: s })),
|
|
199
|
+
rect: ot(o[0].element)
|
|
199
200
|
});
|
|
200
201
|
for (const a of o)
|
|
201
202
|
n.add(a.element);
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
|
-
function
|
|
205
|
+
function Me(e, t, n) {
|
|
205
206
|
for (const o of Array.from(e.querySelectorAll('ul,ol,[role="list"]'))) {
|
|
206
|
-
if (!
|
|
207
|
+
if (!pt(o))
|
|
207
208
|
continue;
|
|
208
|
-
const i = Array.from(o.children).map((r) => $(r)).filter((r) => !!r).slice(0,
|
|
209
|
+
const i = Array.from(o.children).map((r) => $(r)).filter((r) => !!r).slice(0, ne);
|
|
209
210
|
if (i.length !== 0) {
|
|
210
211
|
t.push({
|
|
211
212
|
type: "list",
|
|
212
|
-
heading:
|
|
213
|
+
heading: Pt(o),
|
|
213
214
|
items: i,
|
|
214
|
-
rect:
|
|
215
|
+
rect: ot(o)
|
|
215
216
|
}), n.add(o);
|
|
216
217
|
for (const r of Array.from(o.children))
|
|
217
218
|
n.add(r);
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
function
|
|
222
|
+
function Ne(e, t, n) {
|
|
222
223
|
var o;
|
|
223
224
|
for (const i of Array.from(e.querySelectorAll('table,[role="table"],[role="grid"]'))) {
|
|
224
|
-
if (!
|
|
225
|
+
if (!pt(i))
|
|
225
226
|
continue;
|
|
226
227
|
const r = Array.from(i.querySelectorAll('tr,[role="row"]')).map(
|
|
227
|
-
(s) => Array.from(s.querySelectorAll('th,td,[role="columnheader"],[role="cell"],[role="gridcell"]')).map((d) => $(d)).filter((d) => !!d).slice(0,
|
|
228
|
-
).filter((s) => s.length > 0).slice(0,
|
|
228
|
+
(s) => Array.from(s.querySelectorAll('th,td,[role="columnheader"],[role="cell"],[role="gridcell"]')).map((d) => $(d)).filter((d) => !!d).slice(0, ve)
|
|
229
|
+
).filter((s) => s.length > 0).slice(0, be);
|
|
229
230
|
if (r.length === 0)
|
|
230
231
|
continue;
|
|
231
232
|
const a = (o = r[0]) != null && o.every((s) => s.length <= 120) ? r[0] : void 0;
|
|
232
233
|
t.push({
|
|
233
234
|
type: "table",
|
|
234
|
-
heading:
|
|
235
|
+
heading: Pt(i),
|
|
235
236
|
headers: a,
|
|
236
237
|
rows: a ? r.slice(1) : r,
|
|
237
|
-
rect:
|
|
238
|
+
rect: ot(i)
|
|
238
239
|
}), n.add(i);
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function qe(e, t, n) {
|
|
242
243
|
const o = 'h1,h2,h3,h4,h5,h6,[role="heading"],p,article,section';
|
|
243
244
|
for (const i of Array.from(e.querySelectorAll(o))) {
|
|
244
|
-
if (t.length >=
|
|
245
|
+
if (t.length >= ee)
|
|
245
246
|
break;
|
|
246
|
-
if (n.has(i) || !
|
|
247
|
+
if (n.has(i) || !pt(i))
|
|
247
248
|
continue;
|
|
248
|
-
const r = i.tagName.toLowerCase(), a =
|
|
249
|
+
const r = i.tagName.toLowerCase(), a = ie(i) ?? $(i);
|
|
249
250
|
if (a) {
|
|
250
251
|
if (r.match(/^h[1-6]$/) || i.getAttribute("role") === "heading") {
|
|
251
252
|
const s = r.match(/^h[1-6]$/) ? Number(r.slice(1)) : Number(i.getAttribute("aria-level") ?? 0) || 2;
|
|
@@ -253,24 +254,24 @@ function Te(e, t, n) {
|
|
|
253
254
|
type: "heading",
|
|
254
255
|
level: s,
|
|
255
256
|
text: a,
|
|
256
|
-
rect:
|
|
257
|
+
rect: ot(i)
|
|
257
258
|
});
|
|
258
259
|
continue;
|
|
259
260
|
}
|
|
260
261
|
a.length >= 24 && t.push({
|
|
261
262
|
type: "paragraph",
|
|
262
263
|
text: a,
|
|
263
|
-
rect:
|
|
264
|
+
rect: ot(i)
|
|
264
265
|
});
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
|
-
function
|
|
269
|
+
function Oe(e) {
|
|
269
270
|
return e.querySelectorAll(
|
|
270
271
|
'[aria-expanded="false"],[data-expanded="false"],details:not([open]),[hidden]'
|
|
271
272
|
).length;
|
|
272
273
|
}
|
|
273
|
-
function
|
|
274
|
+
function Le(e) {
|
|
274
275
|
return Array.from(e.querySelectorAll("iframe")).filter((t) => {
|
|
275
276
|
try {
|
|
276
277
|
return !t.contentDocument;
|
|
@@ -279,7 +280,7 @@ function Ce(e) {
|
|
|
279
280
|
}
|
|
280
281
|
}).length;
|
|
281
282
|
}
|
|
282
|
-
function
|
|
283
|
+
function Ot(e) {
|
|
283
284
|
const t = e instanceof Document ? e.body ?? e.documentElement : e;
|
|
284
285
|
if (!t)
|
|
285
286
|
return {
|
|
@@ -297,8 +298,8 @@ function Nt(e) {
|
|
|
297
298
|
}
|
|
298
299
|
};
|
|
299
300
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
300
|
-
|
|
301
|
-
const i =
|
|
301
|
+
Pe(t, n, o), Me(t, n, o), Ne(t, n, o), qe(t, n, o);
|
|
302
|
+
const i = Te(n), r = i.filter((c) => c.truncated).length, a = Oe(t), s = Le(t), d = n.length > i.length || r > 0 || a > 0 || s > 0, u = [];
|
|
302
303
|
return a > 0 && u.push("Some content is inside collapsed sections."), s > 0 && u.push("Some frame content could not be read from DOM."), {
|
|
303
304
|
blocks: i,
|
|
304
305
|
totalBlocks: n.length,
|
|
@@ -315,7 +316,7 @@ function Nt(e) {
|
|
|
315
316
|
...u.length > 0 ? { warnings: u } : {}
|
|
316
317
|
};
|
|
317
318
|
}
|
|
318
|
-
function
|
|
319
|
+
function st(e, t, n) {
|
|
319
320
|
const o = Math.max(1, Math.min(100, Math.floor(n))), i = Math.max(1, Math.ceil(e / o)), r = Math.max(1, Math.min(i, Math.floor(t))), a = (r - 1) * o;
|
|
320
321
|
return {
|
|
321
322
|
page: r,
|
|
@@ -325,55 +326,55 @@ function rt(e, t, n) {
|
|
|
325
326
|
end: Math.min(e, a + o)
|
|
326
327
|
};
|
|
327
328
|
}
|
|
328
|
-
function
|
|
329
|
+
function xt(e) {
|
|
329
330
|
return JSON.stringify(e).length;
|
|
330
331
|
}
|
|
331
|
-
function
|
|
332
|
+
function bt(e, t) {
|
|
332
333
|
const n = e[t];
|
|
333
334
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
334
335
|
}
|
|
335
|
-
function
|
|
336
|
+
function at(e, t) {
|
|
336
337
|
const n = e[t];
|
|
337
338
|
return typeof n == "string" && n.trim() ? n : void 0;
|
|
338
339
|
}
|
|
339
|
-
function
|
|
340
|
+
function Rt(e, t, n = !1) {
|
|
340
341
|
const o = {
|
|
341
342
|
...e,
|
|
342
343
|
truncated: !!e.truncated || n
|
|
343
|
-
}, i =
|
|
344
|
+
}, i = xt(o), r = {
|
|
344
345
|
...o,
|
|
345
346
|
chars: i
|
|
346
347
|
};
|
|
347
|
-
return
|
|
348
|
-
blockId:
|
|
349
|
-
type:
|
|
350
|
-
heading:
|
|
351
|
-
scope:
|
|
352
|
-
page:
|
|
348
|
+
return xt(r) <= t ? r : {
|
|
349
|
+
blockId: at(e, "blockId"),
|
|
350
|
+
type: at(e, "type"),
|
|
351
|
+
heading: we(at(e, "heading"), 120),
|
|
352
|
+
scope: at(e, "scope"),
|
|
353
|
+
page: bt(e, "page"),
|
|
353
354
|
pageSize: 0,
|
|
354
|
-
pageCount:
|
|
355
|
-
nextPage:
|
|
355
|
+
pageCount: bt(e, "pageCount"),
|
|
356
|
+
nextPage: bt(e, "nextPage"),
|
|
356
357
|
chars: i,
|
|
357
358
|
truncated: !0,
|
|
358
359
|
budgetExceeded: !0,
|
|
359
360
|
warning: "Read result exceeded maxChars; retry with a smaller pageSize or a narrower blockId/query."
|
|
360
361
|
};
|
|
361
362
|
}
|
|
362
|
-
function
|
|
363
|
+
function ct(e, t, n) {
|
|
363
364
|
let o = t;
|
|
364
365
|
for (; o >= 1; ) {
|
|
365
|
-
const i = n(o), r =
|
|
366
|
+
const i = n(o), r = Rt(
|
|
366
367
|
i,
|
|
367
368
|
e,
|
|
368
369
|
o < t
|
|
369
370
|
);
|
|
370
|
-
if (
|
|
371
|
+
if (xt(r) <= e)
|
|
371
372
|
return r;
|
|
372
373
|
o = Math.floor(o / 2);
|
|
373
374
|
}
|
|
374
|
-
return
|
|
375
|
+
return Rt(n(1), e, !0);
|
|
375
376
|
}
|
|
376
|
-
function
|
|
377
|
+
function je(e, t = {}) {
|
|
377
378
|
var d;
|
|
378
379
|
const n = typeof t.page == "number" ? t.page : 1, o = typeof t.pageSize == "number" ? t.pageSize : 20, i = typeof t.maxChars == "number" && Number.isFinite(t.maxChars) ? Math.max(500, Math.min(12e3, Math.floor(t.maxChars))) : 4e3, r = (d = t.query) == null ? void 0 : d.trim().toLowerCase(), a = r ? e.blocks.filter(
|
|
379
380
|
(u) => JSON.stringify(u).toLowerCase().includes(r)
|
|
@@ -381,8 +382,8 @@ function Ie(e, t = {}) {
|
|
|
381
382
|
if (s) {
|
|
382
383
|
if (s.fields && s.fields.length > 0) {
|
|
383
384
|
const u = s.fields;
|
|
384
|
-
return
|
|
385
|
-
const l =
|
|
385
|
+
return ct(i, o, (c) => {
|
|
386
|
+
const l = st(u.length, n, c);
|
|
386
387
|
return {
|
|
387
388
|
...s,
|
|
388
389
|
fields: u.slice(l.start, l.end),
|
|
@@ -395,8 +396,8 @@ function Ie(e, t = {}) {
|
|
|
395
396
|
}
|
|
396
397
|
if (s.items && s.items.length > 0) {
|
|
397
398
|
const u = s.items;
|
|
398
|
-
return
|
|
399
|
-
const l =
|
|
399
|
+
return ct(i, o, (c) => {
|
|
400
|
+
const l = st(u.length, n, c);
|
|
400
401
|
return {
|
|
401
402
|
...s,
|
|
402
403
|
items: u.slice(l.start, l.end),
|
|
@@ -409,8 +410,8 @@ function Ie(e, t = {}) {
|
|
|
409
410
|
}
|
|
410
411
|
if (s.rows && s.rows.length > 0) {
|
|
411
412
|
const u = s.rows;
|
|
412
|
-
return
|
|
413
|
-
const l =
|
|
413
|
+
return ct(i, o, (c) => {
|
|
414
|
+
const l = st(u.length, n, c);
|
|
414
415
|
return {
|
|
415
416
|
...s,
|
|
416
417
|
rows: u.slice(l.start, l.end),
|
|
@@ -421,10 +422,10 @@ function Ie(e, t = {}) {
|
|
|
421
422
|
};
|
|
422
423
|
});
|
|
423
424
|
}
|
|
424
|
-
return
|
|
425
|
+
return Rt(s, i);
|
|
425
426
|
}
|
|
426
|
-
return
|
|
427
|
-
const c =
|
|
427
|
+
return ct(i, o, (u) => {
|
|
428
|
+
const c = st(a.length, n, u);
|
|
428
429
|
return {
|
|
429
430
|
scope: "visible",
|
|
430
431
|
blocks: a.slice(c.start, c.end),
|
|
@@ -442,9 +443,9 @@ class W extends Error {
|
|
|
442
443
|
super(t), this.details = n;
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
),
|
|
446
|
+
const Be = new Set(
|
|
447
|
+
te
|
|
448
|
+
), Ve = [
|
|
448
449
|
"a[href]",
|
|
449
450
|
"button",
|
|
450
451
|
"input",
|
|
@@ -459,7 +460,7 @@ const Me = new Set(
|
|
|
459
460
|
"[data-testid]",
|
|
460
461
|
"[data-test-id]",
|
|
461
462
|
"[data-qa]"
|
|
462
|
-
].join(","),
|
|
463
|
+
].join(","), Lt = 100, Fe = 1e4, He = 6e4, jt = 1e4, ze = 100, $e = 6e4, Bt = 2 * 6e4, Ue = [
|
|
463
464
|
"id",
|
|
464
465
|
"role",
|
|
465
466
|
"aria-label",
|
|
@@ -472,46 +473,45 @@ const Me = new Set(
|
|
|
472
473
|
"aria-disabled",
|
|
473
474
|
"hidden"
|
|
474
475
|
];
|
|
475
|
-
function
|
|
476
|
-
|
|
477
|
-
return ((t = (e = globalThis.crypto) == null ? void 0 : e.randomUUID) == null ? void 0 : t.call(e)) ?? `page-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
476
|
+
function Vt() {
|
|
477
|
+
return ge();
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function Tt(e) {
|
|
480
480
|
if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean")
|
|
481
481
|
return e;
|
|
482
482
|
if (Array.isArray(e))
|
|
483
|
-
return e.map(
|
|
483
|
+
return e.map(Tt);
|
|
484
484
|
if (typeof e == "object")
|
|
485
485
|
return Object.fromEntries(
|
|
486
|
-
Object.entries(e).filter(([t, n]) => t !== "actionToken" && n !== void 0).sort(([t], [n]) => t.localeCompare(n)).map(([t, n]) => [t,
|
|
486
|
+
Object.entries(e).filter(([t, n]) => t !== "actionToken" && n !== void 0).sort(([t], [n]) => t.localeCompare(n)).map(([t, n]) => [t, Tt(n)])
|
|
487
487
|
);
|
|
488
488
|
}
|
|
489
|
-
async function
|
|
489
|
+
async function Ft(e) {
|
|
490
490
|
const t = new TextEncoder().encode(
|
|
491
|
-
JSON.stringify(
|
|
491
|
+
JSON.stringify(Tt(e))
|
|
492
492
|
), n = await globalThis.crypto.subtle.digest("SHA-256", t);
|
|
493
493
|
return Array.from(
|
|
494
494
|
new Uint8Array(n),
|
|
495
495
|
(o) => o.toString(16).padStart(2, "0")
|
|
496
496
|
).join("");
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
return
|
|
498
|
+
function Xe(e) {
|
|
499
|
+
return Be.has(e);
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function D(e) {
|
|
502
502
|
if (e.nodeType === 9)
|
|
503
503
|
return e;
|
|
504
504
|
if (!e.ownerDocument)
|
|
505
505
|
throw new Error("Host automation root has no owner document.");
|
|
506
506
|
return e.ownerDocument;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
return
|
|
508
|
+
function q(e) {
|
|
509
|
+
return D(e).defaultView ?? window;
|
|
510
510
|
}
|
|
511
511
|
function A(e) {
|
|
512
512
|
return typeof e == "object" && e !== null && !Array.isArray(e) ? e : {};
|
|
513
513
|
}
|
|
514
|
-
function
|
|
514
|
+
function vt(e, t) {
|
|
515
515
|
if (typeof e != "string" || e.trim() === "")
|
|
516
516
|
throw new Error(`${t} must be a non-empty string.`);
|
|
517
517
|
return e;
|
|
@@ -522,13 +522,13 @@ function m(e) {
|
|
|
522
522
|
function Q(e) {
|
|
523
523
|
return e === "viewport_normalized" ? "viewport_normalized" : "viewport-css-px";
|
|
524
524
|
}
|
|
525
|
-
function
|
|
526
|
-
return
|
|
525
|
+
function Ht(e) {
|
|
526
|
+
return re(e, ["move", "down", "up", "click"]) ?? "click";
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
const n =
|
|
528
|
+
function zt(e, t) {
|
|
529
|
+
const n = $t(t.x, "x"), o = $t(t.y, "y");
|
|
530
530
|
if (Q(t.coordinateSpace) === "viewport_normalized") {
|
|
531
|
-
const i =
|
|
531
|
+
const i = q(e);
|
|
532
532
|
return {
|
|
533
533
|
x: Number((n * i.innerWidth).toFixed(3)),
|
|
534
534
|
y: Number((o * i.innerHeight).toFixed(3))
|
|
@@ -536,21 +536,21 @@ function Ft(e, t) {
|
|
|
536
536
|
}
|
|
537
537
|
return { x: n, y: o };
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function lt(e) {
|
|
540
540
|
return typeof e == "number" && Number.isInteger(e) ? e : void 0;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function $t(e, t) {
|
|
543
543
|
if (typeof e != "number" || !Number.isFinite(e))
|
|
544
544
|
throw new Error(`${t} must be a finite number.`);
|
|
545
545
|
return e;
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function Y(e) {
|
|
548
548
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function re(e, t) {
|
|
551
551
|
return typeof e == "string" && t.includes(e) ? e : void 0;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function We(e) {
|
|
554
554
|
if (typeof e == "string")
|
|
555
555
|
return [e];
|
|
556
556
|
if (Array.isArray(e) && e.every((t) => typeof t == "string"))
|
|
@@ -561,23 +561,23 @@ function _(e) {
|
|
|
561
561
|
const t = (e.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
562
562
|
return t ? t.slice(0, 160) : void 0;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function gt(e) {
|
|
565
565
|
const t = Array.from(e.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim();
|
|
566
566
|
return t ? t.slice(0, 160) : void 0;
|
|
567
567
|
}
|
|
568
568
|
function T(e) {
|
|
569
569
|
return e.tagName.toLowerCase() === "input";
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function U(e) {
|
|
572
572
|
return e.tagName.toLowerCase() === "textarea";
|
|
573
573
|
}
|
|
574
574
|
function L(e) {
|
|
575
575
|
return e.tagName.toLowerCase() === "select";
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function se(e) {
|
|
578
578
|
return e.tagName.toLowerCase() === "button";
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function At(e) {
|
|
581
581
|
return e.tagName.toLowerCase() === "iframe";
|
|
582
582
|
}
|
|
583
583
|
function I(e) {
|
|
@@ -585,34 +585,34 @@ function I(e) {
|
|
|
585
585
|
const t = (n = e.ownerDocument.defaultView) == null ? void 0 : n.HTMLElement;
|
|
586
586
|
return !!(t && e instanceof t);
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function Mt(e) {
|
|
589
589
|
var n;
|
|
590
590
|
const t = (n = e.ownerDocument.defaultView) == null ? void 0 : n.SVGElement;
|
|
591
591
|
return !!(t && e instanceof t);
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
if (T(e) ||
|
|
593
|
+
function ft(e) {
|
|
594
|
+
if (T(e) || U(e) || L(e))
|
|
595
595
|
return e.value;
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function ae(e) {
|
|
598
598
|
return T(e) && (e.type === "checkbox" || e.type === "radio");
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
return T(e) || L(e) ||
|
|
600
|
+
function Ye(e) {
|
|
601
|
+
return T(e) || L(e) || U(e) ? Array.from(e.labels ?? []) : [];
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function Ge(e, t) {
|
|
604
604
|
var o;
|
|
605
605
|
return (((o = e.getAttribute(t)) == null ? void 0 : o.trim().split(/\s+/)) ?? []).map((i) => e.ownerDocument.getElementById(i)).filter((i) => !!i).map((i) => _(i)).filter((i) => !!i);
|
|
606
606
|
}
|
|
607
|
-
function
|
|
608
|
-
const t =
|
|
607
|
+
function Ke(e) {
|
|
608
|
+
const t = Ge(e, "aria-labelledby");
|
|
609
609
|
if (t.length > 0)
|
|
610
610
|
return t.join(" ").slice(0, 160);
|
|
611
|
-
const n =
|
|
611
|
+
const n = Ye(e).map((o) => _(o)).filter((o) => !!o);
|
|
612
612
|
if (n.length > 0)
|
|
613
613
|
return n.join(" ").slice(0, 160);
|
|
614
614
|
}
|
|
615
|
-
function
|
|
615
|
+
function Je(e) {
|
|
616
616
|
const t = [];
|
|
617
617
|
let n = e.nextSibling;
|
|
618
618
|
for (; n; ) {
|
|
@@ -640,7 +640,7 @@ function He(e) {
|
|
|
640
640
|
const o = t.join(" ").replace(/\s+/g, " ").trim();
|
|
641
641
|
return o ? o.slice(0, 160) : void 0;
|
|
642
642
|
}
|
|
643
|
-
function
|
|
643
|
+
function Ut(e, t) {
|
|
644
644
|
var u;
|
|
645
645
|
const n = e.ownerDocument, o = n.body;
|
|
646
646
|
if (!o)
|
|
@@ -652,8 +652,8 @@ function Xt(e, t) {
|
|
|
652
652
|
let d = s.nextNode();
|
|
653
653
|
for (; d; ) {
|
|
654
654
|
const c = d;
|
|
655
|
-
if (c !== e && !c.contains(e) &&
|
|
656
|
-
const l = c.getBoundingClientRect(), h =
|
|
655
|
+
if (c !== e && !c.contains(e) && Nt(c)) {
|
|
656
|
+
const l = c.getBoundingClientRect(), h = gt(c) ?? _(c);
|
|
657
657
|
if (h) {
|
|
658
658
|
const g = l.top + l.height / 2, f = Math.abs(g - r) <= Math.max(28, i.height * 1.25), p = t === "left" ? i.left - l.right : l.left - i.right;
|
|
659
659
|
f && p >= -8 && p <= 240 && a.push({
|
|
@@ -666,39 +666,39 @@ function Xt(e, t) {
|
|
|
666
666
|
}
|
|
667
667
|
return (u = a.sort((c, l) => c.score - l.score)[0]) == null ? void 0 : u.text;
|
|
668
668
|
}
|
|
669
|
-
function
|
|
670
|
-
if (!(T(e) || L(e) ||
|
|
669
|
+
function it(e) {
|
|
670
|
+
if (!(T(e) || L(e) || U(e)))
|
|
671
671
|
return;
|
|
672
|
-
const t =
|
|
673
|
-
return t || (
|
|
672
|
+
const t = Ke(e);
|
|
673
|
+
return t || (ae(e) ? Ut(e, "right") ?? Je(e) ?? X(e)[0] : Ut(e, "left") ?? X(e)[0]);
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function Xt(e, t) {
|
|
676
676
|
const n = t.trim().toLowerCase();
|
|
677
677
|
return T(e) && e.type === "radio" ? n === "radio" || n === "radio button" : T(e) && e.type === "checkbox" ? n === "checkbox" || n === "check box" : L(e) ? n === "select" || n === "select menu" || n === "combobox" || n === "combo box" : !1;
|
|
678
678
|
}
|
|
679
679
|
function R(e) {
|
|
680
|
-
const t =
|
|
681
|
-
if (n != null && n.trim() &&
|
|
680
|
+
const t = it(e), n = e.getAttribute("aria-label");
|
|
681
|
+
if (n != null && n.trim() && !Xt(e, n))
|
|
682
682
|
return n.trim();
|
|
683
683
|
const o = e.getAttribute("title");
|
|
684
|
-
if (o != null && o.trim() &&
|
|
684
|
+
if (o != null && o.trim() && !Xt(e, o))
|
|
685
685
|
return o.trim();
|
|
686
686
|
if (t)
|
|
687
687
|
return t;
|
|
688
|
-
const i =
|
|
688
|
+
const i = X(e)[0];
|
|
689
689
|
return i || _(e);
|
|
690
690
|
}
|
|
691
|
-
function
|
|
692
|
-
if (!(I(e) ||
|
|
691
|
+
function Nt(e) {
|
|
692
|
+
if (!(I(e) || Mt(e)) || !P(e) || e.matches(
|
|
693
693
|
'input,textarea,select,button,a[href],[role="button"],[role="link"]'
|
|
694
694
|
))
|
|
695
695
|
return !1;
|
|
696
|
-
const t =
|
|
696
|
+
const t = gt(e) ?? _(e);
|
|
697
697
|
return !!(t && t.length <= 120);
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function ce(e) {
|
|
700
700
|
var l;
|
|
701
|
-
if (!
|
|
701
|
+
if (!ae(e))
|
|
702
702
|
return;
|
|
703
703
|
const t = e.closest("fieldset"), n = t == null ? void 0 : t.querySelector("legend"), o = n ? _(n) : void 0;
|
|
704
704
|
if (o)
|
|
@@ -713,8 +713,8 @@ function ie(e) {
|
|
|
713
713
|
let c = u.nextNode();
|
|
714
714
|
for (; c; ) {
|
|
715
715
|
const h = c;
|
|
716
|
-
if (h !== e && !h.contains(e) && h.matches('legend,strong,b,[role="heading"],h1,h2,h3,h4,h5,h6') &&
|
|
717
|
-
const g = h.getBoundingClientRect(), f =
|
|
716
|
+
if (h !== e && !h.contains(e) && h.matches('legend,strong,b,[role="heading"],h1,h2,h3,h4,h5,h6') && Nt(h)) {
|
|
717
|
+
const g = h.getBoundingClientRect(), f = gt(h) ?? _(h);
|
|
718
718
|
if (f && g.bottom <= a.top + 8) {
|
|
719
719
|
const p = a.top - g.bottom, b = g.left + g.width / 2;
|
|
720
720
|
p <= 160 && b >= a.left - 120 && b <= a.right + 320 && d.push({
|
|
@@ -727,7 +727,7 @@ function ie(e) {
|
|
|
727
727
|
}
|
|
728
728
|
return (l = d.sort((h, g) => h.score - g.score)[0]) == null ? void 0 : l.text;
|
|
729
729
|
}
|
|
730
|
-
function
|
|
730
|
+
function Qe(e) {
|
|
731
731
|
if (!L(e))
|
|
732
732
|
return;
|
|
733
733
|
const t = Array.from(e.options).map((n) => ({
|
|
@@ -738,13 +738,13 @@ function Xe(e) {
|
|
|
738
738
|
}));
|
|
739
739
|
return t.length ? t : void 0;
|
|
740
740
|
}
|
|
741
|
-
function
|
|
741
|
+
function Ze(e) {
|
|
742
742
|
if (!L(e))
|
|
743
743
|
return;
|
|
744
744
|
const t = e.selectedOptions[0], n = t ? (t.label || t.textContent || t.value).replace(/\s+/g, " ").trim() : void 0;
|
|
745
745
|
return n ? n.slice(0, 160) : void 0;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function X(e) {
|
|
748
748
|
const t = e.ownerDocument, n = t.body;
|
|
749
749
|
if (!n)
|
|
750
750
|
return [];
|
|
@@ -755,8 +755,8 @@ function U(e) {
|
|
|
755
755
|
let d = s.nextNode();
|
|
756
756
|
for (; d; ) {
|
|
757
757
|
const c = d;
|
|
758
|
-
if (c !== e && !c.contains(e) &&
|
|
759
|
-
const l = c.getBoundingClientRect(), h =
|
|
758
|
+
if (c !== e && !c.contains(e) && Nt(c)) {
|
|
759
|
+
const l = c.getBoundingClientRect(), h = gt(c) ?? _(c);
|
|
760
760
|
if (h) {
|
|
761
761
|
const g = l.top + l.height / 2, f = l.left + l.width / 2, p = l.right <= o.left + 12 && Math.abs(g - i) <= Math.max(28, o.height * 1.25), b = l.left >= o.right - 8 && l.left - o.right <= 240 && Math.abs(g - i) <= Math.max(28, o.height * 1.25), v = l.bottom <= o.top + 8 && o.top - l.bottom <= 80 && f >= o.left - 80 && f <= o.right + 80;
|
|
762
762
|
if (p || b || v) {
|
|
@@ -773,10 +773,10 @@ function U(e) {
|
|
|
773
773
|
const u = /* @__PURE__ */ new Set();
|
|
774
774
|
return a.sort((c, l) => c.score - l.score).map((c) => c.text).filter((c) => u.has(c) ? !1 : (u.add(c), !0)).slice(0, 4);
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function tt(e) {
|
|
777
777
|
return e.getAttribute("data-testid") ?? e.getAttribute("data-test-id") ?? e.getAttribute("data-qa") ?? void 0;
|
|
778
778
|
}
|
|
779
|
-
function
|
|
779
|
+
function O(e) {
|
|
780
780
|
const t = e.getAttribute("role");
|
|
781
781
|
if (t != null && t.trim())
|
|
782
782
|
return t.trim();
|
|
@@ -800,26 +800,26 @@ function q(e) {
|
|
|
800
800
|
return "textbox";
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function Ct(e) {
|
|
804
804
|
return {
|
|
805
805
|
tag: e.tagName.toLowerCase(),
|
|
806
|
-
role:
|
|
806
|
+
role: O(e),
|
|
807
807
|
name: R(e),
|
|
808
|
-
testId:
|
|
808
|
+
testId: tt(e)
|
|
809
809
|
};
|
|
810
810
|
}
|
|
811
|
-
function
|
|
812
|
-
const n =
|
|
811
|
+
function tn(e, t) {
|
|
812
|
+
const n = Ct(t);
|
|
813
813
|
return n.tag !== e.tag || n.role !== e.role || S(n.name) !== S(e.name) || n.testId !== e.testId;
|
|
814
814
|
}
|
|
815
|
-
function
|
|
816
|
-
return
|
|
815
|
+
function le(e) {
|
|
816
|
+
return se(e) || T(e) || L(e) || U(e) ? e.disabled || void 0 : e.getAttribute("aria-disabled") === "true" || void 0;
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function Wt(e) {
|
|
819
819
|
return T(e) && (e.type === "checkbox" || e.type === "radio") ? e.checked : void 0;
|
|
820
820
|
}
|
|
821
|
-
function
|
|
822
|
-
const t =
|
|
821
|
+
function en(e) {
|
|
822
|
+
const t = et(e);
|
|
823
823
|
if (!(t.width <= 0 || t.height <= 0))
|
|
824
824
|
return {
|
|
825
825
|
x: t.x + t.width / 2,
|
|
@@ -829,39 +829,39 @@ function Ue(e) {
|
|
|
829
829
|
function H(e) {
|
|
830
830
|
return {
|
|
831
831
|
tag: e.tagName.toLowerCase(),
|
|
832
|
-
role:
|
|
832
|
+
role: O(e),
|
|
833
833
|
name: R(e),
|
|
834
|
-
selector:
|
|
834
|
+
selector: It(e)
|
|
835
835
|
};
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
if (!(I(e) ||
|
|
837
|
+
function P(e) {
|
|
838
|
+
if (!(I(e) || Mt(e)) || I(e) && e.hidden)
|
|
839
839
|
return !1;
|
|
840
840
|
const t = e.ownerDocument.defaultView, n = t == null ? void 0 : t.getComputedStyle(e);
|
|
841
841
|
return !(n && (n.display === "none" || n.visibility === "hidden" || n.opacity === "0"));
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return e.matches(
|
|
843
|
+
function de(e) {
|
|
844
|
+
return e.matches(Ve) && P(e);
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function qt(e) {
|
|
847
847
|
let t = e;
|
|
848
848
|
for (; t; ) {
|
|
849
|
-
if (
|
|
849
|
+
if (le(t) === !0)
|
|
850
850
|
return !1;
|
|
851
851
|
t = t.parentElement;
|
|
852
852
|
}
|
|
853
853
|
return !0;
|
|
854
854
|
}
|
|
855
|
-
function
|
|
855
|
+
function nn(e) {
|
|
856
856
|
var n;
|
|
857
|
-
if (
|
|
857
|
+
if (de(e))
|
|
858
858
|
return !0;
|
|
859
859
|
if (!I(e))
|
|
860
860
|
return !1;
|
|
861
861
|
const t = (n = e.ownerDocument.defaultView) == null ? void 0 : n.getComputedStyle(e);
|
|
862
|
-
return ((t == null ? void 0 : t.cursor) === "pointer" || !!e.onclick) &&
|
|
862
|
+
return ((t == null ? void 0 : t.cursor) === "pointer" || !!e.onclick) && P(e);
|
|
863
863
|
}
|
|
864
|
-
function
|
|
864
|
+
function et(e) {
|
|
865
865
|
var r, a;
|
|
866
866
|
const t = e.getBoundingClientRect();
|
|
867
867
|
let n = t.left, o = t.top, i = null;
|
|
@@ -886,7 +886,7 @@ function tt(e) {
|
|
|
886
886
|
height: t.height
|
|
887
887
|
};
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function Yt(e, t) {
|
|
890
890
|
var r, a;
|
|
891
891
|
let n = 0, o = 0, i = null;
|
|
892
892
|
try {
|
|
@@ -908,7 +908,7 @@ function Ut(e, t) {
|
|
|
908
908
|
y: t.y - o
|
|
909
909
|
};
|
|
910
910
|
}
|
|
911
|
-
function
|
|
911
|
+
function It(e) {
|
|
912
912
|
const t = (i) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(i) : i.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
913
913
|
if (e.getRootNode() !== e.ownerDocument)
|
|
914
914
|
return;
|
|
@@ -932,7 +932,7 @@ function Ct(e) {
|
|
|
932
932
|
`${e.tagName.toLowerCase()}[name="${t(o)}"]`
|
|
933
933
|
);
|
|
934
934
|
}
|
|
935
|
-
function
|
|
935
|
+
function on(e) {
|
|
936
936
|
const t = e.getBoundingClientRect();
|
|
937
937
|
if (!(t.width <= 0 || t.height <= 0))
|
|
938
938
|
return {
|
|
@@ -940,7 +940,7 @@ function Ge(e) {
|
|
|
940
940
|
y: t.top + t.height / 2
|
|
941
941
|
};
|
|
942
942
|
}
|
|
943
|
-
function
|
|
943
|
+
function z(e, t) {
|
|
944
944
|
if (typeof e.elementsFromPoint == "function")
|
|
945
945
|
return e.elementsFromPoint(t.x, t.y);
|
|
946
946
|
if (typeof e.elementFromPoint != "function")
|
|
@@ -948,37 +948,37 @@ function X(e, t) {
|
|
|
948
948
|
const n = e.elementFromPoint(t.x, t.y);
|
|
949
949
|
return n ? [n] : [];
|
|
950
950
|
}
|
|
951
|
-
function
|
|
951
|
+
function dt(e) {
|
|
952
952
|
return typeof e.elementsFromPoint == "function" || typeof e.elementFromPoint == "function";
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function rn(e, t) {
|
|
955
955
|
return e === t || e.contains(t);
|
|
956
956
|
}
|
|
957
|
-
function
|
|
957
|
+
function ut(e) {
|
|
958
958
|
let t = e;
|
|
959
959
|
for (; t; ) {
|
|
960
|
-
if (
|
|
960
|
+
if (nn(t) && qt(t))
|
|
961
961
|
return t;
|
|
962
962
|
t = t.parentElement;
|
|
963
963
|
}
|
|
964
964
|
return e;
|
|
965
965
|
}
|
|
966
|
-
function
|
|
966
|
+
function wt(e) {
|
|
967
967
|
const t = /* @__PURE__ */ new Set();
|
|
968
968
|
let n = e;
|
|
969
969
|
for (; n; ) {
|
|
970
970
|
const o = n.tagName.toLowerCase();
|
|
971
|
-
(
|
|
971
|
+
(se(n) && n.form !== null && n.type === "submit" || T(n) && n.form !== null && (n.type === "submit" || n.type === "image")) && t.add("form_submit"), o === "a" && n.hasAttribute("download") && t.add("download"), n = n.parentElement;
|
|
972
972
|
}
|
|
973
973
|
return Array.from(t);
|
|
974
974
|
}
|
|
975
975
|
function S(e) {
|
|
976
976
|
return (e ?? "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
977
977
|
}
|
|
978
|
-
function
|
|
979
|
-
return
|
|
978
|
+
function G(e) {
|
|
979
|
+
return ue(e)[0];
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function ue(e) {
|
|
982
982
|
const t = e.getBoundingClientRect();
|
|
983
983
|
if (t.width <= 0 || t.height <= 0)
|
|
984
984
|
return [];
|
|
@@ -1002,52 +1002,52 @@ function ae(e) {
|
|
|
1002
1002
|
y: t.bottom - Math.min(8, t.height / 2)
|
|
1003
1003
|
}
|
|
1004
1004
|
].filter((i) => {
|
|
1005
|
-
const r =
|
|
1006
|
-
return r ?
|
|
1005
|
+
const r = z(n, i)[0];
|
|
1006
|
+
return r ? rn(e, r) : !1;
|
|
1007
1007
|
});
|
|
1008
1008
|
}
|
|
1009
|
-
function
|
|
1010
|
-
const n = e.getBoundingClientRect(), o =
|
|
1009
|
+
function ht(e, t) {
|
|
1010
|
+
const n = e.getBoundingClientRect(), o = et(e);
|
|
1011
1011
|
return {
|
|
1012
1012
|
x: t.x + o.x - n.left,
|
|
1013
1013
|
y: t.y + o.y - n.top
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
1016
1016
|
function E(e) {
|
|
1017
|
-
const t = e.ownerDocument, n =
|
|
1018
|
-
(u) =>
|
|
1017
|
+
const t = e.ownerDocument, n = on(e), o = P(e) && !!n, i = qt(e), r = n ? z(t, n) : [], a = r[0], s = ue(e).map(
|
|
1018
|
+
(u) => ht(e, u)
|
|
1019
1019
|
), d = s.length > 0;
|
|
1020
1020
|
return {
|
|
1021
1021
|
visible: o,
|
|
1022
1022
|
enabled: i,
|
|
1023
1023
|
receivesEvents: d,
|
|
1024
1024
|
actionable: o && i && d,
|
|
1025
|
-
center:
|
|
1025
|
+
center: en(e),
|
|
1026
1026
|
hitTarget: a,
|
|
1027
1027
|
hitStack: r,
|
|
1028
1028
|
safeClickPoints: s,
|
|
1029
1029
|
occludedBy: o && i && !d ? a : void 0
|
|
1030
1030
|
};
|
|
1031
1031
|
}
|
|
1032
|
-
function
|
|
1032
|
+
function Gt(e, t) {
|
|
1033
1033
|
var a;
|
|
1034
1034
|
const n = m(t.testId);
|
|
1035
1035
|
if (n)
|
|
1036
|
-
return
|
|
1037
|
-
(s) => s.ownerDocument === e &&
|
|
1036
|
+
return nt(e).filter(
|
|
1037
|
+
(s) => s.ownerDocument === e && tt(s) === n
|
|
1038
1038
|
);
|
|
1039
1039
|
const o = (a = m(t.role)) == null ? void 0 : a.toLowerCase(), i = S(m(t.name)), r = S(m(t.text));
|
|
1040
|
-
return !o && !i && !r ? [] :
|
|
1040
|
+
return !o && !i && !r ? [] : nt(e).filter((s) => s.ownerDocument === e).filter((s) => {
|
|
1041
1041
|
var l;
|
|
1042
|
-
const d = (l =
|
|
1042
|
+
const d = (l = O(s)) == null ? void 0 : l.toLowerCase(), u = S(R(s)), c = S(_(s));
|
|
1043
1043
|
return !(o && d !== o || i && u !== i || r && c !== r);
|
|
1044
1044
|
});
|
|
1045
1045
|
}
|
|
1046
|
-
function
|
|
1046
|
+
function Kt(e) {
|
|
1047
1047
|
const t = e.trim().toLowerCase();
|
|
1048
1048
|
return t === "*" || /^[a-z][a-z0-9-]*$/.test(t) || /^\[role(?:=[^\]]+)?\]$/.test(t) || /^\.[a-z_-][a-z0-9_-]*$/i.test(t);
|
|
1049
1049
|
}
|
|
1050
|
-
function
|
|
1050
|
+
function sn(e, t) {
|
|
1051
1051
|
const n = S(t);
|
|
1052
1052
|
let o = e, i = 0;
|
|
1053
1053
|
for (; o && i < 5; ) {
|
|
@@ -1056,24 +1056,24 @@ function Ke(e, t) {
|
|
|
1056
1056
|
return !1;
|
|
1057
1057
|
if ([
|
|
1058
1058
|
R(o),
|
|
1059
|
-
|
|
1060
|
-
|
|
1059
|
+
it(o),
|
|
1060
|
+
ce(o),
|
|
1061
1061
|
_(o),
|
|
1062
|
-
|
|
1062
|
+
ft(o)
|
|
1063
1063
|
].some((a) => S(a) === n))
|
|
1064
1064
|
return !0;
|
|
1065
1065
|
o = o.parentElement, i += 1;
|
|
1066
1066
|
}
|
|
1067
1067
|
return !1;
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1069
|
+
function Jt(e, t, n, o) {
|
|
1070
1070
|
var d;
|
|
1071
|
-
if (n && S(
|
|
1071
|
+
if (n && S(O(e)) !== S(n))
|
|
1072
1072
|
return !1;
|
|
1073
1073
|
const i = S(t);
|
|
1074
1074
|
if (![
|
|
1075
1075
|
R(e),
|
|
1076
|
-
|
|
1076
|
+
it(e),
|
|
1077
1077
|
_(e)
|
|
1078
1078
|
].some((u) => S(u) === i))
|
|
1079
1079
|
return !1;
|
|
@@ -1081,11 +1081,11 @@ function Yt(e, t, n, o) {
|
|
|
1081
1081
|
return !0;
|
|
1082
1082
|
const a = S(o);
|
|
1083
1083
|
return [
|
|
1084
|
-
...
|
|
1084
|
+
...X(e),
|
|
1085
1085
|
((d = e.parentElement) == null ? void 0 : d.textContent) ?? void 0
|
|
1086
1086
|
].map((u) => S(u)).join(" ").includes(a);
|
|
1087
1087
|
}
|
|
1088
|
-
function
|
|
1088
|
+
function an(e) {
|
|
1089
1089
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1090
1090
|
return;
|
|
1091
1091
|
const t = e;
|
|
@@ -1096,7 +1096,7 @@ function Je(e) {
|
|
|
1096
1096
|
value: t.value
|
|
1097
1097
|
};
|
|
1098
1098
|
}
|
|
1099
|
-
function
|
|
1099
|
+
function he(e) {
|
|
1100
1100
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1101
1101
|
throw new Error("Expectation scope must be an object.");
|
|
1102
1102
|
const t = Reflect.get(e, "documentScope");
|
|
@@ -1107,8 +1107,8 @@ function ce(e) {
|
|
|
1107
1107
|
return { documentScope: t, documentRef: n };
|
|
1108
1108
|
throw new Error("Expectation scope is invalid.");
|
|
1109
1109
|
}
|
|
1110
|
-
function
|
|
1111
|
-
const t =
|
|
1110
|
+
function cn(e) {
|
|
1111
|
+
const t = he(e), n = Reflect.get(e, "kind");
|
|
1112
1112
|
if (n === "test_id") {
|
|
1113
1113
|
const o = Reflect.get(e, "testId");
|
|
1114
1114
|
if (typeof o == "string" && o.trim())
|
|
@@ -1159,12 +1159,12 @@ function V(e) {
|
|
|
1159
1159
|
if (typeof n == "string")
|
|
1160
1160
|
return {
|
|
1161
1161
|
type: t,
|
|
1162
|
-
scope:
|
|
1162
|
+
scope: he(Reflect.get(e, "scope")),
|
|
1163
1163
|
value: n
|
|
1164
1164
|
};
|
|
1165
1165
|
}
|
|
1166
1166
|
if (t === "field_contains" || t === "checked_equals" || t === "element_visible" || t === "element_hidden") {
|
|
1167
|
-
const n =
|
|
1167
|
+
const n = cn(Reflect.get(e, "target"));
|
|
1168
1168
|
if (t === "field_contains") {
|
|
1169
1169
|
const o = Reflect.get(e, "value");
|
|
1170
1170
|
if (typeof o == "string")
|
|
@@ -1178,24 +1178,24 @@ function V(e) {
|
|
|
1178
1178
|
}
|
|
1179
1179
|
throw new Error("Unsupported action expectation.");
|
|
1180
1180
|
}
|
|
1181
|
-
function
|
|
1181
|
+
function ln(e, t) {
|
|
1182
1182
|
const n = t.trim().toLowerCase();
|
|
1183
1183
|
return Array.from(e.querySelectorAll("input,textarea,select")).find(
|
|
1184
1184
|
(o) => [
|
|
1185
|
-
|
|
1185
|
+
it(o),
|
|
1186
1186
|
R(o),
|
|
1187
1187
|
o.getAttribute("name") ?? void 0,
|
|
1188
1188
|
o.getAttribute("placeholder") ?? void 0,
|
|
1189
|
-
...
|
|
1189
|
+
...X(o)
|
|
1190
1190
|
].some(
|
|
1191
1191
|
(r) => r == null ? void 0 : r.trim().toLowerCase().includes(n)
|
|
1192
1192
|
)
|
|
1193
1193
|
);
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function dn(e, t) {
|
|
1196
1196
|
if (!t)
|
|
1197
1197
|
return;
|
|
1198
|
-
const n =
|
|
1198
|
+
const n = ln(e, t.field), o = n ? ft(n) ?? "" : void 0;
|
|
1199
1199
|
return {
|
|
1200
1200
|
...t,
|
|
1201
1201
|
ok: typeof o == "string" && o.toLowerCase().includes(t.value.toLowerCase()),
|
|
@@ -1203,8 +1203,8 @@ function tn(e, t) {
|
|
|
1203
1203
|
matchedField: n ? H(n) : void 0
|
|
1204
1204
|
};
|
|
1205
1205
|
}
|
|
1206
|
-
function
|
|
1207
|
-
const t = e.nodeType === 1 ? e.ownerDocument :
|
|
1206
|
+
function nt(e) {
|
|
1207
|
+
const t = e.nodeType === 1 ? e.ownerDocument : D(e), n = e.nodeType === 9 ? e.body ?? e.documentElement : e;
|
|
1208
1208
|
if (!n)
|
|
1209
1209
|
return [];
|
|
1210
1210
|
const o = [], i = (r) => {
|
|
@@ -1212,36 +1212,36 @@ function et(e) {
|
|
|
1212
1212
|
let s = a.nextNode();
|
|
1213
1213
|
for (; s; ) {
|
|
1214
1214
|
const d = s;
|
|
1215
|
-
|
|
1215
|
+
de(d) && o.push(d);
|
|
1216
1216
|
const u = d.shadowRoot;
|
|
1217
|
-
if (u && i(u),
|
|
1217
|
+
if (u && i(u), At(d))
|
|
1218
1218
|
try {
|
|
1219
1219
|
d.contentDocument && i(d.contentDocument);
|
|
1220
1220
|
} catch {
|
|
1221
1221
|
}
|
|
1222
|
-
if (o.length >=
|
|
1222
|
+
if (o.length >= Lt)
|
|
1223
1223
|
return;
|
|
1224
1224
|
s = a.nextNode();
|
|
1225
1225
|
}
|
|
1226
1226
|
};
|
|
1227
|
-
return i(n), o.slice(0,
|
|
1227
|
+
return i(n), o.slice(0, Lt);
|
|
1228
1228
|
}
|
|
1229
|
-
function
|
|
1229
|
+
function un(e, t) {
|
|
1230
1230
|
var i;
|
|
1231
1231
|
const n = Object.getPrototypeOf(e), o = Object.getOwnPropertyDescriptor(n, "value");
|
|
1232
1232
|
(i = o == null ? void 0 : o.set) == null || i.call(e, t);
|
|
1233
1233
|
}
|
|
1234
|
-
function
|
|
1234
|
+
function St(e) {
|
|
1235
1235
|
e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1236
1236
|
}
|
|
1237
1237
|
function K(e) {
|
|
1238
1238
|
var t, n;
|
|
1239
|
-
(I(e) ||
|
|
1239
|
+
(I(e) || Mt(e)) && ((t = e.scrollIntoView) == null || t.call(e, { block: "center", inline: "center" })), I(e) && ((n = e.focus) == null || n.call(e));
|
|
1240
1240
|
}
|
|
1241
1241
|
function J(e, t) {
|
|
1242
1242
|
return typeof PointerEvent == "function" ? new PointerEvent(e, t) : new MouseEvent(e.replace("pointer", "mouse"), t);
|
|
1243
1243
|
}
|
|
1244
|
-
class
|
|
1244
|
+
class hn {
|
|
1245
1245
|
constructor(t = {}) {
|
|
1246
1246
|
this.options = t, this.refs = /* @__PURE__ */ new Map(), this.nextRef = 1, this.pageStateId = "", this.documentRefs = /* @__PURE__ */ new Map(), this.documents = [], this.pageStateInvalidated = !1, this.cachedSnapshotCreatedAt = 0, this.mutationObservers = [], this.pendingActionApprovals = /* @__PURE__ */ new Map();
|
|
1247
1247
|
}
|
|
@@ -1294,7 +1294,7 @@ class nn {
|
|
|
1294
1294
|
case "host_page_pointer":
|
|
1295
1295
|
return this.executeAction(
|
|
1296
1296
|
() => this.pointer(n),
|
|
1297
|
-
|
|
1297
|
+
Ht(n.action) === "click",
|
|
1298
1298
|
V(n.expectation)
|
|
1299
1299
|
);
|
|
1300
1300
|
case "host_page_screenshot":
|
|
@@ -1309,17 +1309,17 @@ class nn {
|
|
|
1309
1309
|
var d, u;
|
|
1310
1310
|
const n = m(t.pageStateId);
|
|
1311
1311
|
if (n) {
|
|
1312
|
-
if (this.cachedSnapshot && n === this.pageStateId && !this.pageStateInvalidated && Date.now() - this.cachedSnapshotCreatedAt <=
|
|
1312
|
+
if (this.cachedSnapshot && n === this.pageStateId && !this.pageStateInvalidated && Date.now() - this.cachedSnapshotCreatedAt <= Bt && this.cachedSnapshot.url === q(this.getRoot()).location.href)
|
|
1313
1313
|
return this.cachedSnapshot;
|
|
1314
1314
|
this.rejectStalePageState(n);
|
|
1315
1315
|
}
|
|
1316
1316
|
this.refs.clear(), this.pendingActionApprovals.clear(), this.nextRef = 1, this.disconnectMutationObservers();
|
|
1317
|
-
const o = this.getRoot(), i =
|
|
1318
|
-
this.pageStateId =
|
|
1319
|
-
const a =
|
|
1317
|
+
const o = this.getRoot(), i = D(o), r = q(o);
|
|
1318
|
+
this.pageStateId = Vt(), this.pageStateInvalidated = !1, this.indexDocuments(i);
|
|
1319
|
+
const a = nt(o).map(
|
|
1320
1320
|
(c) => this.snapshotElement(c)
|
|
1321
1321
|
);
|
|
1322
|
-
this.readableContent =
|
|
1322
|
+
this.readableContent = Ot(o);
|
|
1323
1323
|
const s = {
|
|
1324
1324
|
pageStateId: this.pageStateId,
|
|
1325
1325
|
url: r.location.href,
|
|
@@ -1368,7 +1368,7 @@ class nn {
|
|
|
1368
1368
|
focused: i.activeElement === ((l = this.refs.get(c.ref)) == null ? void 0 : l.element)
|
|
1369
1369
|
};
|
|
1370
1370
|
}),
|
|
1371
|
-
readableContent:
|
|
1371
|
+
readableContent: De(this.readableContent),
|
|
1372
1372
|
elements: a
|
|
1373
1373
|
};
|
|
1374
1374
|
return this.cachedSnapshot = s, this.cachedSnapshotCreatedAt = Date.now(), this.observePageState(), s;
|
|
@@ -1417,7 +1417,7 @@ class nn {
|
|
|
1417
1417
|
subtree: !0,
|
|
1418
1418
|
childList: !0,
|
|
1419
1419
|
attributes: !0,
|
|
1420
|
-
attributeFilter: [...
|
|
1420
|
+
attributeFilter: [...Ue]
|
|
1421
1421
|
};
|
|
1422
1422
|
r.observe(o.documentElement ?? o, a);
|
|
1423
1423
|
for (const s of Array.from(o.querySelectorAll("*")))
|
|
@@ -1442,7 +1442,7 @@ class nn {
|
|
|
1442
1442
|
getFrameState(t) {
|
|
1443
1443
|
return Array.from(t.querySelectorAll("iframe")).map((n) => {
|
|
1444
1444
|
var i, r;
|
|
1445
|
-
const o =
|
|
1445
|
+
const o = et(n);
|
|
1446
1446
|
try {
|
|
1447
1447
|
return {
|
|
1448
1448
|
url: (i = n.contentWindow) == null ? void 0 : i.location.href,
|
|
@@ -1465,39 +1465,39 @@ class nn {
|
|
|
1465
1465
|
element: t,
|
|
1466
1466
|
pageStateId: this.pageStateId,
|
|
1467
1467
|
documentRef: this.documentRefs.get(t.ownerDocument) ?? "d1",
|
|
1468
|
-
fingerprint:
|
|
1468
|
+
fingerprint: Ct(t)
|
|
1469
1469
|
}), this.createElementSnapshot(t, n);
|
|
1470
1470
|
}
|
|
1471
1471
|
snapshotElementWithoutRef(t) {
|
|
1472
1472
|
return this.createElementSnapshot(t, "");
|
|
1473
1473
|
}
|
|
1474
1474
|
createElementSnapshot(t, n) {
|
|
1475
|
-
const o = (T(t) ||
|
|
1475
|
+
const o = (T(t) || U(t)) && t.placeholder || void 0, i = E(t);
|
|
1476
1476
|
return {
|
|
1477
1477
|
documentRef: this.documentRefs.get(t.ownerDocument) ?? "d1",
|
|
1478
1478
|
ref: n,
|
|
1479
1479
|
tag: t.tagName.toLowerCase(),
|
|
1480
|
-
role:
|
|
1480
|
+
role: O(t),
|
|
1481
1481
|
name: R(t),
|
|
1482
|
-
label:
|
|
1483
|
-
groupLabel:
|
|
1482
|
+
label: it(t),
|
|
1483
|
+
groupLabel: ce(t),
|
|
1484
1484
|
text: _(t),
|
|
1485
|
-
nearbyText:
|
|
1486
|
-
testId:
|
|
1487
|
-
value:
|
|
1488
|
-
selectedLabel:
|
|
1489
|
-
options:
|
|
1485
|
+
nearbyText: X(t),
|
|
1486
|
+
testId: tt(t),
|
|
1487
|
+
value: ft(t),
|
|
1488
|
+
selectedLabel: Ze(t),
|
|
1489
|
+
options: Qe(t),
|
|
1490
1490
|
placeholder: o,
|
|
1491
|
-
selector:
|
|
1492
|
-
disabled:
|
|
1491
|
+
selector: It(t),
|
|
1492
|
+
disabled: le(t),
|
|
1493
1493
|
enabled: i.enabled,
|
|
1494
|
-
checked:
|
|
1494
|
+
checked: Wt(t),
|
|
1495
1495
|
visible: i.visible,
|
|
1496
1496
|
actionable: i.actionable,
|
|
1497
1497
|
receivesEvents: i.receivesEvents,
|
|
1498
1498
|
occludedBy: i.occludedBy ? H(i.occludedBy) : void 0,
|
|
1499
1499
|
safeClickPoints: i.safeClickPoints,
|
|
1500
|
-
rect:
|
|
1500
|
+
rect: et(t),
|
|
1501
1501
|
center: i.center,
|
|
1502
1502
|
hitTarget: i.hitTarget ? H(i.hitTarget) : void 0,
|
|
1503
1503
|
hitStack: i.hitStack.slice(0, 5).map(H)
|
|
@@ -1512,7 +1512,7 @@ class nn {
|
|
|
1512
1512
|
);
|
|
1513
1513
|
const o = m(t.documentRef) ?? ((g = this.documents[0]) == null ? void 0 : g.documentRef) ?? "legacy", i = this.documents.length ? (f = Array.from(this.documentRefs.entries()).find(
|
|
1514
1514
|
([, p]) => p === o
|
|
1515
|
-
)) == null ? void 0 : f[0] :
|
|
1515
|
+
)) == null ? void 0 : f[0] : D(this.getRoot());
|
|
1516
1516
|
(!o || !i) && this.rejectTarget(
|
|
1517
1517
|
"unsupported_target_scope",
|
|
1518
1518
|
"The requested document scope is not available."
|
|
@@ -1531,7 +1531,7 @@ class nn {
|
|
|
1531
1531
|
const h = r ?? a;
|
|
1532
1532
|
if (h) {
|
|
1533
1533
|
const p = this.refs.get(h);
|
|
1534
|
-
if (!p || p.pageStateId !== this.pageStateId || !p.element.isConnected || this.documentRefs.get(p.element.ownerDocument) !== p.documentRef || o && o !== p.documentRef ||
|
|
1534
|
+
if (!p || p.pageStateId !== this.pageStateId || !p.element.isConnected || this.documentRefs.get(p.element.ownerDocument) !== p.documentRef || o && o !== p.documentRef || tn(p.fingerprint, p.element))
|
|
1535
1535
|
throw new W(
|
|
1536
1536
|
`Element ref ${h} is stale. Take a new snapshot.`,
|
|
1537
1537
|
{
|
|
@@ -1575,7 +1575,7 @@ class nn {
|
|
|
1575
1575
|
strategy: "unique_selector",
|
|
1576
1576
|
pageStateId: this.pageStateId
|
|
1577
1577
|
};
|
|
1578
|
-
|
|
1578
|
+
Kt(s) && this.rejectTarget(
|
|
1579
1579
|
"unsafe_selector",
|
|
1580
1580
|
`Selector is too broad for strict targeting: ${s}.`,
|
|
1581
1581
|
b
|
|
@@ -1596,7 +1596,7 @@ class nn {
|
|
|
1596
1596
|
{
|
|
1597
1597
|
...b,
|
|
1598
1598
|
candidates: v.map(
|
|
1599
|
-
(
|
|
1599
|
+
(M) => this.describeElementDescriptor(M)
|
|
1600
1600
|
)
|
|
1601
1601
|
}
|
|
1602
1602
|
);
|
|
@@ -1623,7 +1623,7 @@ class nn {
|
|
|
1623
1623
|
documentRef: o,
|
|
1624
1624
|
match: "exact",
|
|
1625
1625
|
identity: c ? { role: u, name: c } : { role: u, text: l }
|
|
1626
|
-
}, v = p ? "test_id" : "semantic_exact", x =
|
|
1626
|
+
}, v = p ? "test_id" : "semantic_exact", x = Gt(i, t), M = {
|
|
1627
1627
|
requested: b,
|
|
1628
1628
|
strategy: v,
|
|
1629
1629
|
pageStateId: this.pageStateId
|
|
@@ -1631,12 +1631,12 @@ class nn {
|
|
|
1631
1631
|
x.length === 0 && this.rejectTarget(
|
|
1632
1632
|
"target_not_found",
|
|
1633
1633
|
"No element matches the strict target.",
|
|
1634
|
-
|
|
1634
|
+
M
|
|
1635
1635
|
), x.length > 1 && this.rejectTarget(
|
|
1636
1636
|
"ambiguous_target",
|
|
1637
1637
|
`Strict target matches ${x.length} elements.`,
|
|
1638
1638
|
{
|
|
1639
|
-
...
|
|
1639
|
+
...M,
|
|
1640
1640
|
candidates: x.map(
|
|
1641
1641
|
(w) => this.describeElementDescriptor(w)
|
|
1642
1642
|
)
|
|
@@ -1644,12 +1644,12 @@ class nn {
|
|
|
1644
1644
|
);
|
|
1645
1645
|
const y = x[0];
|
|
1646
1646
|
return this.lastResolution = {
|
|
1647
|
-
...
|
|
1647
|
+
...M,
|
|
1648
1648
|
resolved: this.describeElementDescriptor(y)
|
|
1649
1649
|
}, y;
|
|
1650
1650
|
}
|
|
1651
1651
|
if (typeof t.x < "u" || typeof t.y < "u") {
|
|
1652
|
-
const p =
|
|
1652
|
+
const p = zt(this.getRoot(), t), b = D(this.getRoot()).elementFromPoint(
|
|
1653
1653
|
p.x,
|
|
1654
1654
|
p.y
|
|
1655
1655
|
);
|
|
@@ -1691,7 +1691,7 @@ class nn {
|
|
|
1691
1691
|
var o;
|
|
1692
1692
|
if (!this.pageStateId) return;
|
|
1693
1693
|
const n = m(t.pageStateId);
|
|
1694
|
-
(!n || n !== this.pageStateId || this.pageStateInvalidated || Date.now() - this.cachedSnapshotCreatedAt >
|
|
1694
|
+
(!n || n !== this.pageStateId || this.pageStateInvalidated || Date.now() - this.cachedSnapshotCreatedAt > Bt || ((o = this.cachedSnapshot) == null ? void 0 : o.url) !== q(this.getRoot()).location.href) && this.rejectStalePageState(n ?? this.pageStateId);
|
|
1695
1695
|
}
|
|
1696
1696
|
async executeAction(t, n, o) {
|
|
1697
1697
|
this.lastResolution = void 0;
|
|
@@ -1711,10 +1711,10 @@ class nn {
|
|
|
1711
1711
|
async requireActionApproval(t, n, o, i) {
|
|
1712
1712
|
if (o.length === 0)
|
|
1713
1713
|
return;
|
|
1714
|
-
const r =
|
|
1714
|
+
const r = q(this.getRoot()), a = await Ft({ action: t, params: n }), s = await Ft(
|
|
1715
1715
|
i ? {
|
|
1716
1716
|
documentRef: this.documentRefs.get(i.ownerDocument) ?? "legacy",
|
|
1717
|
-
...
|
|
1717
|
+
...Ct(i)
|
|
1718
1718
|
} : null
|
|
1719
1719
|
), d = m(n.actionToken);
|
|
1720
1720
|
let u = "approval_required";
|
|
@@ -1733,7 +1733,7 @@ class nn {
|
|
|
1733
1733
|
}
|
|
1734
1734
|
for (const [g, f] of this.pendingActionApprovals)
|
|
1735
1735
|
f.expiresAt <= Date.now() && this.pendingActionApprovals.delete(g);
|
|
1736
|
-
const c =
|
|
1736
|
+
const c = Vt(), l = Date.now() + $e;
|
|
1737
1737
|
this.pendingActionApprovals.set(c, {
|
|
1738
1738
|
action: t,
|
|
1739
1739
|
actionHash: a,
|
|
@@ -1761,7 +1761,7 @@ class nn {
|
|
|
1761
1761
|
}
|
|
1762
1762
|
getObservationDocument(t) {
|
|
1763
1763
|
var n;
|
|
1764
|
-
return t.documentScope === "current_top" ?
|
|
1764
|
+
return t.documentScope === "current_top" ? D(this.getRoot()) : ((n = Array.from(this.documentRefs.entries()).find(
|
|
1765
1765
|
([, o]) => o === t.documentRef
|
|
1766
1766
|
)) == null ? void 0 : n[0]) ?? null;
|
|
1767
1767
|
}
|
|
@@ -1771,16 +1771,16 @@ class nn {
|
|
|
1771
1771
|
return { status: "not_found" };
|
|
1772
1772
|
let o = [];
|
|
1773
1773
|
if (t.kind === "selector") {
|
|
1774
|
-
if (
|
|
1774
|
+
if (Kt(t.selector))
|
|
1775
1775
|
return { status: "ambiguous" };
|
|
1776
1776
|
try {
|
|
1777
1777
|
o = Array.from(n.querySelectorAll(t.selector));
|
|
1778
1778
|
} catch {
|
|
1779
1779
|
o = [];
|
|
1780
1780
|
}
|
|
1781
|
-
} else t.kind === "test_id" ? o =
|
|
1782
|
-
(i) => i.ownerDocument === n &&
|
|
1783
|
-
) : o =
|
|
1781
|
+
} else t.kind === "test_id" ? o = nt(n).filter(
|
|
1782
|
+
(i) => i.ownerDocument === n && tt(i) === t.testId
|
|
1783
|
+
) : o = Gt(n, {
|
|
1784
1784
|
role: t.identity.role,
|
|
1785
1785
|
..."name" in t.identity ? { name: t.identity.name } : { text: t.identity.text }
|
|
1786
1786
|
});
|
|
@@ -1789,7 +1789,7 @@ class nn {
|
|
|
1789
1789
|
checkExpectation(t) {
|
|
1790
1790
|
var r, a;
|
|
1791
1791
|
if (t.type === "url_matches") {
|
|
1792
|
-
const s =
|
|
1792
|
+
const s = q(this.getRoot()).location.href;
|
|
1793
1793
|
return {
|
|
1794
1794
|
matched: t.mode === "exact" ? s === t.value : s.startsWith(t.value),
|
|
1795
1795
|
actual: s
|
|
@@ -1814,17 +1814,17 @@ class nn {
|
|
|
1814
1814
|
};
|
|
1815
1815
|
const o = n.element;
|
|
1816
1816
|
if (t.type === "field_contains") {
|
|
1817
|
-
const s =
|
|
1817
|
+
const s = ft(o) ?? null;
|
|
1818
1818
|
return {
|
|
1819
1819
|
matched: typeof s == "string" && s.toLowerCase().includes(t.value.toLowerCase()),
|
|
1820
1820
|
actual: s
|
|
1821
1821
|
};
|
|
1822
1822
|
}
|
|
1823
1823
|
if (t.type === "checked_equals") {
|
|
1824
|
-
const s =
|
|
1824
|
+
const s = Wt(o) ?? null;
|
|
1825
1825
|
return { matched: s === t.value, actual: s };
|
|
1826
1826
|
}
|
|
1827
|
-
const i =
|
|
1827
|
+
const i = P(o);
|
|
1828
1828
|
return {
|
|
1829
1829
|
matched: t.type === "element_visible" ? i : !i,
|
|
1830
1830
|
actual: i
|
|
@@ -1833,7 +1833,7 @@ class nn {
|
|
|
1833
1833
|
async verifyExpectation(t) {
|
|
1834
1834
|
const n = Date.now();
|
|
1835
1835
|
let o;
|
|
1836
|
-
for (; Date.now() - n <=
|
|
1836
|
+
for (; Date.now() - n <= jt; ) {
|
|
1837
1837
|
const i = this.checkExpectation(t);
|
|
1838
1838
|
if (o = i.actual, i.matched)
|
|
1839
1839
|
return {
|
|
@@ -1849,10 +1849,10 @@ class nn {
|
|
|
1849
1849
|
elapsedMs: Date.now() - n,
|
|
1850
1850
|
actual: o
|
|
1851
1851
|
};
|
|
1852
|
-
if (Date.now() - n >=
|
|
1852
|
+
if (Date.now() - n >= jt)
|
|
1853
1853
|
break;
|
|
1854
1854
|
await new Promise(
|
|
1855
|
-
(r) => setTimeout(r,
|
|
1855
|
+
(r) => setTimeout(r, ze)
|
|
1856
1856
|
);
|
|
1857
1857
|
}
|
|
1858
1858
|
return {
|
|
@@ -1878,20 +1878,20 @@ class nn {
|
|
|
1878
1878
|
documentRef: this.documentRefs.get(t.ownerDocument) ?? "d1",
|
|
1879
1879
|
...n,
|
|
1880
1880
|
tag: t.tagName.toLowerCase(),
|
|
1881
|
-
role:
|
|
1881
|
+
role: O(t),
|
|
1882
1882
|
name: R(t),
|
|
1883
1883
|
text: _(t),
|
|
1884
|
-
testId:
|
|
1885
|
-
rect:
|
|
1884
|
+
testId: tt(t),
|
|
1885
|
+
rect: et(t)
|
|
1886
1886
|
};
|
|
1887
1887
|
}
|
|
1888
1888
|
async click(t) {
|
|
1889
|
-
const n = A(t), o = this.resolveElement(n), i = E(o), r =
|
|
1889
|
+
const n = A(t), o = this.resolveElement(n), i = E(o), r = ut(o), a = G(r);
|
|
1890
1890
|
if (i.enabled || this.rejectTarget(
|
|
1891
1891
|
"target_disabled",
|
|
1892
1892
|
`Target "${R(o) ?? o.tagName.toLowerCase()}" is disabled.`,
|
|
1893
1893
|
this.lastResolution
|
|
1894
|
-
), !a &&
|
|
1894
|
+
), !a && dt(o.ownerDocument))
|
|
1895
1895
|
throw this.lastResolution && (this.lastResolution = {
|
|
1896
1896
|
...this.lastResolution,
|
|
1897
1897
|
adjustment: r === o ? void 0 : "actionable_ancestor",
|
|
@@ -1926,7 +1926,7 @@ class nn {
|
|
|
1926
1926
|
]
|
|
1927
1927
|
}
|
|
1928
1928
|
);
|
|
1929
|
-
const s =
|
|
1929
|
+
const s = G(r), d = E(r), u = s ? ht(r, s) : dt(r.ownerDocument) ? void 0 : d.center ?? i.center;
|
|
1930
1930
|
if (this.lastResolution) {
|
|
1931
1931
|
const f = this.describeElementDescriptor(r);
|
|
1932
1932
|
this.lastResolution = {
|
|
@@ -1942,7 +1942,7 @@ class nn {
|
|
|
1942
1942
|
await this.requireActionApproval(
|
|
1943
1943
|
"host_page_click",
|
|
1944
1944
|
n,
|
|
1945
|
-
|
|
1945
|
+
wt(r),
|
|
1946
1946
|
r
|
|
1947
1947
|
), K(r), u && await this.showVisualEffect({
|
|
1948
1948
|
type: "click",
|
|
@@ -1951,8 +1951,8 @@ class nn {
|
|
|
1951
1951
|
target: r,
|
|
1952
1952
|
requested: o
|
|
1953
1953
|
});
|
|
1954
|
-
const c =
|
|
1955
|
-
!c &&
|
|
1954
|
+
const c = G(r), l = E(r);
|
|
1955
|
+
!c && dt(r.ownerDocument) && (this.lastResolution && (this.lastResolution = {
|
|
1956
1956
|
...this.lastResolution,
|
|
1957
1957
|
hitTarget: l.hitTarget ? this.describeElementDescriptor(
|
|
1958
1958
|
l.hitTarget
|
|
@@ -1963,7 +1963,7 @@ class nn {
|
|
|
1963
1963
|
`Target "${R(o) ?? o.tagName.toLowerCase()}" stopped receiving pointer events before dispatch.`,
|
|
1964
1964
|
this.lastResolution
|
|
1965
1965
|
));
|
|
1966
|
-
const h = c ?
|
|
1966
|
+
const h = c ? ht(r, c) : u, g = E(o);
|
|
1967
1967
|
return this.lastResolution && (this.lastResolution = {
|
|
1968
1968
|
...this.lastResolution,
|
|
1969
1969
|
point: h,
|
|
@@ -1986,25 +1986,25 @@ class nn {
|
|
|
1986
1986
|
};
|
|
1987
1987
|
}
|
|
1988
1988
|
read(t) {
|
|
1989
|
-
const n = A(t), o = this.getRoot(), i = this.readableContent ??
|
|
1989
|
+
const n = A(t), o = this.getRoot(), i = this.readableContent ?? Ot(o);
|
|
1990
1990
|
this.readableContent = i;
|
|
1991
1991
|
const r = {
|
|
1992
1992
|
blockId: m(n.blockId),
|
|
1993
1993
|
query: m(n.query),
|
|
1994
|
-
page:
|
|
1995
|
-
pageSize:
|
|
1996
|
-
maxChars:
|
|
1994
|
+
page: lt(n.page),
|
|
1995
|
+
pageSize: lt(n.pageSize),
|
|
1996
|
+
maxChars: lt(n.maxChars)
|
|
1997
1997
|
};
|
|
1998
|
-
return
|
|
1998
|
+
return je(i, r);
|
|
1999
1999
|
}
|
|
2000
2000
|
async fill(t) {
|
|
2001
|
-
const n = A(t), o =
|
|
2001
|
+
const n = A(t), o = vt(n.value, "value"), i = this.resolveElement(n);
|
|
2002
2002
|
if (await this.requireActionApproval(
|
|
2003
2003
|
"host_page_fill",
|
|
2004
2004
|
n,
|
|
2005
2005
|
T(i) ? i.type === "password" ? ["password_input"] : i.type === "file" ? ["file_input"] : [] : [],
|
|
2006
2006
|
i
|
|
2007
|
-
), K(i), T(i) ||
|
|
2007
|
+
), K(i), T(i) || U(i))
|
|
2008
2008
|
return await this.showVisualEffect({
|
|
2009
2009
|
type: "fill",
|
|
2010
2010
|
target: i,
|
|
@@ -2012,7 +2012,7 @@ class nn {
|
|
|
2012
2012
|
value: o,
|
|
2013
2013
|
anchor: "target",
|
|
2014
2014
|
point: E(i).center
|
|
2015
|
-
}),
|
|
2015
|
+
}), un(i, o), St(i), this.invalidateReadableContent(), { filled: this.describeElement(i), value: o };
|
|
2016
2016
|
if (I(i) && i.isContentEditable)
|
|
2017
2017
|
return await this.showVisualEffect({
|
|
2018
2018
|
type: "fill",
|
|
@@ -2021,17 +2021,17 @@ class nn {
|
|
|
2021
2021
|
value: o,
|
|
2022
2022
|
anchor: "target",
|
|
2023
2023
|
point: E(i).center
|
|
2024
|
-
}), i.textContent = o,
|
|
2024
|
+
}), i.textContent = o, St(i), this.invalidateReadableContent(), { filled: this.describeElement(i), value: o };
|
|
2025
2025
|
throw new Error("Target element cannot be filled.");
|
|
2026
2026
|
}
|
|
2027
2027
|
async press(t) {
|
|
2028
|
-
const n = A(t), o =
|
|
2028
|
+
const n = A(t), o = vt(n.key, "key"), i = n.ref || n.selector || n.x !== void 0 && n.y !== void 0 ? this.resolveElement(n) : D(this.getRoot()).activeElement ?? D(this.getRoot()).body;
|
|
2029
2029
|
if (!i)
|
|
2030
2030
|
throw new Error("No target element is available for key press.");
|
|
2031
2031
|
await this.requireActionApproval(
|
|
2032
2032
|
"host_page_press",
|
|
2033
2033
|
n,
|
|
2034
|
-
o === "Enter" || o === " " ?
|
|
2034
|
+
o === "Enter" || o === " " ? wt(i) : [],
|
|
2035
2035
|
i
|
|
2036
2036
|
), K(i), await this.showVisualEffect({
|
|
2037
2037
|
type: "press",
|
|
@@ -2045,7 +2045,7 @@ class nn {
|
|
|
2045
2045
|
return i.dispatchEvent(new KeyboardEvent("keydown", r)), o.length === 1 && i.dispatchEvent(new KeyboardEvent("keypress", r)), i.dispatchEvent(new KeyboardEvent("keyup", r)), this.invalidateReadableContent(), { pressed: o, target: this.describeElement(i) };
|
|
2046
2046
|
}
|
|
2047
2047
|
async select(t) {
|
|
2048
|
-
const n = A(t), o =
|
|
2048
|
+
const n = A(t), o = We(n.values ?? n.value), i = this.resolveElement(n);
|
|
2049
2049
|
if (!L(i))
|
|
2050
2050
|
throw new Error("Target element is not a select.");
|
|
2051
2051
|
K(i);
|
|
@@ -2060,7 +2060,7 @@ class nn {
|
|
|
2060
2060
|
});
|
|
2061
2061
|
for (const a of Array.from(i.options))
|
|
2062
2062
|
a.selected = r.has(a.value);
|
|
2063
|
-
return
|
|
2063
|
+
return St(i), this.invalidateReadableContent(), {
|
|
2064
2064
|
selected: Array.from(i.selectedOptions).map(
|
|
2065
2065
|
(a) => a.value
|
|
2066
2066
|
),
|
|
@@ -2070,9 +2070,9 @@ class nn {
|
|
|
2070
2070
|
async scroll(t) {
|
|
2071
2071
|
var d, u, c, l;
|
|
2072
2072
|
const n = A(t), o = n.x !== void 0 || n.y !== void 0 ? {
|
|
2073
|
-
x:
|
|
2074
|
-
y:
|
|
2075
|
-
} : null, i =
|
|
2073
|
+
x: Y(n.x) ?? 0,
|
|
2074
|
+
y: Y(n.y) ?? 0
|
|
2075
|
+
} : null, i = Y(n.deltaX) ?? 0, r = Y(n.deltaY) ?? 0, a = this.getRoot(), s = q(a);
|
|
2076
2076
|
if (n.ref || n.selector || n.role || n.name || n.text || n.testId) {
|
|
2077
2077
|
const h = this.resolveElement(n);
|
|
2078
2078
|
if (!I(h))
|
|
@@ -2103,7 +2103,7 @@ class nn {
|
|
|
2103
2103
|
async navigate(t) {
|
|
2104
2104
|
if (this.options.allowNavigation === !1)
|
|
2105
2105
|
throw new Error("Navigation is disabled for host page automation.");
|
|
2106
|
-
const n = A(t), o = this.getRoot(), i =
|
|
2106
|
+
const n = A(t), o = this.getRoot(), i = q(o), r = vt(n.url, "url"), a = new URL(r, i.location.href);
|
|
2107
2107
|
if (a.protocol !== "http:" && a.protocol !== "https:")
|
|
2108
2108
|
throw new Error("Navigation only supports HTTP(S) URLs.");
|
|
2109
2109
|
return this.refs.clear(), this.invalidateReadableContent(), i.location.assign(a.toString()), { navigated: a.toString() };
|
|
@@ -2143,13 +2143,13 @@ class nn {
|
|
|
2143
2143
|
}), { focused: this.describeElement(o) };
|
|
2144
2144
|
}
|
|
2145
2145
|
async pointer(t) {
|
|
2146
|
-
var x,
|
|
2147
|
-
const n = A(t), o =
|
|
2146
|
+
var x, M;
|
|
2147
|
+
const n = A(t), o = Ht(n.action), i = lt(n.button) ?? 0, r = typeof n.x < "u" || typeof n.y < "u", a = m(n.targetText), s = m(n.targetRole), d = m(n.targetContext);
|
|
2148
2148
|
if (o === "click" && r && !a)
|
|
2149
2149
|
throw new Error(
|
|
2150
2150
|
"Pointer coordinate clicks require targetText to avoid unintended navigation."
|
|
2151
2151
|
);
|
|
2152
|
-
let u =
|
|
2152
|
+
let u = D(this.getRoot()), c = ((x = this.documents[0]) == null ? void 0 : x.documentRef) ?? "legacy";
|
|
2153
2153
|
if (r && this.pageStateId) {
|
|
2154
2154
|
const y = m(n.pageStateId);
|
|
2155
2155
|
(!y || y !== this.pageStateId || this.pageStateInvalidated) && this.rejectStalePageState(y ?? this.pageStateId);
|
|
@@ -2158,21 +2158,21 @@ class nn {
|
|
|
2158
2158
|
"unsupported_target_scope",
|
|
2159
2159
|
"documentRef is required for coordinate targeting."
|
|
2160
2160
|
);
|
|
2161
|
-
const N = (
|
|
2161
|
+
const N = (M = Array.from(this.documentRefs.entries()).find(
|
|
2162
2162
|
([, j]) => j === w
|
|
2163
|
-
)) == null ? void 0 :
|
|
2163
|
+
)) == null ? void 0 : M[0];
|
|
2164
2164
|
N || this.rejectTarget(
|
|
2165
2165
|
"unsupported_target_scope",
|
|
2166
2166
|
"The requested coordinate document scope is not available."
|
|
2167
2167
|
), u = N, c = w;
|
|
2168
2168
|
}
|
|
2169
|
-
const l = n.ref || n.selector || n.role || n.name || n.text || n.testId ? this.resolveElement(n) : null, h = l ? E(l).center :
|
|
2169
|
+
const l = n.ref || n.selector || n.role || n.name || n.text || n.testId ? this.resolveElement(n) : null, h = l ? E(l).center : zt(this.getRoot(), n);
|
|
2170
2170
|
if (!h)
|
|
2171
2171
|
throw new Error("Target element has no clickable point.");
|
|
2172
|
-
const g = r ?
|
|
2172
|
+
const g = r ? Yt(u, h) : h, f = l ?? z(u, g)[0];
|
|
2173
2173
|
if (!f)
|
|
2174
2174
|
throw new Error(`No element found at (${h.x}, ${h.y}).`);
|
|
2175
|
-
if (
|
|
2175
|
+
if (At(f)) {
|
|
2176
2176
|
const y = r ? {
|
|
2177
2177
|
requested: {
|
|
2178
2178
|
kind: "coordinate",
|
|
@@ -2189,7 +2189,7 @@ class nn {
|
|
|
2189
2189
|
resolved: this.describeElementDescriptor(f),
|
|
2190
2190
|
point: h,
|
|
2191
2191
|
hitTarget: this.describeElementDescriptor(f),
|
|
2192
|
-
hitStack:
|
|
2192
|
+
hitStack: z(u, g).slice(0, 5).map((w) => this.describeElementDescriptor(w)),
|
|
2193
2193
|
pageStateId: this.pageStateId
|
|
2194
2194
|
} : this.lastResolution;
|
|
2195
2195
|
this.rejectTarget(
|
|
@@ -2198,20 +2198,20 @@ class nn {
|
|
|
2198
2198
|
y
|
|
2199
2199
|
);
|
|
2200
2200
|
}
|
|
2201
|
-
const p = a ?
|
|
2201
|
+
const p = a ? sn(f, a) : void 0;
|
|
2202
2202
|
if (a && !p && this.rejectTarget(
|
|
2203
2203
|
"coordinate_target_mismatch",
|
|
2204
2204
|
`Pointer target text mismatch: expected exact hit target "${a}".`
|
|
2205
2205
|
), s) {
|
|
2206
|
-
const y =
|
|
2207
|
-
S(
|
|
2206
|
+
const y = ut(f);
|
|
2207
|
+
S(O(y)) !== S(s) && this.rejectTarget(
|
|
2208
2208
|
"coordinate_target_mismatch",
|
|
2209
2209
|
`Pointer target role mismatch: expected "${s}".`
|
|
2210
2210
|
);
|
|
2211
2211
|
}
|
|
2212
2212
|
if (a) {
|
|
2213
|
-
const y =
|
|
2214
|
-
(w) => w.ownerDocument === u &&
|
|
2213
|
+
const y = nt(u).filter(
|
|
2214
|
+
(w) => w.ownerDocument === u && qt(w) && P(w) && !!G(w) && Jt(
|
|
2215
2215
|
w,
|
|
2216
2216
|
a,
|
|
2217
2217
|
s,
|
|
@@ -2261,15 +2261,15 @@ class nn {
|
|
|
2261
2261
|
resolved: this.describeElementDescriptor(f),
|
|
2262
2262
|
point: h,
|
|
2263
2263
|
hitTarget: this.describeElementDescriptor(f),
|
|
2264
|
-
hitStack:
|
|
2264
|
+
hitStack: z(u, g).slice(0, 5).map((y) => this.describeElementDescriptor(y)),
|
|
2265
2265
|
pageStateId: this.pageStateId
|
|
2266
2266
|
}), o === "click" && await this.requireActionApproval(
|
|
2267
2267
|
"host_page_pointer",
|
|
2268
2268
|
n,
|
|
2269
|
-
|
|
2269
|
+
wt(f),
|
|
2270
2270
|
f
|
|
2271
2271
|
);
|
|
2272
|
-
const b = r ? g :
|
|
2272
|
+
const b = r ? g : Yt(f.ownerDocument, h), v = {
|
|
2273
2273
|
bubbles: !0,
|
|
2274
2274
|
cancelable: !0,
|
|
2275
2275
|
clientX: b.x,
|
|
@@ -2308,42 +2308,42 @@ class nn {
|
|
|
2308
2308
|
target: f
|
|
2309
2309
|
});
|
|
2310
2310
|
let y = f, w = h, N = h;
|
|
2311
|
-
if (
|
|
2311
|
+
if (dt(f.ownerDocument)) {
|
|
2312
2312
|
f.isConnected || this.rejectTarget(
|
|
2313
2313
|
"stale_target",
|
|
2314
2314
|
"The coordinate target was replaced before pointer dispatch.",
|
|
2315
2315
|
this.lastResolution
|
|
2316
2316
|
);
|
|
2317
|
-
const
|
|
2318
|
-
if (!
|
|
2317
|
+
const rt = r ? g : G(f);
|
|
2318
|
+
if (!rt) {
|
|
2319
2319
|
const B = E(f);
|
|
2320
2320
|
this.lastResolution && (this.lastResolution = {
|
|
2321
2321
|
...this.lastResolution,
|
|
2322
2322
|
hitTarget: B.hitTarget ? this.describeElementDescriptor(B.hitTarget) : void 0,
|
|
2323
|
-
hitStack: B.hitStack.slice(0, 5).map((
|
|
2323
|
+
hitStack: B.hitStack.slice(0, 5).map((pe) => this.describeElementDescriptor(pe))
|
|
2324
2324
|
}), this.rejectTarget(
|
|
2325
2325
|
"target_occluded",
|
|
2326
2326
|
"The coordinate target stopped receiving pointer events before dispatch.",
|
|
2327
2327
|
this.lastResolution
|
|
2328
2328
|
);
|
|
2329
2329
|
}
|
|
2330
|
-
const
|
|
2330
|
+
const mt = z(
|
|
2331
2331
|
r ? u : f.ownerDocument,
|
|
2332
|
-
|
|
2333
|
-
),
|
|
2334
|
-
|
|
2332
|
+
rt
|
|
2333
|
+
), k = mt[0];
|
|
2334
|
+
k && At(k) && this.rejectTarget(
|
|
2335
2335
|
"unsupported_target_scope",
|
|
2336
2336
|
"The coordinate target became an inaccessible frame before pointer dispatch.",
|
|
2337
2337
|
this.lastResolution
|
|
2338
2338
|
);
|
|
2339
|
-
const
|
|
2339
|
+
const yt = k ? ut(k) : void 0, fe = ut(f);
|
|
2340
2340
|
this.lastResolution && (this.lastResolution = {
|
|
2341
2341
|
...this.lastResolution,
|
|
2342
2342
|
point: w,
|
|
2343
|
-
hitTarget:
|
|
2344
|
-
hitStack:
|
|
2345
|
-
}), (!
|
|
2346
|
-
|
|
2343
|
+
hitTarget: k ? this.describeElementDescriptor(k) : void 0,
|
|
2344
|
+
hitStack: mt.slice(0, 5).map((B) => this.describeElementDescriptor(B))
|
|
2345
|
+
}), (!k || yt !== fe || a && (!yt || !Jt(
|
|
2346
|
+
yt,
|
|
2347
2347
|
a,
|
|
2348
2348
|
s,
|
|
2349
2349
|
d
|
|
@@ -2351,12 +2351,12 @@ class nn {
|
|
|
2351
2351
|
"coordinate_target_mismatch",
|
|
2352
2352
|
"The coordinate target identity changed before pointer dispatch.",
|
|
2353
2353
|
this.lastResolution
|
|
2354
|
-
), y =
|
|
2354
|
+
), y = k, N = rt, w = r ? h : ht(f, rt), this.lastResolution && (this.lastResolution = {
|
|
2355
2355
|
...this.lastResolution,
|
|
2356
2356
|
point: w,
|
|
2357
2357
|
resolved: this.describeElementDescriptor(f),
|
|
2358
|
-
hitTarget: this.describeElementDescriptor(
|
|
2359
|
-
hitStack:
|
|
2358
|
+
hitTarget: this.describeElementDescriptor(k),
|
|
2359
|
+
hitStack: mt.slice(0, 5).map((B) => this.describeElementDescriptor(B))
|
|
2360
2360
|
});
|
|
2361
2361
|
}
|
|
2362
2362
|
const j = {
|
|
@@ -2380,9 +2380,9 @@ class nn {
|
|
|
2380
2380
|
coordinateSpace: "viewport-css-px",
|
|
2381
2381
|
target: this.describeElement(y),
|
|
2382
2382
|
targetTextMatched: p,
|
|
2383
|
-
expectedAfterClick:
|
|
2383
|
+
expectedAfterClick: dn(
|
|
2384
2384
|
this.getRoot(),
|
|
2385
|
-
|
|
2385
|
+
an(n.expectedAfterClick)
|
|
2386
2386
|
)
|
|
2387
2387
|
};
|
|
2388
2388
|
}
|
|
@@ -2417,16 +2417,16 @@ class nn {
|
|
|
2417
2417
|
}
|
|
2418
2418
|
}
|
|
2419
2419
|
async waitFor(t) {
|
|
2420
|
-
const n = A(t), o =
|
|
2420
|
+
const n = A(t), o = re(n.state, [
|
|
2421
2421
|
"attached",
|
|
2422
2422
|
"visible",
|
|
2423
2423
|
"hidden",
|
|
2424
2424
|
"detached"
|
|
2425
|
-
]) ?? "visible", i =
|
|
2426
|
-
|
|
2425
|
+
]) ?? "visible", i = Y(n.timeoutSeconds), r = Math.min(
|
|
2426
|
+
He,
|
|
2427
2427
|
Math.max(
|
|
2428
2428
|
0,
|
|
2429
|
-
(i ??
|
|
2429
|
+
(i ?? Fe / 1e3) * 1e3
|
|
2430
2430
|
)
|
|
2431
2431
|
), a = Date.now(), s = this.tryResolveElement(n);
|
|
2432
2432
|
for (await this.showVisualEffect({
|
|
@@ -2438,7 +2438,7 @@ class nn {
|
|
|
2438
2438
|
point: s ? E(s).center : void 0
|
|
2439
2439
|
}); Date.now() - a <= r; ) {
|
|
2440
2440
|
const d = this.tryResolveElement(n);
|
|
2441
|
-
if (o === "attached" ? !!d : o === "detached" ? !d : o === "hidden" ? !d || !
|
|
2441
|
+
if (o === "attached" ? !!d : o === "detached" ? !d : o === "hidden" ? !d || !P(d) : !!(d && P(d)))
|
|
2442
2442
|
return {
|
|
2443
2443
|
waitedFor: o,
|
|
2444
2444
|
elapsedMs: Date.now() - a,
|
|
@@ -2458,36 +2458,36 @@ class nn {
|
|
|
2458
2458
|
describeElement(t) {
|
|
2459
2459
|
return {
|
|
2460
2460
|
tag: t.tagName.toLowerCase(),
|
|
2461
|
-
role:
|
|
2461
|
+
role: O(t),
|
|
2462
2462
|
name: R(t),
|
|
2463
|
-
selector:
|
|
2463
|
+
selector: It(t)
|
|
2464
2464
|
};
|
|
2465
2465
|
}
|
|
2466
2466
|
}
|
|
2467
|
-
const
|
|
2467
|
+
const fn = /* @__PURE__ */ new Set([
|
|
2468
2468
|
"verified",
|
|
2469
2469
|
"verification_failed",
|
|
2470
2470
|
"executed_unverified",
|
|
2471
2471
|
"rejected_before_execution"
|
|
2472
|
-
]),
|
|
2473
|
-
function
|
|
2472
|
+
]), pn = /(?:token|secret|password|passwd|api[-_]?key|auth|session|code|signature|credential)/i;
|
|
2473
|
+
function gn(e) {
|
|
2474
2474
|
try {
|
|
2475
2475
|
const t = new URL(e);
|
|
2476
2476
|
for (const n of t.searchParams.keys())
|
|
2477
|
-
|
|
2477
|
+
pn.test(n) && t.searchParams.set(n, "[REDACTED]");
|
|
2478
2478
|
return t.hash = "", t.toString();
|
|
2479
2479
|
} catch {
|
|
2480
2480
|
return "[REDACTED_URL]";
|
|
2481
2481
|
}
|
|
2482
2482
|
}
|
|
2483
|
-
function
|
|
2483
|
+
function Qt(e, t, n) {
|
|
2484
2484
|
var a, s;
|
|
2485
|
-
if (!n || typeof n != "object" || Array.isArray(n) || !
|
|
2485
|
+
if (!n || typeof n != "object" || Array.isArray(n) || !te.includes(
|
|
2486
2486
|
e
|
|
2487
2487
|
))
|
|
2488
2488
|
return n;
|
|
2489
2489
|
const o = n;
|
|
2490
|
-
if (!o.outcome || !
|
|
2490
|
+
if (!o.outcome || !fn.has(o.outcome))
|
|
2491
2491
|
return n;
|
|
2492
2492
|
const i = ((a = o.resolution) == null ? void 0 : a.pageStateId) ?? o.invalidatedPageStateId;
|
|
2493
2493
|
if (!i)
|
|
@@ -2495,7 +2495,7 @@ function Kt(e, t, n) {
|
|
|
2495
2495
|
const r = {
|
|
2496
2496
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2497
2497
|
pageStateId: i,
|
|
2498
|
-
url:
|
|
2498
|
+
url: gn(t),
|
|
2499
2499
|
action: e,
|
|
2500
2500
|
outcome: o.outcome,
|
|
2501
2501
|
...(s = o.resolution) != null && s.requested ? { requested: o.resolution.requested } : {},
|
|
@@ -2504,64 +2504,64 @@ function Kt(e, t, n) {
|
|
|
2504
2504
|
};
|
|
2505
2505
|
return { ...o, evidence: r };
|
|
2506
2506
|
}
|
|
2507
|
-
function
|
|
2507
|
+
function mn(e) {
|
|
2508
2508
|
return typeof e == "object" && e !== null && !Array.isArray(e) ? e : {};
|
|
2509
2509
|
}
|
|
2510
|
-
function
|
|
2510
|
+
function yn(e) {
|
|
2511
2511
|
return JSON.stringify(e);
|
|
2512
2512
|
}
|
|
2513
|
-
function
|
|
2513
|
+
function Et(e, t, n) {
|
|
2514
2514
|
return {
|
|
2515
2515
|
tool_call_id: e.tool_call_id ?? e.id,
|
|
2516
2516
|
name: e.name,
|
|
2517
2517
|
status: t,
|
|
2518
|
-
content:
|
|
2518
|
+
content: yn(n)
|
|
2519
2519
|
};
|
|
2520
2520
|
}
|
|
2521
|
-
function
|
|
2521
|
+
function bn(e) {
|
|
2522
2522
|
return e instanceof Error ? e.message : String(e);
|
|
2523
2523
|
}
|
|
2524
|
-
function
|
|
2524
|
+
function vn(e) {
|
|
2525
2525
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
2526
2526
|
return {};
|
|
2527
2527
|
const t = Reflect.get(e, "details");
|
|
2528
2528
|
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
2529
2529
|
}
|
|
2530
|
-
function
|
|
2530
|
+
function wn(e) {
|
|
2531
2531
|
return e !== null && typeof e == "object" && !Array.isArray(e) && Reflect.get(e, "outcome") === "verification_failed";
|
|
2532
2532
|
}
|
|
2533
|
-
function
|
|
2533
|
+
function Zt(e) {
|
|
2534
2534
|
var n, o, i;
|
|
2535
2535
|
const t = e.root && "location" in e.root ? e.root : (n = e.root) == null ? void 0 : n.ownerDocument;
|
|
2536
2536
|
return ((o = t == null ? void 0 : t.location) == null ? void 0 : o.href) ?? ((i = globalThis.location) == null ? void 0 : i.href) ?? "";
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2539
|
-
const t = new
|
|
2538
|
+
function Rn(e = {}) {
|
|
2539
|
+
const t = new hn(e);
|
|
2540
2540
|
return async (n) => {
|
|
2541
|
-
if (!
|
|
2542
|
-
return
|
|
2541
|
+
if (!Xe(n.name))
|
|
2542
|
+
return Et(n, "error", {
|
|
2543
2543
|
ok: !1,
|
|
2544
2544
|
error: `Unknown host page automation tool: ${n.name}`
|
|
2545
2545
|
});
|
|
2546
2546
|
try {
|
|
2547
|
-
const o =
|
|
2547
|
+
const o = Qt(
|
|
2548
2548
|
n.name,
|
|
2549
|
-
|
|
2550
|
-
await t.execute(n.name,
|
|
2551
|
-
), i =
|
|
2552
|
-
return
|
|
2549
|
+
Zt(e),
|
|
2550
|
+
await t.execute(n.name, mn(n.params))
|
|
2551
|
+
), i = wn(o);
|
|
2552
|
+
return Et(n, i ? "error" : "success", {
|
|
2553
2553
|
ok: !i,
|
|
2554
2554
|
result: o
|
|
2555
2555
|
});
|
|
2556
2556
|
} catch (o) {
|
|
2557
|
-
const i =
|
|
2557
|
+
const i = Qt(
|
|
2558
2558
|
n.name,
|
|
2559
|
-
|
|
2560
|
-
|
|
2559
|
+
Zt(e),
|
|
2560
|
+
vn(o)
|
|
2561
2561
|
);
|
|
2562
|
-
return
|
|
2562
|
+
return Et(n, "error", {
|
|
2563
2563
|
ok: !1,
|
|
2564
|
-
error:
|
|
2564
|
+
error: bn(o),
|
|
2565
2565
|
...i
|
|
2566
2566
|
});
|
|
2567
2567
|
}
|
|
@@ -2604,7 +2604,7 @@ const C = {
|
|
|
2604
2604
|
type: "string",
|
|
2605
2605
|
description: "Visible text to match."
|
|
2606
2606
|
}
|
|
2607
|
-
},
|
|
2607
|
+
}, Sn = {
|
|
2608
2608
|
x: {
|
|
2609
2609
|
type: "number",
|
|
2610
2610
|
description: "Viewport x coordinate."
|
|
@@ -2618,7 +2618,7 @@ const C = {
|
|
|
2618
2618
|
enum: ["viewport-css-px", "viewport_normalized"],
|
|
2619
2619
|
description: "Coordinate space for x/y. Use viewport_normalized for screenshot-derived points."
|
|
2620
2620
|
}
|
|
2621
|
-
},
|
|
2621
|
+
}, En = {
|
|
2622
2622
|
type: "object",
|
|
2623
2623
|
properties: {
|
|
2624
2624
|
documentScope: {
|
|
@@ -2660,7 +2660,7 @@ const C = {
|
|
|
2660
2660
|
"text_visible"
|
|
2661
2661
|
]
|
|
2662
2662
|
},
|
|
2663
|
-
target:
|
|
2663
|
+
target: En,
|
|
2664
2664
|
scope: {
|
|
2665
2665
|
type: "object",
|
|
2666
2666
|
properties: {
|
|
@@ -2678,7 +2678,7 @@ const C = {
|
|
|
2678
2678
|
},
|
|
2679
2679
|
required: ["type"],
|
|
2680
2680
|
additionalProperties: !1
|
|
2681
|
-
},
|
|
2681
|
+
}, _n = {
|
|
2682
2682
|
type: "object",
|
|
2683
2683
|
properties: {
|
|
2684
2684
|
type: {
|
|
@@ -2696,7 +2696,7 @@ const C = {
|
|
|
2696
2696
|
},
|
|
2697
2697
|
required: ["type", "field", "value"],
|
|
2698
2698
|
additionalProperties: !1
|
|
2699
|
-
},
|
|
2699
|
+
}, Tn = {
|
|
2700
2700
|
host_page_snapshot: {
|
|
2701
2701
|
type: "object",
|
|
2702
2702
|
properties: {
|
|
@@ -2815,7 +2815,7 @@ const C = {
|
|
|
2815
2815
|
type: "object",
|
|
2816
2816
|
properties: {
|
|
2817
2817
|
...C,
|
|
2818
|
-
...
|
|
2818
|
+
...Sn,
|
|
2819
2819
|
action: {
|
|
2820
2820
|
type: "string",
|
|
2821
2821
|
enum: ["move", "down", "up", "click"],
|
|
@@ -2842,7 +2842,7 @@ const C = {
|
|
|
2842
2842
|
description: "Nearby exact context used to disambiguate coordinates."
|
|
2843
2843
|
},
|
|
2844
2844
|
expectation: F,
|
|
2845
|
-
expectedAfterClick:
|
|
2845
|
+
expectedAfterClick: _n
|
|
2846
2846
|
},
|
|
2847
2847
|
additionalProperties: !1
|
|
2848
2848
|
},
|
|
@@ -2915,10 +2915,10 @@ const C = {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
};
|
|
2917
2917
|
export {
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2918
|
+
te as HOST_PAGE_AUTOMATION_TOOL_NAMES,
|
|
2919
|
+
Tn as HOST_PAGE_AUTOMATION_TOOL_SCHEMAS,
|
|
2920
|
+
hn as HostPageAutomationExecutor,
|
|
2921
|
+
Qt as addBrowserActionEvidence,
|
|
2922
|
+
Rn as createHostPageAutomationClientToolHandler,
|
|
2923
|
+
Xe as isHostPageAutomationToolName
|
|
2924
2924
|
};
|