@opentiny/next-sdk 0.4.1 → 0.4.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 (90) hide show
  1. package/dist/{SimulatorMask-BHVXyogh-iNUb4dyF.js → SimulatorMask-BHVXyogh-CKmEDsYG.js} +1 -1
  2. package/dist/core.js +1 -1
  3. package/dist/{index-CXK8CcKq.js → index-CHMa2zG4.js} +1985 -1434
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.js +69 -50
  6. package/dist/{initialize-builtin-WebMCP-rALfqS-o.js → initialize-builtin-WebMCP-JaoKwVlm.js} +355 -346
  7. package/dist/page-tools/a11y/build.d.ts +3 -4
  8. package/dist/page-tools/a11y/config.d.ts +99 -0
  9. package/dist/page-tools/a11y/constants.d.ts +22 -0
  10. package/dist/page-tools/a11y/search.d.ts +1 -1
  11. package/dist/page-tools/a11y/types.d.ts +13 -22
  12. package/dist/page-tools/a11y/utils.d.ts +46 -11
  13. package/dist/page-tools/a11y/vnode.d.ts +14 -11
  14. package/dist/page-tools/a11y-tree.d.ts +1 -0
  15. package/dist/page-tools/configs/console-cloud.d.ts +6 -0
  16. package/dist/page-tools/constants.d.ts +7 -17
  17. package/dist/page-tools/context.d.ts +14 -0
  18. package/dist/page-tools/handlers/hover.d.ts +9 -0
  19. package/dist/page-tools/handlers/searchTree.d.ts +2 -1
  20. package/dist/page-tools/page-agent-highlight/index.d.ts +12 -0
  21. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +2 -0
  22. package/dist/page-tools/page-agent-tool-event.d.ts +26 -0
  23. package/dist/page-tools/schema.d.ts +4 -3
  24. package/dist/page-tools/tool-config.d.ts +50 -0
  25. package/dist/page-tools/utils/dom.d.ts +8 -2
  26. package/dist/runtime.d.ts +4 -1
  27. package/dist/runtime.js +22 -187
  28. package/dist/vitest.config.d.ts +2 -0
  29. package/package.json +26 -16
  30. package/WebMcpClient.ts +0 -505
  31. package/WebMcpServer.ts +0 -447
  32. package/agent/AgentModelProvider.ts +0 -932
  33. package/agent/type.ts +0 -91
  34. package/agent/utils/generateReActPrompt.ts +0 -71
  35. package/agent/utils/getAISDKTools.ts +0 -34
  36. package/agent/utils/getBuiltinMcpTools.ts +0 -86
  37. package/agent/utils/parseReActAction.ts +0 -34
  38. package/core.ts +0 -26
  39. package/index.ts +0 -56
  40. package/page-tools/a11y/build.ts +0 -70
  41. package/page-tools/a11y/constants.ts +0 -110
  42. package/page-tools/a11y/search.ts +0 -129
  43. package/page-tools/a11y/types.ts +0 -108
  44. package/page-tools/a11y/utils.ts +0 -266
  45. package/page-tools/a11y/vnode.ts +0 -229
  46. package/page-tools/a11y-tree.ts +0 -13
  47. package/page-tools/bridge.ts +0 -702
  48. package/page-tools/constants.ts +0 -72
  49. package/page-tools/context.ts +0 -13
  50. package/page-tools/effects.ts +0 -345
  51. package/page-tools/handlers/browserState.ts +0 -12
  52. package/page-tools/handlers/click.ts +0 -26
  53. package/page-tools/handlers/executeJavascript.ts +0 -22
  54. package/page-tools/handlers/fill.ts +0 -60
  55. package/page-tools/handlers/scroll.ts +0 -66
  56. package/page-tools/handlers/searchTree.ts +0 -30
  57. package/page-tools/handlers/select.ts +0 -34
  58. package/page-tools/initialize-builtin-WebMCP.ts +0 -20
  59. package/page-tools/page-agent-highlight/index.ts +0 -198
  60. package/page-tools/page-agent-mask/SimulatorMask.module.css +0 -14
  61. package/page-tools/page-agent-mask/SimulatorMask.ts +0 -279
  62. package/page-tools/page-agent-mask/checkDarkMode.ts +0 -181
  63. package/page-tools/page-agent-mask/cursor-border.svg +0 -3
  64. package/page-tools/page-agent-mask/cursor-fill.svg +0 -5
  65. package/page-tools/page-agent-mask/cursor.module.css +0 -70
  66. package/page-tools/page-agent-prompt.md +0 -139
  67. package/page-tools/page-agent-tool.ts +0 -175
  68. package/page-tools/page-state-cache.ts +0 -78
  69. package/page-tools/schema.ts +0 -51
  70. package/page-tools/utils/dom.ts +0 -155
  71. package/page-tools/utils/scroll.ts +0 -58
  72. package/remoter/QrCode.ts +0 -54
  73. package/remoter/createRemoter.ts +0 -957
  74. package/remoter/svgs/chat.svg +0 -43
  75. package/remoter/svgs/icon-copy.svg +0 -25
  76. package/remoter/svgs/link.svg +0 -28
  77. package/remoter/svgs/logo.svg +0 -45
  78. package/remoter/svgs/qrcode.svg +0 -35
  79. package/remoter/svgs/scan.svg +0 -21
  80. package/remoter/tooltips.ts +0 -260
  81. package/runtime.html +0 -39
  82. package/runtime.ts +0 -13
  83. package/script/utils.ts +0 -26
  84. package/skills/index.ts +0 -287
  85. package/tsconfig.json +0 -16
  86. package/utils/builtinProxy.ts +0 -144
  87. package/utils/env.ts +0 -13
  88. package/utils/uuid.ts +0 -10
  89. package/vite.config.runtime.ts +0 -22
  90. package/vite.config.ts +0 -63
@@ -6,7 +6,7 @@ import "@modelcontextprotocol/sdk/shared/uriTemplate.js";
6
6
  import "@modelcontextprotocol/sdk/server/completable.js";
7
7
  import "@modelcontextprotocol/sdk/shared/metadataUtils.js";
8
8
  import "@modelcontextprotocol/sdk/inMemory.js";
9
- import { i as initializeBuiltinWebMCP } from "./initialize-builtin-WebMCP-rALfqS-o.js";
9
+ import { i as initializeBuiltinWebMCP } from "./initialize-builtin-WebMCP-JaoKwVlm.js";
10
10
  import QRCodePck from "qrcode";
11
11
  import { tool } from "ai";
12
12
  import { ZodFirstPartyTypeKind } from "zod/v3";
@@ -97,9 +97,9 @@ class Tooltip {
97
97
  this.applyStyle(this.calcStyle("top"));
98
98
  }
99
99
  calcStyle(e) {
100
- const n = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, a = 6, [l, c = "center"] = e.split("-");
101
- let u = 0, d = 0;
102
- return l === "top" ? u = n.top + r - i.height - a : l === "bottom" ? u = n.bottom + r + a : l === "left" ? d = n.left + o - i.width - a : l === "right" && (d = n.right + o + a), (l === "top" || l === "bottom") && (c === "start" ? d = n.left + o : c === "end" ? d = n.right + o - i.width : d = (n.left + n.right) / 2 + o - i.width / 2), (l === "left" || l === "right") && (c === "start" ? u = n.top + r : c === "end" ? u = n.bottom + r - i.height : u = (n.top + n.bottom) / 2 + r - i.height / 2), { top: Math.round(u), left: Math.round(d) };
100
+ const n = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, s = 6, [a, c = "center"] = e.split("-");
101
+ let d = 0, u = 0;
102
+ return a === "top" ? d = n.top + r - i.height - s : a === "bottom" ? d = n.bottom + r + s : a === "left" ? u = n.left + o - i.width - s : a === "right" && (u = n.right + o + s), (a === "top" || a === "bottom") && (c === "start" ? u = n.left + o : c === "end" ? u = n.right + o - i.width : u = (n.left + n.right) / 2 + o - i.width / 2), (a === "left" || a === "right") && (c === "start" ? d = n.top + r : c === "end" ? d = n.bottom + r - i.height : d = (n.top + n.bottom) / 2 + r - i.height / 2), { top: Math.round(d), left: Math.round(u) };
103
103
  }
104
104
  applyStyle({ top: e, left: n }) {
105
105
  Object.assign(this.tip.style, {
@@ -109,8 +109,8 @@ class Tooltip {
109
109
  });
110
110
  }
111
111
  checkViewport({ top: e, left: n }) {
112
- const r = window.innerWidth, o = window.innerHeight, a = this.tip.getBoundingClientRect();
113
- return n >= 5 && e >= 5 && n + a.width <= r - 5 && e + a.height <= o - 5;
112
+ const r = window.innerWidth, o = window.innerHeight, s = this.tip.getBoundingClientRect();
113
+ return n >= 5 && e >= 5 && n + s.width <= r - 5 && e + s.height <= o - 5;
114
114
  }
115
115
  placementList(e) {
116
116
  const n = {
@@ -330,8 +330,8 @@ class FloatingBlock {
330
330
  const n = e.target, i = n.closest(".tiny-remoter-copy-icon");
331
331
  if (i) {
332
332
  e.stopPropagation();
333
- const a = i.dataset.action;
334
- a && this.handleAction(a);
333
+ const s = i.dataset.action;
334
+ s && this.handleAction(s);
335
335
  return;
336
336
  }
337
337
  const o = n.closest(".tiny-remoter-dropdown-item")?.dataset.action;
@@ -880,14 +880,14 @@ async function parseSkillFrontMatter(t) {
880
880
  if (typeof t != "string" && typeof t != "function") return null;
881
881
  const n = (typeof t == "string" ? t : await t()).match(FRONT_MATTER_BLOCK_REG);
882
882
  if (!n?.[1]) return null;
883
- const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), a = r?.[1]?.trim(), l = o?.[1]?.trim();
884
- return a && l ? { name: a, description: l } : null;
883
+ const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), s = r?.[1]?.trim(), a = o?.[1]?.trim();
884
+ return s && a ? { name: s, description: a } : null;
885
885
  }
886
886
  async function normalizeSkillModuleKeys(t) {
887
887
  const e = {};
888
888
  for (const [n, i] of Object.entries(t)) {
889
- const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), a = o >= 0 ? r.slice(o + 7) : r, l = a.startsWith("./") ? a : `./${a}`, c = typeof i == "string" ? i : await i();
890
- e[l] = c;
889
+ const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), s = o >= 0 ? r.slice(o + 7) : r, a = s.startsWith("./") ? s : `./${s}`, c = typeof i == "string" ? i : await i();
890
+ e[a] = c;
891
891
  }
892
892
  return e;
893
893
  }
@@ -900,10 +900,10 @@ async function getSkillOverviews(t) {
900
900
  for (const r of n) {
901
901
  const o = e[r];
902
902
  if (!o) continue;
903
- const a = await parseSkillFrontMatter(o);
904
- a && i.push({
905
- name: a.name,
906
- description: a.description,
903
+ const s = await parseSkillFrontMatter(o);
904
+ s && i.push({
905
+ name: s.name,
906
+ description: s.description,
907
907
  path: r
908
908
  });
909
909
  }
@@ -920,17 +920,17 @@ ${t.map((n) => `- **${n.name}**: ${n.description}`).join(`
920
920
  async function getSkillMdContent(t, e) {
921
921
  const n = await normalizeSkillModuleKeys(t), i = n[e];
922
922
  if (i) return i;
923
- const r = e.replace(/^\.?\//, "/"), o = Object.keys(n).find((a) => a.endsWith(r));
923
+ const r = e.replace(/^\.?\//, "/"), o = Object.keys(n).find((s) => s.endsWith(r));
924
924
  return o ? n[o] : void 0;
925
925
  }
926
926
  async function getMainSkillPathByName(t, e) {
927
927
  const n = await normalizeSkillModuleKeys(t), i = await getMainSkillPaths(n), r = i.find((o) => o.startsWith(`./${e}/SKILL.md`));
928
928
  if (r) return r;
929
929
  for (const o of i) {
930
- const a = n[o];
931
- if (a) {
932
- const l = await parseSkillFrontMatter(a);
933
- if (l && l.name === e)
930
+ const s = n[o];
931
+ if (s) {
932
+ const a = await parseSkillFrontMatter(s);
933
+ if (a && a.name === e)
934
934
  return o;
935
935
  }
936
936
  }
@@ -952,37 +952,37 @@ function createSkillTools(t) {
952
952
  inputSchema: SKILL_INPUT_SCHEMA,
953
953
  execute: async (r) => {
954
954
  e || (n = await normalizeSkillModuleKeys(t), e = !0);
955
- const o = n, { skillName: a, path: l, currentPath: c } = r;
956
- let u, d = "";
957
- if (l) {
958
- let p = ".";
955
+ const o = n, { skillName: s, path: a, currentPath: c } = r;
956
+ let d, u = "";
957
+ if (a) {
958
+ let h = ".";
959
959
  if (c) {
960
960
  const g = c.lastIndexOf("/");
961
- g >= 0 && (p = c.slice(0, g));
961
+ g >= 0 && (h = c.slice(0, g));
962
962
  }
963
- const f = `http://localhost/${p}/`;
964
- if (d = "." + new URL(l, f).pathname, u = await getSkillMdContent(o, d), u === void 0 && (l.startsWith("./") || l.startsWith("../")) && c) {
963
+ const p = `http://localhost/${h}/`;
964
+ if (u = "." + new URL(a, p).pathname, d = await getSkillMdContent(o, u), d === void 0 && (a.startsWith("./") || a.startsWith("../")) && c) {
965
965
  const g = c.split("/");
966
966
  if (g.length >= 2) {
967
- const E = `http://localhost/${g[1]}/`, x = "." + new URL(l, E).pathname;
968
- u = await getSkillMdContent(o, x), u && (d = x);
967
+ const L = `http://localhost/${g[1]}/`, b = "." + new URL(a, L).pathname;
968
+ d = await getSkillMdContent(o, b), d && (u = b);
969
969
  }
970
970
  }
971
- if (u && !o[d]) {
972
- const g = d.replace(/^\.?\//, "/"), S = Object.keys(o).find((E) => E.endsWith(g));
973
- S && (d = S);
971
+ if (d && !o[u]) {
972
+ const g = u.replace(/^\.?\//, "/"), E = Object.keys(o).find((L) => L.endsWith(g));
973
+ E && (u = E);
974
974
  }
975
- } else if (a) {
976
- const p = await getMainSkillPathByName(o, a);
977
- p && (d = p, u = await getSkillMdContent(o, p));
975
+ } else if (s) {
976
+ const h = await getMainSkillPathByName(o, s);
977
+ h && (u = h, d = await getSkillMdContent(o, h));
978
978
  }
979
- return u === void 0 ? {
979
+ return d === void 0 ? {
980
980
  error: "未找到对应技能文档",
981
- skillName: a,
982
- path: l,
981
+ skillName: s,
982
+ path: a,
983
983
  providedCurrentPath: c,
984
- attemptedPath: d
985
- } : { content: u, path: d };
984
+ attemptedPath: u
985
+ } : { content: d, path: u };
986
986
  }
987
987
  })
988
988
  };
@@ -1184,13 +1184,13 @@ function parseIntersectionDef(t, e) {
1184
1184
  if (isJsonSchema7AllOfType(o))
1185
1185
  r.push(...o.allOf), o.unevaluatedProperties === void 0 && (i = void 0);
1186
1186
  else {
1187
- let a = o;
1187
+ let s = o;
1188
1188
  if ("additionalProperties" in o && o.additionalProperties === !1) {
1189
- const { additionalProperties: l, ...c } = o;
1190
- a = c;
1189
+ const { additionalProperties: a, ...c } = o;
1190
+ s = c;
1191
1191
  } else
1192
1192
  i = void 0;
1193
- r.push(a);
1193
+ r.push(s);
1194
1194
  }
1195
1195
  }), r.length ? {
1196
1196
  allOf: r,
@@ -1402,16 +1402,16 @@ function stringifyRegExpWithFlags(t, e) {
1402
1402
  s: t.flags.includes("s")
1403
1403
  // `.` matches newlines
1404
1404
  }, i = n.i ? t.source.toLowerCase() : t.source;
1405
- let r = "", o = !1, a = !1, l = !1;
1405
+ let r = "", o = !1, s = !1, a = !1;
1406
1406
  for (let c = 0; c < i.length; c++) {
1407
1407
  if (o) {
1408
1408
  r += i[c], o = !1;
1409
1409
  continue;
1410
1410
  }
1411
1411
  if (n.i) {
1412
- if (a) {
1412
+ if (s) {
1413
1413
  if (i[c].match(/[a-z]/)) {
1414
- l ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), l = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], l = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
1414
+ a ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), a = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], a = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
1415
1415
  continue;
1416
1416
  }
1417
1417
  } else if (i[c].match(/[a-z]/)) {
@@ -1431,12 +1431,12 @@ function stringifyRegExpWithFlags(t, e) {
1431
1431
  }
1432
1432
  }
1433
1433
  if (n.s && i[c] === ".") {
1434
- r += a ? `${i[c]}\r
1434
+ r += s ? `${i[c]}\r
1435
1435
  ` : `[${i[c]}\r
1436
1436
  ]`;
1437
1437
  continue;
1438
1438
  }
1439
- r += i[c], i[c] === "\\" ? o = !0 : a && i[c] === "]" ? a = !1 : !a && i[c] === "[" && (a = !0);
1439
+ r += i[c], i[c] === "\\" ? o = !0 : s && i[c] === "]" ? s = !1 : !s && i[c] === "[" && (s = !0);
1440
1440
  }
1441
1441
  try {
1442
1442
  new RegExp(r);
@@ -1549,20 +1549,20 @@ function parseUnionDef(t, e) {
1549
1549
  const n = t.options instanceof Map ? Array.from(t.options.values()) : t.options;
1550
1550
  if (n.every((i) => i._def.typeName in primitiveMappings && (!i._def.checks || !i._def.checks.length))) {
1551
1551
  const i = n.reduce((r, o) => {
1552
- const a = primitiveMappings[o._def.typeName];
1553
- return a && !r.includes(a) ? [...r, a] : r;
1552
+ const s = primitiveMappings[o._def.typeName];
1553
+ return s && !r.includes(s) ? [...r, s] : r;
1554
1554
  }, []);
1555
1555
  return {
1556
1556
  type: i.length > 1 ? i : i[0]
1557
1557
  };
1558
1558
  } else if (n.every((i) => i._def.typeName === "ZodLiteral" && !i.description)) {
1559
1559
  const i = n.reduce((r, o) => {
1560
- const a = typeof o._def.value;
1561
- switch (a) {
1560
+ const s = typeof o._def.value;
1561
+ switch (s) {
1562
1562
  case "string":
1563
1563
  case "number":
1564
1564
  case "boolean":
1565
- return [...r, a];
1565
+ return [...r, s];
1566
1566
  case "bigint":
1567
1567
  return [...r, "integer"];
1568
1568
  case "object":
@@ -1576,10 +1576,10 @@ function parseUnionDef(t, e) {
1576
1576
  }
1577
1577
  }, []);
1578
1578
  if (i.length === n.length) {
1579
- const r = i.filter((o, a, l) => l.indexOf(o) === a);
1579
+ const r = i.filter((o, s, a) => a.indexOf(o) === s);
1580
1580
  return {
1581
1581
  type: r.length > 1 ? r : r[0],
1582
- enum: n.reduce((o, a) => o.includes(a._def.value) ? o : [...o, a._def.value], [])
1582
+ enum: n.reduce((o, s) => o.includes(s._def.value) ? o : [...o, s._def.value], [])
1583
1583
  };
1584
1584
  }
1585
1585
  } else if (n.every((i) => i._def.typeName === "ZodEnum"))
@@ -1651,22 +1651,22 @@ function parseObjectDef(t, e) {
1651
1651
  type: "object",
1652
1652
  properties: {}
1653
1653
  }, r = [], o = t.shape();
1654
- for (const l in o) {
1655
- let c = o[l];
1654
+ for (const a in o) {
1655
+ let c = o[a];
1656
1656
  if (c === void 0 || c._def === void 0)
1657
1657
  continue;
1658
- let u = safeIsOptional(c);
1659
- u && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), u = !1);
1660
- const d = parseDef(c._def, {
1658
+ let d = safeIsOptional(c);
1659
+ d && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), d = !1);
1660
+ const u = parseDef(c._def, {
1661
1661
  ...e,
1662
- currentPath: [...e.currentPath, "properties", l],
1663
- propertyPath: [...e.currentPath, "properties", l]
1662
+ currentPath: [...e.currentPath, "properties", a],
1663
+ propertyPath: [...e.currentPath, "properties", a]
1664
1664
  });
1665
- d !== void 0 && (i.properties[l] = d, u || r.push(l));
1665
+ u !== void 0 && (i.properties[a] = u, d || r.push(a));
1666
1666
  }
1667
1667
  r.length && (i.required = r);
1668
- const a = decideAdditionalProperties(t, e);
1669
- return a !== void 0 && (i.additionalProperties = a), i;
1668
+ const s = decideAdditionalProperties(t, e);
1669
+ return s !== void 0 && (i.additionalProperties = s), i;
1670
1670
  }
1671
1671
  function decideAdditionalProperties(t, e) {
1672
1672
  if (t.catchall._def.typeName !== "ZodNever")
@@ -1843,23 +1843,23 @@ const parseReadonlyDef = (t, e) => parseDef(t.innerType._def, e), selectParser =
1843
1843
  function parseDef(t, e, n = !1) {
1844
1844
  const i = e.seen.get(t);
1845
1845
  if (e.override) {
1846
- const l = e.override?.(t, e, i, n);
1847
- if (l !== ignoreOverride)
1848
- return l;
1846
+ const a = e.override?.(t, e, i, n);
1847
+ if (a !== ignoreOverride)
1848
+ return a;
1849
1849
  }
1850
1850
  if (i && !n) {
1851
- const l = get$ref(i, e);
1852
- if (l !== void 0)
1853
- return l;
1851
+ const a = get$ref(i, e);
1852
+ if (a !== void 0)
1853
+ return a;
1854
1854
  }
1855
1855
  const r = { def: t, path: e.currentPath, jsonSchema: void 0 };
1856
1856
  e.seen.set(t, r);
1857
- const o = selectParser(t, t.typeName, e), a = typeof o == "function" ? parseDef(o(), e) : o;
1858
- if (a && addMeta(t, e, a), e.postProcess) {
1859
- const l = e.postProcess(a, t, e);
1860
- return r.jsonSchema = a, l;
1857
+ const o = selectParser(t, t.typeName, e), s = typeof o == "function" ? parseDef(o(), e) : o;
1858
+ if (s && addMeta(t, e, s), e.postProcess) {
1859
+ const a = e.postProcess(s, t, e);
1860
+ return r.jsonSchema = s, a;
1861
1861
  }
1862
- return r.jsonSchema = a, a;
1862
+ return r.jsonSchema = s, s;
1863
1863
  }
1864
1864
  const get$ref = (t, e) => {
1865
1865
  switch (e.$refStrategy) {
@@ -1890,7 +1890,7 @@ const get$ref = (t, e) => {
1890
1890
  ].join("/")
1891
1891
  }
1892
1892
  }));
1893
- const a = r === void 0 ? i ? {
1893
+ const s = r === void 0 ? i ? {
1894
1894
  ...o,
1895
1895
  [n.definitionPath]: i
1896
1896
  } : o : {
@@ -1904,147 +1904,8 @@ const get$ref = (t, e) => {
1904
1904
  [r]: o
1905
1905
  }
1906
1906
  };
1907
- return n.target === "jsonSchema7" ? a.$schema = "http://json-schema.org/draft-07/schema#" : (n.target === "jsonSchema2019-09" || n.target === "openAi") && (a.$schema = "https://json-schema.org/draft/2019-09/schema#"), n.target === "openAi" && ("anyOf" in a || "oneOf" in a || "allOf" in a || "type" in a && Array.isArray(a.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), a;
1908
- }, pageAgentPrompt = `## 角色
1909
-
1910
- 你是浏览器页面的操作工具,你拥有识别网页内容,点击,填写,选择下拉框和滚动页面等功能。
1911
-
1912
- 在执行页面操作之前,你必须先调用\`browserState\`工具一次,根据最新的网页状态,再调用操作动作,比如 'click','fill','select' 等动作。
1913
-
1914
- <intro>
1915
- 你擅长以下任务:
1916
- 1. 导航复杂网站并提取精确信息
1917
- 2. 自动化表单提交和交互式网页操作
1918
- 3. 收集和保存信息
1919
- 4. 在代理循环中有效运行
1920
- 5. 高效执行多样化的网页任务
1921
- </intro>
1922
-
1923
- <input>
1924
- 在每一步,你的输入将包括:
1925
- 1. <agent_history>:一个按时间顺序排列的事件流,包括你之前的操作及其结果。
1926
- 2. <agent_state>:当前的 <user_request> 和 <step_info>。
1927
- 3. <browser_state>:当前 URL、页面标题、可交互元素总数以及语义化 YAML 树。
1928
- </input>
1929
-
1930
- <browser_state>
1931
-
1932
- 浏览器状态包含以下内容:
1933
-
1934
- - url: 当前查看页面的 URL。
1935
- - title: 当前查看页面的标题。
1936
- - 可交互元素总数:带有 \`#N\` 标记的元素数量。
1937
- - YAML 树:页面的语义化结构,格式如下:
1938
-
1939
- \`\`\`yaml
1940
- - region:
1941
- - main:
1942
- - button #9 [cursor=pointer] "产品文档"
1943
- - button #47 [selected] [cursor=pointer] "40元/月 2核CPU 2GB内存"
1944
- - radio #53 [checked] [cursor=pointer] "自动生成密码"
1945
- - button #74 [cursor=pointer] "立即购买"
1946
- - generic #6 [cf-uba="serviceList..Flexus云服务"] "Flexus云服务"
1947
- \`\`\`
1948
-
1949
- 节点格式说明:
1950
- - \`- role #N [token1] [token2] "accessible name"\`
1951
- - \`role\`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)
1952
- - \`#N\`:可交互元素的唯一操作索引,**只有带 \`#N\` 的节点才能被操作**,操作时将 N 作为 \`index\` 参数传入
1953
- - \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[disabled]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
1954
- - \`"accessible name"\`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略
1955
- - 缩进表示父子关系
1956
-
1957
- </browser_state>
1958
-
1959
- <responseMode>
1960
-
1961
- \`page-agent-tool\` 支持 \`responseMode\` 参数,用于控制操作后返回的页面状态形式:
1962
-
1963
- - **\`diff\`**(默认):仅返回自上一次状态以来的增量 DOM 差异,极大节省 Token。
1964
- - **\`full\`**:返回当前视口中完整的语义化 ARIA YAML 树。
1965
- - **\`both\`**:同时返回全量树和增量差异。
1966
-
1967
- 执行 \`click\`、\`fill\`、\`select\`、\`scroll\` 操作后,工具默认自动以 \`diff\` 模式返回最新页面状态,无需再次手动调用 \`browserState\`。
1968
-
1969
- </responseMode>
1970
-
1971
- <browser_state_diff>
1972
-
1973
- 在交互过程中,为了提高效率和减少上下文占用,工具会生成页面的增量差异(Diff)信息。
1974
- Diff 格式示例如下:
1975
- \`\`\`diff
1976
- - button #9: 产品文档
1977
- + button #9: 产品文档 (已点击)
1978
- \`\`\`
1979
- 或者,当页面结构发生改变时,会展示新增或移除的节点差异。
1980
-
1981
- ### 页面状态获取四原则(重要,请严格遵守):
1982
-
1983
- > 与业界 AI 编辑器(Cursor / Windsurf)按需读取文件而非全量加载的理念完全一致——**先精准搜索,再按需拉取全量**,将发送给大模型的 token 降至最低。
1984
-
1985
- 1. **按关键词精准搜索(最高优先级)**:当你已知要找什么类型的元素(如按钮、输入框、特定名称的链接)时,**优先使用 \`searchTree\` 动作**,传入 role 名称、元素文本或状态关键词搜索。它只返回命中行和上下文,token 消耗比全量树减少 80%+。
1986
- - 示例:查找所有按钮 → \`{"action": "searchTree", "query": "button"}\`
1987
- - 示例:查找含"提交"文本的节点 → \`{"action": "searchTree", "query": "提交"}\`
1988
- - 示例:查找已勾选的复选框 → \`{"action": "searchTree", "query": "checked"}\`
1989
- - 示例:精确定位某个 ref → \`{"action": "searchTree", "query": "#5"}\`
1990
- 2. **首次获取全量**:首次进入页面、页面发生重大刷新、或 \`searchTree\` 无法找到所需信息时,调用 \`browserState\` 并指定 \`responseMode\` 为 \`full\` 或 \`both\` 获取完整 A11y 树。
1991
- 3. **增量优先**:执行 \`click\`、\`fill\`、\`select\`、\`scroll\` 操作后,工具默认自动返回 \`diff\` 增量信息。优先阅读这些 Diff,以便快速确认操作是否生效。
1992
- 4. **按需拉取全量**:如果增量 Diff 不足以支持下一步操作,或需要寻找不在 Diff 中的 \`#N\` 节点,且 \`searchTree\` 也无法定位时,再显式调用 \`browserState\` 拉取完整树。
1993
-
1994
- </browser_state_diff>
1995
-
1996
-
1997
-
1998
- <browser_rules>
1999
- 在使用浏览器和浏览网页时严格遵守以下规则:
2000
-
2001
- - 仅与分配有 \`#N\` 索引的元素进行交互,将 N 作为 \`index\` 参数传入。
2002
- - 仅使用明确出现在树中的 \`#N\` 索引,切勿猜测或沿用过期索引。
2003
- - 每次操作后 \`#N\` 索引会重新分配,不要使用旧的索引。
2004
- - 如果页面在执行操作后发生变化(例如输入文本操作),分析是否需要与新元素进行交互,例如从列表中选择正确的选项。
2005
- - 默认情况下,仅列出可见视口中的元素。如果你怀疑需要交互的相关内容在屏幕外,请使用滚动操作。仅在页面下方或上方还有更多像素时才滚动。
2006
- - 你可以使用 num_pages 参数滚动特定页数(例如,0.5 表示半页,2.0 表示两页)。
2007
- - 如果出现验证码,告诉用户你无法解决验证码。完成任务并请用户解决它。
2008
- - 如果缺少预期元素,尝试滚动或导航回退。
2009
- - 除非某些条件发生变化,否则不要重复同一操作超过 3 次。
2010
- - 如果你向输入字段填充文本且操作序列被中断,通常意味着某些内容发生了变化,例如下拉建议弹出。
2011
- - 如果 <user_request> 包含特定的页面信息,如产品类型、评分、价格、位置等,尝试应用过滤器以提高效率。
2012
- - <user_request> 是最终目标。如果用户指定了明确的步骤,它们始终具有最高优先级。
2013
- - 如果你向字段输入文本,可能需要按回车键、点击搜索按钮或从下拉列表中选择以完成操作。
2014
- - **不要通过 executeJavascript 向页面插入 DOM 元素**(如创建 div 显示调试信息)。这会污染页面结构并影响后续操作。如需读取数据,使用 return 语句返回结果即可。
2015
- - 如果操作返回中出现 \`[校验提示]\`,说明页面有表单校验错误未通过,请先根据提示修复错误后再继续操作。
2016
- - 如果操作后页面没有发生预期变化,优先检查是否有 \`[校验提示]\` 或 \`[error]\` token 的错误信息,而非重复操作。
2017
- - 如果不需要,不要登录页面。如果没有凭据,不要登录。
2018
- - 有两种类型的任务,首先思考你正在处理哪种类型的请求:
2019
-
2020
- 1. 非常具体的逐步说明:
2021
-
2022
- - 非常精确地遵循它们,不要跳过步骤。尝试按要求完成所有内容。
2023
-
2024
- 2. 开放式任务。自己规划,在实现目标时保持创造性。
2025
-
2026
- - 如果在开放式任务中陷入困境(例如登录或验证码),可以重新评估任务并尝试替代方法,例如有时即使页面的某些部分可访问或通过 Web 搜索获取一些信息,也会意外弹出登录框。
2027
- </browser_rules>
2028
-
2029
- <capability>
2030
- - 你只能处理单页应用。不要跳出当前页面。
2031
- - 如果链接将在新页面中打开(例如,<a target="_blank">),不要点击该链接。
2032
- - 任务失败是可以接受的。
2033
- - 用户可能是错的。如果用户的请求无法实现、不适当,或者你没有足够的信息或工具来实现它。告诉用户提出更好的请求。
2034
- - 网页可能已损坏。所有网页或应用都有 bug。有些 bug 会使你的工作变得困难。鼓励你告诉用户当前页面的问题。你的反馈(包括失败)对用户很有价值。
2035
- - 过于努力可能有害。来回重复某些操作或在知识有限的情况下推动复杂程序可能导致不良结果和有害副作用。用户宁愿你以失败告终完成任务。
2036
- - 如果你对当前网页或任务没有相关知识。你必须要求用户提供具体说明和详细步骤。
2037
- </capability>
2038
-
2039
- <task_completion_rules>
2040
- 你必须在以下情况时结束任务:
2041
-
2042
- - 当你完全完成用户请求时。
2043
- - 当你感到困惑或无法解决用户请求时。或者用户请求不清楚或包含不当内容。
2044
- - 如果绝对不可能继续。
2045
-
2046
- </task_completion_rules>
2047
- `;
1907
+ return n.target === "jsonSchema7" ? s.$schema = "http://json-schema.org/draft-07/schema#" : (n.target === "jsonSchema2019-09" || n.target === "openAi") && (s.$schema = "https://json-schema.org/draft/2019-09/schema#"), n.target === "openAi" && ("anyOf" in s || "oneOf" in s || "allOf" in s || "type" in s && Array.isArray(s.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), s;
1908
+ }, pageAgentPrompt = '## 角色\n\n你是浏览器页面的操作工具,你拥有识别网页内容,点击,填写,选择下拉框、悬浮(hover)和滚动页面等功能。\n\n在执行页面操作之前,你必须先调用`browserState`工具一次,根据最新的网页状态,再调用操作动作,比如 \'click\',\'fill\',\'select\',\'hover\' 等动作。\n\n<intro>\n你擅长以下任务:\n1. 导航复杂网站并提取精确信息\n2. 自动化表单提交和交互式网页操作\n3. 收集和保存信息\n4. 在代理循环中有效运行\n5. 高效执行多样化的网页任务\n</intro>\n\n<input>\n在每一步,你的输入将包括:\n1. <agent_history>:一个按时间顺序排列的事件流,包括你之前的操作及其结果。\n2. <agent_state>:当前的 <user_request> 和 <step_info>。\n3. <browser_state>:当前 URL、页面标题、可交互元素总数以及语义化 YAML 树。\n</input>\n\n<browser_state>\n\n浏览器状态包含以下内容:\n\n- url: 当前查看页面的 URL。\n- title: 当前查看页面的标题。\n- content: 语义化 YAML 树(或增量 Diff,取决于 responseMode)。\n- dialogs(可选): 当前可见的模态弹窗列表,每项含 `text` 与 `buttons`;若存在请优先处理。\n- validationErrors(可选): 当前可见的表单校验错误文案列表;若存在请先修复。\n- tooltips(可选): 当前可见的 tooltip / 浮层提示文案列表(常见于 hover 后)。\n- 可交互元素总数:带有 `#N` 标记的元素数量。\n- YAML 树:页面的语义化结构,格式如下:\n\n```yaml\n- region:\n - main:\n - button #9 [cursor=pointer] "产品文档"\n - button #47 [selected] [cursor=pointer] "40元/月 2核CPU 2GB内存"\n - radio #53 [checked] [cursor=pointer] "自动生成密码"\n - button #74 [cursor=pointer] "立即购买"\n - generic #6 [cf-uba="serviceList..Flexus云服务"] "Flexus云服务"\n```\n\n节点格式说明:\n- `- role #N [token1] [token2] "accessible name"`\n- `role`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)\n- `#N`:可交互元素的唯一操作索引,**只有带 `#N` 的节点才能被操作**,操作时将 N 作为 `index` 参数传入\n- `[token]`:可选 token,包括状态标记(如 `[checked]` `[selected]` `[pressed]` `[current]` `[expanded]` `[hasPopup]` `[disabled]` `[readonly]` `[required]` `[invalid]` `[busy]` `[error]` `[warning]` `[cursor=pointer]` `[tooltip="帮助文本"]`)和定制属性(如 `[cf-uba="..."]`)\n- `"accessible name"`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略\n- 缩进表示父子关系\n\n</browser_state>\n\n<responseMode>\n\n`page-agent-tool` 支持 `responseMode` 参数,用于控制操作后返回的页面状态形式:\n\n- **`diff`**(默认):仅返回自上一次状态以来的增量 DOM 差异,极大节省 Token。\n- **`full`**:返回当前视口中完整的语义化 ARIA YAML 树。\n- **`both`**:同时返回全量树和增量差异。\n\n执行 `click`、`fill`、`select`、`scroll` 操作后,工具默认自动以 `diff` 模式返回最新页面状态,无需再次手动调用 `browserState`。`hover` 动作返回重建后的页面状态(含 `tooltips` 等结构化字段)。\n\n</responseMode>\n\n<browser_state_diff>\n\n在交互过程中,为了提高效率和减少上下文占用,工具会生成页面的增量差异(Diff)信息。\nDiff 格式示例如下:\n```diff\n- button #9: 产品文档\n+ button #9: 产品文档 (已点击)\n```\n或者,当页面结构发生改变时,会展示新增或移除的节点差异。\n\n### 页面状态获取四原则(重要,请严格遵守):\n\n> 与业界 AI 编辑器(Cursor / Windsurf)按需读取文件而非全量加载的理念完全一致——**先精准搜索,再按需拉取全量**,将发送给大模型的 token 降至最低。\n\n1. **按关键词精准搜索(最高优先级)**:当你已知要找什么类型的元素(如按钮、输入框、特定名称的链接)时,**优先使用 `searchTree` 动作**,传入 role 名称、元素文本或状态关键词搜索。它只返回命中行和上下文,token 消耗比全量树减少 80%+。\n - 示例:查找所有按钮 → `{"action": "searchTree", "query": "button"}`\n - 示例:查找含"提交"文本的节点 → `{"action": "searchTree", "query": "提交"}`\n - 示例:查找已勾选的复选框 → `{"action": "searchTree", "query": "checked"}`\n - 示例:精确定位某个 ref → `{"action": "searchTree", "query": "#5"}`\n2. **首次获取全量**:首次进入页面、页面发生重大刷新、或 `searchTree` 无法找到所需信息时,调用 `browserState` 并指定 `responseMode` 为 `full` 或 `both` 获取完整 A11y 树。\n3. **增量优先**:执行 `click`、`fill`、`select`、`scroll` 操作后,工具默认自动返回 `diff` 增量信息。优先阅读这些 Diff,以便快速确认操作是否生效。\n4. **按需拉取全量**:如果增量 Diff 不足以支持下一步操作,或需要寻找不在 Diff 中的 `#N` 节点,且 `searchTree` 也无法定位时,再显式调用 `browserState` 拉取完整树。\n\n</browser_state_diff>\n\n\n\n<browser_rules>\n在使用浏览器和浏览网页时严格遵守以下规则:\n\n- 仅与分配有 `#N` 索引的元素进行交互,将 N 作为 `index` 参数传入。\n- 仅使用明确出现在树中的 `#N` 索引,切勿猜测或沿用过期索引。\n- 每次操作后 `#N` 索引会重新分配,不要使用旧的索引。\n- 如果页面在执行操作后发生变化(例如输入文本操作),分析是否需要与新元素进行交互,例如从列表中选择正确的选项。\n- 默认情况下,仅列出可见视口中的元素。如果你怀疑需要交互的相关内容在屏幕外,请使用滚动操作。仅在页面下方或上方还有更多像素时才滚动。\n- 你可以使用 num_pages 参数滚动特定页数(例如,0.5 表示半页,2.0 表示两页)。\n- 如果出现验证码,告诉用户你无法解决验证码。完成任务并请用户解决它。\n- 如果缺少预期元素,尝试滚动或导航回退。\n- 除非某些条件发生变化,否则不要重复同一操作超过 3 次。\n- 如果你向输入字段填充文本且操作序列被中断,通常意味着某些内容发生了变化,例如下拉建议弹出。\n- 如果 <user_request> 包含特定的页面信息,如产品类型、评分、价格、位置等,尝试应用过滤器以提高效率。\n- <user_request> 是最终目标。如果用户指定了明确的步骤,它们始终具有最高优先级。\n- 如果你向字段输入文本,可能需要按回车键、点击搜索按钮或从下拉列表中选择以完成操作。\n- 对于带有 `[tooltip="..."]` token 的元素,可以直接阅读提示文本。对于标记为 `tooltip [hasPopup]` 的元素(如帮助提示图标),tooltip 文本需 hover 才会动态出现——**使用 `hover` 动作并传入元素索引即可触发并获取 tooltip 内容**。hover 返回浮层提示文本 + 重建后的完整页面状态,`#N` 索引会更新,可继续操作新出现的交互元素。\n- **对 tooltip 触发元素优先使用 `hover` 而非 `click`**:click 可能触发标签页切换或 DOM 重建导致 ref 索引失效,而 hover 只触发 pointer/mouse 事件,安全且返回 tooltip 内容。\n- **不要通过 executeJavascript 向页面插入 DOM 元素**(如创建 div 显示调试信息)。这会污染页面结构并影响后续操作。如需读取数据,使用 return 语句返回结果即可。\n- 如果操作返回中出现 `[校验提示]`,说明页面有表单校验错误未通过,请先根据提示修复错误后再继续操作。\n- 如果操作后页面没有发生预期变化,优先检查是否有 `[校验提示]` 或 `[error]` token 的错误信息,而非重复操作。\n- 如果不需要,不要登录页面。如果没有凭据,不要登录。\n- 有两种类型的任务,首先思考你正在处理哪种类型的请求:\n\n1. 非常具体的逐步说明:\n\n- 非常精确地遵循它们,不要跳过步骤。尝试按要求完成所有内容。\n\n2. 开放式任务。自己规划,在实现目标时保持创造性。\n\n- 如果在开放式任务中陷入困境(例如登录或验证码),可以重新评估任务并尝试替代方法,例如有时即使页面的某些部分可访问或通过 Web 搜索获取一些信息,也会意外弹出登录框。\n </browser_rules>\n\n<capability>\n- 你只能处理单页应用。不要跳出当前页面。\n- 如果链接将在新页面中打开(例如,<a target="_blank">),不要点击该链接。\n- 任务失败是可以接受的。\n - 用户可能是错的。如果用户的请求无法实现、不适当,或者你没有足够的信息或工具来实现它。告诉用户提出更好的请求。\n - 网页可能已损坏。所有网页或应用都有 bug。有些 bug 会使你的工作变得困难。鼓励你告诉用户当前页面的问题。你的反馈(包括失败)对用户很有价值。\n - 过于努力可能有害。来回重复某些操作或在知识有限的情况下推动复杂程序可能导致不良结果和有害副作用。用户宁愿你以失败告终完成任务。\n- 如果你对当前网页或任务没有相关知识。你必须要求用户提供具体说明和详细步骤。\n</capability>\n\n<task_completion_rules>\n你必须在以下情况时结束任务:\n\n- 当你完全完成用户请求时。\n- 当你感到困惑或无法解决用户请求时。或者用户请求不清楚或包含不当内容。\n- 如果绝对不可能继续。\n\n</task_completion_rules>\n';
2048
1909
  function isHTMLElement(t) {
2049
1910
  return !!t && t.nodeType === 1;
2050
1911
  }
@@ -2114,28 +1975,28 @@ async function clickElement(t) {
2114
1975
  await movePointerToElement(t, i, r), await clickPointer(), await waitFor(0.1);
2115
1976
  const o = t.ownerDocument;
2116
1977
  await enablePassThrough();
2117
- const a = o.elementFromPoint(i, r);
1978
+ const s = o.elementFromPoint(i, r);
2118
1979
  await disablePassThrough();
2119
- const l = a instanceof HTMLElement && t.contains(a) ? a : t, c = {
1980
+ const a = s instanceof HTMLElement && t.contains(s) ? s : t, c = {
2120
1981
  bubbles: !0,
2121
1982
  cancelable: !0,
2122
1983
  clientX: i,
2123
1984
  clientY: r,
2124
1985
  pointerType: "mouse"
2125
- }, u = {
1986
+ }, d = {
2126
1987
  bubbles: !0,
2127
1988
  cancelable: !0,
2128
1989
  clientX: i,
2129
1990
  clientY: r,
2130
1991
  button: 0
2131
1992
  };
2132
- l.dispatchEvent(new PointerEvent("pointerover", c)), l.dispatchEvent(new PointerEvent("pointerenter", {
1993
+ a.dispatchEvent(new PointerEvent("pointerover", c)), a.dispatchEvent(new PointerEvent("pointerenter", {
2133
1994
  ...c,
2134
1995
  bubbles: !1
2135
- })), l.dispatchEvent(new MouseEvent("mouseover", u)), l.dispatchEvent(new MouseEvent("mouseenter", {
2136
- ...u,
1996
+ })), a.dispatchEvent(new MouseEvent("mouseover", d)), a.dispatchEvent(new MouseEvent("mouseenter", {
1997
+ ...d,
2137
1998
  bubbles: !1
2138
- })), l.dispatchEvent(new PointerEvent("pointerdown", c)), l.dispatchEvent(new MouseEvent("mousedown", u)), t.focus({ preventScroll: !0 }), l.dispatchEvent(new PointerEvent("pointerup", c)), l.dispatchEvent(new MouseEvent("mouseup", u)), l.click(), await waitFor(0.2);
1999
+ })), a.dispatchEvent(new PointerEvent("pointerdown", c)), a.dispatchEvent(new MouseEvent("mousedown", d)), t.focus({ preventScroll: !0 }), a.dispatchEvent(new PointerEvent("pointerup", c)), a.dispatchEvent(new MouseEvent("mouseup", d)), a.click(), await waitFor(0.2);
2139
2000
  }
2140
2001
  async function inputTextElement(t, e) {
2141
2002
  const n = t.isContentEditable;
@@ -2182,94 +2043,94 @@ async function scrollIntoViewIfNeeded(t) {
2182
2043
  }
2183
2044
  async function scrollVertically(t, e) {
2184
2045
  if (e) {
2185
- const a = e;
2186
- let l = a, c = !1, u = null, d = 0, p = 0;
2187
- const f = t;
2188
- for (; l && p < 10; ) {
2189
- const m = window.getComputedStyle(l), g = /(auto|scroll|overlay)/.test(m.overflowY) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", S = l.scrollHeight > l.clientHeight;
2190
- if (g && S) {
2191
- const E = l.scrollTop, h = l.scrollHeight - l.clientHeight;
2192
- let x = f / 3;
2193
- x > 0 ? x = Math.min(x, h - E) : x = Math.max(x, -E), l.scrollTop = E + x;
2194
- const T = l.scrollTop - E;
2046
+ const s = e;
2047
+ let a = s, c = !1, d = null, u = 0, h = 0;
2048
+ const p = t;
2049
+ for (; a && h < 10; ) {
2050
+ const m = window.getComputedStyle(a), g = /(auto|scroll|overlay)/.test(m.overflowY) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", E = a.scrollHeight > a.clientHeight;
2051
+ if (g && E) {
2052
+ const L = a.scrollTop, f = a.scrollHeight - a.clientHeight;
2053
+ let b = p / 3;
2054
+ b > 0 ? b = Math.min(b, f - L) : b = Math.max(b, -L), a.scrollTop = L + b;
2055
+ const T = a.scrollTop - L;
2195
2056
  if (Math.abs(T) > 0.5) {
2196
- c = !0, u = l, d = T;
2057
+ c = !0, d = a, u = T;
2197
2058
  break;
2198
2059
  }
2199
2060
  }
2200
- if (l === document.body || l === document.documentElement) break;
2201
- l = l.parentElement, p++;
2061
+ if (a === document.body || a === document.documentElement) break;
2062
+ a = a.parentElement, h++;
2202
2063
  }
2203
- return c ? `Scrolled container (${u?.tagName}) by ${d}px` : `No scrollable container found for element (${a.tagName})`;
2064
+ return c ? `Scrolled container (${d?.tagName}) by ${u}px` : `No scrollable container found for element (${s.tagName})`;
2204
2065
  }
2205
- const n = t, i = (a) => a.clientHeight >= window.innerHeight * 0.5, r = (a) => !!(a && /(auto|scroll|overlay)/.test(getComputedStyle(a).overflowY) && a.scrollHeight > a.clientHeight && i(a));
2066
+ const n = t, i = (s) => s.clientHeight >= window.innerHeight * 0.5, r = (s) => !!(s && /(auto|scroll|overlay)/.test(getComputedStyle(s).overflowY) && s.scrollHeight > s.clientHeight && i(s));
2206
2067
  let o = document.activeElement;
2207
2068
  for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
2208
2069
  if (o = r(o) ? o : Array.from(document.querySelectorAll("*")).find(r) || document.scrollingElement || document.documentElement, o === document.scrollingElement || o === document.documentElement || o === document.body) {
2209
- const a = window.scrollY, l = document.documentElement.scrollHeight - window.innerHeight;
2070
+ const s = window.scrollY, a = document.documentElement.scrollHeight - window.innerHeight;
2210
2071
  window.scrollBy(0, n);
2211
- const c = window.scrollY, u = c - a;
2212
- if (Math.abs(u) < 1) return n > 0 ? "⚠️ Already at the bottom of the page, cannot scroll down further." : "⚠️ Already at the top of the page, cannot scroll up further.";
2213
- const d = n > 0 && c >= l - 1, p = n < 0 && c <= 1;
2214
- return d ? `✅ Scrolled page by ${u}px. Reached the bottom of the page.` : p ? `✅ Scrolled page by ${u}px. Reached the top of the page.` : `✅ Scrolled page by ${u}px.`;
2072
+ const c = window.scrollY, d = c - s;
2073
+ if (Math.abs(d) < 1) return n > 0 ? "⚠️ Already at the bottom of the page, cannot scroll down further." : "⚠️ Already at the top of the page, cannot scroll up further.";
2074
+ const u = n > 0 && c >= a - 1, h = n < 0 && c <= 1;
2075
+ return u ? `✅ Scrolled page by ${d}px. Reached the bottom of the page.` : h ? `✅ Scrolled page by ${d}px. Reached the top of the page.` : `✅ Scrolled page by ${d}px.`;
2215
2076
  } else {
2216
- const a = "The document is not scrollable. Falling back to container scroll.";
2217
- console.log(`[PageController] ${a}`);
2218
- const l = o.scrollTop, c = o.scrollHeight - o.clientHeight;
2077
+ const s = "The document is not scrollable. Falling back to container scroll.";
2078
+ console.log(`[PageController] ${s}`);
2079
+ const a = o.scrollTop, c = o.scrollHeight - o.clientHeight;
2219
2080
  o.scrollBy({
2220
2081
  top: n,
2221
2082
  behavior: "smooth"
2222
2083
  }), await waitFor(0.1);
2223
- const u = o.scrollTop, d = u - l;
2224
- if (Math.abs(d) < 1) return n > 0 ? `⚠️ ${a} Already at the bottom of container (${o.tagName}), cannot scroll down further.` : `⚠️ ${a} Already at the top of container (${o.tagName}), cannot scroll up further.`;
2225
- const p = n > 0 && u >= c - 1, f = n < 0 && u <= 1;
2226
- return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the bottom.` : f ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the top.` : `✅ ${a} Scrolled container (${o.tagName}) by ${d}px.`;
2084
+ const d = o.scrollTop, u = d - a;
2085
+ if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${s} Already at the bottom of container (${o.tagName}), cannot scroll down further.` : `⚠️ ${s} Already at the top of container (${o.tagName}), cannot scroll up further.`;
2086
+ const h = n > 0 && d >= c - 1, p = n < 0 && d <= 1;
2087
+ return h ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the bottom.` : p ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the top.` : `✅ ${s} Scrolled container (${o.tagName}) by ${u}px.`;
2227
2088
  }
2228
2089
  }
2229
2090
  async function scrollHorizontally(t, e) {
2230
2091
  if (e) {
2231
- const a = e;
2232
- let l = a, c = !1, u = null, d = 0, p = 0;
2233
- const f = t;
2234
- for (; l && p < 10; ) {
2235
- const m = window.getComputedStyle(l), g = /(auto|scroll|overlay)/.test(m.overflowX) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", S = l.scrollWidth > l.clientWidth;
2236
- if (g && S) {
2237
- const E = l.scrollLeft, h = l.scrollWidth - l.clientWidth;
2238
- let x = f / 3;
2239
- x > 0 ? x = Math.min(x, h - E) : x = Math.max(x, -E), l.scrollLeft = E + x;
2240
- const T = l.scrollLeft - E;
2092
+ const s = e;
2093
+ let a = s, c = !1, d = null, u = 0, h = 0;
2094
+ const p = t;
2095
+ for (; a && h < 10; ) {
2096
+ const m = window.getComputedStyle(a), g = /(auto|scroll|overlay)/.test(m.overflowX) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", E = a.scrollWidth > a.clientWidth;
2097
+ if (g && E) {
2098
+ const L = a.scrollLeft, f = a.scrollWidth - a.clientWidth;
2099
+ let b = p / 3;
2100
+ b > 0 ? b = Math.min(b, f - L) : b = Math.max(b, -L), a.scrollLeft = L + b;
2101
+ const T = a.scrollLeft - L;
2241
2102
  if (Math.abs(T) > 0.5) {
2242
- c = !0, u = l, d = T;
2103
+ c = !0, d = a, u = T;
2243
2104
  break;
2244
2105
  }
2245
2106
  }
2246
- if (l === document.body || l === document.documentElement) break;
2247
- l = l.parentElement, p++;
2107
+ if (a === document.body || a === document.documentElement) break;
2108
+ a = a.parentElement, h++;
2248
2109
  }
2249
- return c ? `Scrolled container (${u?.tagName}) horizontally by ${d}px` : `No horizontally scrollable container found for element (${a.tagName})`;
2110
+ return c ? `Scrolled container (${d?.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${s.tagName})`;
2250
2111
  }
2251
- const n = t, i = (a) => a.clientWidth >= window.innerWidth * 0.5, r = (a) => !!(a && /(auto|scroll|overlay)/.test(getComputedStyle(a).overflowX) && a.scrollWidth > a.clientWidth && i(a));
2112
+ const n = t, i = (s) => s.clientWidth >= window.innerWidth * 0.5, r = (s) => !!(s && /(auto|scroll|overlay)/.test(getComputedStyle(s).overflowX) && s.scrollWidth > s.clientWidth && i(s));
2252
2113
  let o = document.activeElement;
2253
2114
  for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
2254
2115
  if (o = r(o) ? o : Array.from(document.querySelectorAll("*")).find(r) || document.scrollingElement || document.documentElement, o === document.scrollingElement || o === document.documentElement || o === document.body) {
2255
- const a = window.scrollX, l = document.documentElement.scrollWidth - window.innerWidth;
2116
+ const s = window.scrollX, a = document.documentElement.scrollWidth - window.innerWidth;
2256
2117
  window.scrollBy(n, 0);
2257
- const c = window.scrollX, u = c - a;
2258
- if (Math.abs(u) < 1) return n > 0 ? "⚠️ Already at the right edge of the page, cannot scroll right further." : "⚠️ Already at the left edge of the page, cannot scroll left further.";
2259
- const d = n > 0 && c >= l - 1, p = n < 0 && c <= 1;
2260
- return d ? `✅ Scrolled page by ${u}px. Reached the right edge of the page.` : p ? `✅ Scrolled page by ${u}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${u}px.`;
2118
+ const c = window.scrollX, d = c - s;
2119
+ if (Math.abs(d) < 1) return n > 0 ? "⚠️ Already at the right edge of the page, cannot scroll right further." : "⚠️ Already at the left edge of the page, cannot scroll left further.";
2120
+ const u = n > 0 && c >= a - 1, h = n < 0 && c <= 1;
2121
+ return u ? `✅ Scrolled page by ${d}px. Reached the right edge of the page.` : h ? `✅ Scrolled page by ${d}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${d}px.`;
2261
2122
  } else {
2262
- const a = "The document is not scrollable. Falling back to container scroll.";
2263
- console.log(`[PageController] ${a}`);
2264
- const l = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
2123
+ const s = "The document is not scrollable. Falling back to container scroll.";
2124
+ console.log(`[PageController] ${s}`);
2125
+ const a = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
2265
2126
  o.scrollBy({
2266
2127
  left: n,
2267
2128
  behavior: "smooth"
2268
2129
  }), await waitFor(0.1);
2269
- const u = o.scrollLeft, d = u - l;
2270
- if (Math.abs(d) < 1) return n > 0 ? `⚠️ ${a} Already at the right edge of container (${o.tagName}), cannot scroll right further.` : `⚠️ ${a} Already at the left edge of container (${o.tagName}), cannot scroll left further.`;
2271
- const p = n > 0 && u >= c - 1, f = n < 0 && u <= 1;
2272
- return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the right edge.` : f ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the left edge.` : `✅ ${a} Scrolled container (${o.tagName}) horizontally by ${d}px.`;
2130
+ const d = o.scrollLeft, u = d - a;
2131
+ if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${s} Already at the right edge of container (${o.tagName}), cannot scroll right further.` : `⚠️ ${s} Already at the left edge of container (${o.tagName}), cannot scroll left further.`;
2132
+ const h = n > 0 && d >= c - 1, p = n < 0 && d <= 1;
2133
+ return h ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the right edge.` : p ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the left edge.` : `✅ ${s} Scrolled container (${o.tagName}) horizontally by ${u}px.`;
2273
2134
  }
2274
2135
  }
2275
2136
  var dom_tree_default = (t = {
@@ -2287,51 +2148,51 @@ var dom_tree_default = (t = {
2287
2148
  highlightOpacity: 0.1,
2288
2149
  highlightLabelOpacity: 0.5
2289
2150
  }) => {
2290
- const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: a, viewportExpansion: l, debugMode: c } = t;
2291
- let u = 0;
2292
- const d = /* @__PURE__ */ new WeakMap();
2293
- function p(s, b) {
2294
- !s || s.nodeType !== Node.ELEMENT_NODE || d.set(s, {
2295
- ...d.get(s),
2296
- ...b
2151
+ const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: s, viewportExpansion: a, debugMode: c } = t;
2152
+ let d = 0;
2153
+ const u = /* @__PURE__ */ new WeakMap();
2154
+ function h(l, w) {
2155
+ !l || l.nodeType !== Node.ELEMENT_NODE || u.set(l, {
2156
+ ...u.get(l),
2157
+ ...w
2297
2158
  });
2298
2159
  }
2299
- const f = {
2160
+ const p = {
2300
2161
  boundingRects: /* @__PURE__ */ new WeakMap(),
2301
2162
  clientRects: /* @__PURE__ */ new WeakMap(),
2302
2163
  computedStyles: /* @__PURE__ */ new WeakMap(),
2303
2164
  clearCache: () => {
2304
- f.boundingRects = /* @__PURE__ */ new WeakMap(), f.clientRects = /* @__PURE__ */ new WeakMap(), f.computedStyles = /* @__PURE__ */ new WeakMap();
2165
+ p.boundingRects = /* @__PURE__ */ new WeakMap(), p.clientRects = /* @__PURE__ */ new WeakMap(), p.computedStyles = /* @__PURE__ */ new WeakMap();
2305
2166
  }
2306
2167
  };
2307
- function m(s) {
2308
- if (!s) return null;
2309
- if (f.boundingRects.has(s)) return f.boundingRects.get(s);
2310
- const b = s.getBoundingClientRect();
2311
- return b && f.boundingRects.set(s, b), b;
2312
- }
2313
- function g(s) {
2314
- if (!s) return null;
2315
- if (f.computedStyles.has(s)) return f.computedStyles.get(s);
2316
- const b = window.getComputedStyle(s);
2317
- return b && f.computedStyles.set(s, b), b;
2318
- }
2319
- function S(s) {
2320
- if (!s) return null;
2321
- if (f.clientRects.has(s)) return f.clientRects.get(s);
2322
- const b = s.getClientRects();
2323
- return b && f.clientRects.set(s, b), b;
2324
- }
2325
- const E = {}, h = { current: 0 }, x = "playwright-highlight-container";
2326
- function T(s, b, I = null) {
2327
- if (!s) return b;
2328
- const w = [];
2329
- let _ = null, F = 20, C = 16, P = null;
2168
+ function m(l) {
2169
+ if (!l) return null;
2170
+ if (p.boundingRects.has(l)) return p.boundingRects.get(l);
2171
+ const w = l.getBoundingClientRect();
2172
+ return w && p.boundingRects.set(l, w), w;
2173
+ }
2174
+ function g(l) {
2175
+ if (!l) return null;
2176
+ if (p.computedStyles.has(l)) return p.computedStyles.get(l);
2177
+ const w = window.getComputedStyle(l);
2178
+ return w && p.computedStyles.set(l, w), w;
2179
+ }
2180
+ function E(l) {
2181
+ if (!l) return null;
2182
+ if (p.clientRects.has(l)) return p.clientRects.get(l);
2183
+ const w = l.getClientRects();
2184
+ return w && p.clientRects.set(l, w), w;
2185
+ }
2186
+ const L = {}, f = { current: 0 }, b = "playwright-highlight-container";
2187
+ function T(l, w, M = null) {
2188
+ if (!l) return w;
2189
+ const v = [];
2190
+ let _ = null, O = 20, x = 16, N = null;
2330
2191
  try {
2331
- let k = document.getElementById(x);
2332
- k || (k = document.createElement("div"), k.id = x, k.style.position = "fixed", k.style.pointerEvents = "none", k.style.top = "0", k.style.left = "0", k.style.width = "100%", k.style.height = "100%", k.style.zIndex = "2147483640", k.style.backgroundColor = "transparent", document.body.appendChild(k));
2333
- const D = s.getClientRects();
2334
- if (!D || D.length === 0) return b;
2192
+ let k = document.getElementById(b);
2193
+ k || (k = document.createElement("div"), k.id = b, k.style.position = "fixed", k.style.pointerEvents = "none", k.style.top = "0", k.style.left = "0", k.style.width = "100%", k.style.height = "100%", k.style.zIndex = "2147483640", k.style.backgroundColor = "transparent", document.body.appendChild(k));
2194
+ const I = l.getClientRects();
2195
+ if (!I || I.length === 0) return w;
2335
2196
  const Y = [
2336
2197
  "#FF0000",
2337
2198
  "#00FF00",
@@ -2346,133 +2207,133 @@ var dom_tree_default = (t = {
2346
2207
  "#DC143C",
2347
2208
  "#4682B4"
2348
2209
  ];
2349
- let Z = Y[b % Y.length];
2350
- const X = Z + Math.floor(i * 255).toString(16).padStart(2, "0");
2351
- Z = Z + Math.floor(r * 255).toString(16).padStart(2, "0");
2210
+ let V = Y[w % Y.length];
2211
+ const K = V + Math.floor(i * 255).toString(16).padStart(2, "0");
2212
+ V = V + Math.floor(r * 255).toString(16).padStart(2, "0");
2352
2213
  let j = {
2353
2214
  x: 0,
2354
2215
  y: 0
2355
2216
  };
2356
- if (I) {
2357
- const H = I.getBoundingClientRect();
2217
+ if (M) {
2218
+ const H = M.getBoundingClientRect();
2358
2219
  j.x = H.left, j.y = H.top;
2359
2220
  }
2360
- const ae = document.createDocumentFragment();
2361
- for (const H of D) {
2221
+ const se = document.createDocumentFragment();
2222
+ for (const H of I) {
2362
2223
  if (H.width === 0 || H.height === 0) continue;
2363
2224
  const U = document.createElement("div");
2364
- U.style.position = "fixed", U.style.border = `2px solid ${Z}`, U.style.backgroundColor = X, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
2365
- const O = H.top + j.y, Q = H.left + j.x;
2366
- U.style.top = `${O}px`, U.style.left = `${Q}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, ae.appendChild(U), w.push({
2225
+ U.style.position = "fixed", U.style.border = `2px solid ${V}`, U.style.backgroundColor = K, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
2226
+ const $ = H.top + j.y, X = H.left + j.x;
2227
+ U.style.top = `${$}px`, U.style.left = `${X}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, se.appendChild(U), v.push({
2367
2228
  element: U,
2368
2229
  initialRect: H
2369
2230
  });
2370
2231
  }
2371
- const ie = D[0];
2372
- _ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background = Z, _.style.color = "white", _.style.padding = "1px 4px", _.style.borderRadius = "4px", _.style.fontSize = `${Math.min(12, Math.max(8, ie.height / 2))}px`, _.textContent = b.toString(), F = _.offsetWidth > 0 ? _.offsetWidth : F, C = _.offsetHeight > 0 ? _.offsetHeight : C;
2232
+ const ie = I[0];
2233
+ _ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background = V, _.style.color = "white", _.style.padding = "1px 4px", _.style.borderRadius = "4px", _.style.fontSize = `${Math.min(12, Math.max(8, ie.height / 2))}px`, _.textContent = w.toString(), O = _.offsetWidth > 0 ? _.offsetWidth : O, x = _.offsetHeight > 0 ? _.offsetHeight : x;
2373
2234
  const de = ie.top + j.y, ue = ie.left + j.x;
2374
- let se = de + 2, re = ue + ie.width - F - 2;
2375
- (ie.width < F + 4 || ie.height < C + 4) && (se = de - C - 2, re = ue + ie.width - F, re < j.x && (re = ue)), se = Math.max(0, Math.min(se, window.innerHeight - C)), re = Math.max(0, Math.min(re, window.innerWidth - F)), _.style.top = `${se}px`, _.style.left = `${re}px`, ae.appendChild(_);
2235
+ let ae = de + 2, re = ue + ie.width - O - 2;
2236
+ (ie.width < O + 4 || ie.height < x + 4) && (ae = de - x - 2, re = ue + ie.width - O, re < j.x && (re = ue)), ae = Math.max(0, Math.min(ae, window.innerHeight - x)), re = Math.max(0, Math.min(re, window.innerWidth - O)), _.style.top = `${ae}px`, _.style.left = `${re}px`, se.appendChild(_);
2376
2237
  const le = ((H, U) => {
2377
- let O = 0;
2378
- return (...Q) => {
2238
+ let $ = 0;
2239
+ return (...X) => {
2379
2240
  const q = performance.now();
2380
- if (!(q - O < U))
2381
- return O = q, H(...Q);
2241
+ if (!(q - $ < U))
2242
+ return $ = q, H(...X);
2382
2243
  };
2383
2244
  })(() => {
2384
- const H = s.getClientRects();
2245
+ const H = l.getClientRects();
2385
2246
  let U = {
2386
2247
  x: 0,
2387
2248
  y: 0
2388
2249
  };
2389
- if (I) {
2390
- const O = I.getBoundingClientRect();
2391
- U.x = O.left, U.y = O.top;
2250
+ if (M) {
2251
+ const $ = M.getBoundingClientRect();
2252
+ U.x = $.left, U.y = $.top;
2392
2253
  }
2393
- if (w.forEach((O, Q) => {
2394
- if (Q < H.length) {
2395
- const q = H[Q], oe = q.top + U.y, ne = q.left + U.x;
2396
- O.element.style.top = `${oe}px`, O.element.style.left = `${ne}px`, O.element.style.width = `${q.width}px`, O.element.style.height = `${q.height}px`, O.element.style.display = q.width === 0 || q.height === 0 ? "none" : "block";
2397
- } else O.element.style.display = "none";
2398
- }), H.length < w.length) for (let O = H.length; O < w.length; O++) w[O].element.style.display = "none";
2254
+ if (v.forEach(($, X) => {
2255
+ if (X < H.length) {
2256
+ const q = H[X], oe = q.top + U.y, ne = q.left + U.x;
2257
+ $.element.style.top = `${oe}px`, $.element.style.left = `${ne}px`, $.element.style.width = `${q.width}px`, $.element.style.height = `${q.height}px`, $.element.style.display = q.width === 0 || q.height === 0 ? "none" : "block";
2258
+ } else $.element.style.display = "none";
2259
+ }), H.length < v.length) for (let $ = H.length; $ < v.length; $++) v[$].element.style.display = "none";
2399
2260
  if (_ && H.length > 0) {
2400
- const O = H[0], Q = O.top + U.y, q = O.left + U.x;
2401
- let oe = Q + 2, ne = q + O.width - F - 2;
2402
- (O.width < F + 4 || O.height < C + 4) && (oe = Q - C - 2, ne = q + O.width - F, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - C)), ne = Math.max(0, Math.min(ne, window.innerWidth - F)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
2261
+ const $ = H[0], X = $.top + U.y, q = $.left + U.x;
2262
+ let oe = X + 2, ne = q + $.width - O - 2;
2263
+ ($.width < O + 4 || $.height < x + 4) && (oe = X - x - 2, ne = q + $.width - O, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - x)), ne = Math.max(0, Math.min(ne, window.innerWidth - O)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
2403
2264
  } else _ && (_.style.display = "none");
2404
2265
  }, 16);
2405
- return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), P = () => {
2406
- window.removeEventListener("scroll", le, !0), window.removeEventListener("resize", le), w.forEach((H) => H.element.remove()), _ && _.remove();
2407
- }, k.appendChild(ae), b + 1;
2266
+ return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), N = () => {
2267
+ window.removeEventListener("scroll", le, !0), window.removeEventListener("resize", le), v.forEach((H) => H.element.remove()), _ && _.remove();
2268
+ }, k.appendChild(se), w + 1;
2408
2269
  } finally {
2409
- P && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(P);
2270
+ N && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(N);
2410
2271
  }
2411
2272
  }
2412
- function L(s) {
2413
- if (!s || s.nodeType !== Node.ELEMENT_NODE) return null;
2414
- const b = g(s);
2415
- if (!b) return null;
2416
- const I = b.display;
2417
- if (I === "inline" || I === "inline-block") return null;
2418
- const w = b.overflowX, _ = b.overflowY, F = b.scrollbarWidth && b.scrollbarWidth !== "auto" || b.scrollbarGutter && b.scrollbarGutter !== "auto", C = w === "auto" || w === "scroll", P = _ === "auto" || _ === "scroll";
2419
- if (!C && !P && !F) return null;
2420
- const k = s.scrollWidth - s.clientWidth, D = s.scrollHeight - s.clientHeight, Y = 4;
2421
- if (k < Y && D < Y || !P && !F && k < Y || !C && !F && D < Y) return null;
2422
- const Z = s.scrollTop, X = s.scrollLeft, j = {
2423
- top: Z,
2424
- right: s.scrollWidth - s.clientWidth - s.scrollLeft,
2425
- bottom: s.scrollHeight - s.clientHeight - s.scrollTop,
2426
- left: X
2273
+ function y(l) {
2274
+ if (!l || l.nodeType !== Node.ELEMENT_NODE) return null;
2275
+ const w = g(l);
2276
+ if (!w) return null;
2277
+ const M = w.display;
2278
+ if (M === "inline" || M === "inline-block") return null;
2279
+ const v = w.overflowX, _ = w.overflowY, O = w.scrollbarWidth && w.scrollbarWidth !== "auto" || w.scrollbarGutter && w.scrollbarGutter !== "auto", x = v === "auto" || v === "scroll", N = _ === "auto" || _ === "scroll";
2280
+ if (!x && !N && !O) return null;
2281
+ const k = l.scrollWidth - l.clientWidth, I = l.scrollHeight - l.clientHeight, Y = 4;
2282
+ if (k < Y && I < Y || !N && !O && k < Y || !x && !O && I < Y) return null;
2283
+ const V = l.scrollTop, K = l.scrollLeft, j = {
2284
+ top: V,
2285
+ right: l.scrollWidth - l.clientWidth - l.scrollLeft,
2286
+ bottom: l.scrollHeight - l.clientHeight - l.scrollTop,
2287
+ left: K
2427
2288
  };
2428
- return p(s, {
2289
+ return h(l, {
2429
2290
  scrollable: !0,
2430
2291
  scrollData: j
2431
2292
  }), j;
2432
2293
  }
2433
- function A(s) {
2294
+ function C(l) {
2434
2295
  try {
2435
- if (l === -1) {
2436
- const C = s.parentElement;
2437
- if (!C) return !1;
2296
+ if (a === -1) {
2297
+ const x = l.parentElement;
2298
+ if (!x) return !1;
2438
2299
  try {
2439
- return C.checkVisibility({
2300
+ return x.checkVisibility({
2440
2301
  checkOpacity: !0,
2441
2302
  checkVisibilityCSS: !0
2442
2303
  });
2443
2304
  } catch {
2444
- const k = window.getComputedStyle(C);
2305
+ const k = window.getComputedStyle(x);
2445
2306
  return k.display !== "none" && k.visibility !== "hidden" && k.opacity !== "0";
2446
2307
  }
2447
2308
  }
2448
- const b = document.createRange();
2449
- b.selectNodeContents(s);
2450
- const I = b.getClientRects();
2451
- if (!I || I.length === 0) return !1;
2452
- let w = !1, _ = !1;
2453
- for (const C of I) if (C.width > 0 && C.height > 0 && (w = !0, !(C.bottom < -l || C.top > window.innerHeight + l || C.right < -l || C.left > window.innerWidth + l))) {
2309
+ const w = document.createRange();
2310
+ w.selectNodeContents(l);
2311
+ const M = w.getClientRects();
2312
+ if (!M || M.length === 0) return !1;
2313
+ let v = !1, _ = !1;
2314
+ for (const x of M) if (x.width > 0 && x.height > 0 && (v = !0, !(x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a))) {
2454
2315
  _ = !0;
2455
2316
  break;
2456
2317
  }
2457
- if (!w || !_) return !1;
2458
- const F = s.parentElement;
2459
- if (!F) return !1;
2318
+ if (!v || !_) return !1;
2319
+ const O = l.parentElement;
2320
+ if (!O) return !1;
2460
2321
  try {
2461
- return F.checkVisibility({
2322
+ return O.checkVisibility({
2462
2323
  checkOpacity: !0,
2463
2324
  checkVisibilityCSS: !0
2464
2325
  });
2465
2326
  } catch {
2466
- const P = window.getComputedStyle(F);
2467
- return P.display !== "none" && P.visibility !== "hidden" && P.opacity !== "0";
2327
+ const N = window.getComputedStyle(O);
2328
+ return N.display !== "none" && N.visibility !== "hidden" && N.opacity !== "0";
2468
2329
  }
2469
- } catch (b) {
2470
- return console.warn("Error checking text node visibility:", b), !1;
2330
+ } catch (w) {
2331
+ return console.warn("Error checking text node visibility:", w), !1;
2471
2332
  }
2472
2333
  }
2473
- function v(s) {
2474
- if (!s || !s.tagName) return !1;
2475
- const b = /* @__PURE__ */ new Set([
2334
+ function S(l) {
2335
+ if (!l || !l.tagName) return !1;
2336
+ const w = /* @__PURE__ */ new Set([
2476
2337
  "body",
2477
2338
  "div",
2478
2339
  "main",
@@ -2481,8 +2342,8 @@ var dom_tree_default = (t = {
2481
2342
  "nav",
2482
2343
  "header",
2483
2344
  "footer"
2484
- ]), I = s.tagName.toLowerCase();
2485
- return b.has(I) ? !0 : !(/* @__PURE__ */ new Set([
2345
+ ]), M = l.tagName.toLowerCase();
2346
+ return w.has(M) ? !0 : !(/* @__PURE__ */ new Set([
2486
2347
  "svg",
2487
2348
  "script",
2488
2349
  "style",
@@ -2490,16 +2351,16 @@ var dom_tree_default = (t = {
2490
2351
  "meta",
2491
2352
  "noscript",
2492
2353
  "template"
2493
- ])).has(I);
2354
+ ])).has(M);
2494
2355
  }
2495
- function y(s) {
2496
- const b = g(s);
2497
- return s.offsetWidth > 0 && s.offsetHeight > 0 && b?.visibility !== "hidden" && b?.display !== "none";
2356
+ function A(l) {
2357
+ const w = g(l);
2358
+ return l.offsetWidth > 0 && l.offsetHeight > 0 && w?.visibility !== "hidden" && w?.display !== "none";
2498
2359
  }
2499
- function M(s) {
2500
- if (!s || s.nodeType !== Node.ELEMENT_NODE || e.includes(s)) return !1;
2501
- if (n.includes(s)) return !0;
2502
- const b = s.tagName.toLowerCase(), I = g(s), w = /* @__PURE__ */ new Set([
2360
+ function D(l) {
2361
+ if (!l || l.nodeType !== Node.ELEMENT_NODE || e.includes(l)) return !1;
2362
+ if (n.includes(l)) return !0;
2363
+ const w = l.tagName.toLowerCase(), M = g(l), v = /* @__PURE__ */ new Set([
2503
2364
  "pointer",
2504
2365
  "move",
2505
2366
  "text",
@@ -2537,11 +2398,11 @@ var dom_tree_default = (t = {
2537
2398
  "initial",
2538
2399
  "inherit"
2539
2400
  ]);
2540
- function F(Z) {
2541
- return Z.tagName.toLowerCase() === "html" ? !1 : !!(I?.cursor && w.has(I.cursor));
2401
+ function O(V) {
2402
+ return V.tagName.toLowerCase() === "html" ? !1 : !!(M?.cursor && v.has(M.cursor));
2542
2403
  }
2543
- if (F(s)) return !0;
2544
- const C = /* @__PURE__ */ new Set([
2404
+ if (O(l)) return !0;
2405
+ const x = /* @__PURE__ */ new Set([
2545
2406
  "a",
2546
2407
  "button",
2547
2408
  "input",
@@ -2554,14 +2415,14 @@ var dom_tree_default = (t = {
2554
2415
  "optgroup",
2555
2416
  "fieldset",
2556
2417
  "legend"
2557
- ]), P = /* @__PURE__ */ new Set(["disabled", "readonly"]);
2558
- if (C.has(b)) {
2559
- if (I?.cursor && _.has(I.cursor)) return !1;
2560
- for (const Z of P) if (s.hasAttribute(Z) || s.getAttribute(Z) === "true" || s.getAttribute(Z) === "") return !1;
2561
- return !(s.disabled || s.readOnly || s.inert);
2418
+ ]), N = /* @__PURE__ */ new Set(["disabled", "readonly"]);
2419
+ if (x.has(w)) {
2420
+ if (M?.cursor && _.has(M.cursor)) return !1;
2421
+ for (const V of N) if (l.hasAttribute(V) || l.getAttribute(V) === "true" || l.getAttribute(V) === "") return !1;
2422
+ return !(l.disabled || l.readOnly || l.inert);
2562
2423
  }
2563
- const k = s.getAttribute("role"), D = s.getAttribute("aria-role");
2564
- if (s.getAttribute("contenteditable") === "true" || s.isContentEditable || s.classList && (s.classList.contains("button") || s.classList.contains("dropdown-toggle") || s.getAttribute("data-index") || s.getAttribute("data-toggle") === "dropdown" || s.getAttribute("aria-haspopup") === "true")) return !0;
2424
+ const k = l.getAttribute("role"), I = l.getAttribute("aria-role");
2425
+ if (l.getAttribute("contenteditable") === "true" || l.isContentEditable || l.classList && (l.classList.contains("button") || l.classList.contains("dropdown-toggle") || l.getAttribute("data-index") || l.getAttribute("data-toggle") === "dropdown" || l.getAttribute("aria-haspopup") === "true")) return !0;
2565
2426
  const Y = /* @__PURE__ */ new Set([
2566
2427
  "button",
2567
2428
  "menu",
@@ -2582,20 +2443,20 @@ var dom_tree_default = (t = {
2582
2443
  "option",
2583
2444
  "scrollbar"
2584
2445
  ]);
2585
- if (C.has(b) || k && Y.has(k) || D && Y.has(D)) return !0;
2446
+ if (x.has(w) || k && Y.has(k) || I && Y.has(I)) return !0;
2586
2447
  try {
2587
2448
  if (typeof getEventListeners == "function") {
2588
- const X = getEventListeners(s);
2449
+ const K = getEventListeners(l);
2589
2450
  for (const j of [
2590
2451
  "click",
2591
2452
  "mousedown",
2592
2453
  "mouseup",
2593
2454
  "dblclick"
2594
- ]) if (X[j] && X[j].length > 0) return !0;
2455
+ ]) if (K[j] && K[j].length > 0) return !0;
2595
2456
  }
2596
- const Z = s?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2597
- if (typeof Z == "function") {
2598
- const X = Z(s);
2457
+ const V = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2458
+ if (typeof V == "function") {
2459
+ const K = V(l);
2599
2460
  for (const j of [
2600
2461
  "click",
2601
2462
  "mousedown",
@@ -2607,69 +2468,69 @@ var dom_tree_default = (t = {
2607
2468
  "input",
2608
2469
  "focus",
2609
2470
  "blur"
2610
- ]) for (const ae of X) if (ae.type === j) return !0;
2471
+ ]) for (const se of K) if (se.type === j) return !0;
2611
2472
  }
2612
- for (const X of [
2473
+ for (const K of [
2613
2474
  "onclick",
2614
2475
  "onmousedown",
2615
2476
  "onmouseup",
2616
2477
  "ondblclick"
2617
- ]) if (s.hasAttribute(X) || typeof s[X] == "function") return !0;
2478
+ ]) if (l.hasAttribute(K) || typeof l[K] == "function") return !0;
2618
2479
  } catch {
2619
2480
  }
2620
- return !!L(s);
2621
- }
2622
- function R(s) {
2623
- if (l === -1) return !0;
2624
- const b = S(s);
2625
- if (!b || b.length === 0) return !1;
2626
- let I = !1;
2627
- for (const C of b) if (C.width > 0 && C.height > 0 && !(C.bottom < -l || C.top > window.innerHeight + l || C.right < -l || C.left > window.innerWidth + l)) {
2628
- I = !0;
2481
+ return !!y(l);
2482
+ }
2483
+ function P(l) {
2484
+ if (a === -1) return !0;
2485
+ const w = E(l);
2486
+ if (!w || w.length === 0) return !1;
2487
+ let M = !1;
2488
+ for (const x of w) if (x.width > 0 && x.height > 0 && !(x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a)) {
2489
+ M = !0;
2629
2490
  break;
2630
2491
  }
2631
- if (!I) return !1;
2632
- if (s.ownerDocument !== window.document) return !0;
2633
- let w = Array.from(b).find((C) => C.width > 0 && C.height > 0);
2634
- if (!w) return !1;
2635
- const _ = s.getRootNode();
2492
+ if (!M) return !1;
2493
+ if (l.ownerDocument !== window.document) return !0;
2494
+ let v = Array.from(w).find((x) => x.width > 0 && x.height > 0);
2495
+ if (!v) return !1;
2496
+ const _ = l.getRootNode();
2636
2497
  if (_ instanceof ShadowRoot) {
2637
- const C = w.left + w.width / 2, P = w.top + w.height / 2;
2498
+ const x = v.left + v.width / 2, N = v.top + v.height / 2;
2638
2499
  try {
2639
- const k = _.elementFromPoint(C, P);
2500
+ const k = _.elementFromPoint(x, N);
2640
2501
  if (!k) return !1;
2641
- let D = k;
2642
- for (; D && D !== _; ) {
2643
- if (D === s) return !0;
2644
- D = D.parentElement;
2502
+ let I = k;
2503
+ for (; I && I !== _; ) {
2504
+ if (I === l) return !0;
2505
+ I = I.parentElement;
2645
2506
  }
2646
2507
  return !1;
2647
2508
  } catch {
2648
2509
  return !0;
2649
2510
  }
2650
2511
  }
2651
- const F = 5;
2512
+ const O = 5;
2652
2513
  return [
2653
2514
  {
2654
- x: w.left + w.width / 2,
2655
- y: w.top + w.height / 2
2515
+ x: v.left + v.width / 2,
2516
+ y: v.top + v.height / 2
2656
2517
  },
2657
2518
  {
2658
- x: w.left + F,
2659
- y: w.top + F
2519
+ x: v.left + O,
2520
+ y: v.top + O
2660
2521
  },
2661
2522
  {
2662
- x: w.right - F,
2663
- y: w.bottom - F
2523
+ x: v.right - O,
2524
+ y: v.bottom - O
2664
2525
  }
2665
- ].some(({ x: C, y: P }) => {
2526
+ ].some(({ x, y: N }) => {
2666
2527
  try {
2667
- const k = document.elementFromPoint(C, P);
2528
+ const k = document.elementFromPoint(x, N);
2668
2529
  if (!k) return !1;
2669
- let D = k;
2670
- for (; D && D !== document.documentElement; ) {
2671
- if (D === s) return !0;
2672
- D = D.parentElement;
2530
+ let I = k;
2531
+ for (; I && I !== document.documentElement; ) {
2532
+ if (I === l) return !0;
2533
+ I = I.parentElement;
2673
2534
  }
2674
2535
  return !1;
2675
2536
  } catch {
@@ -2677,19 +2538,19 @@ var dom_tree_default = (t = {
2677
2538
  }
2678
2539
  });
2679
2540
  }
2680
- function N(s, b) {
2681
- if (b === -1) return !0;
2682
- const I = s.getClientRects();
2683
- if (!I || I.length === 0) {
2684
- const w = m(s);
2685
- return !w || w.width === 0 || w.height === 0 ? !1 : !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b);
2541
+ function R(l, w) {
2542
+ if (w === -1) return !0;
2543
+ const M = l.getClientRects();
2544
+ if (!M || M.length === 0) {
2545
+ const v = m(l);
2546
+ return !v || v.width === 0 || v.height === 0 ? !1 : !(v.bottom < -w || v.top > window.innerHeight + w || v.right < -w || v.left > window.innerWidth + w);
2686
2547
  }
2687
- for (const w of I)
2688
- if (!(w.width === 0 || w.height === 0) && !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b))
2548
+ for (const v of M)
2549
+ if (!(v.width === 0 || v.height === 0) && !(v.bottom < -w || v.top > window.innerHeight + w || v.right < -w || v.left > window.innerWidth + w))
2689
2550
  return !0;
2690
2551
  return !1;
2691
2552
  }
2692
- const $ = [
2553
+ const F = [
2693
2554
  "aria-expanded",
2694
2555
  "aria-checked",
2695
2556
  "aria-selected",
@@ -2704,13 +2565,13 @@ var dom_tree_default = (t = {
2704
2565
  "aria-valuemin",
2705
2566
  "aria-autocomplete"
2706
2567
  ];
2707
- function B(s) {
2708
- for (let b = 0; b < $.length; b++) if (s.hasAttribute($[b])) return !0;
2568
+ function B(l) {
2569
+ for (let w = 0; w < F.length; w++) if (l.hasAttribute(F[w])) return !0;
2709
2570
  return !1;
2710
2571
  }
2711
- function K(s) {
2712
- if (!s || s.nodeType !== Node.ELEMENT_NODE) return !1;
2713
- const b = s.tagName.toLowerCase();
2572
+ function J(l) {
2573
+ if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
2574
+ const w = l.tagName.toLowerCase();
2714
2575
  return (/* @__PURE__ */ new Set([
2715
2576
  "a",
2716
2577
  "button",
@@ -2720,9 +2581,9 @@ var dom_tree_default = (t = {
2720
2581
  "details",
2721
2582
  "summary",
2722
2583
  "label"
2723
- ])).has(b) ? !0 : s.hasAttribute("onclick") || s.hasAttribute("role") || s.hasAttribute("tabindex") || B(s) || s.hasAttribute("data-action") || s.getAttribute("contenteditable") === "true";
2584
+ ])).has(w) ? !0 : l.hasAttribute("onclick") || l.hasAttribute("role") || l.hasAttribute("tabindex") || B(l) || l.hasAttribute("data-action") || l.getAttribute("contenteditable") === "true";
2724
2585
  }
2725
- const W = /* @__PURE__ */ new Set([
2586
+ const G = /* @__PURE__ */ new Set([
2726
2587
  "a",
2727
2588
  "button",
2728
2589
  "input",
@@ -2733,7 +2594,7 @@ var dom_tree_default = (t = {
2733
2594
  "label",
2734
2595
  "option",
2735
2596
  "li"
2736
- ]), J = /* @__PURE__ */ new Set([
2597
+ ]), Q = /* @__PURE__ */ new Set([
2737
2598
  "button",
2738
2599
  "link",
2739
2600
  "menuitem",
@@ -2755,20 +2616,20 @@ var dom_tree_default = (t = {
2755
2616
  "option",
2756
2617
  "scrollbar"
2757
2618
  ]);
2758
- function ee(s) {
2759
- if (!s || s.nodeType !== Node.ELEMENT_NODE || !y(s)) return !1;
2760
- const b = s.hasAttribute("role") || s.hasAttribute("tabindex") || s.hasAttribute("onclick") || typeof s.onclick == "function", I = /\b(btn|clickable|menu|item|entry|link)\b/i.test(s.className || ""), w = !!s.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...s.children].some(y), F = s.parentElement && s.parentElement.isSameNode(document.body);
2761
- return (M(s) || b || I) && _ && w && !F;
2762
- }
2763
- function te(s) {
2764
- if (!s || s.nodeType !== Node.ELEMENT_NODE) return !1;
2765
- const b = s.tagName.toLowerCase(), I = s.getAttribute("role");
2766
- if (b === "iframe" || W.has(b) || I && J.has(I) || s.isContentEditable || s.getAttribute("contenteditable") === "true" || s.hasAttribute("data-testid") || s.hasAttribute("data-cy") || s.hasAttribute("data-test") || s.hasAttribute("onclick") || typeof s.onclick == "function" || B(s)) return !0;
2619
+ function ee(l) {
2620
+ if (!l || l.nodeType !== Node.ELEMENT_NODE || !A(l)) return !1;
2621
+ const w = l.hasAttribute("role") || l.hasAttribute("tabindex") || l.hasAttribute("onclick") || typeof l.onclick == "function", M = /\b(btn|clickable|menu|item|entry|link)\b/i.test(l.className || ""), v = !!l.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...l.children].some(A), O = l.parentElement && l.parentElement.isSameNode(document.body);
2622
+ return (D(l) || w || M) && _ && v && !O;
2623
+ }
2624
+ function te(l) {
2625
+ if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
2626
+ const w = l.tagName.toLowerCase(), M = l.getAttribute("role");
2627
+ if (w === "iframe" || G.has(w) || M && Q.has(M) || l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.hasAttribute("data-testid") || l.hasAttribute("data-cy") || l.hasAttribute("data-test") || l.hasAttribute("onclick") || typeof l.onclick == "function" || B(l)) return !0;
2767
2628
  try {
2768
- const w = s?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2769
- if (typeof w == "function") {
2770
- const _ = w(s);
2771
- for (const F of [
2629
+ const v = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2630
+ if (typeof v == "function") {
2631
+ const _ = v(l);
2632
+ for (const O of [
2772
2633
  "click",
2773
2634
  "mousedown",
2774
2635
  "mouseup",
@@ -2779,7 +2640,7 @@ var dom_tree_default = (t = {
2779
2640
  "input",
2780
2641
  "focus",
2781
2642
  "blur"
2782
- ]) for (const C of _) if (C.type === F) return !0;
2643
+ ]) for (const x of _) if (x.type === O) return !0;
2783
2644
  }
2784
2645
  if ([
2785
2646
  "onmousedown",
@@ -2791,119 +2652,119 @@ var dom_tree_default = (t = {
2791
2652
  "oninput",
2792
2653
  "onfocus",
2793
2654
  "onblur"
2794
- ].some((_) => s.hasAttribute(_))) return !0;
2655
+ ].some((_) => l.hasAttribute(_))) return !0;
2795
2656
  } catch {
2796
2657
  }
2797
- return !!(ee(s) || d.get(s)?.scrollable);
2658
+ return !!(ee(l) || u.get(l)?.scrollable);
2798
2659
  }
2799
- function G(s, b, I, w) {
2800
- if (!s.isInteractive) return !1;
2660
+ function W(l, w, M, v) {
2661
+ if (!l.isInteractive) return !1;
2801
2662
  let _ = !1;
2802
- return w ? te(b) ? _ = !0 : _ = !1 : _ = !0, _ && (s.isInViewport = N(b, l), (s.isInViewport || l === -1) && (s.highlightIndex = u++, o)) ? (a >= 0 ? a === s.highlightIndex && T(b, s.highlightIndex, I) : T(b, s.highlightIndex, I), !0) : !1;
2663
+ return v ? te(w) ? _ = !0 : _ = !1 : _ = !0, _ && (l.isInViewport = R(w, a), (l.isInViewport || a === -1) && (l.highlightIndex = d++, o)) ? (s >= 0 ? s === l.highlightIndex && T(w, l.highlightIndex, M) : T(w, l.highlightIndex, M), !0) : !1;
2803
2664
  }
2804
- function V(s, b = null, I = !1) {
2805
- if (!s || s.id === x || s.nodeType !== Node.ELEMENT_NODE && s.nodeType !== Node.TEXT_NODE || !s || s.id === x || s.dataset?.browserUseIgnore === "true" || s.dataset?.pageAgentIgnore === "true" || s.getAttribute && s.getAttribute("aria-hidden") === "true") return null;
2806
- if (s === document.body) {
2807
- const C = {
2665
+ function Z(l, w = null, M = !1) {
2666
+ if (!l || l.id === b || l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE || !l || l.id === b || l.dataset?.browserUseIgnore === "true" || l.dataset?.pageAgentIgnore === "true" || l.getAttribute && l.getAttribute("aria-hidden") === "true") return null;
2667
+ if (l === document.body) {
2668
+ const x = {
2808
2669
  tagName: "body",
2809
2670
  attributes: {},
2810
2671
  xpath: "/body",
2811
2672
  children: []
2812
2673
  };
2813
- for (const k of s.childNodes) {
2814
- const D = V(k, b, !1);
2815
- D && C.children.push(D);
2674
+ for (const k of l.childNodes) {
2675
+ const I = Z(k, w, !1);
2676
+ I && x.children.push(I);
2816
2677
  }
2817
- const P = `${h.current++}`;
2818
- return E[P] = C, P;
2678
+ const N = `${f.current++}`;
2679
+ return L[N] = x, N;
2819
2680
  }
2820
- if (s.nodeType !== Node.ELEMENT_NODE && s.nodeType !== Node.TEXT_NODE) return null;
2821
- if (s.nodeType === Node.TEXT_NODE) {
2822
- const C = s.textContent?.trim();
2823
- if (!C) return null;
2824
- const P = s.parentElement;
2825
- if (!P || P.tagName.toLowerCase() === "script") return null;
2826
- const k = `${h.current++}`;
2827
- return E[k] = {
2681
+ if (l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE) return null;
2682
+ if (l.nodeType === Node.TEXT_NODE) {
2683
+ const x = l.textContent?.trim();
2684
+ if (!x) return null;
2685
+ const N = l.parentElement;
2686
+ if (!N || N.tagName.toLowerCase() === "script") return null;
2687
+ const k = `${f.current++}`;
2688
+ return L[k] = {
2828
2689
  type: "TEXT_NODE",
2829
- text: C,
2830
- isVisible: A(s)
2690
+ text: x,
2691
+ isVisible: C(l)
2831
2692
  }, k;
2832
2693
  }
2833
- if (s.nodeType === Node.ELEMENT_NODE && !v(s)) return null;
2834
- if (l !== -1 && !s.shadowRoot) {
2835
- const C = m(s), P = g(s), k = P && (P.position === "fixed" || P.position === "sticky"), D = s.offsetWidth > 0 || s.offsetHeight > 0;
2836
- if (!C || !k && !D && (C.bottom < -l || C.top > window.innerHeight + l || C.right < -l || C.left > window.innerWidth + l)) return null;
2694
+ if (l.nodeType === Node.ELEMENT_NODE && !S(l)) return null;
2695
+ if (a !== -1 && !l.shadowRoot) {
2696
+ const x = m(l), N = g(l), k = N && (N.position === "fixed" || N.position === "sticky"), I = l.offsetWidth > 0 || l.offsetHeight > 0;
2697
+ if (!x || !k && !I && (x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a)) return null;
2837
2698
  }
2838
- const w = {
2839
- tagName: s.tagName.toLowerCase(),
2699
+ const v = {
2700
+ tagName: l.tagName.toLowerCase(),
2840
2701
  attributes: {},
2841
2702
  /**
2842
2703
  * @edit no need for xpath
2843
2704
  */
2844
2705
  children: []
2845
2706
  };
2846
- if (K(s) || s.tagName.toLowerCase() === "iframe" || s.tagName.toLowerCase() === "body") {
2847
- const C = s.getAttributeNames?.() || [];
2848
- for (const P of C) {
2849
- const k = s.getAttribute(P);
2850
- w.attributes[P] = k;
2707
+ if (J(l) || l.tagName.toLowerCase() === "iframe" || l.tagName.toLowerCase() === "body") {
2708
+ const x = l.getAttributeNames?.() || [];
2709
+ for (const N of x) {
2710
+ const k = l.getAttribute(N);
2711
+ v.attributes[N] = k;
2851
2712
  }
2852
- s.tagName.toLowerCase() === "input" && (s.type === "checkbox" || s.type === "radio") && (w.attributes.checked = s.checked ? "true" : "false");
2713
+ l.tagName.toLowerCase() === "input" && (l.type === "checkbox" || l.type === "radio") && (v.attributes.checked = l.checked ? "true" : "false");
2853
2714
  }
2854
2715
  let _ = !1;
2855
- if (s.nodeType === Node.ELEMENT_NODE && (w.isVisible = y(s), w.isVisible)) {
2856
- w.isTopElement = R(s);
2857
- const C = s.getAttribute("role"), P = C === "menu" || C === "menubar" || C === "listbox";
2858
- if ((w.isTopElement || P) && (w.isInteractive = M(s), _ = G(w, s, b, I), w.ref = s, w.isInteractive && Object.keys(w.attributes).length === 0)) {
2859
- const k = s.getAttributeNames?.() || [];
2860
- for (const D of k) {
2861
- const Y = s.getAttribute(D);
2862
- w.attributes[D] = Y;
2716
+ if (l.nodeType === Node.ELEMENT_NODE && (v.isVisible = A(l), v.isVisible)) {
2717
+ v.isTopElement = P(l);
2718
+ const x = l.getAttribute("role"), N = x === "menu" || x === "menubar" || x === "listbox";
2719
+ if ((v.isTopElement || N) && (v.isInteractive = D(l), _ = W(v, l, w, M), v.ref = l, v.isInteractive && Object.keys(v.attributes).length === 0)) {
2720
+ const k = l.getAttributeNames?.() || [];
2721
+ for (const I of k) {
2722
+ const Y = l.getAttribute(I);
2723
+ v.attributes[I] = Y;
2863
2724
  }
2864
2725
  }
2865
2726
  }
2866
- if (s.tagName) {
2867
- const C = s.tagName.toLowerCase();
2868
- if (C === "iframe") try {
2869
- const P = s.contentDocument || s.contentWindow?.document;
2870
- if (P) for (const k of P.childNodes) {
2871
- const D = V(k, s, !1);
2872
- D && w.children.push(D);
2727
+ if (l.tagName) {
2728
+ const x = l.tagName.toLowerCase();
2729
+ if (x === "iframe") try {
2730
+ const N = l.contentDocument || l.contentWindow?.document;
2731
+ if (N) for (const k of N.childNodes) {
2732
+ const I = Z(k, l, !1);
2733
+ I && v.children.push(I);
2873
2734
  }
2874
- } catch (P) {
2875
- console.warn("Unable to access iframe:", P);
2735
+ } catch (N) {
2736
+ console.warn("Unable to access iframe:", N);
2876
2737
  }
2877
- else if (s.isContentEditable || s.getAttribute("contenteditable") === "true" || s.id === "tinymce" || s.classList.contains("mce-content-body") || C === "body" && s.getAttribute("data-id")?.startsWith("mce_")) for (const P of s.childNodes) {
2878
- const k = V(P, b, _);
2879
- k && w.children.push(k);
2738
+ else if (l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.id === "tinymce" || l.classList.contains("mce-content-body") || x === "body" && l.getAttribute("data-id")?.startsWith("mce_")) for (const N of l.childNodes) {
2739
+ const k = Z(N, w, _);
2740
+ k && v.children.push(k);
2880
2741
  }
2881
2742
  else {
2882
- if (s.shadowRoot) {
2883
- w.shadowRoot = !0;
2884
- for (const P of s.shadowRoot.childNodes) {
2885
- const k = V(P, b, _);
2886
- k && w.children.push(k);
2743
+ if (l.shadowRoot) {
2744
+ v.shadowRoot = !0;
2745
+ for (const N of l.shadowRoot.childNodes) {
2746
+ const k = Z(N, w, _);
2747
+ k && v.children.push(k);
2887
2748
  }
2888
2749
  }
2889
- for (const P of s.childNodes) {
2890
- const k = V(P, b, _ || I);
2891
- k && w.children.push(k);
2750
+ for (const N of l.childNodes) {
2751
+ const k = Z(N, w, _ || M);
2752
+ k && v.children.push(k);
2892
2753
  }
2893
2754
  }
2894
2755
  }
2895
- if (w.tagName === "a" && w.children.length === 0 && !w.attributes.href) {
2896
- const C = m(s);
2897
- if (!(C && C.width > 0 && C.height > 0 || s.offsetWidth > 0 || s.offsetHeight > 0)) return null;
2756
+ if (v.tagName === "a" && v.children.length === 0 && !v.attributes.href) {
2757
+ const x = m(l);
2758
+ if (!(x && x.width > 0 && x.height > 0 || l.offsetWidth > 0 || l.offsetHeight > 0)) return null;
2898
2759
  }
2899
- w.extra = d.get(s) || null;
2900
- const F = `${h.current++}`;
2901
- return E[F] = w, F;
2760
+ v.extra = u.get(l) || null;
2761
+ const O = `${f.current++}`;
2762
+ return L[O] = v, O;
2902
2763
  }
2903
- const ce = V(document.body);
2904
- return f.clearCache(), {
2764
+ const ce = Z(document.body);
2765
+ return p.clearCache(), {
2905
2766
  rootId: ce,
2906
- map: E
2767
+ map: L
2907
2768
  };
2908
2769
  }, DEFAULT_VIEWPORT_EXPANSION = -1;
2909
2770
  function resolveViewportExpansion(t) {
@@ -2919,9 +2780,9 @@ var SEMANTIC_TAGS = /* @__PURE__ */ new Set([
2919
2780
  ]), newElementsCache = /* @__PURE__ */ new WeakMap();
2920
2781
  function getFlatTree(t) {
2921
2782
  const e = resolveViewportExpansion(t.viewportExpansion), n = [];
2922
- for (const a of t.interactiveBlacklist || []) typeof a == "function" ? n.push(a()) : n.push(a);
2783
+ for (const s of t.interactiveBlacklist || []) typeof s == "function" ? n.push(s()) : n.push(s);
2923
2784
  const i = [];
2924
- for (const a of t.interactiveWhitelist || []) typeof a == "function" ? i.push(a()) : i.push(a);
2785
+ for (const s of t.interactiveWhitelist || []) typeof s == "function" ? i.push(s()) : i.push(s);
2925
2786
  const r = dom_tree_default({
2926
2787
  doHighlightElements: !0,
2927
2788
  debugMode: !0,
@@ -2932,11 +2793,11 @@ function getFlatTree(t) {
2932
2793
  highlightOpacity: t.highlightOpacity ?? 0,
2933
2794
  highlightLabelOpacity: t.highlightLabelOpacity ?? 0.1
2934
2795
  }), o = window.location.href;
2935
- for (const a in r.map) {
2936
- const l = r.map[a];
2937
- if (l.isInteractive && l.ref) {
2938
- const c = l.ref;
2939
- newElementsCache.has(c) || (newElementsCache.set(c, o), l.isNew = !0);
2796
+ for (const s in r.map) {
2797
+ const a = r.map[s];
2798
+ if (a.isInteractive && a.ref) {
2799
+ const c = a.ref;
2800
+ newElementsCache.has(c) || (newElementsCache.set(c, o), a.isNew = !0);
2940
2801
  }
2941
2802
  }
2942
2803
  return r;
@@ -2983,8 +2844,8 @@ function flatTreeToString(t, e = [], n = !1) {
2983
2844
  "aria-controls",
2984
2845
  "aria-owns",
2985
2846
  "contenteditable"
2986
- ], r = [...e, ...i], o = (f, m) => f.length > m ? f.substring(0, m) + "..." : f, a = (f) => {
2987
- const m = t.map[f];
2847
+ ], r = [...e, ...i], o = (p, m) => p.length > m ? p.substring(0, m) + "..." : p, s = (p) => {
2848
+ const m = t.map[p];
2988
2849
  if (!m) return null;
2989
2850
  if (m.type === "TEXT_NODE") {
2990
2851
  const g = m;
@@ -2996,10 +2857,10 @@ function flatTreeToString(t, e = [], n = !1) {
2996
2857
  children: []
2997
2858
  };
2998
2859
  } else {
2999
- const g = m, S = [];
3000
- if (g.children) for (const E of g.children) {
3001
- const h = a(E);
3002
- h && (h.parent = null, S.push(h));
2860
+ const g = m, E = [];
2861
+ if (g.children) for (const L of g.children) {
2862
+ const f = s(L);
2863
+ f && (f.parent = null, E.push(f));
3003
2864
  }
3004
2865
  return {
3005
2866
  type: "element",
@@ -3011,78 +2872,78 @@ function flatTreeToString(t, e = [], n = !1) {
3011
2872
  isNew: g.isNew ?? !1,
3012
2873
  highlightIndex: g.highlightIndex,
3013
2874
  parent: null,
3014
- children: S,
2875
+ children: E,
3015
2876
  extra: g.extra ?? {}
3016
2877
  };
3017
2878
  }
3018
- }, l = (f, m = null) => {
3019
- f.parent = m;
3020
- for (const g of f.children) l(g, f);
3021
- }, c = a(t.rootId);
2879
+ }, a = (p, m = null) => {
2880
+ p.parent = m;
2881
+ for (const g of p.children) a(g, p);
2882
+ }, c = s(t.rootId);
3022
2883
  if (!c) return "";
3023
- l(c);
3024
- const u = (f) => {
3025
- let m = f.parent;
2884
+ a(c);
2885
+ const d = (p) => {
2886
+ let m = p.parent;
3026
2887
  for (; m; ) {
3027
2888
  if (m.type === "element" && m.highlightIndex !== void 0) return !0;
3028
2889
  m = m.parent;
3029
2890
  }
3030
2891
  return !1;
3031
- }, d = (f, m, g) => {
3032
- let S = m;
3033
- const E = " ".repeat(m);
3034
- if (f.type === "element") {
3035
- const h = n && f.tagName && SEMANTIC_TAGS.has(f.tagName);
3036
- if (f.highlightIndex !== void 0) {
3037
- S += 1;
3038
- const L = getAllTextTillNextClickableElement(f);
3039
- let A = "";
3040
- if (r.length > 0 && f.attributes) {
3041
- const y = matchAttributes(f.attributes, r), M = Object.keys(y);
3042
- if (M.length > 1) {
3043
- const R = /* @__PURE__ */ new Set(), N = {};
3044
- for (const $ of M) {
3045
- const B = y[$];
3046
- B.length > 5 && (B in N ? R.add($) : N[B] = $);
2892
+ }, u = (p, m, g) => {
2893
+ let E = m;
2894
+ const L = " ".repeat(m);
2895
+ if (p.type === "element") {
2896
+ const f = n && p.tagName && SEMANTIC_TAGS.has(p.tagName);
2897
+ if (p.highlightIndex !== void 0) {
2898
+ E += 1;
2899
+ const y = getAllTextTillNextClickableElement(p);
2900
+ let C = "";
2901
+ if (r.length > 0 && p.attributes) {
2902
+ const A = matchAttributes(p.attributes, r), D = Object.keys(A);
2903
+ if (D.length > 1) {
2904
+ const P = /* @__PURE__ */ new Set(), R = {};
2905
+ for (const F of D) {
2906
+ const B = A[F];
2907
+ B.length > 5 && (B in R ? P.add(F) : R[B] = F);
3047
2908
  }
3048
- for (const $ of R) delete y[$];
2909
+ for (const F of P) delete A[F];
3049
2910
  }
3050
- y.role === f.tagName && delete y.role;
3051
- for (const R of [
2911
+ A.role === p.tagName && delete A.role;
2912
+ for (const P of [
3052
2913
  "aria-label",
3053
2914
  "placeholder",
3054
2915
  "title"
3055
- ]) y[R] && y[R].toLowerCase().trim() === L.toLowerCase().trim() && delete y[R];
3056
- Object.keys(y).length > 0 && (A = Object.entries(y).map(([R, N]) => `${R}=${o(N, 20)}`).join(" "));
2916
+ ]) A[P] && A[P].toLowerCase().trim() === y.toLowerCase().trim() && delete A[P];
2917
+ Object.keys(A).length > 0 && (C = Object.entries(A).map(([P, R]) => `${P}=${o(R, 20)}`).join(" "));
3057
2918
  }
3058
- let v = `${E}${f.isNew ? `*[${f.highlightIndex}]` : `[${f.highlightIndex}]`}<${f.tagName ?? ""}`;
3059
- if (A && (v += ` ${A}`), f.extra && f.extra.scrollable) {
3060
- let y = "";
3061
- f.extra.scrollData?.left && (y += `left=${f.extra.scrollData.left}, `), f.extra.scrollData?.top && (y += `top=${f.extra.scrollData.top}, `), f.extra.scrollData?.right && (y += `right=${f.extra.scrollData.right}, `), f.extra.scrollData?.bottom && (y += `bottom=${f.extra.scrollData.bottom}`), v += ` data-scrollable="${y}"`;
2919
+ let S = `${L}${p.isNew ? `*[${p.highlightIndex}]` : `[${p.highlightIndex}]`}<${p.tagName ?? ""}`;
2920
+ if (C && (S += ` ${C}`), p.extra && p.extra.scrollable) {
2921
+ let A = "";
2922
+ p.extra.scrollData?.left && (A += `left=${p.extra.scrollData.left}, `), p.extra.scrollData?.top && (A += `top=${p.extra.scrollData.top}, `), p.extra.scrollData?.right && (A += `right=${p.extra.scrollData.right}, `), p.extra.scrollData?.bottom && (A += `bottom=${p.extra.scrollData.bottom}`), S += ` data-scrollable="${A}"`;
3062
2923
  }
3063
- if (L) {
3064
- const y = L.trim();
3065
- A || (v += " "), v += `>${y}`;
3066
- } else A || (v += " ");
3067
- v += " />", g.push(v);
2924
+ if (y) {
2925
+ const A = y.trim();
2926
+ C || (S += " "), S += `>${A}`;
2927
+ } else C || (S += " ");
2928
+ S += " />", g.push(S);
3068
2929
  }
3069
- const x = h && f.highlightIndex === void 0, T = x ? g.length : -1;
3070
- x && (g.push(`${E}<${f.tagName}>`), S += 1);
3071
- for (const L of f.children) d(L, S, g);
3072
- x && (g.length === T + 1 ? g.pop() : g.push(`${E}</${f.tagName}>`));
3073
- } else if (f.type === "text") {
3074
- if (u(f)) return;
3075
- f.parent && f.parent.type === "element" && f.parent.isVisible && f.parent.isTopElement && g.push(`${E}${f.text ?? ""}`);
2930
+ const b = f && p.highlightIndex === void 0, T = b ? g.length : -1;
2931
+ b && (g.push(`${L}<${p.tagName}>`), E += 1);
2932
+ for (const y of p.children) u(y, E, g);
2933
+ b && (g.length === T + 1 ? g.pop() : g.push(`${L}</${p.tagName}>`));
2934
+ } else if (p.type === "text") {
2935
+ if (d(p)) return;
2936
+ p.parent && p.parent.type === "element" && p.parent.isVisible && p.parent.isTopElement && g.push(`${L}${p.text ?? ""}`);
3076
2937
  }
3077
- }, p = [];
3078
- return d(c, 0, p), p.join(`
2938
+ }, h = [];
2939
+ return u(c, 0, h), h.join(`
3079
2940
  `);
3080
2941
  }
3081
2942
  var getAllTextTillNextClickableElement = (t, e = -1) => {
3082
2943
  const n = [], i = (r, o) => {
3083
2944
  if (!(e !== -1 && o > e) && !(r.type === "element" && r !== t && r.highlightIndex !== void 0)) {
3084
2945
  if (r.type === "text" && r.text) n.push(r.text);
3085
- else if (r.type === "element") for (const a of r.children) i(a, o + 1);
2946
+ else if (r.type === "element") for (const s of r.children) i(s, o + 1);
3086
2947
  }
3087
2948
  };
3088
2949
  return i(t, 0), n.join(`
@@ -3133,7 +2994,7 @@ else {
3133
2994
  }, 500);
3134
2995
  }
3135
2996
  function getPageInfo() {
3136
- const t = window.innerWidth, e = window.innerHeight, n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight || 0), r = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, o = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, a = Math.max(0, i - (window.innerHeight + o)), l = Math.max(0, n - (window.innerWidth + r));
2997
+ const t = window.innerWidth, e = window.innerHeight, n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight || 0), r = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, o = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, s = Math.max(0, i - (window.innerHeight + o)), a = Math.max(0, n - (window.innerWidth + r));
3137
2998
  return {
3138
2999
  viewport_width: t,
3139
3000
  viewport_height: e,
@@ -3142,13 +3003,13 @@ function getPageInfo() {
3142
3003
  scroll_x: r,
3143
3004
  scroll_y: o,
3144
3005
  pixels_above: o,
3145
- pixels_below: a,
3006
+ pixels_below: s,
3146
3007
  pages_above: e > 0 ? o / e : 0,
3147
- pages_below: e > 0 ? a / e : 0,
3008
+ pages_below: e > 0 ? s / e : 0,
3148
3009
  total_pages: e > 0 ? i / e : 0,
3149
3010
  current_page_position: o / Math.max(1, i - e),
3150
3011
  pixels_left: r,
3151
- pixels_right: l
3012
+ pixels_right: a
3152
3013
  };
3153
3014
  }
3154
3015
  function patchReact(t) {
@@ -3186,7 +3047,7 @@ var PageController = class extends EventTarget {
3186
3047
  */
3187
3048
  initMask() {
3188
3049
  this.maskReady === null && (this.maskReady = (async () => {
3189
- const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-iNUb4dyF.js");
3050
+ const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-CKmEDsYG.js");
3190
3051
  this.mask = new t();
3191
3052
  })());
3192
3053
  }
@@ -3380,14 +3241,9 @@ ${n.pixels_above > 4 && i !== -1 ? `... ${n.pixels_above} pixels above (${n.page
3380
3241
  cleanUpHighlights(), this.flatTree = null, this.selectorMap.clear(), this.elementTextMap.clear(), this.simplifiedHTML = "<EMPTY>", this.isIndexed = !1, this.mask?.dispose(), this.mask = null;
3381
3242
  }
3382
3243
  };
3383
- const DEFAULT_ERROR_SELECTORS$1 = [
3244
+ const DEFAULT_ERROR_SELECTORS = [
3384
3245
  '[role="alert"]',
3385
3246
  '[aria-invalid="true"]',
3386
- ".ti3-unifyvalid-error",
3387
- ".ti3-error",
3388
- ".ti-error",
3389
- ".lego-text-error",
3390
- ".lego-error",
3391
3247
  ".el-form-item__error",
3392
3248
  ".ant-form-item-explain-error",
3393
3249
  ".is-invalid",
@@ -3403,13 +3259,40 @@ const DEFAULT_ERROR_SELECTORS$1 = [
3403
3259
  ".validate-error",
3404
3260
  ".valid-error"
3405
3261
  ], DEFAULT_WARNING_SELECTORS = [
3406
- ".ti3-warning",
3407
- ".ti-warning",
3408
- ".lego-text-warning",
3409
3262
  ".warning-msg",
3410
3263
  ".warning-text",
3411
3264
  ".is-warning",
3412
3265
  ".has-warning"
3266
+ ], DEFAULT_DIALOG_SELECTORS = [
3267
+ // W3C ARIA 标准
3268
+ '[role="dialog"]',
3269
+ '[role="alertdialog"]',
3270
+ // Element UI / Element Plus
3271
+ '[class*="el-dialog"]',
3272
+ '[class*="el-message-box"]',
3273
+ // Ant Design
3274
+ '[class*="ant-modal"]',
3275
+ // Bootstrap
3276
+ '[class*="modal-content"]',
3277
+ // Vuetify
3278
+ '[class*="v-dialog"]',
3279
+ // Naive UI
3280
+ '[class*="n-modal"]'
3281
+ ], DEFAULT_TOOLTIP_SELECTORS = [
3282
+ // W3C ARIA 标准
3283
+ '[role="tooltip"]',
3284
+ // Element Plus
3285
+ '[class*="el-tooltip-popper"]',
3286
+ '[class*="el-popper"]',
3287
+ // Ant Design
3288
+ '[class*="ant-tooltip"]',
3289
+ '[class*="ant-popover"]',
3290
+ // Naive UI
3291
+ '[class*="n-tooltip"]',
3292
+ '[class*="n-popover"]',
3293
+ // Vuetify
3294
+ '[class*="v-tooltip"]',
3295
+ '[class*="v-menu"]'
3413
3296
  ], TAG_ROLE_MAP = {
3414
3297
  a: "link",
3415
3298
  article: "article",
@@ -3472,7 +3355,7 @@ const DEFAULT_ERROR_SELECTORS$1 = [
3472
3355
  time: "time",
3473
3356
  tr: "row",
3474
3357
  ul: "list"
3475
- }, INPUT_TYPE_ROLE = {
3358
+ }, DEFAULT_ROLE_OVERRIDES = [], INPUT_TYPE_ROLE = {
3476
3359
  button: "button",
3477
3360
  checkbox: "checkbox",
3478
3361
  color: "textbox",
@@ -3488,7 +3371,222 @@ const DEFAULT_ERROR_SELECTORS$1 = [
3488
3371
  tel: "textbox",
3489
3372
  text: "textbox",
3490
3373
  url: "textbox"
3491
- };
3374
+ }, RESOLVED_A11Y_BRAND = Symbol.for("@opentiny/next-sdk:ResolvedA11yConfig");
3375
+ function markResolved(t) {
3376
+ return Object.assign(t, { [RESOLVED_A11Y_BRAND]: !0 });
3377
+ }
3378
+ function isResolvedA11yConfig(t) {
3379
+ return !!t && t[RESOLVED_A11Y_BRAND] === !0;
3380
+ }
3381
+ const STANDARD_STATE_NAMES = [
3382
+ "checked",
3383
+ "selected",
3384
+ "pressed",
3385
+ "current",
3386
+ "expanded",
3387
+ "hasPopup",
3388
+ "disabled",
3389
+ "readonly",
3390
+ "required",
3391
+ "invalid",
3392
+ "busy",
3393
+ "error",
3394
+ "warning"
3395
+ ], DEFAULT_SELECTED_CLASS_RE = /\b(is-active|isActive|is-selected|isSelected|is-current|isCurrent|active-item|activeItem|tab-active|tabActive|active|selected|current)\b/;
3396
+ function defaultSelectedMatch(t) {
3397
+ const e = typeof t.className == "string" ? t.className : "";
3398
+ if (!e || !DEFAULT_SELECTED_CLASS_RE.test(e)) return !1;
3399
+ const n = t.getAttribute("role") || t.tagName.toLowerCase();
3400
+ return ["button", "option", "a", "li", "generic"].includes(n) || n.startsWith("tab");
3401
+ }
3402
+ const DEFAULT_A11Y_CONFIG = markResolved({
3403
+ // 框架级 role 覆盖:Tiny3 Tabs、tp-helptip 等非标准 UI 组件(规则定义见 constants.ts)
3404
+ // + dialog/tooltip 选择器转为 role 规则,统一走 roles 通道做 role 推断与 DOM 检测
3405
+ roles: [
3406
+ ...DEFAULT_ROLE_OVERRIDES,
3407
+ // Dialog:补齐缺失的 role="dialog"(如 Tiny3 ti3-modal、Element Plus el-dialog)
3408
+ ...DEFAULT_DIALOG_SELECTORS.map((t) => ({ selector: t, role: "dialog" })),
3409
+ // Tooltip:补齐缺失的 role="tooltip"(如 Tiny3 ti3-tooltip、Element Plus el-tooltip-popper)
3410
+ ...DEFAULT_TOOLTIP_SELECTORS.map((t) => ({ selector: t, role: "tooltip" }))
3411
+ ],
3412
+ states: {
3413
+ selected: [
3414
+ { match: defaultSelectedMatch },
3415
+ // Tiny3 按钮组/单选按钮组:选中 class 在容器上(.ti3-btn-item-container.ti3-active),
3416
+ // 内部 button 自身无 aria-selected / ti3-active,需靠 closest 命中
3417
+ { selector: ".ti3-btn-item-container.ti3-active" }
3418
+ ],
3419
+ error: [{ selector: DEFAULT_ERROR_SELECTORS }],
3420
+ warning: [{ selector: DEFAULT_WARNING_SELECTORS }]
3421
+ },
3422
+ whitelist: [],
3423
+ blacklist: [],
3424
+ exposedAttributes: []
3425
+ });
3426
+ function normalizeSelector(t) {
3427
+ return t && (Array.isArray(t) ? t.filter(Boolean).join(", ") : t) || void 0;
3428
+ }
3429
+ function getSelectorsForRole(t, e) {
3430
+ const n = [];
3431
+ for (const i of t)
3432
+ i.role !== e || !i.selector || (Array.isArray(i.selector) ? n.push(...i.selector.filter(Boolean)) : n.push(i.selector));
3433
+ return n;
3434
+ }
3435
+ function matchesRule(t, e) {
3436
+ if (e.match)
3437
+ try {
3438
+ return !!e.match(t);
3439
+ } catch {
3440
+ return !1;
3441
+ }
3442
+ const n = normalizeSelector(e.selector);
3443
+ if (n)
3444
+ try {
3445
+ return !!t.closest(n);
3446
+ } catch {
3447
+ return !1;
3448
+ }
3449
+ return !1;
3450
+ }
3451
+ function matchesRoleRule(t, e) {
3452
+ if (e.match)
3453
+ try {
3454
+ return !!e.match(t);
3455
+ } catch {
3456
+ return !1;
3457
+ }
3458
+ const n = normalizeSelector(e.selector);
3459
+ if (n)
3460
+ try {
3461
+ return !!t.matches(n);
3462
+ } catch {
3463
+ return !1;
3464
+ }
3465
+ return !1;
3466
+ }
3467
+ function matchesAnyRule(t, e) {
3468
+ return e ? (Array.isArray(e) ? e : [e]).some((i) => matchesRule(t, i)) : !1;
3469
+ }
3470
+ function extractSelectors(t) {
3471
+ return t ? (Array.isArray(t) ? t : [t]).flatMap((n) => Array.isArray(n.selector) ? n.selector.filter(Boolean) : n.selector ? [n.selector] : []) : [];
3472
+ }
3473
+ function concatArr(t, e) {
3474
+ return [...t ?? [], ...e ?? []];
3475
+ }
3476
+ function normalizeMatcherList(t) {
3477
+ return t ? Array.isArray(t) ? t : [t] : [];
3478
+ }
3479
+ function mergeStates(t, e) {
3480
+ const n = {}, i = /* @__PURE__ */ new Set([...Object.keys(t ?? {}), ...Object.keys(e ?? {})]);
3481
+ for (const r of i)
3482
+ n[r] = [...normalizeMatcherList(t?.[r]), ...normalizeMatcherList(e?.[r])];
3483
+ return n;
3484
+ }
3485
+ function mergeA11yConfigs(t, e) {
3486
+ return markResolved({
3487
+ roles: concatArr(t.roles, e.roles),
3488
+ states: mergeStates(t.states, e.states),
3489
+ whitelist: concatArr(t.whitelist, e.whitelist),
3490
+ blacklist: concatArr(t.blacklist, e.blacklist),
3491
+ exposedAttributes: concatArr(t.exposedAttributes, e.exposedAttributes)
3492
+ });
3493
+ }
3494
+ function mergeA11yConfig(t) {
3495
+ return isResolvedA11yConfig(t) ? t : mergeA11yConfigs(DEFAULT_A11Y_CONFIG, t ?? {});
3496
+ }
3497
+ function ensureResolvedA11yConfig(t) {
3498
+ return isResolvedA11yConfig(t) ? t : mergeA11yConfig(t);
3499
+ }
3500
+ function defineA11yConfig(t) {
3501
+ return t;
3502
+ }
3503
+ function computeRole(t, e) {
3504
+ const n = t.getAttribute("role"), i = !!n && n !== "presentation" && n !== "none";
3505
+ for (const o of e.roles)
3506
+ if (!(i && !o.force) && matchesRoleRule(t, o))
3507
+ return o.role;
3508
+ if (i) return n;
3509
+ const r = t.tagName.toLowerCase();
3510
+ if (r === "input") {
3511
+ const o = t.type?.toLowerCase() ?? "text";
3512
+ return INPUT_TYPE_ROLE[o] ?? "textbox";
3513
+ }
3514
+ return TAG_ROLE_MAP[r] ?? "generic";
3515
+ }
3516
+ function computeStates(t, e) {
3517
+ const n = [], i = (b) => t.getAttribute(b), r = e.states, o = (b) => matchesAnyRule(t, r[b]), s = i("aria-checked");
3518
+ if (s === "true")
3519
+ n.push("checked");
3520
+ else if (s === "mixed")
3521
+ n.push("checked=mixed");
3522
+ else if (s === "false")
3523
+ n.push("unchecked");
3524
+ else {
3525
+ const b = t.tagName.toLowerCase();
3526
+ let T;
3527
+ if (b === "input" && (t.type === "checkbox" || t.type === "radio"))
3528
+ T = t.checked;
3529
+ else if (b === "label" && t.hasAttribute("for")) {
3530
+ const y = document.getElementById(t.getAttribute("for"));
3531
+ y instanceof HTMLInputElement && (y.type === "checkbox" || y.type === "radio") && (T = y.checked);
3532
+ }
3533
+ T !== void 0 ? n.push(T ? "checked" : "unchecked") : o("checked") && n.push("checked");
3534
+ }
3535
+ (i("aria-selected") === "true" || o("selected")) && n.push("selected");
3536
+ const a = i("aria-pressed");
3537
+ a === "true" ? n.push("pressed") : a === "mixed" ? n.push("pressed=mixed") : a !== "false" && o("pressed") && n.push("pressed");
3538
+ const c = i("aria-current");
3539
+ c && c !== "false" ? n.push(c === "true" ? "current" : `current=${c}`) : o("current") && n.push("current"), (i("aria-disabled") === "true" || t.disabled || o("disabled")) && n.push("disabled");
3540
+ const d = i("aria-haspopup");
3541
+ (d && d !== "false" || o("hasPopup")) && n.push("hasPopup"), (i("aria-expanded") === "true" || o("expanded")) && n.push("expanded");
3542
+ const u = i("aria-invalid");
3543
+ u && u !== "false" ? n.push(u === "true" ? "invalid" : `invalid=${u}`) : o("invalid") && n.push("invalid"), (i("aria-readonly") === "true" || t.readOnly || o("readonly")) && n.push("readonly"), (i("aria-required") === "true" || t.required || o("required")) && n.push("required"), (i("aria-busy") === "true" || o("busy")) && n.push("busy");
3544
+ const h = i("aria-orientation");
3545
+ h && n.push(`orientation=${h}`);
3546
+ const p = i("aria-sort");
3547
+ p && p !== "none" && n.push(`sort=${p}`), i("aria-multiselectable") === "true" && n.push("multiselectable");
3548
+ const m = t.tagName.match(/^H([1-6])$/);
3549
+ m && n.push(`level=${m[1]}`);
3550
+ const g = i("aria-level");
3551
+ g && !m && n.push(`level=${g}`);
3552
+ try {
3553
+ window.getComputedStyle(t).cursor === "pointer" && n.push("cursor=pointer");
3554
+ } catch {
3555
+ }
3556
+ const E = t.tagName.toLowerCase();
3557
+ if (E === "input" || E === "textarea" || E === "select") {
3558
+ const b = t.value;
3559
+ b !== void 0 && b !== "" && n.push(`value="${b}"`);
3560
+ }
3561
+ const L = i("aria-valuenow");
3562
+ L && n.push(`valuenow="${L}"`);
3563
+ const f = i("aria-valuetext");
3564
+ if (f && n.push(`valuetext="${f}"`), E === "a") {
3565
+ const b = i("target");
3566
+ b && n.push(`target=${b}`);
3567
+ }
3568
+ o("error") ? n.push("error") : o("warning") && n.push("warning");
3569
+ for (const b of Object.keys(r))
3570
+ STANDARD_STATE_NAMES.includes(b) || matchesAnyRule(t, r[b]) && n.push(b);
3571
+ for (const b of e.exposedAttributes) {
3572
+ const T = t.getAttribute(b);
3573
+ T !== null && n.push(`${b}="${T}"`);
3574
+ }
3575
+ return Array.from(new Set(n));
3576
+ }
3577
+ function resolveA11yRole(t, e) {
3578
+ return computeRole(t, ensureResolvedA11yConfig(e));
3579
+ }
3580
+ function resolveA11yStates(t, e) {
3581
+ return computeStates(t, ensureResolvedA11yConfig(e));
3582
+ }
3583
+ function resolveA11yInfo(t, e) {
3584
+ const n = ensureResolvedA11yConfig(e);
3585
+ return {
3586
+ role: computeRole(t, n),
3587
+ tokens: computeStates(t, n)
3588
+ };
3589
+ }
3492
3590
  var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "area[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], candidateSelector = /* @__PURE__ */ candidateSelectors.join(","), NoElement = typeof Element > "u", matches = NoElement ? function() {
3493
3591
  } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, getRootNode = !NoElement && Element.prototype.getRootNode ? function(t) {
3494
3592
  var e;
@@ -3520,16 +3618,16 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3520
3618
  }, isTabbableRadio = function t(e) {
3521
3619
  if (!e.name)
3522
3620
  return !0;
3523
- var n = e.form || getRootNode(e), i = function(l) {
3524
- return n.querySelectorAll('input[type="radio"][name="' + l + '"]');
3621
+ var n = e.form || getRootNode(e), i = function(a) {
3622
+ return n.querySelectorAll('input[type="radio"][name="' + a + '"]');
3525
3623
  }, r;
3526
3624
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
3527
3625
  r = i(window.CSS.escape(e.name));
3528
3626
  else
3529
3627
  try {
3530
3628
  r = i(e.name);
3531
- } catch (a) {
3532
- return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", a.message), !1;
3629
+ } catch (s) {
3630
+ return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", s.message), !1;
3533
3631
  }
3534
3632
  var o = getCheckedRadio(r, e.form);
3535
3633
  return !o || o === e;
@@ -3540,10 +3638,10 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3540
3638
  }, isNodeAttached = function t(e) {
3541
3639
  var n, i = e && getRootNode(e), r = (n = i) === null || n === void 0 ? void 0 : n.host, o = !1;
3542
3640
  if (i && i !== e) {
3543
- var a, l, c;
3544
- for (o = !!((a = r) !== null && a !== void 0 && (l = a.ownerDocument) !== null && l !== void 0 && l.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
3545
- var u, d, p;
3546
- i = getRootNode(r), r = (u = i) === null || u === void 0 ? void 0 : u.host, o = !!((d = r) !== null && d !== void 0 && (p = d.ownerDocument) !== null && p !== void 0 && p.contains(r));
3641
+ var s, a, c;
3642
+ for (o = !!((s = r) !== null && s !== void 0 && (a = s.ownerDocument) !== null && a !== void 0 && a.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
3643
+ var d, u, h;
3644
+ i = getRootNode(r), r = (d = i) === null || d === void 0 ? void 0 : d.host, o = !!((u = r) !== null && u !== void 0 && (h = u.ownerDocument) !== null && h !== void 0 && h.contains(r));
3547
3645
  }
3548
3646
  }
3549
3647
  return o;
@@ -3568,23 +3666,23 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3568
3666
  });
3569
3667
  return !o;
3570
3668
  }
3571
- var a = getComputedStyle(e), l = a.visibility;
3572
- if (l === "hidden" || l === "collapse")
3669
+ var s = getComputedStyle(e), a = s.visibility;
3670
+ if (a === "hidden" || a === "collapse")
3573
3671
  return !0;
3574
- var c = matches.call(e, "details>summary:first-of-type"), u = c ? e.parentElement : e;
3575
- if (matches.call(u, "details:not([open]) *"))
3672
+ var c = matches.call(e, "details>summary:first-of-type"), d = c ? e.parentElement : e;
3673
+ if (matches.call(d, "details:not([open]) *"))
3576
3674
  return !0;
3577
3675
  if (!i || i === "full" || // full-native can run this branch when it falls through in case
3578
3676
  // Element#checkVisibility is unsupported
3579
3677
  i === "full-native" || i === "legacy-full") {
3580
3678
  if (typeof r == "function") {
3581
- for (var d = e; e; ) {
3582
- var p = e.parentElement, f = getRootNode(e);
3583
- if (p && !p.shadowRoot && r(p) === !0)
3679
+ for (var u = e; e; ) {
3680
+ var h = e.parentElement, p = getRootNode(e);
3681
+ if (h && !h.shadowRoot && r(h) === !0)
3584
3682
  return isZeroArea(e);
3585
- e.assignedSlot ? e = e.assignedSlot : !p && f !== e.ownerDocument ? e = f.host : e = p;
3683
+ e.assignedSlot ? e = e.assignedSlot : !h && p !== e.ownerDocument ? e = p.host : e = h;
3586
3684
  }
3587
- e = d;
3685
+ e = u;
3588
3686
  }
3589
3687
  if (isNodeAttached(e))
3590
3688
  return !e.getClientRects().length;
@@ -3617,98 +3715,193 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3617
3715
  throw new Error("No node provided");
3618
3716
  return matches.call(e, candidateSelector) === !1 ? !1 : isNodeMatchingSelectorTabbable(n, e);
3619
3717
  };
3620
- function inferRole(t) {
3621
- const e = t.getAttribute("role");
3622
- if (e && e !== "presentation" && e !== "none")
3623
- return e;
3624
- const n = t.tagName.toLowerCase();
3625
- if (n === "input") {
3626
- const i = t.type?.toLowerCase() ?? "text";
3627
- return INPUT_TYPE_ROLE[i] ?? "textbox";
3628
- }
3629
- return TAG_ROLE_MAP[n] ?? "generic";
3630
- }
3631
- function getStateTokens(t, e, n, i) {
3632
- const r = [], o = (v) => t.getAttribute(v), a = o("aria-checked");
3633
- if (a === "true")
3634
- r.push("checked");
3635
- else if (a === "false")
3636
- r.push("unchecked");
3637
- else {
3638
- const v = t.tagName.toLowerCase();
3639
- let y;
3640
- if (v === "input" && (t.type === "checkbox" || t.type === "radio"))
3641
- y = t.checked;
3642
- else if (v === "label" && t.hasAttribute("for")) {
3643
- const M = document.getElementById(t.getAttribute("for"));
3644
- M instanceof HTMLInputElement && (M.type === "checkbox" || M.type === "radio") && (y = M.checked);
3718
+ const DEFAULT_PAGE_AGENT_TOOL_CONFIG = {
3719
+ enableHighlight: !1,
3720
+ removeMaskAfterToolCall: !0,
3721
+ a11yConfig: DEFAULT_A11Y_CONFIG
3722
+ };
3723
+ function getPageAgentToolConfig() {
3724
+ return typeof window < "u" && window.__webmcpcli_toolConfig ? window.__webmcpcli_toolConfig : {
3725
+ enableHighlight: DEFAULT_PAGE_AGENT_TOOL_CONFIG.enableHighlight,
3726
+ removeMaskAfterToolCall: DEFAULT_PAGE_AGENT_TOOL_CONFIG.removeMaskAfterToolCall,
3727
+ a11yConfig: mergeA11yConfig()
3728
+ };
3729
+ }
3730
+ function resolvePatch(t, e) {
3731
+ return {
3732
+ enableHighlight: t.enableHighlight ?? e.enableHighlight,
3733
+ removeMaskAfterToolCall: t.removeMaskAfterToolCall ?? e.removeMaskAfterToolCall,
3734
+ a11yConfig: mergeA11yConfigs(e.a11yConfig, t.a11yConfig ?? {})
3735
+ };
3736
+ }
3737
+ function setPageAgentToolConfig(t, e) {
3738
+ const n = e?.mode ?? "merge", i = getPageAgentToolConfig(), r = typeof t == "function" ? resolvePatch(t(i), DEFAULT_PAGE_AGENT_TOOL_CONFIG) : resolvePatch(t, n === "replace" ? DEFAULT_PAGE_AGENT_TOOL_CONFIG : i);
3739
+ return typeof window < "u" && (window.__webmcpcli_toolConfig = r), r;
3740
+ }
3741
+ function isInShadowDom(t) {
3742
+ return t.getRootNode() instanceof ShadowRoot;
3743
+ }
3744
+ function dispatchComposedEvents(t, ...e) {
3745
+ for (const n of e)
3746
+ t.dispatchEvent(new Event(n, { bubbles: !0, composed: !0 }));
3747
+ }
3748
+ function deepQuerySelectorAll(t, e = document) {
3749
+ const n = Array.from(e.querySelectorAll(t)), i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, null);
3750
+ let r = i.currentNode;
3751
+ for (; r; )
3752
+ r.shadowRoot && n.push(...deepQuerySelectorAll(t, r.shadowRoot)), r = i.nextNode();
3753
+ return n;
3754
+ }
3755
+ function waitForDomSettled(t = 600, e = 150) {
3756
+ return new Promise((n) => {
3757
+ let i = !1, r;
3758
+ const o = () => {
3759
+ i || (i = !0, s.disconnect(), r && clearTimeout(r), n());
3760
+ }, s = new MutationObserver(() => {
3761
+ r && clearTimeout(r), r = setTimeout(o, e);
3762
+ });
3763
+ r = setTimeout(o, e), setTimeout(o, t), s.observe(document.body, {
3764
+ childList: !0,
3765
+ subtree: !0,
3766
+ attributes: !0,
3767
+ attributeFilter: ["class", "style", "hidden"]
3768
+ });
3769
+ });
3770
+ }
3771
+ function detectPageDialog() {
3772
+ const t = /* @__PURE__ */ new Set(), e = [], n = getSelectorsForRole(getPageAgentToolConfig().a11yConfig.roles, "dialog");
3773
+ for (const i of n)
3774
+ try {
3775
+ for (const r of deepQuerySelectorAll(i)) {
3776
+ if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
3777
+ const o = r.getBoundingClientRect();
3778
+ if (o.width < 50 || o.height < 50) continue;
3779
+ const s = window.getComputedStyle(r);
3780
+ if (s.display === "none" || s.visibility === "hidden") continue;
3781
+ const a = s.position === "fixed" || s.position === "absolute", c = parseInt(s.zIndex || "0", 10);
3782
+ if (!a || c < 100) continue;
3783
+ const d = window.innerWidth, u = window.innerHeight;
3784
+ if (!(o.left < d * 0.6 && o.right > d * 0.4 && o.top < u * 0.6 && o.bottom > u * 0.4)) continue;
3785
+ t.add(r);
3786
+ const p = (r.textContent || "").trim().replace(/\s+/g, " ");
3787
+ if (p.length > 5) {
3788
+ const m = r.querySelectorAll('button, [role="button"], a'), g = Array.from(m).map((E) => (E.textContent || "").trim()).filter((E) => E.length > 0 && E.length < 20).slice(0, 5);
3789
+ e.push({ text: p.substring(0, 300), buttons: g });
3790
+ }
3791
+ }
3792
+ } catch {
3793
+ }
3794
+ return e;
3795
+ }
3796
+ function detectValidationErrors() {
3797
+ const t = /* @__PURE__ */ new Set(), e = [], n = extractSelectors(getPageAgentToolConfig().a11yConfig.states.error);
3798
+ for (const i of n)
3799
+ try {
3800
+ for (const r of deepQuerySelectorAll(i)) {
3801
+ if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
3802
+ const o = r.getBoundingClientRect();
3803
+ if (o.width < 1 || o.height < 1) continue;
3804
+ const s = window.getComputedStyle(r);
3805
+ if (s.display === "none" || s.visibility === "hidden") continue;
3806
+ const a = (r.textContent || "").trim().replace(/\s+/g, " ");
3807
+ a.length > 2 && a.length < 200 && (t.add(r), e.push(a));
3808
+ }
3809
+ } catch {
3645
3810
  }
3646
- y !== void 0 && r.push(y ? "checked" : "unchecked");
3647
- }
3648
- o("aria-selected") === "true" && r.push("selected"), (o("aria-disabled") === "true" || t.disabled) && r.push("disabled");
3649
- const c = o("aria-haspopup");
3650
- c && c !== "false" && r.push("hasPopup"), o("aria-expanded") === "true" && r.push("expanded");
3651
- const u = t.tagName.match(/^H([1-6])$/);
3652
- u && r.push(`level=${u[1]}`);
3653
- const d = o("aria-level");
3654
- d && !u && r.push(`level=${d}`);
3811
+ return e;
3812
+ }
3813
+ function getVisibleTooltipElements() {
3814
+ const t = /* @__PURE__ */ new Set(), e = [], n = getSelectorsForRole(getPageAgentToolConfig().a11yConfig.roles, "tooltip");
3815
+ for (const i of n)
3816
+ try {
3817
+ for (const r of deepQuerySelectorAll(i)) {
3818
+ if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
3819
+ const o = r.getBoundingClientRect();
3820
+ if (o.width < 1 || o.height < 1) continue;
3821
+ const s = window.getComputedStyle(r);
3822
+ if (s.display === "none" || s.visibility === "hidden" || s.opacity === "0") continue;
3823
+ const a = (r.textContent || "").trim().replace(/\s+/g, " ");
3824
+ if (a.length > 1) {
3825
+ if (r.querySelector?.('[name="cloudx-action-help"]')) continue;
3826
+ t.add(r), e.push({ el: r, text: a });
3827
+ }
3828
+ }
3829
+ } catch {
3830
+ }
3831
+ return e;
3832
+ }
3833
+ function detectVisibleTooltips() {
3834
+ return getVisibleTooltipElements().map((t) => t.text);
3835
+ }
3836
+ const NON_CONTENT_TAGS = /* @__PURE__ */ new Set([
3837
+ "script",
3838
+ "style",
3839
+ "noscript",
3840
+ "template",
3841
+ "link",
3842
+ "meta",
3843
+ "head",
3844
+ "title"
3845
+ ]);
3846
+ function isNonContentElement(t) {
3847
+ return NON_CONTENT_TAGS.has(t.tagName.toLowerCase());
3848
+ }
3849
+ function hasOwnPointerCursor(t) {
3655
3850
  try {
3656
- window.getComputedStyle(t).cursor === "pointer" && r.push("cursor=pointer");
3851
+ if (window.getComputedStyle(t).cursor !== "pointer") return !1;
3852
+ const e = t.parentElement;
3853
+ return e ? window.getComputedStyle(e).cursor !== "pointer" : !0;
3657
3854
  } catch {
3855
+ return !1;
3658
3856
  }
3659
- const p = t.tagName.toLowerCase();
3660
- if (p === "input" || p === "textarea" || p === "select") {
3661
- const v = t.value;
3662
- v !== void 0 && v !== "" && r.push(`value="${v}"`);
3663
- }
3664
- const f = t.getAttribute("aria-valuenow");
3665
- f && r.push(`valuenow="${f}"`), t.tagName.toLowerCase() === "a" && t.getAttribute("target") === "_blank" && r.push("opens-new-tab");
3666
- const m = typeof t.className == "string" ? t.className : "", S = [
3667
- "is-active",
3668
- "isActive",
3669
- "is-selected",
3670
- "isSelected",
3671
- "is-current",
3672
- "isCurrent",
3673
- "active-item",
3674
- "activeItem",
3675
- "tab-active",
3676
- "tabActive",
3677
- // 仅当作为独立 class 词或有连字符前缀时匹配 "active",避免误匹配 "interactive" 等
3678
- /\bactive\b/,
3679
- /\bselected\b/,
3680
- /\bcurrent\b/
3681
- ].some(
3682
- (v) => typeof v == "string" ? m.split(/\s+/).includes(v) : v.test(m)
3683
- ), x = (t.getAttribute("role") || t.tagName.toLowerCase()).split(/\s+/).some((v) => ["button", "option", "a", "li", "generic"].includes(v) || v.startsWith("tab"));
3684
- S && x && !r.includes("checked") && !r.includes("selected") && r.push("active");
3685
- const T = Array.isArray(n) ? n.join(", ") : n || DEFAULT_ERROR_SELECTORS$1.join(", "), L = Array.isArray(i) ? i.join(", ") : i || DEFAULT_WARNING_SELECTORS.join(", ");
3686
- let A = null;
3687
- if (T)
3688
- try {
3689
- A = t.closest(T);
3690
- } catch {
3857
+ }
3858
+ const INTERACTION_PSEUDO_RE = /:(hover|focus|focus-visible|focus-within|active)\b/gi;
3859
+ function collectInteractivePointerSelectors(t, e) {
3860
+ for (const n of Array.from(t)) {
3861
+ const i = n, r = n;
3862
+ if (!i.selectorText && r.cssRules) {
3863
+ collectInteractivePointerSelectors(r.cssRules, e);
3864
+ continue;
3691
3865
  }
3692
- if (A)
3693
- r.push("error");
3694
- else {
3695
- let v = null;
3696
- if (L)
3866
+ const o = i.selectorText;
3867
+ if (!(!o || !i.style || i.style.cursor !== "pointer") && /:(hover|focus|focus-visible|focus-within|active)\b/i.test(o))
3868
+ for (const s of o.split(",")) {
3869
+ const a = s.replace(INTERACTION_PSEUDO_RE, "").trim();
3870
+ a && a !== "*" && e.add(a);
3871
+ }
3872
+ }
3873
+ }
3874
+ function collectHoverPointerElements(t) {
3875
+ const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
3876
+ try {
3877
+ for (const r of Array.from(document.styleSheets)) {
3878
+ let o = null;
3697
3879
  try {
3698
- v = t.closest(L);
3880
+ o = r.cssRules;
3699
3881
  } catch {
3882
+ continue;
3700
3883
  }
3701
- v && r.push("warning");
3702
- }
3703
- if (e)
3704
- for (const v of e) {
3705
- const y = t.getAttribute(v);
3706
- y !== null && r.push(`${v}="${y}"`);
3884
+ o && collectInteractivePointerSelectors(o, n);
3707
3885
  }
3708
- return r;
3886
+ } catch {
3887
+ return e;
3888
+ }
3889
+ if (n.size === 0) return e;
3890
+ const i = Array.from(n);
3891
+ try {
3892
+ for (const r of deepQuerySelectorAll(i.join(", "), t)) e.add(r);
3893
+ return e;
3894
+ } catch {
3895
+ for (const r of i)
3896
+ try {
3897
+ for (const o of deepQuerySelectorAll(r, t)) e.add(o);
3898
+ } catch {
3899
+ }
3900
+ }
3901
+ return e;
3709
3902
  }
3710
3903
  function isHidden$1(t) {
3711
- if (t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
3904
+ if (isNonContentElement(t) || t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
3712
3905
  try {
3713
3906
  const e = window.getComputedStyle(t);
3714
3907
  if (e.display === "none" || e.visibility === "hidden" || e.opacity === "0") return !0;
@@ -3718,29 +3911,30 @@ function isHidden$1(t) {
3718
3911
  }
3719
3912
  return !1;
3720
3913
  }
3721
- function collectDescendantText(t) {
3722
- let e = "";
3723
- const n = (i) => {
3724
- if (i.nodeType === Node.TEXT_NODE)
3725
- e += (i.textContent ?? "") + " ";
3726
- else if (i.nodeType === Node.ELEMENT_NODE) {
3727
- const r = i;
3728
- if (isHidden$1(r)) return;
3729
- if (r !== t) {
3730
- const o = r.tagName.toLowerCase(), a = inferRole(r), l = ["button", "a", "input", "select", "textarea", "li", "option"].includes(o), c = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(a), u = isTabbable(r);
3731
- let d = !1;
3732
- try {
3733
- d = window.getComputedStyle(r).cursor === "pointer";
3734
- } catch {
3735
- }
3736
- if (u && !(a === "generic" && !d) || l || c)
3914
+ function collectTitleLabel(t) {
3915
+ const e = t.getAttribute("title")?.trim();
3916
+ if (e) return e;
3917
+ const i = t.querySelector("[title]")?.getAttribute("title")?.trim();
3918
+ return i || "";
3919
+ }
3920
+ function collectDescendantText(t, e) {
3921
+ let n = "";
3922
+ const i = (r) => {
3923
+ if (r.nodeType === Node.TEXT_NODE)
3924
+ n += (r.textContent ?? "") + " ";
3925
+ else if (r.nodeType === Node.ELEMENT_NODE) {
3926
+ const o = r;
3927
+ if (o !== t && isNonContentElement(o) || isHidden$1(o) && o !== t || o === t && isNonContentElement(o)) return;
3928
+ if (o !== t) {
3929
+ const s = o.tagName.toLowerCase(), a = resolveA11yRole(o, e), c = ["button", "a", "input", "select", "textarea", "li", "option"].includes(s), d = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(a), u = isTabbable(o), h = hasOwnPointerCursor(o);
3930
+ if (u && !(a === "generic" && !h) || c || d)
3737
3931
  return;
3738
3932
  }
3739
- for (const o of Array.from(r.childNodes))
3740
- n(o);
3933
+ for (const s of Array.from(o.childNodes))
3934
+ i(s);
3741
3935
  }
3742
3936
  };
3743
- return n(t), e.trim().replace(/\s+/g, " ");
3937
+ return i(t), n.trim().replace(/\s+/g, " ");
3744
3938
  }
3745
3939
  function getComposedChildren(t) {
3746
3940
  const e = t.shadowRoot ? t.shadowRoot.children : t.children, n = [];
@@ -3752,6 +3946,37 @@ function getComposedChildren(t) {
3752
3946
  n.push(i);
3753
3947
  return n;
3754
3948
  }
3949
+ function extractTooltipText(t) {
3950
+ const e = t.getAttribute("title");
3951
+ if (e && e.trim())
3952
+ return e.trim().replace(/"/g, '\\"').substring(0, 200);
3953
+ const n = t.getAttribute("aria-describedby");
3954
+ if (n)
3955
+ for (const o of n.split(/\s+/)) {
3956
+ const s = document.getElementById(o);
3957
+ if (s) {
3958
+ const a = (s.textContent || "").trim().replace(/\s+/g, " ");
3959
+ if (a)
3960
+ return a.replace(/"/g, '\\"').substring(0, 200);
3961
+ }
3962
+ }
3963
+ for (const o of ["data-tooltip", "data-tips", "data-tip"]) {
3964
+ const s = t.getAttribute(o);
3965
+ if (s && s.trim())
3966
+ return s.trim().replace(/"/g, '\\"').substring(0, 200);
3967
+ }
3968
+ const i = t.tagName.toLowerCase();
3969
+ if (i === "tp-helptip" || t.closest("tp-helptip")) {
3970
+ const s = (i === "tp-helptip" ? t : t.closest("tp-helptip")).querySelector('.tp-helptip-label, [class*="tp-helptip-label"]');
3971
+ if (s) {
3972
+ const a = (s.textContent || "").trim();
3973
+ if (a)
3974
+ return a.replace(/"/g, '\\"').substring(0, 200);
3975
+ }
3976
+ }
3977
+ const r = t.getAttribute("mattooltip") || t.getAttribute("matTooltip");
3978
+ return r && r.trim() ? r.trim().replace(/"/g, '\\"').substring(0, 200) : "";
3979
+ }
3755
3980
  var toStr = Object.prototype.toString;
3756
3981
  function isCallable(t) {
3757
3982
  return typeof t == "function" || toStr.call(t) === "[object Function]";
@@ -3769,8 +3994,8 @@ function arrayFrom(t, e) {
3769
3994
  var n = Array, i = Object(t);
3770
3995
  if (t == null)
3771
3996
  throw new TypeError("Array.from requires an array-like object - not null or undefined");
3772
- for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), a = 0, l; a < r; )
3773
- l = i[a], o[a] = l, a += 1;
3997
+ for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), s = 0, a; s < r; )
3998
+ a = i[s], o[s] = a, s += 1;
3774
3999
  return o.length = r, o;
3775
4000
  }
3776
4001
  function _typeof$1(t) {
@@ -4175,105 +4400,105 @@ function getSlotContents(t) {
4175
4400
  return e.length === 0 ? arrayFrom(t.childNodes) : e;
4176
4401
  }
4177
4402
  function computeTextAlternative(t) {
4178
- var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = new SetLike$1(), i = safeWindow(t), r = e.compute, o = r === void 0 ? "name" : r, a = e.computedStyleSupportsPseudoElements, l = a === void 0 ? e.getComputedStyle !== void 0 : a, c = e.getComputedStyle, u = c === void 0 ? i.getComputedStyle.bind(i) : c, d = e.hidden, p = d === void 0 ? !1 : d;
4179
- function f(h, x) {
4403
+ var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = new SetLike$1(), i = safeWindow(t), r = e.compute, o = r === void 0 ? "name" : r, s = e.computedStyleSupportsPseudoElements, a = s === void 0 ? e.getComputedStyle !== void 0 : s, c = e.getComputedStyle, d = c === void 0 ? i.getComputedStyle.bind(i) : c, u = e.hidden, h = u === void 0 ? !1 : u;
4404
+ function p(f, b) {
4180
4405
  var T = "";
4181
- if (isElement(h) && l) {
4182
- var L = u(h, "::before"), A = getTextualContent(L);
4183
- T = "".concat(A, " ").concat(T);
4406
+ if (isElement(f) && a) {
4407
+ var y = d(f, "::before"), C = getTextualContent(y);
4408
+ T = "".concat(C, " ").concat(T);
4184
4409
  }
4185
- var v = isHTMLSlotElement(h) ? getSlotContents(h) : arrayFrom(h.childNodes).concat(queryIdRefs(h, "aria-owns"));
4186
- if (v.forEach(function(R) {
4187
- var N = E(R, {
4188
- isEmbeddedInLabel: x.isEmbeddedInLabel,
4410
+ var S = isHTMLSlotElement(f) ? getSlotContents(f) : arrayFrom(f.childNodes).concat(queryIdRefs(f, "aria-owns"));
4411
+ if (S.forEach(function(P) {
4412
+ var R = L(P, {
4413
+ isEmbeddedInLabel: b.isEmbeddedInLabel,
4189
4414
  isReferenced: !1,
4190
4415
  recursion: !0
4191
- }), $ = isElement(R) ? u(R).getPropertyValue("display") : "inline", B = $ !== "inline" ? " " : "";
4192
- T += "".concat(B).concat(N).concat(B);
4193
- }), isElement(h) && l) {
4194
- var y = u(h, "::after"), M = getTextualContent(y);
4195
- T = "".concat(T, " ").concat(M);
4416
+ }), F = isElement(P) ? d(P).getPropertyValue("display") : "inline", B = F !== "inline" ? " " : "";
4417
+ T += "".concat(B).concat(R).concat(B);
4418
+ }), isElement(f) && a) {
4419
+ var A = d(f, "::after"), D = getTextualContent(A);
4420
+ T = "".concat(T, " ").concat(D);
4196
4421
  }
4197
4422
  return T.trim();
4198
4423
  }
4199
- function m(h, x) {
4200
- var T = h.getAttributeNode(x);
4424
+ function m(f, b) {
4425
+ var T = f.getAttributeNode(b);
4201
4426
  return T !== null && !n.has(T) && T.value.trim() !== "" ? (n.add(T), T.value) : null;
4202
4427
  }
4203
- function g(h) {
4204
- return isElement(h) ? m(h, "title") : null;
4428
+ function g(f) {
4429
+ return isElement(f) ? m(f, "title") : null;
4205
4430
  }
4206
- function S(h) {
4207
- if (!isElement(h))
4431
+ function E(f) {
4432
+ if (!isElement(f))
4208
4433
  return null;
4209
- if (isHTMLFieldSetElement(h)) {
4210
- n.add(h);
4211
- for (var x = arrayFrom(h.childNodes), T = 0; T < x.length; T += 1) {
4212
- var L = x[T];
4213
- if (isHTMLLegendElement(L))
4214
- return E(L, {
4434
+ if (isHTMLFieldSetElement(f)) {
4435
+ n.add(f);
4436
+ for (var b = arrayFrom(f.childNodes), T = 0; T < b.length; T += 1) {
4437
+ var y = b[T];
4438
+ if (isHTMLLegendElement(y))
4439
+ return L(y, {
4215
4440
  isEmbeddedInLabel: !1,
4216
4441
  isReferenced: !1,
4217
4442
  recursion: !1
4218
4443
  });
4219
4444
  }
4220
- } else if (isHTMLTableElement(h)) {
4221
- n.add(h);
4222
- for (var A = arrayFrom(h.childNodes), v = 0; v < A.length; v += 1) {
4223
- var y = A[v];
4224
- if (isHTMLTableCaptionElement(y))
4225
- return E(y, {
4445
+ } else if (isHTMLTableElement(f)) {
4446
+ n.add(f);
4447
+ for (var C = arrayFrom(f.childNodes), S = 0; S < C.length; S += 1) {
4448
+ var A = C[S];
4449
+ if (isHTMLTableCaptionElement(A))
4450
+ return L(A, {
4226
4451
  isEmbeddedInLabel: !1,
4227
4452
  isReferenced: !1,
4228
4453
  recursion: !1
4229
4454
  });
4230
4455
  }
4231
- } else if (isSVGSVGElement(h)) {
4232
- n.add(h);
4233
- for (var M = arrayFrom(h.childNodes), R = 0; R < M.length; R += 1) {
4234
- var N = M[R];
4235
- if (isSVGTitleElement(N))
4236
- return N.textContent;
4456
+ } else if (isSVGSVGElement(f)) {
4457
+ n.add(f);
4458
+ for (var D = arrayFrom(f.childNodes), P = 0; P < D.length; P += 1) {
4459
+ var R = D[P];
4460
+ if (isSVGTitleElement(R))
4461
+ return R.textContent;
4237
4462
  }
4238
4463
  return null;
4239
- } else if (getLocalName(h) === "img" || getLocalName(h) === "area") {
4240
- var $ = m(h, "alt");
4241
- if ($ !== null)
4242
- return $;
4243
- } else if (isHTMLOptGroupElement(h)) {
4244
- var B = m(h, "label");
4464
+ } else if (getLocalName(f) === "img" || getLocalName(f) === "area") {
4465
+ var F = m(f, "alt");
4466
+ if (F !== null)
4467
+ return F;
4468
+ } else if (isHTMLOptGroupElement(f)) {
4469
+ var B = m(f, "label");
4245
4470
  if (B !== null)
4246
4471
  return B;
4247
4472
  }
4248
- if (isHTMLInputElement(h) && (h.type === "button" || h.type === "submit" || h.type === "reset")) {
4249
- var K = m(h, "value");
4250
- if (K !== null)
4251
- return K;
4252
- if (h.type === "submit")
4473
+ if (isHTMLInputElement(f) && (f.type === "button" || f.type === "submit" || f.type === "reset")) {
4474
+ var J = m(f, "value");
4475
+ if (J !== null)
4476
+ return J;
4477
+ if (f.type === "submit")
4253
4478
  return "Submit";
4254
- if (h.type === "reset")
4479
+ if (f.type === "reset")
4255
4480
  return "Reset";
4256
4481
  }
4257
- var W = getLabels(h);
4258
- if (W !== null && W.length !== 0)
4259
- return n.add(h), arrayFrom(W).map(function(G) {
4260
- return E(G, {
4482
+ var G = getLabels(f);
4483
+ if (G !== null && G.length !== 0)
4484
+ return n.add(f), arrayFrom(G).map(function(W) {
4485
+ return L(W, {
4261
4486
  isEmbeddedInLabel: !0,
4262
4487
  isReferenced: !1,
4263
4488
  recursion: !0
4264
4489
  });
4265
- }).filter(function(G) {
4266
- return G.length > 0;
4490
+ }).filter(function(W) {
4491
+ return W.length > 0;
4267
4492
  }).join(" ");
4268
- if (isHTMLInputElement(h) && h.type === "image") {
4269
- var J = m(h, "alt");
4270
- if (J !== null)
4271
- return J;
4272
- var ee = m(h, "title");
4493
+ if (isHTMLInputElement(f) && f.type === "image") {
4494
+ var Q = m(f, "alt");
4495
+ if (Q !== null)
4496
+ return Q;
4497
+ var ee = m(f, "title");
4273
4498
  return ee !== null ? ee : "Submit Query";
4274
4499
  }
4275
- if (hasAnyConcreteRoles(h, ["button"])) {
4276
- var te = f(h, {
4500
+ if (hasAnyConcreteRoles(f, ["button"])) {
4501
+ var te = p(f, {
4277
4502
  isEmbeddedInLabel: !1
4278
4503
  });
4279
4504
  if (te !== "")
@@ -4281,16 +4506,16 @@ function computeTextAlternative(t) {
4281
4506
  }
4282
4507
  return null;
4283
4508
  }
4284
- function E(h, x) {
4285
- if (n.has(h))
4509
+ function L(f, b) {
4510
+ if (n.has(f))
4286
4511
  return "";
4287
- if (!p && isHidden(h, u) && !x.isReferenced)
4288
- return n.add(h), "";
4289
- var T = isElement(h) ? h.getAttributeNode("aria-labelledby") : null, L = T !== null && !n.has(T) ? queryIdRefs(h, "aria-labelledby") : [];
4290
- if (o === "name" && !x.isReferenced && L.length > 0)
4291
- return n.add(T), L.map(function($) {
4292
- return E($, {
4293
- isEmbeddedInLabel: x.isEmbeddedInLabel,
4512
+ if (!h && isHidden(f, d) && !b.isReferenced)
4513
+ return n.add(f), "";
4514
+ var T = isElement(f) ? f.getAttributeNode("aria-labelledby") : null, y = T !== null && !n.has(T) ? queryIdRefs(f, "aria-labelledby") : [];
4515
+ if (o === "name" && !b.isReferenced && y.length > 0)
4516
+ return n.add(T), y.map(function(F) {
4517
+ return L(F, {
4518
+ isEmbeddedInLabel: b.isEmbeddedInLabel,
4294
4519
  isReferenced: !0,
4295
4520
  // this isn't recursion as specified, otherwise we would skip
4296
4521
  // `aria-label` in
@@ -4298,53 +4523,53 @@ function computeTextAlternative(t) {
4298
4523
  recursion: !1
4299
4524
  });
4300
4525
  }).join(" ");
4301
- var A = x.recursion && isControl(h) && o === "name";
4302
- if (!A) {
4303
- var v = (isElement(h) && h.getAttribute("aria-label") || "").trim();
4304
- if (v !== "" && o === "name")
4305
- return n.add(h), v;
4306
- if (!isMarkedPresentational(h)) {
4307
- var y = S(h);
4308
- if (y !== null)
4309
- return n.add(h), y;
4526
+ var C = b.recursion && isControl(f) && o === "name";
4527
+ if (!C) {
4528
+ var S = (isElement(f) && f.getAttribute("aria-label") || "").trim();
4529
+ if (S !== "" && o === "name")
4530
+ return n.add(f), S;
4531
+ if (!isMarkedPresentational(f)) {
4532
+ var A = E(f);
4533
+ if (A !== null)
4534
+ return n.add(f), A;
4310
4535
  }
4311
4536
  }
4312
- if (hasAnyConcreteRoles(h, ["menu"]))
4313
- return n.add(h), "";
4314
- if (A || x.isEmbeddedInLabel || x.isReferenced) {
4315
- if (hasAnyConcreteRoles(h, ["combobox", "listbox"])) {
4316
- n.add(h);
4317
- var M = querySelectedOptions(h);
4318
- return M.length === 0 ? isHTMLInputElement(h) ? h.value : "" : arrayFrom(M).map(function($) {
4319
- return E($, {
4320
- isEmbeddedInLabel: x.isEmbeddedInLabel,
4537
+ if (hasAnyConcreteRoles(f, ["menu"]))
4538
+ return n.add(f), "";
4539
+ if (C || b.isEmbeddedInLabel || b.isReferenced) {
4540
+ if (hasAnyConcreteRoles(f, ["combobox", "listbox"])) {
4541
+ n.add(f);
4542
+ var D = querySelectedOptions(f);
4543
+ return D.length === 0 ? isHTMLInputElement(f) ? f.value : "" : arrayFrom(D).map(function(F) {
4544
+ return L(F, {
4545
+ isEmbeddedInLabel: b.isEmbeddedInLabel,
4321
4546
  isReferenced: !1,
4322
4547
  recursion: !0
4323
4548
  });
4324
4549
  }).join(" ");
4325
4550
  }
4326
- if (hasAbstractRole(h, "range"))
4327
- return n.add(h), h.hasAttribute("aria-valuetext") ? h.getAttribute("aria-valuetext") : h.hasAttribute("aria-valuenow") ? h.getAttribute("aria-valuenow") : h.getAttribute("value") || "";
4328
- if (hasAnyConcreteRoles(h, ["textbox"]))
4329
- return n.add(h), getValueOfTextbox(h);
4551
+ if (hasAbstractRole(f, "range"))
4552
+ return n.add(f), f.hasAttribute("aria-valuetext") ? f.getAttribute("aria-valuetext") : f.hasAttribute("aria-valuenow") ? f.getAttribute("aria-valuenow") : f.getAttribute("value") || "";
4553
+ if (hasAnyConcreteRoles(f, ["textbox"]))
4554
+ return n.add(f), getValueOfTextbox(f);
4330
4555
  }
4331
- if (allowsNameFromContent(h) || isElement(h) && x.isReferenced || isNativeHostLanguageTextAlternativeElement(h) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
4332
- var R = f(h, {
4333
- isEmbeddedInLabel: x.isEmbeddedInLabel
4556
+ if (allowsNameFromContent(f) || isElement(f) && b.isReferenced || isNativeHostLanguageTextAlternativeElement(f) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
4557
+ var P = p(f, {
4558
+ isEmbeddedInLabel: b.isEmbeddedInLabel
4334
4559
  });
4335
- if (R !== "")
4336
- return n.add(h), R;
4560
+ if (P !== "")
4561
+ return n.add(f), P;
4337
4562
  }
4338
- if (h.nodeType === h.TEXT_NODE)
4339
- return n.add(h), h.textContent || "";
4340
- if (x.recursion)
4341
- return n.add(h), f(h, {
4342
- isEmbeddedInLabel: x.isEmbeddedInLabel
4563
+ if (f.nodeType === f.TEXT_NODE)
4564
+ return n.add(f), f.textContent || "";
4565
+ if (b.recursion)
4566
+ return n.add(f), p(f, {
4567
+ isEmbeddedInLabel: b.isEmbeddedInLabel
4343
4568
  });
4344
- var N = g(h);
4345
- return N !== null ? (n.add(h), N) : (n.add(h), "");
4569
+ var R = g(f);
4570
+ return R !== null ? (n.add(f), R) : (n.add(f), "");
4346
4571
  }
4347
- return asFlatString(E(t, {
4572
+ return asFlatString(L(t, {
4348
4573
  isEmbeddedInLabel: !1,
4349
4574
  // by spec computeAccessibleDescription starts with the referenced elements as roots
4350
4575
  isReferenced: o === "description",
@@ -4358,42 +4583,105 @@ function computeAccessibleName(t) {
4358
4583
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4359
4584
  return prohibitsNaming(t) ? "" : computeTextAlternative(t, e);
4360
4585
  }
4361
- function buildVNode(t, e, n, i, r, o, a, l, c = !1) {
4362
- if (isHidden$1(t) || i.has(t)) return null;
4363
- const u = inferRole(t), d = getStateTokens(t, o, a, l);
4364
- let p = computeAccessibleName(t);
4365
- const f = isTabbable(t), m = d.includes("cursor=pointer"), g = r.has(t) || (o?.some((v) => t.hasAttribute(v)) ?? !1), S = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
4366
- if (!p.trim()) {
4367
- const v = t.tagName.toLowerCase();
4368
- if (!(v === "select" || u === "combobox" || u === "listbox")) {
4369
- const M = ["button", "a", "input", "textarea", "li", "label"].includes(v);
4370
- (f || g || m || M || u === "listitem" || u === "option") && (p = collectDescendantText(t));
4586
+ const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
4587
+ "button",
4588
+ "link",
4589
+ "textbox",
4590
+ "searchbox",
4591
+ "combobox",
4592
+ "listbox",
4593
+ "checkbox",
4594
+ "radio",
4595
+ "switch",
4596
+ "slider",
4597
+ "spinbutton",
4598
+ "menuitem",
4599
+ "menuitemcheckbox",
4600
+ "menuitemradio",
4601
+ "tab",
4602
+ "treeitem"
4603
+ ]);
4604
+ function buildVNode(t, e, n, i, r, o, s = /* @__PURE__ */ new Set()) {
4605
+ if (isNonContentElement(t) || isHidden$1(t) || i.has(t)) return null;
4606
+ const { role: a, tokens: c } = resolveA11yInfo(t, o), d = extractTooltipText(t);
4607
+ d && c.push(`tooltip="${d}"`);
4608
+ const u = c.some((P) => P.startsWith("tooltip="));
4609
+ let h = computeAccessibleName(t);
4610
+ const p = isTabbable(t), m = c.includes("cursor=pointer"), g = hasOwnPointerCursor(t) || s.has(t), E = r.has(t), L = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
4611
+ if (!h.trim()) {
4612
+ const P = t.tagName.toLowerCase();
4613
+ if (!(P === "select" || a === "combobox" || a === "listbox")) {
4614
+ const F = ["button", "a", "input", "textarea", "li", "label"].includes(P);
4615
+ (p || E || m || g || F || a === "listitem" || a === "option" || a === "button") && (h = collectDescendantText(t, o));
4371
4616
  }
4372
4617
  }
4373
- if (!p.trim() && !(getComposedChildren(t).length > 0)) {
4374
- const y = collectDescendantText(t);
4375
- y && (p = y);
4376
- }
4377
- const E = t.tagName.toLowerCase(), h = E === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(E) && !t.hasAttribute("disabled"), T = f && !(u === "generic" && !m) || g || S || h || !c && m && (u !== "generic" || p !== "");
4378
- let L;
4379
- T && (L = e.value, n.set(L, t), e.value++);
4618
+ if (!h.trim() && (p || E || m || g || a === "button") && (h = collectTitleLabel(t)), !h.trim() && a === "button") {
4619
+ const P = t.getAttribute("name") || "";
4620
+ (P.includes("help") || P.includes("tip") || P.includes("info")) && (h = "帮助");
4621
+ }
4622
+ if (!h.trim() && u) {
4623
+ const P = c.find((R) => R.startsWith("tooltip="));
4624
+ P && (h = P.replace(/^tooltip="/, "").replace(/"$/, ""));
4625
+ }
4626
+ if (!h.trim() && ["tab", "menuitem", "option", "treeitem", "button"].includes(a) && (h = collectVisiblePlainText(t)), !h.trim() && !(getComposedChildren(t).length > 0)) {
4627
+ const R = collectDescendantText(t, o);
4628
+ R && (h = R);
4629
+ }
4630
+ const f = t.tagName.toLowerCase(), b = f === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(f) && !t.hasAttribute("disabled") || a === "button" && m && !["button", "a", "input", "select", "textarea"].includes(f), T = p && !(a === "generic" && !g), y = c.includes("disabled"), C = !y && T || E || L || b || !y && INTERACTIVE_ROLES.has(a) || // hasClickableCursor 已排除 CSS 继承(hasOwnPointerCursor)并覆盖 hover 态手势,
4631
+ // 无需再要求 role≠generic 或 name≠''——否则无文本的图标按钮(tp-icon.common-icon 等)
4632
+ // 虽是真正的可点击边界,仍会因 generic+空名被漏判。
4633
+ !y && g || // 有 tooltip 的元素分配 ref,使 AI 能 hover 触发动态 tip
4634
+ u;
4635
+ let S;
4636
+ C && (S = e.value, n.set(S, t), e.value++);
4380
4637
  const A = [];
4381
- for (const v of getComposedChildren(t)) {
4382
- const y = buildVNode(
4383
- v,
4638
+ for (const P of getComposedChildren(t)) {
4639
+ const R = buildVNode(
4640
+ P,
4384
4641
  e,
4385
4642
  n,
4386
4643
  i,
4387
4644
  r,
4388
4645
  o,
4389
- a,
4390
- l,
4391
- // 将当前节点的交互性向下传递,子节点据此决定是否抑制 cursor=pointer
4392
- T || c
4646
+ s
4393
4647
  );
4394
- y && A.push(y);
4648
+ R && A.push(R);
4649
+ }
4650
+ const D = { role: a, name: h, tokens: c, ref: S, el: t, children: A };
4651
+ return hasInteractiveDescendant(D) && (D.name = getOwnDeclaredName(t)), D;
4652
+ }
4653
+ function getOwnDeclaredName(t) {
4654
+ return t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby") ? computeAccessibleName(t).trim() : "";
4655
+ }
4656
+ function isStaticBranch(t) {
4657
+ return t.ref === void 0 && !hasInteractiveDescendant(t);
4658
+ }
4659
+ function collectVisiblePlainText(t) {
4660
+ return collectDescendantText(t).replace(/\s+/g, " ").trim();
4661
+ }
4662
+ function collectDirectTextNodes(t) {
4663
+ let e = "";
4664
+ for (const n of Array.from(t.childNodes))
4665
+ n.nodeType === Node.TEXT_NODE && (e += (n.textContent ?? "") + " ");
4666
+ return e.replace(/\s+/g, " ").trim();
4667
+ }
4668
+ function getStaticDisplayText(t) {
4669
+ const e = t.children.length > 0 ? t.children.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim() : "", n = t.children.length === 0 ? collectVisiblePlainText(t.el) : "", i = t.name.trim(), r = [];
4670
+ if (i && !isNoiseAccessibleName(i) && r.push(i), e && !isNoiseAccessibleName(e)) {
4671
+ const o = i.replace(/\s+/g, " ").trim(), s = e.replace(/\s+/g, " ").trim();
4672
+ (!o || s !== o && !o.includes(s)) && r.push(e);
4395
4673
  }
4396
- return { role: u, name: p, tokens: d, ref: L, el: t, children: A };
4674
+ return r.length === 0 && n && !isNoiseAccessibleName(n) && r.push(n), r.join(" ").replace(/\s+/g, " ").trim();
4675
+ }
4676
+ function isNoiseAccessibleName(t) {
4677
+ const e = t.trim();
4678
+ return e ? !!(/@font-face\b/i.test(e) || /data:(?:font|application|image)\//i.test(e) || /base64,[A-Za-z0-9+/=]{80,}/.test(e)) : !1;
4679
+ }
4680
+ function canOmitStaticChild(t, e, n) {
4681
+ const i = getStaticDisplayText(t);
4682
+ if (!i || !e.trim()) return !1;
4683
+ const r = e.replace(/\s+/g, " ").trim(), o = i.replace(/\s+/g, " ").trim();
4684
+ return n ? o === r : r.includes(o);
4397
4685
  }
4398
4686
  function hasValue(t) {
4399
4687
  return t.ref !== void 0 || t.name.trim() !== "" ? !0 : t.children.some(hasValue);
@@ -4410,23 +4698,35 @@ function findSingleRefDescendant(t) {
4410
4698
  function shouldPassThrough(t, e) {
4411
4699
  return !(!e.pruneUnnamed || e.preserveRoles.includes(t.role) || t.ref !== void 0 || t.name.trim() !== "");
4412
4700
  }
4701
+ function formatNameAttr(t) {
4702
+ const e = t.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"').trim();
4703
+ return e ? ` "${e}"` : "";
4704
+ }
4413
4705
  function serializeVNode(t, e, n) {
4414
- if (shouldPassThrough(t, n))
4415
- return t.children.filter((p) => hasValue(p)).flatMap((p) => serializeVNode(p, e, n));
4416
- const i = " ".repeat(e), r = t.ref !== void 0 ? ` #${t.ref}` : "", o = t.tokens.map((p) => p.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), a = o.length > 0 ? ` [${o.join(" ")}]` : "";
4706
+ const i = hasInteractiveDescendant(t), r = n.preserveRoles.includes(t.role), o = " ".repeat(e), s = t.ref !== void 0 ? ` #${t.ref}` : "", a = t.tokens.map((y) => y.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), c = a.length > 0 ? ` [${a.join(" ")}]` : "";
4707
+ if (!i && !r) {
4708
+ if (shouldPassThrough(t, n))
4709
+ return t.children.filter((C) => hasValue(C)).flatMap((C) => serializeVNode(C, e, n));
4710
+ let y = t.name.trim();
4711
+ return !y && t.children.length > 0 && (y = collectVisiblePlainText(t.el)), isNoiseAccessibleName(y) && (y = ""), [`${o}- ${t.role}${s}${c}${formatNameAttr(y)}`];
4712
+ }
4713
+ if (!i && r) {
4714
+ const y = getOwnDeclaredName(t.el), C = `${o}- ${t.role}${s}${c}${formatNameAttr(y)}`, S = t.children.flatMap((A) => serializeVNode(A, e + 1, n));
4715
+ return [C, ...S];
4716
+ }
4717
+ const d = getOwnDeclaredName(t.el), u = d !== "", h = t.children.filter(isStaticBranch), p = h.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), m = collectDirectTextNodes(t.el), g = [p, m].filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
4718
+ let E = u ? d : g;
4719
+ if (isNoiseAccessibleName(E) && (E = ""), !u && isNoiseAccessibleName(t.name) && (E = g && !isNoiseAccessibleName(g) ? g : ""), !(t.ref !== void 0 || E !== "" || r || !n.pruneUnnamed))
4720
+ return t.children.filter((y) => hasValue(y)).flatMap((y) => serializeVNode(y, e, n));
4417
4721
  if (t.ref !== void 0) {
4418
- if (!hasInteractiveDescendant(t)) {
4419
- const f = t.name ? t.name.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"') : "", m = f ? ` "${f}"` : "";
4420
- return [`${i}- ${t.role}${r}${a}${m}`];
4421
- }
4422
- const p = findSingleRefDescendant(t);
4423
- if (p && p.role === "generic" && !hasInteractiveDescendant(p)) {
4424
- const f = (t.name.trim() || p.name.trim()).replace(/[\r\n]+/g, " ").replace(/"/g, '\\"'), m = f ? ` "${f}"` : "";
4425
- return [`${i}- ${t.role}${r}${a}${m}`];
4722
+ const y = findSingleRefDescendant(t);
4723
+ if (y && y.role === "generic" && !hasInteractiveDescendant(y) && h.length === 0) {
4724
+ const C = E.trim() || y.name.trim(), S = y.ref !== void 0 ? ` #${y.ref}` : s;
4725
+ return [`${o}- ${t.role}${S}${c}${formatNameAttr(C)}`];
4426
4726
  }
4427
4727
  }
4428
- const l = t.name ? t.name.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"') : "", c = l ? ` "${l}"` : "", u = `${i}- ${t.role}${r}${a}${c}`, d = t.children.flatMap((p) => serializeVNode(p, e + 1, n));
4429
- return [u, ...d];
4728
+ const f = t.children.filter((y) => isStaticBranch(y) ? !canOmitStaticChild(y, E, u) : !0), b = `${o}- ${t.role}${s}${c}${formatNameAttr(E)}`, T = f.flatMap((y) => serializeVNode(y, e + 1, n));
4729
+ return [b, ...T];
4430
4730
  }
4431
4731
  const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAINER_STYLE_ID = "webmcpcli-highlight-container-style", colors = [
4432
4732
  "#FF0000",
@@ -4468,10 +4768,34 @@ const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAI
4468
4768
  padding: 0 2px;
4469
4769
  border-radius: 4px;
4470
4770
  }
4471
- `;
4472
- function isElementViewport(t) {
4771
+ `, MAX_ICON_FALLBACK_SIZE = 48;
4772
+ function resolveHighlightRect(t) {
4473
4773
  const e = t.getBoundingClientRect();
4474
- return e.top >= 0 && e.left >= 0 && e.bottom <= (window.innerHeight || document.documentElement.clientHeight) && e.right <= (window.innerWidth || document.documentElement.clientWidth);
4774
+ if (e.width > 0 && e.height > 0)
4775
+ return { top: e.top, left: e.left, width: e.width, height: e.height };
4776
+ let n = t.parentElement;
4777
+ for (let i = 0; i < 3 && n; i++) {
4778
+ const r = n.getBoundingClientRect();
4779
+ if (r.width > 0 && r.height > 0 && r.width <= MAX_ICON_FALLBACK_SIZE && r.height <= MAX_ICON_FALLBACK_SIZE)
4780
+ return { top: r.top, left: r.left, width: r.width, height: r.height };
4781
+ n = n.parentElement;
4782
+ }
4783
+ if (e.width > 0 || e.height > 0)
4784
+ try {
4785
+ const i = parseFloat(getComputedStyle(t).fontSize) || 16, r = e.width > 0 ? e.width : i, o = e.height > 0 ? e.height : i;
4786
+ return {
4787
+ top: e.height > 0 ? e.top : e.top - (o - e.height) / 2,
4788
+ left: e.width > 0 ? e.left : e.left - (r - e.width) / 2,
4789
+ width: r,
4790
+ height: o
4791
+ };
4792
+ } catch {
4793
+ }
4794
+ return null;
4795
+ }
4796
+ function isRectInViewport(t) {
4797
+ const e = window.innerHeight || document.documentElement.clientHeight, n = window.innerWidth || document.documentElement.clientWidth;
4798
+ return t.top < e && t.top + t.height > 0 && t.left < n && t.left + t.width > 0;
4475
4799
  }
4476
4800
  const doHighlight = (t, e = null) => {
4477
4801
  if (!document.head.querySelector(`#${HIGHLIGHT_CONTAINER_STYLE_ID}`)) {
@@ -4486,33 +4810,32 @@ const doHighlight = (t, e = null) => {
4486
4810
  i.x = o.left, i.y = o.top;
4487
4811
  }
4488
4812
  const r = document.createDocumentFragment();
4489
- for (const [o, a] of t.entries()) {
4490
- if (!isElementViewport(a)) continue;
4491
- const c = colors[o % colors.length] + opacity, u = a.getBoundingClientRect();
4492
- if (u.width === 0 || u.height === 0) continue;
4493
- const d = document.createElement("div");
4494
- d.style.border = `2px solid ${c}`;
4495
- const p = u.top + i.y, f = u.left + i.x;
4496
- d.style.top = `${p}px`, d.style.left = `${f}px`, d.style.width = `${u.width}px`, d.style.height = `${u.height}px`;
4497
- const m = document.createElement("span");
4498
- m.style.backgroundColor = c, m.style.height = `${u.height - 4}px`, m.style.lineHeight = `${u.height - 4}px`, m.textContent = o.toString(), d.appendChild(m), r.appendChild(d);
4813
+ for (const [o, s] of t.entries()) {
4814
+ const a = resolveHighlightRect(s);
4815
+ if (!a) continue;
4816
+ const c = a.top + i.y, d = a.left + i.x, u = { top: c, left: d, width: a.width, height: a.height };
4817
+ if (!isRectInViewport(u)) continue;
4818
+ const p = colors[o % colors.length] + opacity, m = document.createElement("div");
4819
+ m.style.border = `2px solid ${p}`, m.dataset.refIndex = String(o), m.style.top = `${c}px`, m.style.left = `${d}px`, m.style.width = `${a.width}px`, m.style.height = `${a.height}px`;
4820
+ const g = document.createElement("span");
4821
+ g.style.backgroundColor = p, g.style.height = `${Math.max(a.height - 4, 0)}px`, g.style.lineHeight = `${Math.max(a.height - 4, 0)}px`, g.textContent = o.toString(), m.appendChild(g), r.appendChild(m);
4499
4822
  }
4500
4823
  n.appendChild(r);
4501
4824
  }, highlight = (t, e = null) => {
4502
4825
  doHighlight(t, e);
4503
- const r = ((l, c) => {
4504
- let u = 0;
4505
- return (...d) => {
4506
- const p = performance.now();
4507
- if (!(p - u < c))
4508
- return u = p, l(...d);
4826
+ const r = ((a, c) => {
4827
+ let d = 0;
4828
+ return (...u) => {
4829
+ const h = performance.now();
4830
+ if (!(h - d < c))
4831
+ return d = h, a(...u);
4509
4832
  };
4510
4833
  })(() => doHighlight(t, e), 16);
4511
4834
  window.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
4512
4835
  const o = () => {
4513
4836
  window.removeEventListener("scroll", r, !0), window.removeEventListener("resize", r);
4514
- }, a = window;
4515
- (a._highlightCleanupFunctions = a._highlightCleanupFunctions || []).push(o);
4837
+ }, s = window;
4838
+ (s._highlightCleanupFunctions = s._highlightCleanupFunctions || []).push(o);
4516
4839
  }, unhighlight = () => {
4517
4840
  document.getElementById(HIGHLIGHT_CONTAINER_ID)?.remove();
4518
4841
  const t = window._highlightCleanupFunctions || [];
@@ -4539,87 +4862,84 @@ const doHighlight = (t, e = null) => {
4539
4862
  window.location.href !== e && (e = window.location.href, unhighlight());
4540
4863
  }, 500);
4541
4864
  }
4542
- }, DEFAULT_OPTIONS = {
4543
- pruneUnnamed: !0,
4544
- preserveRoles: [],
4545
- exposedAttributes: [],
4546
- errorSelectors: DEFAULT_ERROR_SELECTORS$1,
4547
- warningSelectors: DEFAULT_WARNING_SELECTORS
4548
4865
  };
4549
- function buildA11yTree(t = document.body, e = [], n = [], i) {
4550
- const r = { ...DEFAULT_OPTIONS, ...i }, o = { value: 0 }, a = /* @__PURE__ */ new Map(), l = new Set(e), c = new Set(n), u = [];
4551
- l.add(document.getElementById(HIGHLIGHT_CONTAINER_ID));
4552
- for (const p of getComposedChildren(t)) {
4553
- const f = buildVNode(
4554
- p,
4555
- o,
4556
- a,
4557
- l,
4558
- c,
4559
- r.exposedAttributes,
4560
- r.errorSelectors,
4561
- r.warningSelectors
4562
- );
4563
- f && u.push(...serializeVNode(f, 0, r));
4866
+ function resolveElementList(t, e) {
4867
+ const n = /* @__PURE__ */ new Set();
4868
+ for (const i of t)
4869
+ if (typeof i == "string")
4870
+ try {
4871
+ for (const r of deepQuerySelectorAll(i, e)) n.add(r);
4872
+ } catch {
4873
+ }
4874
+ else i && n.add(i);
4875
+ return n;
4876
+ }
4877
+ function buildA11yTree(t = document.body, e) {
4878
+ const { pruneUnnamed: n = !0, preserveRoles: i = [], ...r } = e ?? {}, o = ensureResolvedA11yConfig(r), s = { pruneUnnamed: n, preserveRoles: i }, a = { value: 0 }, c = /* @__PURE__ */ new Map(), d = resolveElementList(o.blacklist, t), u = resolveElementList(o.whitelist, t), h = [], p = document.getElementById(HIGHLIGHT_CONTAINER_ID);
4879
+ p && d.add(p);
4880
+ const m = collectHoverPointerElements(t);
4881
+ for (const E of getComposedChildren(t)) {
4882
+ const L = buildVNode(E, a, c, d, u, o, m);
4883
+ L && h.push(...serializeVNode(L, 0, s));
4564
4884
  }
4565
4885
  return {
4566
- yaml: "```yaml\n" + u.join(`
4886
+ yaml: "```yaml\n" + h.join(`
4567
4887
  `) + "\n```",
4568
- refMap: a,
4569
- interactiveCount: a.size,
4570
- lines: u
4888
+ refMap: c,
4889
+ interactiveCount: c.size,
4890
+ lines: h
4571
4891
  };
4572
4892
  }
4573
- function searchA11yTree(t, e = document.body, n = [], i = [], r) {
4893
+ function searchA11yTree(t, e = document.body, n) {
4574
4894
  const {
4575
- contextLines: o = 2,
4576
- caseInsensitive: a = !0,
4577
- maxMatches: l = 20,
4578
- ...c
4579
- } = r ?? {}, u = Math.max(0, o), d = Math.max(1, l), { lines: p, refMap: f, yaml: m } = buildA11yTree(e, n, i, c), g = a ? t.toLowerCase() : t, S = p.length, h = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, x = [];
4580
- for (let y = 0; y < p.length; y++) {
4581
- let M = !1;
4582
- h ? M = h.test(p[y]) : M = (a ? p[y].toLowerCase() : p[y]).includes(g), M && x.push(y);
4583
- }
4584
- const T = [];
4585
- let L = !1;
4586
- for (const y of x) {
4587
- const M = Math.max(0, y - u), R = Math.min(S - 1, y + u), N = T[T.length - 1];
4588
- if (N && M <= N.end + 1)
4589
- N.end = Math.max(N.end, R), N.hits.push(y);
4895
+ contextLines: i = 2,
4896
+ caseInsensitive: r = !0,
4897
+ maxMatches: o = 20,
4898
+ ...s
4899
+ } = n ?? {}, a = Math.max(0, i), c = Math.max(1, o), { lines: d, refMap: u, yaml: h } = buildA11yTree(e, s), p = r ? t.toLowerCase() : t, m = d.length, E = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, L = [];
4900
+ for (let C = 0; C < d.length; C++) {
4901
+ let S = !1;
4902
+ E ? S = E.test(d[C]) : S = (r ? d[C].toLowerCase() : d[C]).includes(p), S && L.push(C);
4903
+ }
4904
+ const f = [];
4905
+ let b = !1;
4906
+ for (const C of L) {
4907
+ const S = Math.max(0, C - a), A = Math.min(m - 1, C + a), D = f[f.length - 1];
4908
+ if (D && S <= D.end + 1)
4909
+ D.end = Math.max(D.end, A), D.hits.push(C);
4590
4910
  else {
4591
- if (T.length >= d) {
4592
- L = !0;
4911
+ if (f.length >= c) {
4912
+ b = !0;
4593
4913
  break;
4594
4914
  }
4595
- T.push({ start: M, end: R, hits: [y] });
4915
+ f.push({ start: S, end: A, hits: [C] });
4596
4916
  }
4597
4917
  }
4598
- const A = T.map((y) => ({
4599
- lineNumber: y.hits[0] + 1,
4600
- line: p[y.hits[0]],
4601
- context: Array.from({ length: y.end - y.start + 1 }, (M, R) => ({
4602
- lineNumber: y.start + R + 1,
4603
- line: p[y.start + R]
4918
+ const T = f.map((C) => ({
4919
+ lineNumber: C.hits[0] + 1,
4920
+ line: d[C.hits[0]],
4921
+ context: Array.from({ length: C.end - C.start + 1 }, (S, A) => ({
4922
+ lineNumber: C.start + A + 1,
4923
+ line: d[C.start + A]
4604
4924
  }))
4605
- })), v = [
4606
- `无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${S} | 命中: ${x.length} 行 | 返回分组: ${A.length}`,
4925
+ })), y = [
4926
+ `无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${m} | 命中: ${L.length} 行 | 返回分组: ${T.length}`,
4607
4927
  ""
4608
4928
  ];
4609
- return A.length === 0 ? v.push("(未找到匹配项)") : (A.forEach((y, M) => {
4610
- const R = T[M];
4611
- v.push(`── 分组 ${M + 1}(第 ${R.start + 1}–${R.end + 1} 行)──`), y.context.forEach(({ lineNumber: N, line: $ }) => {
4612
- const B = R.hits.includes(N - 1), K = String(N).padStart(4);
4613
- v.push(B ? `>>>${K} | ${$}` : ` ${K} | ${$}`);
4614
- }), v.push("");
4615
- }), L && v.push(`⚠️ 命中过多,已截断至前 ${d} 个分组,建议缩小搜索范围`), v.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
4616
- text: v.join(`
4929
+ return T.length === 0 ? y.push("(未找到匹配项)") : (T.forEach((C, S) => {
4930
+ const A = f[S];
4931
+ y.push(`── 分组 ${S + 1}(第 ${A.start + 1}–${A.end + 1} 行)──`), C.context.forEach(({ lineNumber: D, line: P }) => {
4932
+ const R = A.hits.includes(D - 1), F = String(D).padStart(4);
4933
+ y.push(R ? `>>>${F} | ${P}` : ` ${F} | ${P}`);
4934
+ }), y.push("");
4935
+ }), b && y.push(`⚠️ 命中过多,已截断至前 ${c} 个分组,建议缩小搜索范围`), y.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
4936
+ text: y.join(`
4617
4937
  `),
4618
- matches: A,
4619
- totalLines: S,
4620
- matchCount: x.length,
4621
- refMap: f,
4622
- yaml: m
4938
+ matches: T,
4939
+ totalLines: m,
4940
+ matchCount: L.length,
4941
+ refMap: u,
4942
+ yaml: h
4623
4943
  };
4624
4944
  }
4625
4945
  function Diff() {
@@ -4628,66 +4948,66 @@ Diff.prototype = {
4628
4948
  diff: function t(e, n) {
4629
4949
  var i, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o = r.callback;
4630
4950
  typeof r == "function" && (o = r, r = {});
4631
- var a = this;
4632
- function l(L) {
4633
- return L = a.postProcess(L, r), o ? (setTimeout(function() {
4634
- o(L);
4635
- }, 0), !0) : L;
4951
+ var s = this;
4952
+ function a(y) {
4953
+ return y = s.postProcess(y, r), o ? (setTimeout(function() {
4954
+ o(y);
4955
+ }, 0), !0) : y;
4636
4956
  }
4637
4957
  e = this.castInput(e, r), n = this.castInput(n, r), e = this.removeEmpty(this.tokenize(e, r)), n = this.removeEmpty(this.tokenize(n, r));
4638
- var c = n.length, u = e.length, d = 1, p = c + u;
4639
- r.maxEditLength != null && (p = Math.min(p, r.maxEditLength));
4640
- var f = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, m = Date.now() + f, g = [{
4958
+ var c = n.length, d = e.length, u = 1, h = c + d;
4959
+ r.maxEditLength != null && (h = Math.min(h, r.maxEditLength));
4960
+ var p = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, m = Date.now() + p, g = [{
4641
4961
  oldPos: -1,
4642
4962
  lastComponent: void 0
4643
- }], S = this.extractCommon(g[0], n, e, 0, r);
4644
- if (g[0].oldPos + 1 >= u && S + 1 >= c)
4645
- return l(buildValues(a, g[0].lastComponent, n, e, a.useLongestToken));
4646
- var E = -1 / 0, h = 1 / 0;
4647
- function x() {
4648
- for (var L = Math.max(E, -d); L <= Math.min(h, d); L += 2) {
4649
- var A = void 0, v = g[L - 1], y = g[L + 1];
4650
- v && (g[L - 1] = void 0);
4651
- var M = !1;
4652
- if (y) {
4653
- var R = y.oldPos - L;
4654
- M = y && 0 <= R && R < c;
4963
+ }], E = this.extractCommon(g[0], n, e, 0, r);
4964
+ if (g[0].oldPos + 1 >= d && E + 1 >= c)
4965
+ return a(buildValues(s, g[0].lastComponent, n, e, s.useLongestToken));
4966
+ var L = -1 / 0, f = 1 / 0;
4967
+ function b() {
4968
+ for (var y = Math.max(L, -u); y <= Math.min(f, u); y += 2) {
4969
+ var C = void 0, S = g[y - 1], A = g[y + 1];
4970
+ S && (g[y - 1] = void 0);
4971
+ var D = !1;
4972
+ if (A) {
4973
+ var P = A.oldPos - y;
4974
+ D = A && 0 <= P && P < c;
4655
4975
  }
4656
- var N = v && v.oldPos + 1 < u;
4657
- if (!M && !N) {
4658
- g[L] = void 0;
4976
+ var R = S && S.oldPos + 1 < d;
4977
+ if (!D && !R) {
4978
+ g[y] = void 0;
4659
4979
  continue;
4660
4980
  }
4661
- if (!N || M && v.oldPos < y.oldPos ? A = a.addToPath(y, !0, !1, 0, r) : A = a.addToPath(v, !1, !0, 1, r), S = a.extractCommon(A, n, e, L, r), A.oldPos + 1 >= u && S + 1 >= c)
4662
- return l(buildValues(a, A.lastComponent, n, e, a.useLongestToken));
4663
- g[L] = A, A.oldPos + 1 >= u && (h = Math.min(h, L - 1)), S + 1 >= c && (E = Math.max(E, L + 1));
4981
+ if (!R || D && S.oldPos < A.oldPos ? C = s.addToPath(A, !0, !1, 0, r) : C = s.addToPath(S, !1, !0, 1, r), E = s.extractCommon(C, n, e, y, r), C.oldPos + 1 >= d && E + 1 >= c)
4982
+ return a(buildValues(s, C.lastComponent, n, e, s.useLongestToken));
4983
+ g[y] = C, C.oldPos + 1 >= d && (f = Math.min(f, y - 1)), E + 1 >= c && (L = Math.max(L, y + 1));
4664
4984
  }
4665
- d++;
4985
+ u++;
4666
4986
  }
4667
4987
  if (o)
4668
- (function L() {
4988
+ (function y() {
4669
4989
  setTimeout(function() {
4670
- if (d > p || Date.now() > m)
4990
+ if (u > h || Date.now() > m)
4671
4991
  return o();
4672
- x() || L();
4992
+ b() || y();
4673
4993
  }, 0);
4674
4994
  })();
4675
4995
  else
4676
- for (; d <= p && Date.now() <= m; ) {
4677
- var T = x();
4996
+ for (; u <= h && Date.now() <= m; ) {
4997
+ var T = b();
4678
4998
  if (T)
4679
4999
  return T;
4680
5000
  }
4681
5001
  },
4682
5002
  addToPath: function t(e, n, i, r, o) {
4683
- var a = e.lastComponent;
4684
- return a && !o.oneChangePerToken && a.added === n && a.removed === i ? {
5003
+ var s = e.lastComponent;
5004
+ return s && !o.oneChangePerToken && s.added === n && s.removed === i ? {
4685
5005
  oldPos: e.oldPos + r,
4686
5006
  lastComponent: {
4687
- count: a.count + 1,
5007
+ count: s.count + 1,
4688
5008
  added: n,
4689
5009
  removed: i,
4690
- previousComponent: a.previousComponent
5010
+ previousComponent: s.previousComponent
4691
5011
  }
4692
5012
  } : {
4693
5013
  oldPos: e.oldPos + r,
@@ -4695,24 +5015,24 @@ Diff.prototype = {
4695
5015
  count: 1,
4696
5016
  added: n,
4697
5017
  removed: i,
4698
- previousComponent: a
5018
+ previousComponent: s
4699
5019
  }
4700
5020
  };
4701
5021
  },
4702
5022
  extractCommon: function t(e, n, i, r, o) {
4703
- for (var a = n.length, l = i.length, c = e.oldPos, u = c - r, d = 0; u + 1 < a && c + 1 < l && this.equals(i[c + 1], n[u + 1], o); )
4704
- u++, c++, d++, o.oneChangePerToken && (e.lastComponent = {
5023
+ for (var s = n.length, a = i.length, c = e.oldPos, d = c - r, u = 0; d + 1 < s && c + 1 < a && this.equals(i[c + 1], n[d + 1], o); )
5024
+ d++, c++, u++, o.oneChangePerToken && (e.lastComponent = {
4705
5025
  count: 1,
4706
5026
  previousComponent: e.lastComponent,
4707
5027
  added: !1,
4708
5028
  removed: !1
4709
5029
  });
4710
- return d && !o.oneChangePerToken && (e.lastComponent = {
4711
- count: d,
5030
+ return u && !o.oneChangePerToken && (e.lastComponent = {
5031
+ count: u,
4712
5032
  previousComponent: e.lastComponent,
4713
5033
  added: !1,
4714
5034
  removed: !1
4715
- }), e.oldPos = c, u;
5035
+ }), e.oldPos = c, d;
4716
5036
  },
4717
5037
  equals: function t(e, n, i) {
4718
5038
  return i.comparator ? i.comparator(e, n) : e === n || i.ignoreCase && e.toLowerCase() === n.toLowerCase();
@@ -4736,23 +5056,23 @@ Diff.prototype = {
4736
5056
  }
4737
5057
  };
4738
5058
  function buildValues(t, e, n, i, r) {
4739
- for (var o = [], a; e; )
4740
- o.push(e), a = e.previousComponent, delete e.previousComponent, e = a;
5059
+ for (var o = [], s; e; )
5060
+ o.push(e), s = e.previousComponent, delete e.previousComponent, e = s;
4741
5061
  o.reverse();
4742
- for (var l = 0, c = o.length, u = 0, d = 0; l < c; l++) {
4743
- var p = o[l];
4744
- if (p.removed)
4745
- p.value = t.join(i.slice(d, d + p.count)), d += p.count;
5062
+ for (var a = 0, c = o.length, d = 0, u = 0; a < c; a++) {
5063
+ var h = o[a];
5064
+ if (h.removed)
5065
+ h.value = t.join(i.slice(u, u + h.count)), u += h.count;
4746
5066
  else {
4747
- if (!p.added && r) {
4748
- var f = n.slice(u, u + p.count);
4749
- f = f.map(function(m, g) {
4750
- var S = i[d + g];
4751
- return S.length > m.length ? S : m;
4752
- }), p.value = t.join(f);
5067
+ if (!h.added && r) {
5068
+ var p = n.slice(d, d + h.count);
5069
+ p = p.map(function(m, g) {
5070
+ var E = i[u + g];
5071
+ return E.length > m.length ? E : m;
5072
+ }), h.value = t.join(p);
4753
5073
  } else
4754
- p.value = t.join(n.slice(u, u + p.count));
4755
- u += p.count, p.added || (d += p.count);
5074
+ h.value = t.join(n.slice(d, d + h.count));
5075
+ d += h.count, h.added || (u += h.count);
4756
5076
  }
4757
5077
  }
4758
5078
  return o;
@@ -4801,16 +5121,16 @@ function overlapCount(t, e) {
4801
5121
  t.length < e.length && (i = t.length);
4802
5122
  var r = Array(i), o = 0;
4803
5123
  r[0] = 0;
4804
- for (var a = 1; a < i; a++) {
4805
- for (e[a] == e[o] ? r[a] = r[o] : r[a] = o; o > 0 && e[a] != e[o]; )
5124
+ for (var s = 1; s < i; s++) {
5125
+ for (e[s] == e[o] ? r[s] = r[o] : r[s] = o; o > 0 && e[s] != e[o]; )
4806
5126
  o = r[o];
4807
- e[a] == e[o] && o++;
5127
+ e[s] == e[o] && o++;
4808
5128
  }
4809
5129
  o = 0;
4810
- for (var l = n; l < t.length; l++) {
4811
- for (; o > 0 && t[l] != e[o]; )
5130
+ for (var a = n; a < t.length; a++) {
5131
+ for (; o > 0 && t[a] != e[o]; )
4812
5132
  o = r[o];
4813
- t[l] == e[o] && o++;
5133
+ t[a] == e[o] && o++;
4814
5134
  }
4815
5135
  return o;
4816
5136
  }
@@ -4848,28 +5168,28 @@ wordDiff.postProcess = function(t, e) {
4848
5168
  };
4849
5169
  function dedupeWhitespaceInChangeObjects(t, e, n, i) {
4850
5170
  if (e && n) {
4851
- var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], a = n.value.match(/^\s*/)[0], l = n.value.match(/\s*$/)[0];
5171
+ var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], s = n.value.match(/^\s*/)[0], a = n.value.match(/\s*$/)[0];
4852
5172
  if (t) {
4853
- var c = longestCommonPrefix(r, a);
4854
- t.value = replaceSuffix(t.value, a, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
5173
+ var c = longestCommonPrefix(r, s);
5174
+ t.value = replaceSuffix(t.value, s, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
4855
5175
  }
4856
5176
  if (i) {
4857
- var u = longestCommonSuffix(o, l);
4858
- i.value = replacePrefix(i.value, l, u), e.value = removeSuffix(e.value, u), n.value = removeSuffix(n.value, u);
5177
+ var d = longestCommonSuffix(o, a);
5178
+ i.value = replacePrefix(i.value, a, d), e.value = removeSuffix(e.value, d), n.value = removeSuffix(n.value, d);
4859
5179
  }
4860
5180
  } else if (n)
4861
5181
  t && (n.value = n.value.replace(/^\s*/, "")), i && (i.value = i.value.replace(/^\s*/, ""));
4862
5182
  else if (t && i) {
4863
- var d = i.value.match(/^\s*/)[0], p = e.value.match(/^\s*/)[0], f = e.value.match(/\s*$/)[0], m = longestCommonPrefix(d, p);
5183
+ var u = i.value.match(/^\s*/)[0], h = e.value.match(/^\s*/)[0], p = e.value.match(/\s*$/)[0], m = longestCommonPrefix(u, h);
4864
5184
  e.value = removePrefix(e.value, m);
4865
- var g = longestCommonSuffix(removePrefix(d, m), f);
4866
- e.value = removeSuffix(e.value, g), i.value = replacePrefix(i.value, d, g), t.value = replaceSuffix(t.value, d, d.slice(0, d.length - g.length));
5185
+ var g = longestCommonSuffix(removePrefix(u, m), p);
5186
+ e.value = removeSuffix(e.value, g), i.value = replacePrefix(i.value, u, g), t.value = replaceSuffix(t.value, u, u.slice(0, u.length - g.length));
4867
5187
  } else if (i) {
4868
- var S = i.value.match(/^\s*/)[0], E = e.value.match(/\s*$/)[0], h = maximumOverlap(E, S);
4869
- e.value = removeSuffix(e.value, h);
5188
+ var E = i.value.match(/^\s*/)[0], L = e.value.match(/\s*$/)[0], f = maximumOverlap(L, E);
5189
+ e.value = removeSuffix(e.value, f);
4870
5190
  } else if (t) {
4871
- var x = t.value.match(/\s*$/)[0], T = e.value.match(/^\s*/)[0], L = maximumOverlap(x, T);
4872
- e.value = removePrefix(e.value, L);
5191
+ var b = t.value.match(/\s*$/)[0], T = e.value.match(/^\s*/)[0], y = maximumOverlap(b, T);
5192
+ e.value = removePrefix(e.value, y);
4873
5193
  }
4874
5194
  }
4875
5195
  var wordWithSpaceDiff = new Diff();
@@ -4919,8 +5239,8 @@ var jsonDiff = new Diff();
4919
5239
  jsonDiff.useLongestToken = !0;
4920
5240
  jsonDiff.tokenize = lineDiff.tokenize;
4921
5241
  jsonDiff.castInput = function(t, e) {
4922
- var n = e.undefinedReplacement, i = e.stringifyReplacer, r = i === void 0 ? function(o, a) {
4923
- return typeof a > "u" ? n : a;
5242
+ var n = e.undefinedReplacement, i = e.stringifyReplacer, r = i === void 0 ? function(o, s) {
5243
+ return typeof s > "u" ? n : s;
4924
5244
  } : i;
4925
5245
  return typeof t == "string" ? t : JSON.stringify(canonicalize(t, null, null, r), r, " ");
4926
5246
  };
@@ -4933,23 +5253,23 @@ function canonicalize(t, e, n, i, r) {
4933
5253
  for (o = 0; o < e.length; o += 1)
4934
5254
  if (e[o] === t)
4935
5255
  return n[o];
4936
- var a;
5256
+ var s;
4937
5257
  if (Object.prototype.toString.call(t) === "[object Array]") {
4938
- for (e.push(t), a = new Array(t.length), n.push(a), o = 0; o < t.length; o += 1)
4939
- a[o] = canonicalize(t[o], e, n, i, r);
4940
- return e.pop(), n.pop(), a;
5258
+ for (e.push(t), s = new Array(t.length), n.push(s), o = 0; o < t.length; o += 1)
5259
+ s[o] = canonicalize(t[o], e, n, i, r);
5260
+ return e.pop(), n.pop(), s;
4941
5261
  }
4942
5262
  if (t && t.toJSON && (t = t.toJSON()), _typeof(t) === "object" && t !== null) {
4943
- e.push(t), a = {}, n.push(a);
4944
- var l = [], c;
5263
+ e.push(t), s = {}, n.push(s);
5264
+ var a = [], c;
4945
5265
  for (c in t)
4946
- Object.prototype.hasOwnProperty.call(t, c) && l.push(c);
4947
- for (l.sort(), o = 0; o < l.length; o += 1)
4948
- c = l[o], a[c] = canonicalize(t[c], e, n, i, c);
5266
+ Object.prototype.hasOwnProperty.call(t, c) && a.push(c);
5267
+ for (a.sort(), o = 0; o < a.length; o += 1)
5268
+ c = a[o], s[c] = canonicalize(t[c], e, n, i, c);
4949
5269
  e.pop(), n.pop();
4950
5270
  } else
4951
- a = t;
4952
- return a;
5271
+ s = t;
5272
+ return s;
4953
5273
  }
4954
5274
  var arrayDiff = new Diff();
4955
5275
  arrayDiff.tokenize = function(t) {
@@ -4973,18 +5293,18 @@ class PageStateCache {
4973
5293
  */
4974
5294
  update(e, n) {
4975
5295
  const i = this.isFullRefresh(e), r = this.prev?.url ?? "";
4976
- let o = 0, a = 0, l = "";
5296
+ let o = 0, s = 0, a = "";
4977
5297
  if (!i && this.prev) {
4978
- const c = diffLines(this.prev.yaml, n), u = [];
4979
- c.forEach((d) => {
4980
- if (!d.added && !d.removed) return;
4981
- const p = d.value.split(`
5298
+ const c = diffLines(this.prev.yaml, n), d = [];
5299
+ c.forEach((u) => {
5300
+ if (!u.added && !u.removed) return;
5301
+ const h = u.value.split(`
4982
5302
  `).filter(Boolean);
4983
- d.added ? (o += p.length, p.forEach((f) => u.push(`+ ${f}`))) : (a += p.length, p.forEach((f) => u.push(`- ${f}`)));
4984
- }), l = u.join(`
5303
+ u.added ? (o += h.length, h.forEach((p) => d.push(`+ ${p}`))) : (s += h.length, h.forEach((p) => d.push(`- ${p}`)));
5304
+ }), a = d.join(`
4985
5305
  `);
4986
5306
  }
4987
- return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: a, diffText: l };
5307
+ return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: s, diffText: a };
4988
5308
  }
4989
5309
  /** 强制清空缓存(页面刷新 / 手动重置场景) */
4990
5310
  invalidate() {
@@ -4992,114 +5312,114 @@ class PageStateCache {
4992
5312
  }
4993
5313
  }
4994
5314
  function computeBorderGeometry(t, e, n, i) {
4995
- const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), l = Math.min(o + i, r), c = Math.min(l, Math.floor(t / 2)), u = Math.min(l, Math.floor(e / 2)), d = (b) => b / t * 2 - 1, p = (b) => b / e * 2 - 1, f = 0, m = t, g = 0, S = e, E = c, h = t - c, x = u, T = e - u, L = d(f), A = d(m), v = p(g), y = p(S), M = d(E), R = d(h), N = p(x), $ = p(T), B = 0, K = 0, W = 1, J = 1, ee = c / t, te = 1 - c / t, G = u / e, V = 1 - u / e, ce = new Float32Array([
5315
+ const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), a = Math.min(o + i, r), c = Math.min(a, Math.floor(t / 2)), d = Math.min(a, Math.floor(e / 2)), u = (w) => w / t * 2 - 1, h = (w) => w / e * 2 - 1, p = 0, m = t, g = 0, E = e, L = c, f = t - c, b = d, T = e - d, y = u(p), C = u(m), S = h(g), A = h(E), D = u(L), P = u(f), R = h(b), F = h(T), B = 0, J = 0, G = 1, Q = 1, ee = c / t, te = 1 - c / t, W = d / e, Z = 1 - d / e, ce = new Float32Array([
4996
5316
  // Top strip
4997
- L,
4998
- v,
4999
- A,
5000
- v,
5001
- L,
5002
- N,
5003
- L,
5004
- N,
5005
- A,
5006
- v,
5007
- A,
5008
- N,
5317
+ y,
5318
+ S,
5319
+ C,
5320
+ S,
5321
+ y,
5322
+ R,
5323
+ y,
5324
+ R,
5325
+ C,
5326
+ S,
5327
+ C,
5328
+ R,
5009
5329
  // Bottom strip
5010
- L,
5011
- $,
5012
- A,
5013
- $,
5014
- L,
5015
5330
  y,
5016
- L,
5331
+ F,
5332
+ C,
5333
+ F,
5017
5334
  y,
5018
5335
  A,
5019
- $,
5020
- A,
5021
5336
  y,
5337
+ A,
5338
+ C,
5339
+ F,
5340
+ C,
5341
+ A,
5022
5342
  // Left strip
5023
- L,
5024
- N,
5025
- M,
5026
- N,
5027
- L,
5028
- $,
5029
- L,
5030
- $,
5031
- M,
5032
- N,
5033
- M,
5034
- $,
5343
+ y,
5344
+ R,
5345
+ D,
5346
+ R,
5347
+ y,
5348
+ F,
5349
+ y,
5350
+ F,
5351
+ D,
5352
+ R,
5353
+ D,
5354
+ F,
5035
5355
  // Right strip
5356
+ P,
5036
5357
  R,
5037
- N,
5038
- A,
5039
- N,
5358
+ C,
5040
5359
  R,
5041
- $,
5360
+ P,
5361
+ F,
5362
+ P,
5363
+ F,
5364
+ C,
5042
5365
  R,
5043
- $,
5044
- A,
5045
- N,
5046
- A,
5047
- $
5048
- ]), s = new Float32Array([
5366
+ C,
5367
+ F
5368
+ ]), l = new Float32Array([
5049
5369
  // Top strip
5050
5370
  B,
5051
- K,
5052
- W,
5053
- K,
5054
- B,
5371
+ J,
5055
5372
  G,
5373
+ J,
5056
5374
  B,
5057
- G,
5058
5375
  W,
5059
- K,
5376
+ B,
5060
5377
  W,
5061
5378
  G,
5379
+ J,
5380
+ G,
5381
+ W,
5062
5382
  // Bottom strip
5063
5383
  B,
5064
- V,
5065
- W,
5066
- V,
5384
+ Z,
5385
+ G,
5386
+ Z,
5067
5387
  B,
5068
- J,
5388
+ Q,
5069
5389
  B,
5070
- J,
5071
- W,
5072
- V,
5073
- W,
5074
- J,
5390
+ Q,
5391
+ G,
5392
+ Z,
5393
+ G,
5394
+ Q,
5075
5395
  // Left strip
5076
5396
  B,
5077
- G,
5397
+ W,
5078
5398
  ee,
5079
- G,
5399
+ W,
5080
5400
  B,
5081
- V,
5401
+ Z,
5082
5402
  B,
5083
- V,
5403
+ Z,
5084
5404
  ee,
5085
- G,
5405
+ W,
5086
5406
  ee,
5087
- V,
5407
+ Z,
5088
5408
  // Right strip
5089
5409
  te,
5090
- G,
5091
5410
  W,
5092
5411
  G,
5412
+ W,
5093
5413
  te,
5094
- V,
5414
+ Z,
5095
5415
  te,
5096
- V,
5097
- W,
5416
+ Z,
5098
5417
  G,
5099
5418
  W,
5100
- V
5419
+ G,
5420
+ Z
5101
5421
  ]);
5102
- return { positions: ce, uvs: s };
5422
+ return { positions: ce, uvs: l };
5103
5423
  }
5104
5424
  function compileShader(t, e, n) {
5105
5425
  const i = t.createShader(e);
@@ -5114,8 +5434,8 @@ function createProgram(t, e, n) {
5114
5434
  const i = compileShader(t, t.VERTEX_SHADER, e), r = compileShader(t, t.FRAGMENT_SHADER, n), o = t.createProgram();
5115
5435
  if (!o) throw new Error("Failed to create program");
5116
5436
  if (t.attachShader(o, i), t.attachShader(o, r), t.linkProgram(o), !t.getProgramParameter(o, t.LINK_STATUS)) {
5117
- const a = t.getProgramInfoLog(o) || "Unknown link error";
5118
- throw t.deleteProgram(o), t.deleteShader(i), t.deleteShader(r), new Error(a);
5437
+ const s = t.getProgramInfoLog(o) || "Unknown link error";
5438
+ throw t.deleteProgram(o), t.deleteShader(i), t.deleteShader(r), new Error(s);
5119
5439
  }
5120
5440
  return t.deleteShader(i), t.deleteShader(r), o;
5121
5441
  }
@@ -5298,23 +5618,23 @@ class Motion {
5298
5618
  resize(e, n, i) {
5299
5619
  if (this.disposed) throw new Error("Motion instance has been disposed.");
5300
5620
  if (this.options.width = e, this.options.height = n, i && (this.options.ratio = i), !this.running) return;
5301
- const { gl: r, program: o, vao: a, positionBuffer: l, uvBuffer: c, uResolution: u } = this.glr, d = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, p = Math.max(1, Math.floor(e * d)), f = Math.max(1, Math.floor(n * d));
5302
- this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== p || this.canvas.height !== f) && (this.canvas.width = p, this.canvas.height = f), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
5621
+ const { gl: r, program: o, vao: s, positionBuffer: a, uvBuffer: c, uResolution: d } = this.glr, u = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, h = Math.max(1, Math.floor(e * u)), p = Math.max(1, Math.floor(n * u));
5622
+ this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== h || this.canvas.height !== p) && (this.canvas.width = h, this.canvas.height = p), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
5303
5623
  const { positions: m, uvs: g } = computeBorderGeometry(
5304
5624
  this.canvas.width,
5305
5625
  this.canvas.height,
5306
- this.options.borderWidth * d,
5307
- this.options.glowWidth * d
5626
+ this.options.borderWidth * u,
5627
+ this.options.glowWidth * u
5308
5628
  );
5309
- r.bindVertexArray(a), r.bindBuffer(r.ARRAY_BUFFER, l), r.bufferData(r.ARRAY_BUFFER, m, r.STATIC_DRAW);
5310
- const S = r.getAttribLocation(o, "aPosition");
5311
- r.enableVertexAttribArray(S), r.vertexAttribPointer(S, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after position buffer update"), r.bindBuffer(r.ARRAY_BUFFER, c), r.bufferData(r.ARRAY_BUFFER, g, r.STATIC_DRAW);
5312
- const E = r.getAttribLocation(o, "aUV");
5313
- r.enableVertexAttribArray(E), r.vertexAttribPointer(E, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after UV buffer update"), r.useProgram(o), r.uniform2f(u, this.canvas.width, this.canvas.height), r.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * d), r.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * d), r.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * d), this.checkGLError(r, "resize: after uniform updates");
5314
- const h = performance.now();
5315
- this.lastTime = h;
5316
- const x = (h - this.startTime) * 1e-3;
5317
- this.render(x);
5629
+ r.bindVertexArray(s), r.bindBuffer(r.ARRAY_BUFFER, a), r.bufferData(r.ARRAY_BUFFER, m, r.STATIC_DRAW);
5630
+ const E = r.getAttribLocation(o, "aPosition");
5631
+ r.enableVertexAttribArray(E), r.vertexAttribPointer(E, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after position buffer update"), r.bindBuffer(r.ARRAY_BUFFER, c), r.bufferData(r.ARRAY_BUFFER, g, r.STATIC_DRAW);
5632
+ const L = r.getAttribLocation(o, "aUV");
5633
+ r.enableVertexAttribArray(L), r.vertexAttribPointer(L, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after UV buffer update"), r.useProgram(o), r.uniform2f(d, this.canvas.width, this.canvas.height), r.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * u), r.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * u), r.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * u), this.checkGLError(r, "resize: after uniform updates");
5634
+ const f = performance.now();
5635
+ this.lastTime = f;
5636
+ const b = (f - this.startTime) * 1e-3;
5637
+ this.render(b);
5318
5638
  }
5319
5639
  /**
5320
5640
  * Automatically resizes the canvas to match the dimensions of the given element.
@@ -5388,36 +5708,36 @@ class Motion {
5388
5708
  this.checkGLError(e, "setupGL: after createProgram");
5389
5709
  const i = e.createVertexArray();
5390
5710
  e.bindVertexArray(i), this.checkGLError(e, "setupGL: after VAO creation");
5391
- const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: a, uvs: l } = computeBorderGeometry(
5711
+ const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: s, uvs: a } = computeBorderGeometry(
5392
5712
  r,
5393
5713
  o,
5394
5714
  this.options.borderWidth,
5395
5715
  this.options.glowWidth
5396
5716
  ), c = e.createBuffer();
5397
- e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
5398
- const u = e.getAttribLocation(n, "aPosition");
5399
- e.enableVertexAttribArray(u), e.vertexAttribPointer(u, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
5400
- const d = e.createBuffer();
5401
- e.bindBuffer(e.ARRAY_BUFFER, d), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
5402
- const p = e.getAttribLocation(n, "aUV");
5403
- e.enableVertexAttribArray(p), e.vertexAttribPointer(p, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
5404
- const f = e.getUniformLocation(n, "uResolution"), m = e.getUniformLocation(n, "uTime"), g = e.getUniformLocation(n, "uBorderWidth"), S = e.getUniformLocation(n, "uGlowWidth"), E = e.getUniformLocation(n, "uBorderRadius"), h = e.getUniformLocation(n, "uColors"), x = e.getUniformLocation(n, "uGlowExponent"), T = e.getUniformLocation(n, "uGlowFactor");
5405
- e.useProgram(n), e.uniform1f(g, this.options.borderWidth), e.uniform1f(S, this.options.glowWidth), e.uniform1f(E, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(x, 2), e.uniform1f(T, 1.8)) : (e.uniform1f(x, 1), e.uniform1f(T, 1));
5406
- const L = (this.options.colors || DEFAULT_COLORS).map(parseColor);
5407
- for (let A = 0; A < L.length; A++)
5408
- e.uniform3f(e.getUniformLocation(n, `uColors[${A}]`), ...L[A]);
5717
+ e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, s, e.STATIC_DRAW);
5718
+ const d = e.getAttribLocation(n, "aPosition");
5719
+ e.enableVertexAttribArray(d), e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
5720
+ const u = e.createBuffer();
5721
+ e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
5722
+ const h = e.getAttribLocation(n, "aUV");
5723
+ e.enableVertexAttribArray(h), e.vertexAttribPointer(h, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
5724
+ const p = e.getUniformLocation(n, "uResolution"), m = e.getUniformLocation(n, "uTime"), g = e.getUniformLocation(n, "uBorderWidth"), E = e.getUniformLocation(n, "uGlowWidth"), L = e.getUniformLocation(n, "uBorderRadius"), f = e.getUniformLocation(n, "uColors"), b = e.getUniformLocation(n, "uGlowExponent"), T = e.getUniformLocation(n, "uGlowFactor");
5725
+ e.useProgram(n), e.uniform1f(g, this.options.borderWidth), e.uniform1f(E, this.options.glowWidth), e.uniform1f(L, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(b, 2), e.uniform1f(T, 1.8)) : (e.uniform1f(b, 1), e.uniform1f(T, 1));
5726
+ const y = (this.options.colors || DEFAULT_COLORS).map(parseColor);
5727
+ for (let C = 0; C < y.length; C++)
5728
+ e.uniform3f(e.getUniformLocation(n, `uColors[${C}]`), ...y[C]);
5409
5729
  this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
5410
5730
  gl: e,
5411
5731
  program: n,
5412
5732
  vao: i,
5413
5733
  positionBuffer: c,
5414
- uvBuffer: d,
5415
- uResolution: f,
5734
+ uvBuffer: u,
5735
+ uResolution: p,
5416
5736
  uTime: m,
5417
5737
  uBorderWidth: g,
5418
- uGlowWidth: S,
5419
- uBorderRadius: E,
5420
- uColors: h
5738
+ uGlowWidth: E,
5739
+ uBorderRadius: L,
5740
+ uColors: f
5421
5741
  };
5422
5742
  }
5423
5743
  render(e) {
@@ -5474,8 +5794,8 @@ function isMainContentBackgroundDark() {
5474
5794
  for (const r of i) {
5475
5795
  const o = document.querySelector(r);
5476
5796
  if (!o) continue;
5477
- const a = o.getBoundingClientRect();
5478
- if (!(a.width * a.height < n) && isColorDark(window.getComputedStyle(o).backgroundColor))
5797
+ const s = o.getBoundingClientRect();
5798
+ if (!(s.width * s.height < n) && isColorDark(window.getComputedStyle(o).backgroundColor))
5479
5799
  return !0;
5480
5800
  }
5481
5801
  return !1;
@@ -5507,31 +5827,15 @@ const injectStyles = `
5507
5827
  z-index: 10000;
5508
5828
  }
5509
5829
 
5510
- .webmcp-page-agent-cursorBorder {
5511
- position: absolute;
5512
- width: 100%;
5513
- height: 100%;
5514
- background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));
5515
- mask-image: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");
5516
- mask-size: 100% 100%;
5517
- mask-repeat: no-repeat;
5518
-
5519
- transform-origin: center;
5520
- transform: rotate(-90deg) scale(0.8);
5521
- margin-left: -10px;
5522
- margin-top: -18px;
5523
- }
5524
-
5525
5830
  .webmcp-page-agent-cursorFilling {
5526
5831
  position: absolute;
5527
5832
  width: 100%;
5528
5833
  height: 100%;
5529
- background: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");
5530
- background-size: 100% 100%;
5834
+ background: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2079.0834%2079.4553%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20%20width%3D%2779.083374%27%20height%3D%2779.455322%27%20fill%3D%27none%27%20%3E--%3Cdefs%3E%3Cfilter%20id%3D%27filter_0%27%20width%3D%2779.083374%27%20height%3D%2779.455322%27%20x%3D%270.000000%27%20y%3D%270.000000%27%20filterUnits%3D%27userSpaceOnUse%27%20%20color-interpolation-filters%3D%27sRGB%27%3E%3CfeFlood%20flood-opacity%3D%270%27%20result%3D%27BackgroundImageFix%27%20%2F%3E%3CfeOffset%20dx%3D%276.000000%27%20dy%3D%276.000000%27%20in%3D%27SourceAlpha%27%20%2F%3E%3CfeGaussianBlur%20stdDeviation%3D%276.66666651%27%20%2F%3E%3CfeColorMatrix%20type%3D%27matrix%27%20values%3D%270%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.18%200%20%27%20%2F%3E%3CfeBlend%20result%3D%27effect_dropShadow_1%27%20in2%3D%27BackgroundImageFix%27%20mode%3D%27normal%27%20%2F%3E%3CfeBlend%20result%3D%27shape%27%20in%3D%27SourceGraphic%27%20in2%3D%27effect_dropShadow_1%27%20mode%3D%27normal%27%20%2F%3E%3C%2Ffilter%3E%3ClinearGradient%20id%3D%27paint_linear_0%27%20x1%3D%2718.4743214%27%20x2%3D%2718.4213886%27%20y1%3D%27-1.86264515e-09%27%20y2%3D%2734.9221306%27%20gradientUnits%3D%27userSpaceOnUse%27%3E%3Cstop%20stop-color%3D%27rgb%28255%2C181%2C96%29%27%20offset%3D%270%27%20stop-opacity%3D%271%27%20%2F%3E%3Cstop%20stop-color%3D%27rgb%28255%2C120%2C114%29%27%20offset%3D%270.5%27%20stop-opacity%3D%271%27%20%2F%3E%3Cstop%20stop-color%3D%27rgb%28241%2C109%2C237%29%27%20offset%3D%271%27%20stop-opacity%3D%271%27%20%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cg%20filter%3D%27url%28%23filter_0%29%27%3E%3Cpath%20d%3D%27M20.2632%203.57771L34.6257%2032.3027C35.4444%2033.9402%2033.8152%2035.7258%2032.1097%2035.0603L19.2014%2030.0229C18.7339%2029.8404%2018.2148%2029.8404%2017.7472%2030.0229L4.83891%2035.0603C3.13343%2035.7258%201.50423%2033.9402%202.32297%2032.3027L16.6855%203.57771C17.4225%202.10361%2019.5261%202.10361%2020.2632%203.57771Z%27%20fill%3D%27url%28%23paint_linear_0%29%27%20fill-rule%3D%27evenodd%27%20transform%3D%27matrix%280.719908%2C-0.69407%2C0.69407%2C0.719908%2C2.00256%2C28.0095%29%27%20%2F%3E%3Cpath%20d%3D%27M37.2169%2032.6848C37.1578%2032.189%2037.0096%2031.7039%2036.7723%2031.2294L22.4098%202.5044C22.1973%202.07946%2021.9328%201.70554%2021.6163%201.38261C21.3524%201.11342%2021.0524%200.879671%2020.7162%200.681366C20.3925%200.490407%2020.0558%200.34434%2019.7061%200.243163C19.312%200.129145%2018.9014%200.0721366%2018.4743%200.0721366C18.0472%200.0721366%2017.6367%200.129145%2017.2426%200.243163C16.8929%200.34434%2016.5562%200.490407%2016.2324%200.681366C15.8962%200.879671%2015.5962%201.11342%2015.3323%201.38261C15.0158%201.70553%2014.7513%202.07946%2014.5388%202.5044L0.176342%2031.2294C-0.0609121%2031.7039%20-0.209128%2032.189%20-0.268305%2032.6848C-0.316251%2033.0865%20-0.305747%2033.4951%20-0.236792%2033.9108C-0.171059%2034.307%20-0.0570567%2034.6809%200.105216%2035.0326C0.292784%2035.4391%200.544845%2035.8158%200.861397%2036.1627C1.17794%2036.5097%201.53001%2036.7951%201.91761%2037.0191C2.25297%2037.2128%202.61492%2037.3606%203.00348%2037.4623C3.41106%2037.5689%203.81704%2037.6168%204.22142%2037.6058C4.72053%2037.5922%205.21719%2037.4889%205.71141%2037.2961L18.4743%2032.3154L31.2372%2037.2961C31.7315%2037.4889%2032.2281%2037.5922%2032.7272%2037.6058C33.1316%2037.6168%2033.5376%2037.5689%2033.9452%2037.4623C34.3337%2037.3606%2034.6957%2037.2128%2035.0311%2037.0191C35.4187%2036.7951%2035.7707%2036.5097%2036.0873%2036.1627C36.4038%2035.8158%2036.6558%2035.4391%2036.8434%2035.0327C37.0057%2034.681%2037.1197%2034.307%2037.1854%2033.9108C37.2544%2033.4951%2037.2649%2033.0865%2037.2169%2032.6848ZM34.6257%2032.3027L20.2632%203.57771C19.5261%202.10361%2017.4225%202.10361%2016.6855%203.57771L2.32297%2032.3027C1.50423%2033.9402%203.13343%2035.7258%204.83891%2035.0603L17.7472%2030.0229C18.2148%2029.8404%2018.7339%2029.8404%2019.2014%2030.0229L32.1097%2035.0603C33.8152%2035.7258%2035.4444%2033.9402%2034.6257%2032.3027Z%27%20fill%3D%27rgb%28255%2C255%2C255%29%27%20fill-rule%3D%27evenodd%27%20transform%3D%27matrix%280.719908%2C-0.69407%2C0.69407%2C0.719908%2C2.00256%2C28.0095%29%27%20%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
5835
+ background-size: 100% 100%;
5531
5836
  background-repeat: no-repeat;
5532
5837
 
5533
5838
  transform-origin: center;
5534
- transform: rotate(-90deg) scale(0.8);
5535
5839
  margin-left: -10px;
5536
5840
  margin-top: -18px;
5537
5841
  }
@@ -5589,23 +5893,26 @@ class SimulatorMask extends EventTarget {
5589
5893
  constructor() {
5590
5894
  super(), this.shown = !1, this.wrapper = document.createElement("div"), this.motion = null, this.#i = !1, this.#e = document.createElement("div"), this.#t = 0, this.#n = 0, this.#r = 0, this.#o = 0, document.head.appendChild(document.createElement("style")).textContent = injectStyles, this.wrapper.id = "page-agent-runtime_simulator-mask", this.wrapper.className = "webmcp-page-agent-wrapper", this.wrapper.setAttribute("data-browser-use-ignore", "true"), this.wrapper.setAttribute("data-page-agent-ignore", "true");
5591
5895
  try {
5592
- const a = new Motion({
5896
+ const s = new Motion({
5593
5897
  mode: isPageDark() ? "dark" : "light",
5594
- styles: { position: "absolute", inset: "0" }
5898
+ styles: { position: "absolute", inset: "0" },
5899
+ glowWidth: 80,
5900
+ borderWidth: 8,
5901
+ colors: ["rgb(121, 216, 247)", "rgb(171, 219, 110)", "rgb(252, 188, 114)", "rgb(235, 117, 231)"]
5595
5902
  });
5596
- this.motion = a, this.wrapper.appendChild(a.element), a.autoResize(this.wrapper);
5597
- } catch (a) {
5598
- console.warn("[SimulatorMask] Motion overlay unavailable:", a);
5903
+ this.motion = s, this.wrapper.appendChild(s.element), s.autoResize(this.wrapper);
5904
+ } catch (s) {
5905
+ console.warn("[SimulatorMask] Motion overlay unavailable:", s);
5599
5906
  }
5600
- const e = (a) => {
5601
- a.stopPropagation(), a.preventDefault();
5907
+ const e = (s) => {
5908
+ s.stopPropagation(), s.preventDefault();
5602
5909
  };
5603
5910
  ["click", "mousedown", "mouseup", "mousemove", "wheel", "keydown", "keyup"].forEach(
5604
- (a) => this.wrapper.addEventListener(a, e)
5605
- ), this.#s(), document.body.appendChild(this.wrapper), this.#a();
5606
- const n = (a) => {
5607
- const { x: l, y: c } = a.detail;
5608
- this.setCursorPosition(l, c);
5911
+ (s) => this.wrapper.addEventListener(s, e)
5912
+ ), this.#a(), document.body.appendChild(this.wrapper), this.#s();
5913
+ const n = (s) => {
5914
+ const { x: a, y: c } = s.detail;
5915
+ this.setCursorPosition(a, c);
5609
5916
  }, i = () => {
5610
5917
  this.triggerClickAnimation();
5611
5918
  }, r = () => {
@@ -5623,21 +5930,19 @@ class SimulatorMask extends EventTarget {
5623
5930
  #n;
5624
5931
  #r;
5625
5932
  #o;
5626
- #s() {
5933
+ #a() {
5627
5934
  this.#e.className = "webmcp-page-agent-cursor";
5628
5935
  const e = document.createElement("div");
5629
5936
  e.className = "webmcp-page-agent-cursorRipple", this.#e.appendChild(e);
5630
5937
  const n = document.createElement("div");
5631
- n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n);
5632
- const i = document.createElement("div");
5633
- i.className = "webmcp-page-agent-cursorBorder", this.#e.appendChild(i), this.wrapper.appendChild(this.#e);
5938
+ n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n), this.wrapper.appendChild(this.#e);
5634
5939
  }
5635
- #a() {
5940
+ #s() {
5636
5941
  if (this.#i) return;
5637
5942
  const e = this.#t + (this.#r - this.#t) * 0.2, n = this.#n + (this.#o - this.#n) * 0.2, i = Math.abs(e - this.#r);
5638
5943
  i > 0 && (i < 2 ? this.#t = this.#r : this.#t = e, this.#e.style.left = `${this.#t}px`);
5639
5944
  const r = Math.abs(n - this.#o);
5640
- r > 0 && (r < 2 ? this.#n = this.#o : this.#n = n, this.#e.style.top = `${this.#n}px`), requestAnimationFrame(() => this.#a());
5945
+ r > 0 && (r < 2 ? this.#n = this.#o : this.#n = n, this.#e.style.top = `${this.#n}px`), requestAnimationFrame(() => this.#s());
5641
5946
  }
5642
5947
  setCursorPosition(e, n) {
5643
5948
  this.#i || (this.#r = e, this.#o = n);
@@ -5656,56 +5961,19 @@ class SimulatorMask extends EventTarget {
5656
5961
  dispose() {
5657
5962
  this.#i = !0, this.motion?.dispose(), this.wrapper.remove(), this.dispatchEvent(new Event("dispose"));
5658
5963
  }
5964
+ // 根据目标元素大小,在 wrapper 添加绝对定位边框:2px 宽、与目标间距 2px,对角渐变 (0,0 → 1,1)
5965
+ borderElement(e) {
5966
+ if (!e) return;
5967
+ this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
5968
+ const n = e.getBoundingClientRect(), i = 2, r = 2, o = i + r, s = document.createElement("div");
5969
+ s.className = "webmcp-page-agent-border", s.style.position = "absolute", s.style.left = `${n.left - o}px`, s.style.top = `${n.top - o}px`, s.style.width = `${n.width + o * 2}px`, s.style.height = `${n.height + o * 2}px`, s.style.boxSizing = "border-box", s.style.pointerEvents = "none", s.style.zIndex = "10000", s.style.border = `${r}px solid transparent`, s.style.borderImageSource = "linear-gradient(to bottom right, #79D8F7, #ABDB6E, #FCBC72, #FA8682, #EB75E7)", s.style.borderImageSlice = "1", s.style.borderImageWidth = `${r}px`, this.wrapper.appendChild(s);
5970
+ }
5971
+ removeBorderElement() {
5972
+ this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
5973
+ }
5659
5974
  }
5660
- const DEFAULT_ERROR_SELECTORS = [
5661
- // W3C ARIA 标准(最可靠,框架无关)
5662
- '[role="alert"]',
5663
- '[aria-invalid="true"]',
5664
- // Tiny3 / Lego(华为云)
5665
- ".ti3-unifyvalid-error",
5666
- ".ti3-error",
5667
- ".ti-error",
5668
- ".lego-text-error",
5669
- ".lego-error",
5670
- // Element UI / Element Plus
5671
- ".el-form-item__error",
5672
- // Ant Design
5673
- ".ant-form-item-explain-error",
5674
- // Bootstrap
5675
- ".is-invalid",
5676
- ".invalid-feedback",
5677
- // Angular
5678
- ".ng-invalid",
5679
- // 通用命名约定
5680
- ".error-msg",
5681
- ".error-message",
5682
- ".error-text",
5683
- ".field-error",
5684
- ".form-error",
5685
- ".is-error",
5686
- ".has-error",
5687
- ".validate-error",
5688
- ".valid-error"
5689
- ], DEFAULT_DIALOG_SELECTORS = [
5690
- // W3C ARIA 标准
5691
- '[role="dialog"]',
5692
- '[role="alertdialog"]',
5693
- // Tiny3 / Lego(华为云)
5694
- '[class*="ti3-modal"]',
5695
- '[class*="ti3-message-box"]',
5696
- // Element UI / Element Plus
5697
- '[class*="el-dialog"]',
5698
- '[class*="el-message-box"]',
5699
- // Ant Design
5700
- '[class*="ant-modal"]',
5701
- // Bootstrap
5702
- '[class*="modal-content"]',
5703
- // Vuetify
5704
- '[class*="v-dialog"]',
5705
- // Naive UI
5706
- '[class*="n-modal"]'
5707
- ], inputSchema = z.object({
5708
- action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
5975
+ const inputSchema = z.object({
5976
+ action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree", "hover"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select', 'hover'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
5709
5977
  browserState: '查询整个页面的浏览器状态;返回页面的标题、URL、YAML格式的语义化页面树',
5710
5978
  click: '根据元素索引点击;',
5711
5979
  fill: '根据元素索引填写文本;';
@@ -5713,8 +5981,9 @@ const DEFAULT_ERROR_SELECTORS = [
5713
5981
  scroll: '滚动页面的动作,可以指定水平滚动还是上下滚动; 不带元素索引时:滚动整个文档。带元素索引时:滚动该索引处的容器(或其最近的可滚动祖先元素)'
5714
5982
  executeJavascript: '执行javascript代码'
5715
5983
  searchTree: '按关键词搜索无障碍树,返回带行号的匹配节点及上下文,无需获取全量树。适合快速定位特定元素(如所有按钮、特定名称的链接等),显著减少上下文消耗。必须提供 query 参数。'
5984
+ hover: '根据元素索引悬浮(hover)目标元素; 触发 mouseover/mouseenter 等事件,用于显示 tooltip、展开悬浮菜单等交互; 操作后自动返回最新页面状态。'
5716
5985
  `),
5717
- index: z.number().min(0).optional().describe("执行动作 of the element index, 动作为 click,fill,select时,必须提供元素索引"),
5986
+ index: z.number().min(0).optional().describe("执行动作 of the element index, 动作为 click,fill,select,hover时,必须提供元素索引"),
5718
5987
  text: z.string().optional().describe("执行动作的文本内容, 动作为 fill,select 时,必须提供文本内容"),
5719
5988
  down: z.boolean().optional().describe("执行上下滚动时,必须提供down参数"),
5720
5989
  right: z.boolean().optional().describe("执行水平滚动方向, 必须提供right参数"),
@@ -5729,86 +5998,97 @@ const DEFAULT_ERROR_SELECTORS = [
5729
5998
  responseMode: z.enum(["full", "diff", "both"]).optional().default("diff").describe(
5730
5999
  "返回浏览器状态的模式。full: 仅返回当前全量 A11y 树;diff: 仅返回与上一次状态的增量差异;both: 同时返回全量 A11y 树与增量差异。默认值为 diff。"
5731
6000
  )
5732
- });
5733
- function isInShadowDom(t) {
5734
- return t.getRootNode() instanceof ShadowRoot;
5735
- }
5736
- function dispatchComposedEvents(t, ...e) {
5737
- for (const n of e)
5738
- t.dispatchEvent(new Event(n, { bubbles: !0, composed: !0 }));
5739
- }
5740
- function deepQuerySelectorAll(t, e = document) {
5741
- const n = Array.from(e.querySelectorAll(t)), i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, null);
5742
- let r = i.currentNode;
5743
- for (; r; )
5744
- r.shadowRoot && n.push(...deepQuerySelectorAll(t, r.shadowRoot)), r = i.nextNode();
5745
- return n;
5746
- }
5747
- function waitForDomSettled(t = 600, e = 150) {
5748
- return new Promise((n) => {
5749
- let i = !1, r;
5750
- const o = () => {
5751
- i || (i = !0, a.disconnect(), r && clearTimeout(r), n());
5752
- }, a = new MutationObserver(() => {
5753
- r && clearTimeout(r), r = setTimeout(o, e);
5754
- });
5755
- r = setTimeout(o, e), setTimeout(o, t), a.observe(document.body, {
5756
- childList: !0,
5757
- subtree: !0,
5758
- attributes: !0,
5759
- attributeFilter: ["class", "style", "hidden"]
5760
- });
5761
- });
5762
- }
5763
- function detectPageDialog() {
5764
- const t = /* @__PURE__ */ new Set(), e = [], n = window.__webmcpcli_dialogSelectors ?? DEFAULT_DIALOG_SELECTORS;
5765
- for (const i of n)
5766
- try {
5767
- for (const r of deepQuerySelectorAll(i)) {
5768
- if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
5769
- const o = r.getBoundingClientRect();
5770
- if (o.width < 50 || o.height < 50) continue;
5771
- const a = window.getComputedStyle(r);
5772
- if (a.display === "none" || a.visibility === "hidden") continue;
5773
- const l = a.position === "fixed" || a.position === "absolute", c = parseInt(a.zIndex || "0", 10);
5774
- if (!l || c < 100) continue;
5775
- const u = window.innerWidth, d = window.innerHeight;
5776
- if (!(o.left < u * 0.6 && o.right > u * 0.4 && o.top < d * 0.6 && o.bottom > d * 0.4)) continue;
5777
- t.add(r);
5778
- const f = (r.textContent || "").trim().replace(/\s+/g, " ");
5779
- if (f.length > 5) {
5780
- const m = r.querySelectorAll('button, [role="button"], a'), g = Array.from(m).map((E) => (E.textContent || "").trim()).filter((E) => E.length > 0 && E.length < 20).slice(0, 5), S = g.length ? ` [可操作按钮: ${g.join(" / ")}]` : "";
5781
- e.push(`${f.substring(0, 300)}${S}`);
6001
+ }), PAGE_AGENT_TOOL_CALL_EVENT = "page-agent-tool-call", PAGE_AGENT_TOOL_RESULT_EVENT = "page-agent-tool-result", PAGE_AGENT_CHAT_END_EVENT = "page-agent-chat-end";
6002
+ function isPageAgentToolErrorResult(t) {
6003
+ return typeof t == "object" && t !== null && "isError" in t && t.isError === !0 && "error" in t && typeof t.error == "string";
6004
+ }
6005
+ function dispatchPageAgentToolResult(t) {
6006
+ window.dispatchEvent(new CustomEvent(PAGE_AGENT_TOOL_RESULT_EVENT, { detail: t }));
6007
+ }
6008
+ function setupPageAgentToolEventBridge(t, e) {
6009
+ window.__nextSdkPageAgentToolEventCleanup?.();
6010
+ const n = async (r) => {
6011
+ const o = r.detail, s = o?.requestId;
6012
+ if (!s) {
6013
+ dispatchPageAgentToolResult({
6014
+ requestId: "",
6015
+ data: {
6016
+ success: !1,
6017
+ error: "缺少 requestId"
5782
6018
  }
5783
- }
5784
- } catch {
6019
+ });
6020
+ return;
5785
6021
  }
5786
- return e.length === 0 ? "" : `
5787
- [页面弹窗检测] 检测到 ${e.length} 个模态弹窗,请优先处理:
5788
- ${e.map((i, r) => `${r + 1}. ${i}`).join(`
5789
- `)}
5790
- `;
5791
- }
5792
- function detectValidationErrors() {
5793
- const t = /* @__PURE__ */ new Set(), e = [], n = window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS;
5794
- for (const i of n)
5795
6022
  try {
5796
- for (const r of deepQuerySelectorAll(i)) {
5797
- if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
5798
- const o = r.getBoundingClientRect();
5799
- if (o.width < 1 || o.height < 1) continue;
5800
- const a = window.getComputedStyle(r);
5801
- if (a.display === "none" || a.visibility === "hidden") continue;
5802
- const l = (r.textContent || "").trim().replace(/\s+/g, " ");
5803
- l.length > 2 && l.length < 200 && (t.add(r), e.push(l));
6023
+ const a = inputSchema.parse(o.data), c = await t(a);
6024
+ if (isPageAgentToolErrorResult(c)) {
6025
+ dispatchPageAgentToolResult({
6026
+ requestId: s,
6027
+ data: {
6028
+ success: !1,
6029
+ error: c.error,
6030
+ result: c
6031
+ }
6032
+ });
6033
+ return;
5804
6034
  }
6035
+ dispatchPageAgentToolResult({
6036
+ requestId: s,
6037
+ data: {
6038
+ success: !0,
6039
+ result: c
6040
+ }
6041
+ });
6042
+ } catch (a) {
6043
+ dispatchPageAgentToolResult({
6044
+ requestId: s,
6045
+ data: {
6046
+ success: !1,
6047
+ error: a instanceof Error ? a.message : String(a)
6048
+ }
6049
+ });
6050
+ }
6051
+ }, i = async () => {
6052
+ try {
6053
+ await e.hideMask();
5805
6054
  } catch {
5806
6055
  }
5807
- return e.length === 0 ? "" : `
5808
- [校验提示] 检测到 ${e.length} 个表单校验错误,请先修复后再继续:
5809
- ${e.map((i, r) => `${r + 1}. ${i}`).join(`
5810
- `)}
5811
- `;
6056
+ };
6057
+ window.addEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.addEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = () => {
6058
+ window.removeEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.removeEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = void 0;
6059
+ };
6060
+ }
6061
+ function withStateFields(t, e) {
6062
+ try {
6063
+ const n = JSON.parse(t);
6064
+ return JSON.stringify({ ...n, ...e });
6065
+ } catch {
6066
+ return JSON.stringify({ ...e, raw: t });
6067
+ }
6068
+ }
6069
+ async function createActionErrorResult(t, e) {
6070
+ try {
6071
+ const n = await e("full");
6072
+ return {
6073
+ isError: !0,
6074
+ error: t,
6075
+ content: [{ type: "text", text: withStateFields(n.content[0].text, { error: t }) }]
6076
+ };
6077
+ } catch (n) {
6078
+ return {
6079
+ isError: !0,
6080
+ error: t,
6081
+ content: [
6082
+ {
6083
+ type: "text",
6084
+ text: JSON.stringify({
6085
+ error: t,
6086
+ stateError: n instanceof Error ? n.message : String(n)
6087
+ })
6088
+ }
6089
+ ]
6090
+ };
6091
+ }
5812
6092
  }
5813
6093
  async function handleBrowserState(t, e) {
5814
6094
  if (window.__webmcpcli_beforeGetBrowserState)
@@ -5821,9 +6101,12 @@ async function handleBrowserState(t, e) {
5821
6101
  }
5822
6102
  async function handleClick(t, e) {
5823
6103
  const n = t.responseMode ?? "diff";
5824
- if (t.index === void 0) return e.errContent("点击结果: 缺少元素索引");
6104
+ if (t.index === void 0) return e.actionError("点击结果: 缺少元素索引");
5825
6105
  const i = e.getRefMap().get(t.index);
5826
- if (!i) return e.refreshOnStaleRef("点击", t.index);
6106
+ if (!i)
6107
+ return e.actionError(
6108
+ `点击失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
6109
+ );
5827
6110
  let r = i;
5828
6111
  if (i.shadowRoot && !(i instanceof HTMLButtonElement) && !(i instanceof HTMLAnchorElement)) {
5829
6112
  const o = i.shadowRoot.querySelector(
@@ -5835,9 +6118,13 @@ async function handleClick(t, e) {
5835
6118
  }
5836
6119
  async function handleFill(t, e) {
5837
6120
  const n = t.responseMode ?? "diff";
5838
- if (t.index === void 0 || typeof t.text != "string") return e.errContent("填写结果: 缺少元素索引或文本内容");
6121
+ if (t.index === void 0 || typeof t.text != "string")
6122
+ return e.actionError("填写结果: 缺少元素索引或文本内容");
5839
6123
  const i = e.getRefMap().get(t.index);
5840
- if (!i) return e.refreshOnStaleRef("填写", t.index);
6124
+ if (!i)
6125
+ return e.actionError(
6126
+ `填写失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
6127
+ );
5841
6128
  let r = i;
5842
6129
  if (!(r instanceof HTMLInputElement) && !(r instanceof HTMLTextAreaElement)) {
5843
6130
  const o = i.querySelector("input, textarea") ?? i.shadowRoot?.querySelector("input, textarea");
@@ -5850,23 +6137,27 @@ async function handleFill(t, e) {
5850
6137
  try {
5851
6138
  await inputTextElement(r, t.text), o = !0;
5852
6139
  } catch {
5853
- const l = Object.getOwnPropertyDescriptor(
6140
+ const a = Object.getOwnPropertyDescriptor(
5854
6141
  (r instanceof HTMLTextAreaElement ? HTMLTextAreaElement : HTMLInputElement).prototype,
5855
6142
  "value"
5856
6143
  )?.set;
5857
- l && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (l.call(r, t.text), r.dispatchEvent(new Event("focus", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("blur", { bubbles: !0, composed: !0 })), o = !0);
6144
+ a && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (a.call(r, t.text), r.dispatchEvent(new Event("focus", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("blur", { bubbles: !0, composed: !0 })), o = !0);
5858
6145
  }
5859
6146
  if (!o)
5860
- return e.errContent(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
6147
+ return e.actionError(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
5861
6148
  isInShadowDom(r) && dispatchComposedEvents(r, "input", "change");
5862
6149
  }
5863
6150
  return await waitForDomSettled(), e.buildBrowserStateResponse(n);
5864
6151
  }
5865
6152
  async function handleSelect(t, e) {
5866
6153
  const n = t.responseMode ?? "diff";
5867
- if (t.index === void 0 || typeof t.text != "string") return e.errContent("选择结果: 缺少元素索引或文本内容");
6154
+ if (t.index === void 0 || typeof t.text != "string")
6155
+ return e.actionError("选择结果: 缺少元素索引或文本内容");
5868
6156
  let i = e.getRefMap().get(t.index);
5869
- if (!i) return e.refreshOnStaleRef("选择", t.index);
6157
+ if (!i)
6158
+ return e.actionError(
6159
+ `选择失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
6160
+ );
5870
6161
  let r = null;
5871
6162
  if (i instanceof HTMLSelectElement)
5872
6163
  r = i;
@@ -5874,24 +6165,24 @@ async function handleSelect(t, e) {
5874
6165
  const o = i.querySelector("select") ?? i.shadowRoot?.querySelector("select");
5875
6166
  o && (r = o);
5876
6167
  }
5877
- return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.errContent(`选择结果: 无法选择元素 ${t.index},未找到对应的 <select> 元素`);
6168
+ return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.actionError(`选择结果: 无法选择元素 ${t.index},未找到对应的 <select> 元素`);
5878
6169
  }
5879
6170
  function getScrollInfo(t = window) {
5880
6171
  if (t === window) {
5881
- const e = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), i = window.scrollY, r = window.scrollX, o = Math.max(0, e - (window.innerHeight + i)), a = Math.max(0, n - (window.innerWidth + r));
6172
+ const e = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), i = window.scrollY, r = window.scrollX, o = Math.max(0, e - (window.innerHeight + i)), s = Math.max(0, n - (window.innerWidth + r));
5882
6173
  return {
5883
6174
  scrollY: i,
5884
6175
  scrollX: r,
5885
6176
  pixelsAbove: i,
5886
6177
  pixelsBelow: o,
5887
6178
  pixelsLeft: r,
5888
- pixelsRight: a,
6179
+ pixelsRight: s,
5889
6180
  pagesAbove: window.innerHeight > 0 ? i / window.innerHeight : 0,
5890
6181
  pagesBelow: window.innerHeight > 0 ? o / window.innerHeight : 0,
5891
6182
  atTop: i <= 1,
5892
6183
  atBottom: o <= 1,
5893
6184
  atLeft: r <= 1,
5894
- atRight: a <= 1
6185
+ atRight: s <= 1
5895
6186
  };
5896
6187
  } else {
5897
6188
  const e = t, n = e.scrollTop, i = e.scrollLeft, r = e.scrollHeight - e.clientHeight - n, o = e.scrollWidth - e.clientWidth - i;
@@ -5915,9 +6206,9 @@ function waitForScrollEnd(t, e = 2e3) {
5915
6206
  return new Promise((n) => {
5916
6207
  let i = !1;
5917
6208
  const r = t === window ? document : t, o = () => {
5918
- i || (i = !0, r.removeEventListener("scrollend", a), clearTimeout(l), n());
5919
- }, a = () => o(), l = setTimeout(o, e);
5920
- r.addEventListener("scrollend", a, { once: !0 });
6209
+ i || (i = !0, r.removeEventListener("scrollend", s), clearTimeout(a), n());
6210
+ }, s = () => o(), a = setTimeout(o, e);
6211
+ r.addEventListener("scrollend", s, { once: !0 });
5921
6212
  });
5922
6213
  }
5923
6214
  async function handleScroll(t, e) {
@@ -5938,20 +6229,18 @@ async function handleScroll(t, e) {
5938
6229
  i.scrollBy({ top: t.down ? m : -m, behavior: "smooth" });
5939
6230
  }
5940
6231
  await waitForScrollEnd(i);
5941
- const o = getScrollInfo(i), a = Math.round(o.scrollY - r.scrollY), l = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
5942
- let u;
5943
- if (Math.abs(a) < 1 && Math.abs(l) < 1)
5944
- c ? u = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : u = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
6232
+ const o = getScrollInfo(i), s = Math.round(o.scrollY - r.scrollY), a = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
6233
+ let d;
6234
+ if (Math.abs(s) < 1 && Math.abs(a) < 1)
6235
+ c ? d = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : d = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
5945
6236
  else {
5946
- const m = c ? `水平滚动 ${l}px` : `垂直滚动 ${a}px`;
6237
+ const m = c ? `水平滚动 ${a}px` : `垂直滚动 ${s}px`;
5947
6238
  let g = "";
5948
- c ? t.right && o.atRight ? g = ",已到达右边界" : !t.right && o.atLeft && (g = ",已到达左边界") : t.down && o.atBottom ? g = ",已到达底部" : !t.down && o.atTop && (g = ",已到达顶部"), u = `✅ ${m}${g}`;
6239
+ c ? t.right && o.atRight ? g = ",已到达右边界" : !t.right && o.atLeft && (g = ",已到达左边界") : t.down && o.atBottom ? g = ",已到达底部" : !t.down && o.atTop && (g = ",已到达顶部"), d = `✅ ${m}${g}`;
5949
6240
  }
5950
- const d = t.right !== void 0 ? `当前水平滚动位置: scrollX=${Math.round(o.scrollX)}px,左侧 ${o.pagesAbove.toFixed(1)} 屏,右侧 ${o.pagesBelow.toFixed(1)} 屏` : `当前滚动位置: scrollY=${Math.round(o.scrollY)}px,上方 ${o.pagesAbove.toFixed(1)} 屏,下方 ${o.pagesBelow.toFixed(1)} 屏`, p = `[滚动结果] ${u}
5951
- ${d}`, f = await e.buildBrowserStateResponse(n);
5952
- return f.content[0].text = `${p}
5953
-
5954
- ${f.content[0].text}`, f;
6241
+ const u = t.right !== void 0 ? `当前水平滚动位置: scrollX=${Math.round(o.scrollX)}px,左侧 ${o.pagesAbove.toFixed(1)} 屏,右侧 ${o.pagesBelow.toFixed(1)} 屏` : `当前滚动位置: scrollY=${Math.round(o.scrollY)}px,上方 ${o.pagesAbove.toFixed(1)} 屏,下方 ${o.pagesBelow.toFixed(1)} 屏`, h = `[滚动结果] ${d}
6242
+ ${u}`, p = await e.buildBrowserStateResponse(n);
6243
+ return p.content[0].text = withStateFields(p.content[0].text, { scrollResult: h }), p;
5955
6244
  }
5956
6245
  async function handleExecuteJavascript(t, e) {
5957
6246
  if (!t.script) return e.errContent("脚本执行异常: 缺少javascript代码");
@@ -5967,110 +6256,372 @@ async function handleExecuteJavascript(t, e) {
5967
6256
  }
5968
6257
  async function handleSearchTree(t, e) {
5969
6258
  if (!t.query) return e.errContent("搜索失败: 缺少 query 参数");
5970
- const n = window.__webmcpcli_interactiveBlacklist ?? [], i = window.__webmcpcli_interactiveWhitelist ?? [], r = window.__webmcpcli_exposedAttributes ?? [], o = searchA11yTree(t.query, document.body, n, i, {
6259
+ const n = searchA11yTree(t.query, document.body, {
6260
+ ...getPageAgentToolConfig().a11yConfig,
5971
6261
  contextLines: t.contextLines,
5972
- maxMatches: t.maxMatches,
5973
- exposedAttributes: r,
5974
- errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS).join(", ")
6262
+ maxMatches: t.maxMatches
5975
6263
  });
5976
- e.setRefMap(o.refMap), e.stateCache.update(window.location.href, o.yaml), await e.pageController.hideMask();
5977
- const a = detectPageDialog(), l = detectValidationErrors(), c = `${a}${l}`;
6264
+ e.setRefMap(n.refMap), e.stateCache.update(window.location.href, n.yaml), await e.pageController.hideMask();
6265
+ const i = detectPageDialog(), r = detectValidationErrors();
6266
+ if (i.length === 0 && r.length === 0)
6267
+ return { content: [{ type: "text", text: n.text }] };
6268
+ const o = {
6269
+ ...i.length > 0 ? { dialogs: i } : {},
6270
+ ...r.length > 0 ? { validationErrors: r } : {}
6271
+ };
5978
6272
  return {
5979
- content: [{ type: "text", text: c ? `${c}
5980
- ${o.text}` : o.text }]
6273
+ content: [{ type: "text", text: `${JSON.stringify(o)}
6274
+ ${n.text}` }]
5981
6275
  };
5982
6276
  }
6277
+ async function handleHover(t, e) {
6278
+ if (t.index === void 0) return e.errContent("悬浮结果: 缺少元素索引");
6279
+ const n = e.getRefMap().get(t.index);
6280
+ if (!n) return e.refreshOnStaleRef("悬浮", t.index);
6281
+ let i = n;
6282
+ if (n.shadowRoot && !(n instanceof HTMLButtonElement) && !(n instanceof HTMLAnchorElement)) {
6283
+ const d = n.shadowRoot.querySelector(
6284
+ 'button, a, [role="button"], [role="link"]'
6285
+ );
6286
+ d && (i = d);
6287
+ }
6288
+ const r = i.getBoundingClientRect(), o = r.left + r.width / 2, s = r.top + r.height / 2, a = [
6289
+ { type: "pointerenter", bubbles: !1, usePointer: !0 },
6290
+ { type: "pointerover", bubbles: !0, usePointer: !0 },
6291
+ { type: "pointermove", bubbles: !0, usePointer: !0 },
6292
+ { type: "mouseenter", bubbles: !1, usePointer: !1 },
6293
+ { type: "mouseover", bubbles: !0, usePointer: !1 },
6294
+ { type: "mousemove", bubbles: !0, usePointer: !1 }
6295
+ ];
6296
+ for (const { type: d, bubbles: u, usePointer: h } of a) {
6297
+ const p = h ? PointerEvent : MouseEvent;
6298
+ i.dispatchEvent(new p(d, {
6299
+ bubbles: u,
6300
+ cancelable: !0,
6301
+ view: window,
6302
+ clientX: o,
6303
+ clientY: s
6304
+ }));
6305
+ }
6306
+ await waitForDomSettled();
6307
+ const c = t.responseMode ?? "diff";
6308
+ return e.buildBrowserStateResponse(c);
6309
+ }
5983
6310
  function registerPageAgentTool(t = {}) {
5984
- initializeBuiltinWebMCP(), typeof t.enableHighlight > "u" && (t.enableHighlight = !0), window.__webmcpcli_interactiveWhitelist = window.__webmcpcli_interactiveWhitelist || [], window.__webmcpcli_interactiveBlacklist = window.__webmcpcli_interactiveBlacklist || [], window.__webmcpcli_exposedAttributes = window.__webmcpcli_exposedAttributes || t?.exposedAttributes || [], window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null, window.__webmcpcli_errorSelectors = window.__webmcpcli_errorSelectors || DEFAULT_ERROR_SELECTORS, window.__webmcpcli_dialogSelectors = window.__webmcpcli_dialogSelectors || DEFAULT_DIALOG_SELECTORS;
6311
+ initializeBuiltinWebMCP(), setPageAgentToolConfig(t, { mode: "replace" }), window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null;
5985
6312
  const e = new PageController({ enableMask: !1 });
5986
6313
  e.maskReady = (async () => {
5987
6314
  e.mask = new SimulatorMask();
5988
6315
  })();
5989
6316
  const n = new PageStateCache();
5990
6317
  let i = /* @__PURE__ */ new Map();
5991
- async function r(c) {
5992
- return await e.hideMask(), { content: [{ type: "text", text: c }] };
6318
+ async function r(u) {
6319
+ return { content: [{ type: "text", text: u }] };
5993
6320
  }
5994
- async function o(c, u) {
5995
- const d = await a("full");
6321
+ async function o(u) {
6322
+ const h = await createActionErrorResult(u, a);
6323
+ return t.removeMaskAfterToolCall && await e.hideMask(), h;
6324
+ }
6325
+ async function s(u, h) {
6326
+ const p = await a("full"), m = `⚠️ ${u}失败: ref 索引 ${h} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`;
5996
6327
  return {
5997
- content: [{ type: "text", text: `⚠️ ${c}失败: ref 索引 ${u} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。
5998
- ` + d.content[0].text }]
6328
+ content: [
6329
+ {
6330
+ type: "text",
6331
+ text: withStateFields(p.content[0].text, { warning: m })
6332
+ }
6333
+ ]
5999
6334
  };
6000
6335
  }
6001
- async function a(c = "diff") {
6002
- const u = window.location.href, d = document.title, p = window.__webmcpcli_interactiveBlacklist ?? [], f = window.__webmcpcli_interactiveWhitelist ?? [], m = window.__webmcpcli_exposedAttributes ?? [], { yaml: g, refMap: S } = buildA11yTree(document.body, p, f, {
6003
- exposedAttributes: m,
6004
- errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS).join(", ")
6005
- });
6006
- i = S, t?.enableHighlight && (highlight(S), globalRemoveListener());
6007
- const E = n.update(u, g);
6008
- await e.hideMask();
6009
- const h = detectPageDialog(), x = detectValidationErrors();
6336
+ async function a(u = "diff") {
6337
+ const h = window.location.href, p = document.title, { yaml: m, refMap: g } = buildA11yTree(document.body, getPageAgentToolConfig().a11yConfig);
6338
+ i = g, getPageAgentToolConfig().enableHighlight && (highlight(g), globalRemoveListener());
6339
+ const E = n.update(h, m), L = detectPageDialog(), f = detectValidationErrors(), b = detectVisibleTooltips();
6010
6340
  let T = "";
6011
- return c === "full" ? T = g : c === "diff" ? T = E.isFullRefresh ? g : E.diffText : c === "both" && (T = `【全量页面树】:
6012
- ${g}
6341
+ u === "full" ? T = m : u === "diff" ? T = E.isFullRefresh ? m : E.diffText : u === "both" && (T = `【全量页面树】:
6342
+ ${m}
6013
6343
 
6014
6344
  【增量差异】:
6015
- ${E.isFullRefresh ? "(首次/刷新,无增量差异)" : E.diffText}`), { content: [{ type: "text", text: `浏览器状态: ${JSON.stringify({
6016
- url: u,
6017
- title: d,
6018
- content: T
6019
- })}${h}${x}` }] };
6345
+ ${E.isFullRefresh ? "(首次/刷新,无增量差异)" : E.diffText}`);
6346
+ const y = {
6347
+ url: h,
6348
+ title: p,
6349
+ content: T,
6350
+ ...L.length > 0 ? { dialogs: L } : {},
6351
+ ...f.length > 0 ? { validationErrors: f } : {},
6352
+ ...b.length > 0 ? { tooltips: b } : {}
6353
+ };
6354
+ return { content: [{ type: "text", text: JSON.stringify(y) }] };
6020
6355
  }
6021
- const l = {
6356
+ const c = {
6022
6357
  pageController: e,
6023
6358
  stateCache: n,
6024
6359
  getRefMap: () => i,
6025
- setRefMap: (c) => {
6026
- i = c;
6360
+ setRefMap: (u) => {
6361
+ i = u;
6027
6362
  },
6028
6363
  buildBrowserStateResponse: a,
6029
- refreshOnStaleRef: o,
6030
- errContent: r
6364
+ refreshOnStaleRef: s,
6365
+ errContent: r,
6366
+ actionError: o
6031
6367
  };
6368
+ async function d(u) {
6369
+ try {
6370
+ let h;
6371
+ switch (u.action) {
6372
+ case "browserState":
6373
+ h = await handleBrowserState(u, c);
6374
+ break;
6375
+ case "click":
6376
+ await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleClick(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6377
+ break;
6378
+ case "fill":
6379
+ await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleFill(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6380
+ break;
6381
+ case "select":
6382
+ await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleSelect(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6383
+ break;
6384
+ case "scroll":
6385
+ await e.showMask(), h = await handleScroll(u, c), t.removeMaskAfterToolCall && await e.hideMask();
6386
+ break;
6387
+ case "executeJavascript":
6388
+ h = await handleExecuteJavascript(u, c);
6389
+ break;
6390
+ case "searchTree":
6391
+ h = await handleSearchTree(u, c);
6392
+ break;
6393
+ case "hover":
6394
+ h = await handleHover(u, c);
6395
+ break;
6396
+ default:
6397
+ h = { content: [{ type: "text", text: `未知操作: ${u.action}` }] };
6398
+ }
6399
+ return h;
6400
+ } catch (h) {
6401
+ const p = {
6402
+ click: "点击",
6403
+ fill: "填写",
6404
+ select: "选择"
6405
+ };
6406
+ if (u.action in p)
6407
+ return o(
6408
+ `${p[u.action]}执行异常: ${h instanceof Error ? h.message : String(h)}`
6409
+ );
6410
+ throw t.removeMaskAfterToolCall && await e.hideMask(), h;
6411
+ }
6412
+ }
6032
6413
  document.modelContext.registerTool({
6033
6414
  name: "page-agent-tool",
6034
6415
  description: pageAgentPrompt,
6035
6416
  // @ts-ignore
6036
6417
  inputSchema: zodToJsonSchema(inputSchema),
6037
- async execute(c) {
6038
- await e.showMask();
6418
+ async execute(u) {
6039
6419
  try {
6040
- switch (c.action) {
6041
- case "browserState":
6042
- return await handleBrowserState(c, l);
6043
- case "click":
6044
- return await handleClick(c, l);
6045
- case "fill":
6046
- return await handleFill(c, l);
6047
- case "select":
6048
- return await handleSelect(c, l);
6049
- case "scroll":
6050
- return await handleScroll(c, l);
6051
- case "executeJavascript":
6052
- return await handleExecuteJavascript(c, l);
6053
- case "searchTree":
6054
- return await handleSearchTree(c, l);
6055
- default:
6056
- return await e.hideMask(), { content: [{ type: "text", text: `未知操作: ${c.action}` }] };
6057
- }
6058
- } catch (u) {
6059
- return await e.hideMask(), { content: [{ type: "text", text: `异常: ${String(u)}` }] };
6420
+ return d(u);
6421
+ } catch (h) {
6422
+ return { content: [{ type: "text", text: `异常: ${String(h)}` }] };
6060
6423
  }
6061
6424
  }
6062
- });
6425
+ }), setupPageAgentToolEventBridge(d, e);
6426
+ }
6427
+ const consoleCloudPageAgentToolOptions = {
6428
+ enableHighlight: !1,
6429
+ a11yConfig: {
6430
+ roles: [
6431
+ // Tiny3 Tabs:真正可聚焦/可点击的是内部 .ti3-tabs-text(tabindex=0)
6432
+ { role: "tablist", selector: "ul.ti3-tabs" },
6433
+ { role: "tab", selector: ".ti3-tabs-text" },
6434
+ { role: "tabpanel", selector: ["ti-tab.ti3-tab-pane", ".ti3-tab-pane"] },
6435
+ // 自定义下拉 / 区域选择触发器
6436
+ {
6437
+ role: "combobox",
6438
+ selector: [
6439
+ ".ti3-select-dominator-container",
6440
+ ".selected-label",
6441
+ ".sort-select",
6442
+ ".service-select",
6443
+ ".region-select",
6444
+ '[cf-uba="searchableRegion..open"]'
6445
+ ]
6446
+ },
6447
+ // 图标型 / 无语义按钮
6448
+ {
6449
+ role: "button",
6450
+ selector: [
6451
+ ".modules-service-list-menu-service-icon-container",
6452
+ ".ti3-btn-only-icon-noborder",
6453
+ ".ti3-select-dominator-dropdown-btn",
6454
+ ".modules-right-sidebar-icon-item-wrapper",
6455
+ ".modules-right-sidebar-hide-state-plugin",
6456
+ ".components-service-list-container-service-list-input-service-close",
6457
+ ".modules-searchable-region-region-panel-close",
6458
+ ".modules-searchable-region-region-panel-search-btn",
6459
+ '[cf-uba="rightSidebar..hideBtn"]',
6460
+ // Tiny3 图标组件:帮助中心固定/全屏/关闭等(ti-icon / tp-icon 无原生 button 语义)
6461
+ ".ti-global-help-panel-header-icon",
6462
+ "ti-icon[name]",
6463
+ "tp-icon[name]",
6464
+ // 无 name 的箭头/操作图标(如 latest news 区 common-icon 展开箭头)
6465
+ "tp-icon.common-icon",
6466
+ "ti-icon.common-icon",
6467
+ "ti-icon.ti3-icon-full-screen",
6468
+ "ti-icon.ti3-icon-close",
6469
+ "tp-icon.ti3-icon-full-screen",
6470
+ "tp-icon.ti3-icon-close"
6471
+ ]
6472
+ },
6473
+ // 服务列表侧栏分类 / 顶栏菜单项
6474
+ {
6475
+ role: "menuitem",
6476
+ selector: [
6477
+ ".components-service-list-left-box-sidebar-visit-panel > li",
6478
+ ".modules-menus-menu-item",
6479
+ ".components-menu-wrapper-menu-text"
6480
+ ]
6481
+ },
6482
+ // 区域筛选项 / 下拉选项
6483
+ {
6484
+ role: "option",
6485
+ selector: [
6486
+ ".region-selector-item",
6487
+ ".modules-searchable-region-project-item-region-item",
6488
+ ".modules-searchable-region-region-panel-recent-region-item",
6489
+ ".ti3-multiselect-box-cell"
6490
+ ]
6491
+ },
6492
+ // 模态弹窗:补齐缺失的 role="dialog"(Tiny3 modal/message-box/drawer/侧栏面板)
6493
+ {
6494
+ role: "dialog",
6495
+ selector: [
6496
+ '[class*="ti3-modal"]',
6497
+ '[class*="ti3-message-box"]',
6498
+ '[class*="drawer"]',
6499
+ ".modules-layout-module-sidebar-panel"
6500
+ ]
6501
+ },
6502
+ // Tiny3 tooltip / 帮助提示:补齐缺失的 role="tooltip"
6503
+ {
6504
+ role: "tooltip",
6505
+ selector: ["tp-helptip", '[class*="ti3-tooltip"]', ".tp-helptip-content", ".ti3-tooltip", ".ti3-tooltip-popper"]
6506
+ }
6507
+ ],
6508
+ states: {
6509
+ // 选中态:挂在容器 class 上,用 selector + closest 即可命中内部交互节点
6510
+ selected: [
6511
+ { selector: "li.ti3-tab-li.ti3-tab-active" },
6512
+ // Tiny3 按钮组(计费模式等):ti3-active 在 .ti3-btn-item-container 上,不在 button 上
6513
+ { selector: ".ti3-btn-item-container.ti3-active" },
6514
+ { selector: ".components-service-list-left-box-active" },
6515
+ {
6516
+ selector: [
6517
+ ".modules-searchable-region-project-item-region-item-selected",
6518
+ ".components-search-content-search-select-search-select-selected"
6519
+ ]
6520
+ }
6521
+ ],
6522
+ hasPopup: [
6523
+ {
6524
+ selector: [
6525
+ ".ti3-select-dominator-container",
6526
+ ".selected-label",
6527
+ ".sort-select",
6528
+ ".service-select",
6529
+ ".region-select",
6530
+ '[cf-uba="searchableRegion..open"]',
6531
+ '[cf-uba="serviceList..open"]',
6532
+ '[cf-uba="userinfo"]',
6533
+ "tp-helptip"
6534
+ ]
6535
+ }
6536
+ ],
6537
+ disabled: [{ selector: ".ti3-disabled" }],
6538
+ // Tiny3 / Lego 校验错误
6539
+ error: [{ selector: [".ti3-unifyvalid-error", ".ti3-error", ".ti-error", ".lego-text-error", ".lego-error"] }],
6540
+ // Tiny3 / Lego 警告
6541
+ warning: [{ selector: [".ti3-warning", ".ti-warning", ".lego-text-warning"] }],
6542
+ // 展开态:需结合计算样式,选择器表达不了「可见」
6543
+ expanded: [
6544
+ {
6545
+ match: (t) => {
6546
+ try {
6547
+ if (!t.matches(
6548
+ ".modules-layout-module-sidebar-panel, .modules-searchable-region-region-panel, .ti3-dropdown-container"
6549
+ ))
6550
+ return !1;
6551
+ const e = window.getComputedStyle(t);
6552
+ return e.display !== "none" && e.visibility !== "hidden" && e.opacity !== "0";
6553
+ } catch {
6554
+ return !1;
6555
+ }
6556
+ }
6557
+ }
6558
+ ]
6559
+ },
6560
+ // exposedAttributes 输出属性 token;带 name 的 ti-icon/tp-icon 可交互性由 roles/whitelist 中 ti-icon[name] 等规则判定。
6561
+ exposedAttributes: ["cf-uba", "data-qa-id", "name"],
6562
+ whitelist: [
6563
+ ".modules-service-list-menu-service-icon-container",
6564
+ ".ti3-tabs-text",
6565
+ "tp-helptip",
6566
+ '[cf-uba="cloudShell"]',
6567
+ '[cf-uba="messageBox"]',
6568
+ '[cf-uba="helpFeedback"]',
6569
+ '[cf-uba="globalMessage"]',
6570
+ '[cf-uba="rightSidebar..hideBtn"]',
6571
+ // 帮助中心等区域的 ti-icon / tp-icon 图标按钮
6572
+ ".ti-global-help-panel-header-icon",
6573
+ "ti-icon[name]",
6574
+ "tp-icon[name]",
6575
+ "tp-icon.common-icon",
6576
+ "ti-icon.common-icon",
6577
+ "ti-icon.ti3-icon-full-screen"
6578
+ ],
6579
+ blacklist: [
6580
+ "noscript",
6581
+ "pan-gu",
6582
+ // 忽略 WebMCP 高亮容器
6583
+ "#webmcpcli-highlight-container",
6584
+ "#page-agent-runtime_simulator-mask",
6585
+ // CFUI 忽略几个大区域
6586
+ "#J_header",
6587
+ "#J_rightSidebar",
6588
+ "#cf_service_icon",
6589
+ "tp-helptip"
6590
+ ]
6591
+ }
6592
+ };
6593
+ function isConsoleCloudHost(t = typeof location < "u" ? location.hostname : "") {
6594
+ return /(^|\.)console\.huaweicloud\.com$/i.test(t);
6063
6595
  }
6064
6596
  export {
6597
+ DEFAULT_PAGE_AGENT_TOOL_CONFIG as D,
6065
6598
  Motion as M,
6599
+ PAGE_AGENT_TOOL_CALL_EVENT as P,
6066
6600
  QrCode as Q,
6067
6601
  getSkillMdContent as a,
6068
6602
  getMainSkillPaths as b,
6069
6603
  getMainSkillPathByName as c,
6070
6604
  createSkillTools as d,
6071
- createRemoter as e,
6605
+ PAGE_AGENT_TOOL_RESULT_EVENT as e,
6072
6606
  formatSkillsForSystemPrompt as f,
6073
6607
  getSkillOverviews as g,
6608
+ getPageAgentToolConfig as h,
6609
+ consoleCloudPageAgentToolOptions as i,
6610
+ isConsoleCloudHost as j,
6611
+ DEFAULT_A11Y_CONFIG as k,
6612
+ defineA11yConfig as l,
6613
+ resolveA11yInfo as m,
6614
+ resolveA11yRole as n,
6615
+ resolveA11yStates as o,
6074
6616
  parseSkillFrontMatter as p,
6075
- registerPageAgentTool as r
6617
+ mergeA11yConfig as q,
6618
+ registerPageAgentTool as r,
6619
+ setPageAgentToolConfig as s,
6620
+ mergeA11yConfigs as t,
6621
+ ensureResolvedA11yConfig as u,
6622
+ isResolvedA11yConfig as v,
6623
+ extractSelectors as w,
6624
+ buildA11yTree as x,
6625
+ searchA11yTree as y,
6626
+ createRemoter as z
6076
6627
  };