@matterfact/embed 0.3.0 → 0.5.0

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 (56) hide show
  1. package/README.md +45 -5
  2. package/dist/{chunk-33LPVL2R.js → chunk-GZZYR6YF.js} +3 -3
  3. package/dist/{chunk-33LPVL2R.js.map → chunk-GZZYR6YF.js.map} +3 -3
  4. package/dist/chunk-JN3ZMONO.js +2 -0
  5. package/dist/chunk-JN3ZMONO.js.map +7 -0
  6. package/dist/{chunk-CHPADW72.js → chunk-JSH3BRYP.js} +80 -47
  7. package/dist/chunk-JSH3BRYP.js.map +1 -0
  8. package/dist/{chunk-SQJX27LT.js → chunk-NZIN3LK7.js} +79 -46
  9. package/dist/chunk-NZIN3LK7.js.map +1 -0
  10. package/dist/chunk-Z53V2P4B.js +2 -0
  11. package/dist/context-AQY2LJWK.js +3 -0
  12. package/dist/{context-BFNFFHC2.js.map → context-AQY2LJWK.js.map} +1 -1
  13. package/dist/{context-MORDASRH.js → context-UBTZEEWS.js} +6 -6
  14. package/dist/embed.js +1 -1
  15. package/dist/embed.js.map +3 -3
  16. package/dist/index.cjs +106 -63
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +23 -3
  19. package/dist/index.d.ts +23 -3
  20. package/dist/index.js +23 -17
  21. package/dist/index.js.map +1 -1
  22. package/dist/react.cjs +109 -66
  23. package/dist/react.cjs.map +1 -1
  24. package/dist/react.d.cts +14 -1
  25. package/dist/react.d.ts +14 -1
  26. package/dist/react.js +25 -19
  27. package/dist/react.js.map +1 -1
  28. package/dist/{snapshot-IWVXLE4G.js → snapshot-HYMRZTZC.js} +6 -2
  29. package/dist/snapshot-HYMRZTZC.js.map +1 -0
  30. package/dist/{snapshot-QBV7DTJP.js → snapshot-XFCV2MYR.js} +7 -4
  31. package/dist/snapshot-XFCV2MYR.js.map +1 -0
  32. package/examples/README.md +46 -0
  33. package/examples/demo-host/index.html +163 -0
  34. package/examples/demo-host/serve.mjs +62 -0
  35. package/examples/embed-demo/.env.example +24 -0
  36. package/examples/embed-demo/README.md +72 -0
  37. package/examples/embed-demo/index.html +12 -0
  38. package/examples/embed-demo/package.json +25 -0
  39. package/examples/embed-demo/src/App.tsx +189 -0
  40. package/examples/embed-demo/src/config.ts +43 -0
  41. package/examples/embed-demo/src/main.tsx +10 -0
  42. package/examples/embed-demo/src/styles.css +354 -0
  43. package/examples/embed-demo/tsconfig.json +16 -0
  44. package/examples/embed-demo/vite.config.ts +11 -0
  45. package/examples/host-panel.html +237 -0
  46. package/package.json +3 -2
  47. package/dist/chunk-CHPADW72.js.map +0 -1
  48. package/dist/chunk-F7DLOR7F.js +0 -2
  49. package/dist/chunk-F7DLOR7F.js.map +0 -7
  50. package/dist/chunk-FBIJZJGL.js +0 -2
  51. package/dist/chunk-SQJX27LT.js.map +0 -1
  52. package/dist/context-BFNFFHC2.js +0 -3
  53. package/dist/snapshot-IWVXLE4G.js.map +0 -1
  54. package/dist/snapshot-QBV7DTJP.js.map +0 -1
  55. /package/dist/{chunk-FBIJZJGL.js.map → chunk-Z53V2P4B.js.map} +0 -0
  56. /package/dist/{context-MORDASRH.js.map → context-UBTZEEWS.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../node_modules/dom-accessibility-api/sources/polyfills/array.from.ts", "../node_modules/dom-accessibility-api/sources/polyfills/SetLike.ts", "../node_modules/dom-accessibility-api/sources/getRole.ts", "../node_modules/dom-accessibility-api/sources/util.ts", "../node_modules/dom-accessibility-api/sources/accessible-name-and-description.ts", "../node_modules/dom-accessibility-api/sources/accessible-name.ts", "../node_modules/dom-accessibility-api/sources/is-inaccessible.ts", "../node_modules/dom-accessibility-api/sources/is-disabled.ts", "../src/dom/a11y.ts", "../src/dom/refs.ts", "../src/dom/snapshot.ts"],
4
- "sourcesContent": ["/**\n * @source {https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill}\n * but without thisArg (too hard to type, no need to `this`)\n */\nconst toStr = Object.prototype.toString;\nfunction isCallable(fn: unknown): boolean {\n\treturn typeof fn === \"function\" || toStr.call(fn) === \"[object Function]\";\n}\nfunction toInteger(value: unknown): number {\n\tconst number = Number(value);\n\tif (isNaN(number)) {\n\t\treturn 0;\n\t}\n\tif (number === 0 || !isFinite(number)) {\n\t\treturn number;\n\t}\n\treturn (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));\n}\nconst maxSafeInteger = Math.pow(2, 53) - 1;\nfunction toLength(value: unknown): number {\n\tconst len = toInteger(value);\n\treturn Math.min(Math.max(len, 0), maxSafeInteger);\n}\n/**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n */\nexport default function arrayFrom<T>(iterable: Iterable<T> | ArrayLike<T>): T[];\n/**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n * @param mapfn A mapping function to call on every element of the array.\n * @param thisArg Value of 'this' used to invoke the mapfn.\n */\nexport default function arrayFrom<T, U>(\n\tarrayLike: Iterable<T> | ArrayLike<T>,\n\tmapFn?: (v: T, k: number) => U,\n): U[] {\n\t// 1. Let C be the this value.\n\t// edit(@eps1lon): we're not calling it as Array.from\n\tconst C = Array;\n\n\t// 2. Let items be ToObject(arrayLike).\n\tconst items = Object(arrayLike);\n\n\t// 3. ReturnIfAbrupt(items).\n\tif (arrayLike == null) {\n\t\tthrow new TypeError(\n\t\t\t\"Array.from requires an array-like object - not null or undefined\",\n\t\t);\n\t}\n\n\t// 4. If mapfn is undefined, then let mapping be false.\n\t// const mapFn = arguments.length > 1 ? arguments[1] : void undefined;\n\n\tif (typeof mapFn !== \"undefined\") {\n\t\t// 5. else\n\t\t// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n\t\tif (!isCallable(mapFn)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Array.from: when provided, the second argument must be a function\",\n\t\t\t);\n\t\t}\n\t}\n\n\t// 10. Let lenValue be Get(items, \"length\").\n\t// 11. Let len be ToLength(lenValue).\n\tconst len = toLength(items.length);\n\n\t// 13. If IsConstructor(C) is true, then\n\t// 13. a. Let A be the result of calling the [[Construct]] internal method\n\t// of C with an argument list containing the single item len.\n\t// 14. a. Else, Let A be ArrayCreate(len).\n\tconst A = isCallable(C) ? Object(new C(len)) : new Array(len);\n\n\t// 16. Let k be 0.\n\tlet k = 0;\n\t// 17. Repeat, while k < len… (also steps a - h)\n\tlet kValue;\n\twhile (k < len) {\n\t\tkValue = items[k];\n\t\tif (mapFn) {\n\t\t\tA[k] = mapFn(kValue, k);\n\t\t} else {\n\t\t\tA[k] = kValue;\n\t\t}\n\t\tk += 1;\n\t}\n\t// 18. Let putStatus be Put(A, \"length\", len, true).\n\tA.length = len;\n\t// 20. Return A.\n\treturn A;\n}\n", "declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown,\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n", "// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html\n\nimport { presentationRoles } from \"./util\";\n\n/**\n * Safe Element.localName for all supported environments\n * @param element\n */\nexport function getLocalName(element: Element): string {\n\treturn (\n\t\t// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName\n\t\telement.localName ??\n\t\t// eslint-disable-next-line no-restricted-properties -- required for the fallback\n\t\telement.tagName.toLowerCase()\n\t);\n}\n\nconst localNameToRoleMappings: Record<string, string | undefined> = {\n\tarticle: \"article\",\n\taside: \"complementary\",\n\tbutton: \"button\",\n\tdatalist: \"listbox\",\n\tdd: \"definition\",\n\tdetails: \"group\",\n\tdialog: \"dialog\",\n\tdt: \"term\",\n\tfieldset: \"group\",\n\tfigure: \"figure\",\n\t// WARNING: Only with an accessible name\n\tform: \"form\",\n\tfooter: \"contentinfo\",\n\th1: \"heading\",\n\th2: \"heading\",\n\th3: \"heading\",\n\th4: \"heading\",\n\th5: \"heading\",\n\th6: \"heading\",\n\theader: \"banner\",\n\thr: \"separator\",\n\thtml: \"document\",\n\tlegend: \"legend\",\n\tli: \"listitem\",\n\tmath: \"math\",\n\tmain: \"main\",\n\tmenu: \"list\",\n\tnav: \"navigation\",\n\tol: \"list\",\n\toptgroup: \"group\",\n\t// WARNING: Only in certain context\n\toption: \"option\",\n\toutput: \"status\",\n\tprogress: \"progressbar\",\n\t// WARNING: Only with an accessible name\n\tsection: \"region\",\n\tsummary: \"button\",\n\ttable: \"table\",\n\ttbody: \"rowgroup\",\n\ttextarea: \"textbox\",\n\ttfoot: \"rowgroup\",\n\t// WARNING: Only in certain context\n\ttd: \"cell\",\n\tth: \"columnheader\",\n\tthead: \"rowgroup\",\n\ttr: \"row\",\n\tul: \"list\",\n};\n\nconst prohibitedAttributes: Record<string, Set<string>> = {\n\tcaption: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tcode: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tdeletion: new Set([\"aria-label\", \"aria-labelledby\"]),\n\temphasis: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tgeneric: new Set([\"aria-label\", \"aria-labelledby\", \"aria-roledescription\"]),\n\tinsertion: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tnone: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tparagraph: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tpresentation: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tstrong: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tsubscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tsuperscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n};\n\n/**\n *\n * @param element\n * @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.\n */\nfunction hasGlobalAriaAttributes(element: Element, role: string): boolean {\n\t// https://rawgit.com/w3c/aria/stable/#global_states\n\t// commented attributes are deprecated\n\treturn [\n\t\t\"aria-atomic\",\n\t\t\"aria-busy\",\n\t\t\"aria-controls\",\n\t\t\"aria-current\",\n\t\t\"aria-description\",\n\t\t\"aria-describedby\",\n\t\t\"aria-details\",\n\t\t// \"disabled\",\n\t\t\"aria-dropeffect\",\n\t\t// \"errormessage\",\n\t\t\"aria-flowto\",\n\t\t\"aria-grabbed\",\n\t\t// \"haspopup\",\n\t\t\"aria-hidden\",\n\t\t// \"invalid\",\n\t\t\"aria-keyshortcuts\",\n\t\t\"aria-label\",\n\t\t\"aria-labelledby\",\n\t\t\"aria-live\",\n\t\t\"aria-owns\",\n\t\t\"aria-relevant\",\n\t\t\"aria-roledescription\",\n\t].some((attributeName) => {\n\t\treturn (\n\t\t\telement.hasAttribute(attributeName) &&\n\t\t\t!prohibitedAttributes[role]?.has(attributeName)\n\t\t);\n\t});\n}\n\nfunction ignorePresentationalRole(\n\telement: Element,\n\timplicitRole: string,\n): boolean {\n\t// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none\n\treturn hasGlobalAriaAttributes(element, implicitRole);\n}\n\nexport default function getRole(element: Element): string | null {\n\tconst explicitRole = getExplicitRole(element);\n\tif (explicitRole === null || presentationRoles.indexOf(explicitRole) !== -1) {\n\t\tconst implicitRole = getImplicitRole(element);\n\t\tif (\n\t\t\tpresentationRoles.indexOf(explicitRole || \"\") === -1 ||\n\t\t\tignorePresentationalRole(element, implicitRole || \"\")\n\t\t) {\n\t\t\treturn implicitRole;\n\t\t}\n\t}\n\n\treturn explicitRole;\n}\n\nfunction getImplicitRole(element: Element): string | null {\n\tconst mappedByTag = localNameToRoleMappings[getLocalName(element)];\n\tif (mappedByTag !== undefined) {\n\t\treturn mappedByTag;\n\t}\n\n\tswitch (getLocalName(element)) {\n\t\tcase \"a\":\n\t\tcase \"area\":\n\t\tcase \"link\":\n\t\t\tif (element.hasAttribute(\"href\")) {\n\t\t\t\treturn \"link\";\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"img\":\n\t\t\tif (\n\t\t\t\telement.getAttribute(\"alt\") === \"\" &&\n\t\t\t\t!ignorePresentationalRole(element, \"img\")\n\t\t\t) {\n\t\t\t\treturn \"presentation\";\n\t\t\t}\n\t\t\treturn \"img\";\n\t\tcase \"input\": {\n\t\t\tconst { type } = element as HTMLInputElement;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"button\":\n\t\t\t\tcase \"image\":\n\t\t\t\tcase \"reset\":\n\t\t\t\tcase \"submit\":\n\t\t\t\t\treturn \"button\";\n\t\t\t\tcase \"checkbox\":\n\t\t\t\tcase \"radio\":\n\t\t\t\t\treturn type;\n\t\t\t\tcase \"range\":\n\t\t\t\t\treturn \"slider\";\n\t\t\t\tcase \"email\":\n\t\t\t\tcase \"tel\":\n\t\t\t\tcase \"text\":\n\t\t\t\tcase \"url\":\n\t\t\t\t\tif (element.hasAttribute(\"list\")) {\n\t\t\t\t\t\treturn \"combobox\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"textbox\";\n\n\t\t\t\tcase \"search\":\n\t\t\t\t\tif (element.hasAttribute(\"list\")) {\n\t\t\t\t\t\treturn \"combobox\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"searchbox\";\n\t\t\t\tcase \"number\":\n\t\t\t\t\treturn \"spinbutton\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tcase \"select\":\n\t\t\tif (\n\t\t\t\telement.hasAttribute(\"multiple\") ||\n\t\t\t\t(element as HTMLSelectElement).size > 1\n\t\t\t) {\n\t\t\t\treturn \"listbox\";\n\t\t\t}\n\t\t\treturn \"combobox\";\n\t}\n\treturn null;\n}\n\nfunction getExplicitRole(element: Element): string | null {\n\tconst role = element.getAttribute(\"role\");\n\tif (role !== null) {\n\t\tconst explicitRole = role.trim().split(\" \")[0];\n\t\t// String.prototype.split(sep, limit) will always return an array with at least one member\n\t\t// as long as limit is either undefined or > 0\n\t\tif (explicitRole.length > 0) {\n\t\t\treturn explicitRole;\n\t\t}\n\t}\n\n\treturn null;\n}\n", "export { getLocalName } from \"./getRole\";\nimport getRole, { getLocalName } from \"./getRole\";\n\nexport const presentationRoles = [\"presentation\", \"none\"];\n\nexport function isElement(node: Node | null): node is Element {\n\treturn node !== null && node.nodeType === node.ELEMENT_NODE;\n}\n\nexport function isHTMLTableCaptionElement(\n\tnode: Node | null,\n): node is HTMLTableCaptionElement {\n\treturn isElement(node) && getLocalName(node) === \"caption\";\n}\n\nexport function isHTMLInputElement(\n\tnode: Node | null,\n): node is HTMLInputElement {\n\treturn isElement(node) && getLocalName(node) === \"input\";\n}\n\nexport function isHTMLOptGroupElement(\n\tnode: Node | null,\n): node is HTMLOptGroupElement {\n\treturn isElement(node) && getLocalName(node) === \"optgroup\";\n}\n\nexport function isHTMLSelectElement(\n\tnode: Node | null,\n): node is HTMLSelectElement {\n\treturn isElement(node) && getLocalName(node) === \"select\";\n}\n\nexport function isHTMLTableElement(\n\tnode: Node | null,\n): node is HTMLTableElement {\n\treturn isElement(node) && getLocalName(node) === \"table\";\n}\n\nexport function isHTMLTextAreaElement(\n\tnode: Node | null,\n): node is HTMLTextAreaElement {\n\treturn isElement(node) && getLocalName(node) === \"textarea\";\n}\n\nexport function safeWindow(node: Node): Window {\n\tconst { defaultView } =\n\t\tnode.ownerDocument === null ? (node as Document) : node.ownerDocument;\n\n\tif (defaultView === null) {\n\t\tthrow new TypeError(\"no window available\");\n\t}\n\treturn defaultView;\n}\n\nexport function isHTMLFieldSetElement(\n\tnode: Node | null,\n): node is HTMLFieldSetElement {\n\treturn isElement(node) && getLocalName(node) === \"fieldset\";\n}\n\nexport function isHTMLLegendElement(\n\tnode: Node | null,\n): node is HTMLLegendElement {\n\treturn isElement(node) && getLocalName(node) === \"legend\";\n}\n\nexport function isHTMLSlotElement(node: Node | null): node is HTMLSlotElement {\n\treturn isElement(node) && getLocalName(node) === \"slot\";\n}\n\nexport function isSVGElement(node: Node | null): node is SVGElement {\n\treturn isElement(node) && (node as SVGElement).ownerSVGElement !== undefined;\n}\n\nexport function isSVGSVGElement(node: Node | null): node is SVGSVGElement {\n\treturn isElement(node) && getLocalName(node) === \"svg\";\n}\n\nexport function isSVGTitleElement(node: Node | null): node is SVGTitleElement {\n\treturn isSVGElement(node) && getLocalName(node) === \"title\";\n}\n\n/**\n *\n * @param {Node} node -\n * @param {string} attributeName -\n * @returns {Element[]} -\n */\nexport function queryIdRefs(node: Node, attributeName: string): Element[] {\n\tif (isElement(node) && node.hasAttribute(attributeName)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check\n\t\tconst ids = node.getAttribute(attributeName)!.split(\" \");\n\n\t\t// Browsers that don't support shadow DOM won't have getRootNode\n\t\tconst root = node.getRootNode\n\t\t\t? (node.getRootNode() as Document | ShadowRoot)\n\t\t\t: node.ownerDocument;\n\n\t\treturn ids\n\t\t\t.map((id) => root.getElementById(id))\n\t\t\t.filter(\n\t\t\t\t(element: Element | null): element is Element => element !== null,\n\t\t\t\t// TODO: why does this not narrow?\n\t\t\t) as Element[];\n\t}\n\n\treturn [];\n}\n\nexport function hasAnyConcreteRoles(\n\tnode: Node,\n\troles: Array<string | null>,\n): node is Element {\n\tif (isElement(node)) {\n\t\treturn roles.indexOf(getRole(node)) !== -1;\n\t}\n\treturn false;\n}\n", "/**\n * implements https://w3c.github.io/accname/\n */\nimport ArrayFrom from \"./polyfills/array.from\";\nimport SetLike from \"./polyfills/SetLike\";\nimport {\n\thasAnyConcreteRoles,\n\tisElement,\n\tisHTMLTableCaptionElement,\n\tisHTMLInputElement,\n\tisHTMLSelectElement,\n\tisHTMLTextAreaElement,\n\tsafeWindow,\n\tisHTMLFieldSetElement,\n\tisHTMLLegendElement,\n\tisHTMLOptGroupElement,\n\tisHTMLTableElement,\n\tisHTMLSlotElement,\n\tisSVGSVGElement,\n\tisSVGTitleElement,\n\tqueryIdRefs,\n\tgetLocalName,\n\tpresentationRoles,\n} from \"./util\";\n\n/**\n * A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup.\n */\ntype FlatString = string & {\n\t__flat: true;\n};\ntype GetComputedStyle = typeof window.getComputedStyle;\n\n/**\n * interface for an options-bag where `window.getComputedStyle` can be mocked\n */\nexport interface ComputeTextAlternativeOptions {\n\tcompute?: \"description\" | \"name\";\n\t/**\n\t * Set to true if window.computedStyle supports the second argument.\n\t * This should be false in JSDOM. Otherwise JSDOM will log console errors.\n\t */\n\tcomputedStyleSupportsPseudoElements?: boolean;\n\t/**\n\t * mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n\t */\n\tgetComputedStyle?: GetComputedStyle;\n\t/**\n\t * Set to `true` if you want to include hidden elements in the accessible name and description computation.\n\t * Skips 2A in https://w3c.github.io/accname/#computation-steps.\n\t * @default false\n\t */\n\thidden?: boolean;\n}\n\n/**\n *\n * @param {string} string -\n * @returns {FlatString} -\n */\nfunction asFlatString(s: string): FlatString {\n\treturn s.trim().replace(/\\s\\s+/g, \" \") as FlatString;\n}\n\n/**\n *\n * @param node -\n * @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`\n * @returns {boolean} -\n */\nfunction isHidden(\n\tnode: Node,\n\tgetComputedStyleImplementation: GetComputedStyle,\n): node is Element {\n\tif (!isElement(node)) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tnode.hasAttribute(\"hidden\") ||\n\t\tnode.getAttribute(\"aria-hidden\") === \"true\"\n\t) {\n\t\treturn true;\n\t}\n\n\tconst style = getComputedStyleImplementation(node);\n\treturn (\n\t\tstyle.getPropertyValue(\"display\") === \"none\" ||\n\t\tstyle.getPropertyValue(\"visibility\") === \"hidden\"\n\t);\n}\n\n/**\n * @param {Node} node -\n * @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te\n */\nfunction isControl(node: Node): boolean {\n\treturn (\n\t\thasAnyConcreteRoles(node, [\"button\", \"combobox\", \"listbox\", \"textbox\"]) ||\n\t\thasAbstractRole(node, \"range\")\n\t);\n}\n\nfunction hasAbstractRole(node: Node, role: string): node is Element {\n\tif (!isElement(node)) {\n\t\treturn false;\n\t}\n\n\tswitch (role) {\n\t\tcase \"range\":\n\t\t\treturn hasAnyConcreteRoles(node, [\n\t\t\t\t\"meter\",\n\t\t\t\t\"progressbar\",\n\t\t\t\t\"scrollbar\",\n\t\t\t\t\"slider\",\n\t\t\t\t\"spinbutton\",\n\t\t\t]);\n\t\tdefault:\n\t\t\tthrow new TypeError(\n\t\t\t\t`No knowledge about abstract role '${role}'. This is likely a bug :(`,\n\t\t\t);\n\t}\n}\n\n/**\n * element.querySelectorAll but also considers owned tree\n * @param element\n * @param selectors\n */\nfunction querySelectorAllSubtree(\n\telement: Element,\n\tselectors: string,\n): Element[] {\n\tconst elements = ArrayFrom(element.querySelectorAll(selectors));\n\n\tqueryIdRefs(element, \"aria-owns\").forEach((root) => {\n\t\t// babel transpiles this assuming an iterator\n\t\telements.push.apply(elements, ArrayFrom(root.querySelectorAll(selectors)));\n\t});\n\n\treturn elements;\n}\n\nfunction querySelectedOptions(listbox: Element): ArrayLike<Element> {\n\tif (isHTMLSelectElement(listbox)) {\n\t\t// IE11 polyfill\n\t\treturn (\n\t\t\tlistbox.selectedOptions || querySelectorAllSubtree(listbox, \"[selected]\")\n\t\t);\n\t}\n\treturn querySelectorAllSubtree(listbox, '[aria-selected=\"true\"]');\n}\n\nfunction isMarkedPresentational(node: Node): node is Element {\n\treturn hasAnyConcreteRoles(node, presentationRoles);\n}\n\n/**\n * Elements specifically listed in html-aam\n *\n * We don't need this for `label` or `legend` elements.\n * Their implicit roles already allow \"naming from content\".\n *\n * sources:\n *\n * - https://w3c.github.io/html-aam/#table-element\n */\nfunction isNativeHostLanguageTextAlternativeElement(\n\tnode: Node,\n): node is Element {\n\treturn isHTMLTableCaptionElement(node);\n}\n\n/**\n * https://w3c.github.io/aria/#namefromcontent\n */\nfunction allowsNameFromContent(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"button\",\n\t\t\"cell\",\n\t\t\"checkbox\",\n\t\t\"columnheader\",\n\t\t\"gridcell\",\n\t\t\"heading\",\n\t\t\"label\",\n\t\t\"legend\",\n\t\t\"link\",\n\t\t\"menuitem\",\n\t\t\"menuitemcheckbox\",\n\t\t\"menuitemradio\",\n\t\t\"option\",\n\t\t\"radio\",\n\t\t\"row\",\n\t\t\"rowheader\",\n\t\t\"switch\",\n\t\t\"tab\",\n\t\t\"tooltip\",\n\t\t\"treeitem\",\n\t]);\n}\n\n/**\n * TODO https://github.com/eps1lon/dom-accessibility-api/issues/100\n */\nfunction isDescendantOfNativeHostLanguageTextAlternativeElement(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet\n\tnode: Node,\n): boolean {\n\treturn false;\n}\n\nfunction getValueOfTextbox(element: Element): string {\n\tif (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {\n\t\treturn element.value;\n\t}\n\t// https://github.com/eps1lon/dom-accessibility-api/issues/4\n\treturn element.textContent || \"\";\n}\n\nfunction getTextualContent(declaration: CSSStyleDeclaration): string {\n\tconst content = declaration.getPropertyValue(\"content\");\n\tif (/^[\"'].*[\"']$/.test(content)) {\n\t\treturn content.slice(1, -1);\n\t}\n\treturn \"\";\n}\n\n/**\n * https://html.spec.whatwg.org/multipage/forms.html#category-label\n * TODO: form-associated custom elements\n * @param element\n */\nfunction isLabelableElement(element: Element): boolean {\n\tconst localName = getLocalName(element);\n\n\treturn (\n\t\tlocalName === \"button\" ||\n\t\t(localName === \"input\" && element.getAttribute(\"type\") !== \"hidden\") ||\n\t\tlocalName === \"meter\" ||\n\t\tlocalName === \"output\" ||\n\t\tlocalName === \"progress\" ||\n\t\tlocalName === \"select\" ||\n\t\tlocalName === \"textarea\"\n\t);\n}\n\n/**\n * > [...], then the first such descendant in tree order is the label element's labeled control.\n * -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control\n * @param element\n */\nfunction findLabelableElement(element: Element): Element | null {\n\tif (isLabelableElement(element)) {\n\t\treturn element;\n\t}\n\tlet labelableElement: Element | null = null;\n\telement.childNodes.forEach((childNode) => {\n\t\tif (labelableElement === null && isElement(childNode)) {\n\t\t\tconst descendantLabelableElement = findLabelableElement(childNode);\n\t\t\tif (descendantLabelableElement !== null) {\n\t\t\t\tlabelableElement = descendantLabelableElement;\n\t\t\t}\n\t\t}\n\t});\n\n\treturn labelableElement;\n}\n\n/**\n * Polyfill of HTMLLabelElement.control\n * https://html.spec.whatwg.org/multipage/forms.html#labeled-control\n * @param label\n */\nfunction getControlOfLabel(label: HTMLLabelElement): Element | null {\n\tif (label.control !== undefined) {\n\t\treturn label.control;\n\t}\n\n\tconst htmlFor = label.getAttribute(\"for\");\n\tif (htmlFor !== null) {\n\t\treturn label.ownerDocument.getElementById(htmlFor);\n\t}\n\n\treturn findLabelableElement(label);\n}\n\n/**\n * Polyfill of HTMLInputElement.labels\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels\n * @param element\n */\nfunction getLabels(element: Element): HTMLLabelElement[] | null {\n\tconst labelsProperty = (element as HTMLInputElement).labels as\n\t\t| HTMLInputElement[\"labels\"]\n\t\t| undefined;\n\n\tif (labelsProperty === null) {\n\t\treturn labelsProperty;\n\t}\n\tif (labelsProperty !== undefined) {\n\t\treturn ArrayFrom(labelsProperty);\n\t}\n\n\t// polyfill\n\tif (!isLabelableElement(element)) {\n\t\treturn null;\n\t}\n\tconst document = element.ownerDocument;\n\n\treturn ArrayFrom(document.querySelectorAll(\"label\")).filter((label) => {\n\t\treturn getControlOfLabel(label) === element;\n\t});\n}\n\n/**\n * Gets the contents of a slot used for computing the accname\n * @param slot\n */\nfunction getSlotContents(slot: HTMLSlotElement): Node[] {\n\t// Computing the accessible name for elements containing slots is not\n\t// currently defined in the spec. This implementation reflects the\n\t// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.\n\tconst assignedNodes = slot.assignedNodes();\n\tif (assignedNodes.length === 0) {\n\t\t// if no nodes are assigned to the slot, it displays the default content\n\t\treturn ArrayFrom(slot.childNodes);\n\t}\n\treturn assignedNodes;\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_te\n * @param root\n * @param options\n * @returns\n */\nexport function computeTextAlternative(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {},\n): string {\n\tconst consultedNodes = new SetLike<Node>();\n\tconst computedStyles =\n\t\ttypeof Map === \"undefined\"\n\t\t\t? undefined\n\t\t\t: new Map<Element, CSSStyleDeclaration>();\n\n\tconst window = safeWindow(root);\n\tconst {\n\t\tcompute = \"name\",\n\t\tcomputedStyleSupportsPseudoElements = options.getComputedStyle !==\n\t\t\tundefined,\n\t\t// This might be overengineered. I don't know what happens if I call\n\t\t// window.getComputedStyle(elementFromAnotherWindow) or if I don't bind it\n\t\t// the type declarations don't require a `this`\n\t\t// eslint-disable-next-line no-restricted-properties\n\t\tgetComputedStyle: uncachedGetComputedStyle = window.getComputedStyle.bind(\n\t\t\twindow,\n\t\t),\n\t\thidden = false,\n\t} = options;\n\tconst getComputedStyle: GetComputedStyle = (\n\t\tel,\n\t\tpseudoElement,\n\t): CSSStyleDeclaration => {\n\t\t// We don't cache the pseudoElement styles and calls with psuedo elements\n\t\t// should use the uncached version instead\n\t\tif (pseudoElement !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"use uncachedGetComputedStyle directly for pseudo elements\",\n\t\t\t);\n\t\t}\n\t\t// If Map is not available, it is probably faster to just use the uncached\n\t\t// version since a polyfill lookup would be O(n) instead of O(1) and\n\t\t// the getComputedStyle function in those environments(e.g. IE11) is fast\n\t\tif (computedStyles === undefined) {\n\t\t\treturn uncachedGetComputedStyle(el);\n\t\t}\n\t\tconst cachedStyles = computedStyles.get(el);\n\t\tif (cachedStyles) {\n\t\t\treturn cachedStyles;\n\t\t}\n\t\tconst style = uncachedGetComputedStyle(el, pseudoElement);\n\t\tcomputedStyles.set(el, style);\n\t\treturn style;\n\t};\n\n\t// 2F.i\n\tfunction computeMiscTextAlternative(\n\t\tnode: Node,\n\t\tcontext: { isEmbeddedInLabel: boolean; isReferenced: boolean },\n\t): string {\n\t\tlet accumulatedText = \"\";\n\t\tif (isElement(node) && computedStyleSupportsPseudoElements) {\n\t\t\tconst pseudoBefore = uncachedGetComputedStyle(node, \"::before\");\n\t\t\tconst beforeContent = getTextualContent(pseudoBefore);\n\t\t\taccumulatedText = `${beforeContent} ${accumulatedText}`;\n\t\t}\n\n\t\t// FIXME: Including aria-owns is not defined in the spec\n\t\t// But it is required in the web-platform-test\n\t\tconst childNodes = isHTMLSlotElement(node)\n\t\t\t? getSlotContents(node)\n\t\t\t: ArrayFrom(node.childNodes).concat(queryIdRefs(node, \"aria-owns\"));\n\t\tchildNodes.forEach((child) => {\n\t\t\tconst result = computeTextAlternative(child, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t\trecursion: true,\n\t\t\t});\n\t\t\t// TODO: Unclear why display affects delimiter\n\t\t\t// see https://github.com/w3c/accname/issues/3\n\t\t\tconst display = isElement(child)\n\t\t\t\t? getComputedStyle(child).getPropertyValue(\"display\")\n\t\t\t\t: \"inline\";\n\t\t\tconst separator = display !== \"inline\" ? \" \" : \"\";\n\t\t\t// trailing separator for wpt tests\n\t\t\taccumulatedText += `${separator}${result}${separator}`;\n\t\t});\n\t\tif (isElement(node) && computedStyleSupportsPseudoElements) {\n\t\t\tconst pseudoAfter = uncachedGetComputedStyle(node, \"::after\");\n\t\t\tconst afterContent = getTextualContent(pseudoAfter);\n\t\t\taccumulatedText = `${accumulatedText} ${afterContent}`;\n\t\t}\n\n\t\treturn accumulatedText.trim();\n\t}\n\n\t/**\n\t *\n\t * @param element\n\t * @param attributeName\n\t * @returns A string non-empty string or `null`\n\t */\n\tfunction useAttribute(\n\t\telement: Element,\n\t\tattributeName: string,\n\t): string | null {\n\t\tconst attribute = element.getAttributeNode(attributeName);\n\t\tif (\n\t\t\tattribute !== null &&\n\t\t\t!consultedNodes.has(attribute) &&\n\t\t\tattribute.value.trim() !== \"\"\n\t\t) {\n\t\t\tconsultedNodes.add(attribute);\n\t\t\treturn attribute.value;\n\t\t}\n\t\treturn null;\n\t}\n\n\tfunction computeTooltipAttributeValue(node: Node): string | null {\n\t\tif (!isElement(node)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn useAttribute(node, \"title\");\n\t}\n\n\tfunction computeElementTextAlternative(node: Node): string | null {\n\t\tif (!isElement(node)) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// https://w3c.github.io/html-aam/#fieldset-and-legend-elements\n\t\tif (isHTMLFieldSetElement(node)) {\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isHTMLLegendElement(child)) {\n\t\t\t\t\treturn computeTextAlternative(child, {\n\t\t\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isHTMLTableElement(node)) {\n\t\t\t// https://w3c.github.io/html-aam/#table-element\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isHTMLTableCaptionElement(child)) {\n\t\t\t\t\treturn computeTextAlternative(child, {\n\t\t\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isSVGSVGElement(node)) {\n\t\t\t// https://www.w3.org/TR/svg-aam-1.0/\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isSVGTitleElement(child)) {\n\t\t\t\t\treturn child.textContent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} else if (getLocalName(node) === \"img\" || getLocalName(node) === \"area\") {\n\t\t\t// https://w3c.github.io/html-aam/#area-element\n\t\t\t// https://w3c.github.io/html-aam/#img-element\n\t\t\tconst nameFromAlt = useAttribute(node, \"alt\");\n\t\t\tif (nameFromAlt !== null) {\n\t\t\t\treturn nameFromAlt;\n\t\t\t}\n\t\t} else if (isHTMLOptGroupElement(node)) {\n\t\t\tconst nameFromLabel = useAttribute(node, \"label\");\n\t\t\tif (nameFromLabel !== null) {\n\t\t\t\treturn nameFromLabel;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tisHTMLInputElement(node) &&\n\t\t\t(node.type === \"button\" ||\n\t\t\t\tnode.type === \"submit\" ||\n\t\t\t\tnode.type === \"reset\")\n\t\t) {\n\t\t\t// https://w3c.github.io/html-aam/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-description-computation\n\t\t\tconst nameFromValue = useAttribute(node, \"value\");\n\t\t\tif (nameFromValue !== null) {\n\t\t\t\treturn nameFromValue;\n\t\t\t}\n\n\t\t\t// TODO: l10n\n\t\t\tif (node.type === \"submit\") {\n\t\t\t\treturn \"Submit\";\n\t\t\t}\n\t\t\t// TODO: l10n\n\t\t\tif (node.type === \"reset\") {\n\t\t\t\treturn \"Reset\";\n\t\t\t}\n\t\t}\n\n\t\tconst labels = getLabels(node);\n\t\tif (labels !== null && labels.length !== 0) {\n\t\t\tconsultedNodes.add(node);\n\t\t\treturn ArrayFrom(labels)\n\t\t\t\t.map((element) => {\n\t\t\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t\t\tisEmbeddedInLabel: true,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: true,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.filter((label) => {\n\t\t\t\t\treturn label.length > 0;\n\t\t\t\t})\n\t\t\t\t.join(\" \");\n\t\t}\n\n\t\t// https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation\n\t\t// TODO: wpt test consider label elements but html-aam does not mention them\n\t\t// We follow existing implementations over spec\n\t\tif (isHTMLInputElement(node) && node.type === \"image\") {\n\t\t\tconst nameFromAlt = useAttribute(node, \"alt\");\n\t\t\tif (nameFromAlt !== null) {\n\t\t\t\treturn nameFromAlt;\n\t\t\t}\n\n\t\t\tconst nameFromTitle = useAttribute(node, \"title\");\n\t\t\tif (nameFromTitle !== null) {\n\t\t\t\treturn nameFromTitle;\n\t\t\t}\n\n\t\t\t// TODO: l10n\n\t\t\treturn \"Submit Query\";\n\t\t}\n\n\t\tif (hasAnyConcreteRoles(node, [\"button\"])) {\n\t\t\t// https://www.w3.org/TR/html-aam-1.0/#button-element\n\t\t\tconst nameFromSubTree = computeMiscTextAlternative(node, {\n\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t\tif (nameFromSubTree !== \"\") {\n\t\t\t\treturn nameFromSubTree;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfunction computeTextAlternative(\n\t\tcurrent: Node,\n\t\tcontext: {\n\t\t\tisEmbeddedInLabel: boolean;\n\t\t\tisReferenced: boolean;\n\t\t\trecursion: boolean;\n\t\t},\n\t): string {\n\t\tif (consultedNodes.has(current)) {\n\t\t\treturn \"\";\n\t\t}\n\t\t// 2A\n\t\tif (\n\t\t\t!hidden &&\n\t\t\tisHidden(current, getComputedStyle) &&\n\t\t\t!context.isReferenced\n\t\t) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn \"\" as FlatString;\n\t\t}\n\n\t\t// 2B\n\t\tconst labelAttributeNode = isElement(current)\n\t\t\t? current.getAttributeNode(\"aria-labelledby\")\n\t\t\t: null;\n\t\t// TODO: Do we generally need to block query IdRefs of attributes we have already consulted?\n\t\tconst labelElements =\n\t\t\tlabelAttributeNode !== null && !consultedNodes.has(labelAttributeNode)\n\t\t\t\t? queryIdRefs(current, \"aria-labelledby\")\n\t\t\t\t: [];\n\t\tif (\n\t\t\tcompute === \"name\" &&\n\t\t\t!context.isReferenced &&\n\t\t\tlabelElements.length > 0\n\t\t) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Can't be null here otherwise labelElements would be empty\n\t\t\tconsultedNodes.add(labelAttributeNode!);\n\n\t\t\treturn labelElements\n\t\t\t\t.map((element) => {\n\t\t\t\t\t// TODO: Chrome will consider repeated values i.e. use a node multiple times while we'll bail out in computeTextAlternative.\n\t\t\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\t\t\tisReferenced: true,\n\t\t\t\t\t\t// this isn't recursion as specified, otherwise we would skip\n\t\t\t\t\t\t// `aria-label` in\n\t\t\t\t\t\t// <input id=\"myself\" aria-label=\"foo\" aria-labelledby=\"myself\"\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.join(\" \");\n\t\t}\n\n\t\t// 2C\n\t\t// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64\n\t\t// spec says we should only consider skipping if we have a non-empty label\n\t\tconst skipToStep2E =\n\t\t\tcontext.recursion && isControl(current) && compute === \"name\";\n\t\tif (!skipToStep2E) {\n\t\t\tconst ariaLabel = (\n\t\t\t\t(isElement(current) && current.getAttribute(\"aria-label\")) ||\n\t\t\t\t\"\"\n\t\t\t).trim();\n\t\t\tif (ariaLabel !== \"\" && compute === \"name\") {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn ariaLabel;\n\t\t\t}\n\n\t\t\t// 2D\n\t\t\tif (!isMarkedPresentational(current)) {\n\t\t\t\tconst elementTextAlternative = computeElementTextAlternative(current);\n\t\t\t\tif (elementTextAlternative !== null) {\n\t\t\t\t\tconsultedNodes.add(current);\n\t\t\t\t\treturn elementTextAlternative;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// special casing, cheating to make tests pass\n\t\t// https://github.com/w3c/accname/issues/67\n\t\tif (hasAnyConcreteRoles(current, [\"menu\"])) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn \"\";\n\t\t}\n\n\t\t// 2E\n\t\tif (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {\n\t\t\tif (hasAnyConcreteRoles(current, [\"combobox\", \"listbox\"])) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\tconst selectedOptions = querySelectedOptions(current);\n\t\t\t\tif (selectedOptions.length === 0) {\n\t\t\t\t\t// defined per test `name_heading_combobox`\n\t\t\t\t\treturn isHTMLInputElement(current) ? current.value : \"\";\n\t\t\t\t}\n\t\t\t\treturn ArrayFrom(selectedOptions)\n\t\t\t\t\t.map((selectedOption) => {\n\t\t\t\t\t\treturn computeTextAlternative(selectedOption, {\n\t\t\t\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\t\trecursion: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.join(\" \");\n\t\t\t}\n\t\t\tif (hasAbstractRole(current, \"range\")) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\tif (current.hasAttribute(\"aria-valuetext\")) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard\n\t\t\t\t\treturn current.getAttribute(\"aria-valuetext\")!;\n\t\t\t\t}\n\t\t\t\tif (current.hasAttribute(\"aria-valuenow\")) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard\n\t\t\t\t\treturn current.getAttribute(\"aria-valuenow\")!;\n\t\t\t\t}\n\t\t\t\t// Otherwise, use the value as specified by a host language attribute.\n\t\t\t\treturn current.getAttribute(\"value\") || \"\";\n\t\t\t}\n\t\t\tif (hasAnyConcreteRoles(current, [\"textbox\"])) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn getValueOfTextbox(current);\n\t\t\t}\n\t\t}\n\n\t\t// 2F: https://w3c.github.io/accname/#step2F\n\t\tif (\n\t\t\tallowsNameFromContent(current) ||\n\t\t\t(isElement(current) && context.isReferenced) ||\n\t\t\tisNativeHostLanguageTextAlternativeElement(current) ||\n\t\t\tisDescendantOfNativeHostLanguageTextAlternativeElement(current)\n\t\t) {\n\t\t\tconst accumulatedText2F = computeMiscTextAlternative(current, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t\tif (accumulatedText2F !== \"\") {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn accumulatedText2F;\n\t\t\t}\n\t\t}\n\n\t\tif (current.nodeType === current.TEXT_NODE) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn current.textContent || \"\";\n\t\t}\n\n\t\tif (context.recursion) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn computeMiscTextAlternative(current, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t}\n\n\t\tconst tooltipAttributeValue = computeTooltipAttributeValue(current);\n\t\tif (tooltipAttributeValue !== null) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn tooltipAttributeValue;\n\t\t}\n\n\t\t// TODO should this be reachable?\n\t\tconsultedNodes.add(current);\n\t\treturn \"\";\n\t}\n\n\treturn asFlatString(\n\t\tcomputeTextAlternative(root, {\n\t\t\tisEmbeddedInLabel: false,\n\t\t\t// by spec computeAccessibleDescription starts with the referenced elements as roots\n\t\t\tisReferenced: compute === \"description\",\n\t\t\trecursion: false,\n\t\t}),\n\t);\n}\n", "import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { hasAnyConcreteRoles } from \"./util\";\n\n/**\n * https://w3c.github.io/aria/#namefromprohibited\n */\nfunction prohibitsNaming(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"caption\",\n\t\t\"code\",\n\t\t\"deletion\",\n\t\t\"emphasis\",\n\t\t\"generic\",\n\t\t\"insertion\",\n\t\t\"none\",\n\t\t\"paragraph\",\n\t\t\"presentation\",\n\t\t\"strong\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t]);\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_name\n * @param root\n * @param options\n * @returns\n */\nexport function computeAccessibleName(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {},\n): string {\n\tif (prohibitsNaming(root)) {\n\t\treturn \"\";\n\t}\n\n\treturn computeTextAlternative(root, options);\n}\n", "export interface IsInaccessibleOptions {\n\tgetComputedStyle?: typeof window.getComputedStyle;\n\t/**\n\t * Can be used to return cached results from previous isSubtreeInaccessible calls.\n\t */\n\tisSubtreeInaccessible?: (element: Element) => boolean;\n}\n\n/**\n * Partial implementation https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion\n * which should only be used for elements with a non-presentational role i.e.\n * `role=\"none\"` and `role=\"presentation\"` will not be excluded.\n *\n * Implements aria-hidden semantics (i.e. parent overrides child)\n * Ignores \"Child Presentational: True\" characteristics\n *\n * @param element\n * @param options\n * @returns {boolean} true if excluded, otherwise false\n */\nexport function isInaccessible(\n\telement: Element,\n\toptions: IsInaccessibleOptions = {},\n): boolean {\n\tconst {\n\t\tgetComputedStyle = element.ownerDocument.defaultView?.getComputedStyle,\n\t\tisSubtreeInaccessible: isSubtreeInaccessibleImpl = isSubtreeInaccessible,\n\t} = options;\n\tif (typeof getComputedStyle !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Owner document of the element needs to have an associated window.\",\n\t\t);\n\t}\n\t// since visibility is inherited we can exit early\n\tif (getComputedStyle(element).visibility === \"hidden\") {\n\t\treturn true;\n\t}\n\n\tlet currentElement: Element | null = element;\n\twhile (currentElement) {\n\t\tif (isSubtreeInaccessibleImpl(currentElement, { getComputedStyle })) {\n\t\t\treturn true;\n\t\t}\n\n\t\tcurrentElement = currentElement.parentElement;\n\t}\n\n\treturn false;\n}\n\nexport interface IsSubtreeInaccessibleOptions {\n\tgetComputedStyle?: typeof window.getComputedStyle;\n}\n\n/**\n *\n * @param element\n * @param options\n * @returns {boolean} - `true` if every child of the element is inaccessible\n */\nexport function isSubtreeInaccessible(\n\telement: Element,\n\toptions: IsSubtreeInaccessibleOptions = {},\n): boolean {\n\tconst {\n\t\tgetComputedStyle = element.ownerDocument.defaultView?.getComputedStyle,\n\t} = options;\n\tif (typeof getComputedStyle !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Owner document of the element needs to have an associated window.\",\n\t\t);\n\t}\n\n\tif ((element as HTMLElement).hidden === true) {\n\t\treturn true;\n\t}\n\n\tif (element.getAttribute(\"aria-hidden\") === \"true\") {\n\t\treturn true;\n\t}\n\n\tif (getComputedStyle(element).display === \"none\") {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n", "import { getLocalName } from \"./getRole\";\n\nconst elementsSupportingDisabledAttribute = new Set([\n\t\"button\",\n\t\"fieldset\",\n\t\"input\",\n\t\"optgroup\",\n\t\"option\",\n\t\"select\",\n\t\"textarea\",\n]);\n\n/**\n * Check if an element is disabled\n * https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings\n * https://www.w3.org/TR/wai-aria-1.1/#aria-disabled\n *\n * @param element\n * @returns {boolean} true if disabled, otherwise false\n */\nexport function isDisabled(element: Element): boolean {\n\tconst localName = getLocalName(element);\n\treturn elementsSupportingDisabledAttribute.has(localName) &&\n\t\telement.hasAttribute(\"disabled\")\n\t\t? true\n\t\t: element.getAttribute(\"aria-disabled\") === \"true\";\n}\n", "import {\n computeAccessibleName,\n getRole,\n isDisabled,\n} from 'dom-accessibility-api';\n\n/**\n * Role, name, visibility, interactability, state.\n *\n * WHAT WE ADOPTED: role and accessible name come from `dom-accessibility-api`\n * (MIT, zero deps) \u2014 the engine behind testing-library's `getByRole`. Accessible\n * name is a genuinely hard spec (accname walks aria-labelledby graphs, ::before\n * content, <label> associations, alt/title fallbacks, and recursive\n * name-from-content) and a hand-rolled version is wrong in ways you only discover\n * on a customer's page.\n *\n * WHAT WE BUILT: everything below that. Visibility and pointer-events are ~20 lines\n * from first principles (see `isVisible`/`receivesPointerEvents`) and the state\n * reads are direct DOM/ARIA reads, so we vendored nothing and took on no\n * Apache-2.0 attribution obligation.\n */\n\n/** A memoised `getComputedStyle`, shaped to be passed straight to accname. */\nexport type StyleOf = typeof window.getComputedStyle;\n\n/**\n * One computed style per element per snapshot.\n *\n * Not a micro-optimisation: `computeAccessibleName` calls back into\n * getComputedStyle for every descendant it walks while building a name from\n * content, so on a page of nested divs the uncached cost is quadratic-ish. The\n * cache is per-snapshot (a fresh WeakMap each walk), so it can never go stale\n * across snapshots.\n */\nexport function createStyleCache(): StyleOf {\n const cache = new WeakMap<Element, CSSStyleDeclaration>();\n return ((el: Element, pseudo?: string | null): CSSStyleDeclaration => {\n // Pseudo-element lookups are rare and must not poison the element cache.\n if (pseudo) return window.getComputedStyle(el, pseudo);\n let style = cache.get(el);\n if (!style) {\n style = window.getComputedStyle(el);\n cache.set(el, style);\n }\n return style;\n }) as StyleOf;\n}\n\n/**\n * Does this environment do layout at all?\n *\n * In a browser the root element always has a box. In jsdom \u2014 which has no layout\n * engine \u2014 *everything* reports zero client rects, so a box-based visibility check\n * would hide the entire page and our tests would assert on an empty snapshot. So we\n * feature-detect layout once per walk and fall back to style-only visibility when\n * there is none. This is a test-environment concession, stated out loud rather than\n * hidden behind a mock.\n */\nexport function hasLayout(): boolean {\n return document.documentElement.getClientRects().length > 0;\n}\n\n/**\n * Visible enough to be worth telling the agent about.\n *\n * `display` and `visibility` are read from the computed style, which already\n * accounts for inheritance \u2014 and because the walk is top-down and prunes whole\n * subtrees, we never pay for an ancestor walk. `display: contents` is the one\n * subtlety: such an element generates no box of its own but its children do, so it\n * must not be treated as invisible or we would drop a real subtree.\n */\nexport function isVisible(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n const display = style.display;\n if (display === 'none') return false;\n\n const visibility = style.visibility;\n if (visibility === 'hidden' || visibility === 'collapse') return false;\n\n // `opacity: 0` is a standard \"hide from sight, keep for a11y\" technique. It still\n // reports a box, so the area check below misses it. We treat fully-transparent as\n // hidden; a partially-transparent element is genuinely on screen.\n if (Number(style.opacity) === 0) return false;\n\n // A `display: contents` element generates no box of its own but its children do,\n // so it must not be judged by its own (nonexistent) geometry \u2014 we let it through\n // and test each child on its own merits.\n if (layout && display !== 'contents') {\n // Area, not merely \"has a box\": `width:0;height:0;overflow:hidden` is one of the\n // commonest ways to hide a thing, and such an element still reports a client\n // rect. This is the check Playwright's own isVisible() makes.\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return false;\n\n // The sr-only / visually-hidden family: `clip: rect(0 0 0 0)` and its modern\n // `clip-path: inset(50%)` shrink the element to nothing while keeping a 1px box,\n // and `position:absolute; left:-9999px` parks it far off any real page. All three\n // are \"screen-reader only\" idioms \u2014 present for a11y, not for sight \u2014 so an agent\n // reading the page should skip them too. (getClientRects().length === 0 catches\n // the clipped ones; the far-offscreen check catches the parked ones.)\n if (el.getClientRects().length === 0) return false;\n if (box.right < -2000 || box.bottom < -2000) return false;\n }\n\n return true;\n}\n\n/**\n * Can a pointer actually reach it?\n *\n * `pointer-events` is an INHERITED property, so the computed value on the element\n * already encodes every ancestor's `pointer-events: none` \u2014 and correctly honours a\n * descendant that opts back in with `pointer-events: auto`. That is the whole check:\n * no ancestor walk, no hit-test. We deliberately do NOT test for occlusion (is\n * something painted on top of it) the way Playwright's actionability check does \u2014\n * we are describing the page, not clicking it, and an element under a sticky header\n * is still worth telling the agent about.\n */\nexport function receivesPointerEvents(style: CSSStyleDeclaration): boolean {\n return style.pointerEvents !== 'none';\n}\n\n/** Roles that are inherently operable. */\nconst INTERACTIVE_ROLES = new Set([\n 'button',\n 'checkbox',\n 'combobox',\n 'link',\n 'listbox',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'searchbox',\n 'slider',\n 'spinbutton',\n 'switch',\n 'tab',\n 'textbox',\n 'treeitem',\n]);\n\n/** Tags that are operable regardless of what role they compute to. */\nconst INTERACTIVE_TAGS = new Set([\n 'BUTTON',\n 'INPUT',\n 'SELECT',\n 'TEXTAREA',\n 'SUMMARY',\n]);\n\n/** `contenteditable` \u2014 present and not explicitly \"false\" (covers \"\", \"true\", \"plaintext-only\"). */\nexport function isEditable(el: Element): boolean {\n const v = el.getAttribute('contenteditable');\n return v !== null && v !== 'false';\n}\n\n/**\n * Is this element something the user can operate?\n *\n * THIS IS THE INTERESTING FUNCTION, so here is the reasoning in full.\n *\n * The obvious way to answer it \u2014 ask the DOM what event listeners are attached \u2014\n * IS NOT AVAILABLE. `getEventListeners()` exists only inside DevTools (and via CDP).\n * We are ordinary page JS on a customer's website, so every `addEventListener` a\n * React, Vue or Svelte app ever registered is, to us, completely invisible. This is\n * precisely where the browser-use style of in-page DOM extraction degrades on real\n * apps: it cannot see a single handler, so it either misses the app's controls or\n * guesses wildly. We therefore never ask \"does it have a handler\"; we ask \"does it\n * PRESENT ITSELF as operable\", in four descending tiers of confidence:\n *\n * 1. TAG SEMANTICS (certain). button, input, select, textarea, summary, a[href].\n * 2. COMPUTED ROLE (certain). role=button|link|checkbox|\u2026 whether implicit or\n * author-supplied. A div with role=\"button\" is a\n * button as far as the platform, a screen reader,\n * and the user are concerned.\n * 3. FOCUSABILITY (strong). tabindex >= 0, or contenteditable. An app that\n * made a div keyboard-reachable did so on purpose.\n * 4. `cursor: pointer` (WEAK). Last resort, and the reason for the guard below.\n *\n * Tier 4 needs care, because `cursor` is INHERITED: a card with `cursor: pointer`\n * makes every span, every icon and every text node inside it report `pointer` too,\n * and a naive check would mint a ref for each of them and drown the snapshot. So we\n * only count the element that *introduced* the pointer cursor \u2014 the one whose parent\n * did not already have it. That is almost exactly the clickable card itself.\n */\nexport function isInteractive(\n el: Element,\n role: string | null,\n style: CSSStyleDeclaration,\n parentStyle: CSSStyleDeclaration | null,\n): boolean {\n const tag = el.tagName;\n\n // 1. tag semantics\n // An <a href> is interactive, but a hrefless <a> is NOT a dead end \u2014 it may be a\n // JS-nav link, an <a role=\"button\">, or a Bootstrap `.btn` anchor. So href is a\n // positive signal, not a gate: fall through to the role/tabindex/cursor tiers\n // rather than returning false and dropping every SPA link.\n if (tag === 'A' && el.hasAttribute('href')) return true;\n if (INTERACTIVE_TAGS.has(tag)) return true;\n\n // 2. computed role\n if (role !== null && INTERACTIVE_ROLES.has(role)) return true;\n\n // 3. focusability\n const tabindex = el.getAttribute('tabindex');\n if (tabindex !== null && Number(tabindex) >= 0) return true;\n if (isEditable(el)) return true;\n\n // 4. cursor: pointer, but only where it originates (see above)\n if (style.cursor === 'pointer' && parentStyle?.cursor !== 'pointer')\n return true;\n\n return false;\n}\n\n/**\n * Roles whose accessible name IS their text content (ARIA \"Name From: contents\").\n *\n * This is the exact list from the ARIA spec, and it earns its place: it is what tells\n * the walk that the \"Export CSV\" inside `<button>Export CSV</button>` has ALREADY been\n * emitted, as the button's name, and must not be repeated as a child text node.\n *\n * The tempting shortcut \u2014 \"skip any text that appears inside the parent's name\" \u2014 is\n * wrong, and wrong in a way that silently deletes content: a card labelled\n * `aria-label=\"Acme Corp order\"` containing the text \"Acme Corp\" would lose it,\n * because one is a substring of the other by coincidence. Ask the role, not the string.\n */\nexport const NAME_FROM_CONTENT = new Set([\n 'button',\n 'cell',\n 'checkbox',\n 'columnheader',\n 'gridcell',\n 'heading',\n 'link',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'row',\n 'rowheader',\n 'switch',\n 'tab',\n 'tooltip',\n 'treeitem',\n]);\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** Roles whose content IS the user's data. We report that a value exists, never what it is. */\nconst VALUE_ROLES = new Set(['textbox', 'searchbox', 'spinbutton']);\n\n/**\n * Roles we refuse to descend into, because their children/content ARE the value.\n *\n * A `<textarea>`'s child text node is literally what the user typed; a\n * contenteditable's subtree is the document they are writing. Refusing to walk in is\n * how \"never emit a value\" is enforced STRUCTURALLY, rather than by remembering to\n * filter at every emit site.\n *\n * `<select>` is deliberately NOT here. Its options are a bounded, author-defined\n * enumeration \u2014 the affordance the agent most needs (\"what can I set this to\"), not\n * the free-text user data the opaque rule exists to contain. The snapshot emits them\n * directly instead (capped, selected one marked): see emitSelectOptions in\n * snapshot.ts.\n */\nconst OPAQUE_TAGS = new Set(['INPUT', 'TEXTAREA']);\n\nexport function isOpaque(el: Element): boolean {\n return OPAQUE_TAGS.has(el.tagName) || isEditable(el);\n}\n\n/**\n * Has the user put something in this field?\n *\n * `.value` is read and immediately thrown away \u2014 only its LENGTH escapes. This is\n * the single most useful bit about a form (\"is the email box already filled in?\")\n * and the single most dangerous string on the page, so it is reduced to one bit at\n * the point of reading and never travels.\n */\nfunction isFilled(el: Element, role: string): boolean {\n const tag = el.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA') {\n if (!VALUE_ROLES.has(role)) return false; // checkbox.value is \"on\" \u2014 meaningless\n return ((el as HTMLInputElement).value ?? '').length > 0;\n }\n if (isEditable(el)) return (el.textContent ?? '').trim().length > 0;\n return false;\n}\n\nfunction ariaFlag(el: Element, attr: string): 'true' | 'mixed' | null {\n const v = el.getAttribute(attr);\n if (v === 'true') return 'true';\n if (v === 'mixed') return 'mixed';\n return null;\n}\n\n/**\n * The bracketed attributes, in Playwright's order:\n * [checked] [disabled] [expanded] [level=N] [pressed] [selected]\n * plus our one addition, [filled] \u2014 see isFilled. `[ref=eN]` is appended by the\n * caller and always comes last.\n */\nexport function states(el: Element, role: string): string {\n const out: string[] = [];\n const tag = el.tagName;\n\n // checked\n if (tag === 'INPUT' && (role === 'checkbox' || role === 'radio')) {\n if ((el as HTMLInputElement).checked) out.push('[checked]');\n } else {\n const checked = ariaFlag(el, 'aria-checked');\n if (checked === 'mixed') out.push('[checked=mixed]');\n else if (checked === 'true') out.push('[checked]');\n }\n\n // disabled \u2014 dom-accessibility-api handles fieldset/optgroup inheritance and aria-disabled\n if (isDisabled(el)) out.push('[disabled]');\n\n // expanded \u2014 <summary> reflects its parent <details>, which has no ARIA attribute\n const expanded = el.getAttribute('aria-expanded');\n if (expanded === 'true' || expanded === 'false') {\n if (expanded === 'true') out.push('[expanded]');\n } else if (tag === 'SUMMARY') {\n const details = el.parentElement;\n if (\n details?.tagName === 'DETAILS' &&\n (details as HTMLDetailsElement).open\n ) {\n out.push('[expanded]');\n }\n }\n\n // level\n if (role === 'heading') {\n const aria = el.getAttribute('aria-level');\n const level = aria ? Number(aria) : Number(tag[1]);\n if (Number.isFinite(level) && level > 0) out.push(`[level=${level}]`);\n }\n\n // pressed\n const pressed = ariaFlag(el, 'aria-pressed');\n if (pressed === 'mixed') out.push('[pressed=mixed]');\n else if (pressed === 'true') out.push('[pressed]');\n\n // selected\n if (el.getAttribute('aria-selected') === 'true') out.push('[selected]');\n\n // filled (ours \u2014 a boolean, never the value)\n if (isFilled(el, role)) out.push('[filled]');\n\n return out.join(' ');\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 role & name \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * The computed role, with one correction.\n *\n * `getRole` follows HTML-AAM and returns null for a contenteditable div \u2014 but every\n * real browser exposes it to assistive tech as a textbox, and that is what it is to\n * the user and to the agent. We say textbox.\n */\nexport function roleOf(el: Element): string | null {\n if (isEditable(el)) return 'textbox';\n return getRole(el);\n}\n\n/**\n * Selector for anything whose CONTENT is the user's data \u2014 a form control, a\n * contenteditable, a valued widget, or a host-marked private region.\n */\nconst UNTRUSTED_CONTENT =\n 'input,textarea,select,[contenteditable=\"\"],[contenteditable=\"true\"],[aria-valuetext],[data-mf-private]';\n\n/**\n * Would computing this element's ACCESSIBLE NAME read the user's data?\n *\n * This is the leak the structural `isOpaque` walk cannot see. `computeAccessibleName`\n * runs its OWN descendant walk, inside dom-accessibility-api, that knows nothing about\n * our opaque set or `data-mf-private` \u2014 it will happily read `input.value`,\n * `aria-valuetext`, a contenteditable's text, or a private subtree, and fold it into\n * the name of a name-from-content ANCESTOR or any `aria-labelledby` referrer. So a\n * value our walk refuses to enter re-enters through the parent's name.\n *\n * Two vectors, both handled:\n * - name-from-content: the name is built from descendant text. If any descendant is\n * untrusted, the name is tainted.\n * - aria-labelledby: the name is pulled from a referenced element. If any referent\n * is (or contains) untrusted content, the name is tainted.\n *\n * `aria-label` and `title` are author-written static strings; a site that copies its\n * own secret into one is exposing it deliberately and we cannot defend that. The\n * automatic-computation vectors are the ones we must close.\n */\nfunction nameIsUntrusted(el: Element): boolean {\n const labelledby = el.getAttribute('aria-labelledby');\n if (labelledby) {\n for (const id of labelledby.split(/\\s+/)) {\n if (!id) continue;\n const ref = el.ownerDocument.getElementById(id);\n if (!ref) continue;\n if (\n ref.matches(UNTRUSTED_CONTENT) ||\n ref.querySelector(UNTRUSTED_CONTENT)\n ) {\n return true;\n }\n }\n return false;\n }\n // No explicit label attributes \u2192 the name, if any, is name-from-content.\n if (el.hasAttribute('aria-label')) return false;\n return el.querySelector(UNTRUSTED_CONTENT) !== null;\n}\n\nexport function nameOf(el: Element, styleOf: StyleOf): string {\n const name = computeAccessibleName(el, {\n getComputedStyle: styleOf,\n // jsdom logs a console error if you claim pseudo-element support it doesn't have.\n computedStyleSupportsPseudoElements: false,\n });\n if (!name) return '';\n\n // A tainted name would leak a value or a private string. Drop it entirely and let\n // the element stand on its role + ref. Losing a name costs the agent a little\n // context; keeping a leaked one is a breach. The trade is not close.\n if (nameIsUntrusted(el)) {\n // Preserve an explicit author label if one exists and is not itself the taint \u2014\n // aria-labelledby taints were already caught above, so any aria-label here is safe.\n return el.getAttribute('aria-label') || '';\n }\n return name;\n}\n", "import type { ElementRef } from '../protocol';\n\n/**\n * Element handles.\n *\n * The mechanism is Playwright's, deliberately (see protocol.ts): the agent never\n * learns a selector, it learns `e12`, and `e12` is turned back into an element\n * HERE, in the page, by us.\n *\n * Three properties matter and all are load-bearing:\n *\n * 1. THE MAP IS A WeakMap, NOT AN EXPANDO ON THE ELEMENT. An earlier version\n * stamped `el._mfRef`. Non-enumerable, so invisible to `Object.keys`/spreads/\n * `JSON.stringify` \u2014 but STILL reachable via `Object.getOwnPropertyNames` and\n * `Reflect.ownKeys`, and, worse, it parked the element's accessible name on the\n * customer's live DOM node indefinitely. A `WeakMap<Element, RefEntry>` mutates\n * nothing on their objects, is invisible to every enumeration and serialization\n * API without exception, cannot collide with a property the host already has,\n * and still gives us node-identity survival across GC for free.\n *\n * 2. A REF IS REGENERATED WHEN ROLE OR NAME CHANGES. Frameworks recycle DOM nodes:\n * a virtualised list scrolls, and the <button> that said \"Approve\" is the very\n * same node that now says \"Delete\". Keying the ref on (role, name) means that\n * node gets a NEW id and the old id resolves to nothing.\n *\n * 3. A REF IS SCOPED TO ONE SNAPSHOT GENERATION. (2) is necessary but not\n * sufficient: two icon-only \"Delete\" buttons in a virtualised table have the\n * SAME (role, name), so a recycled node whose role+name are unchanged would keep\n * its ref and silently retarget a different logical row. So a ref also carries\n * the generation it was minted in, and resolveRef refuses a ref from an older\n * generation \u2014 the agent must re-snapshot to get a fresh, valid handle. Loud\n * staleness beats silent retargeting.\n */\n\ninterface RefEntry {\n id: ElementRef;\n /** role + name at mint time. Changes here invalidate the ref. */\n key: string;\n /** The snapshot generation this ref belongs to. */\n gen: number;\n}\n\n/**\n * Monotonic across snapshots, never reused \u2014 like Playwright's. An id is only ever\n * handed out once in a page's lifetime, so a stale ref can never be *silently*\n * correct by colliding with a newer element; it just resolves to null.\n */\nlet counter = 0;\n\n/** Bumped once per full snapshot. A ref is only valid within its own generation. */\nlet generation = 0;\n\n/**\n * Element identity, off the host's objects entirely. Keyed by element so a recycled\n * node is recognised across snapshots; the entry carries the (role,name) key and the\n * generation for the two staleness checks above.\n */\nconst entries = new WeakMap<Element, RefEntry>();\n\n/** id -> element, for resolution. Rebuilt each generation from exactly what was emitted. */\nconst registry = new Map<ElementRef, Element>();\n\n/** Called once per FULL snapshot, before the walk. A region read does NOT call this. */\nexport function beginSnapshot(): void {\n generation++;\n registry.clear();\n}\n\n/**\n * Mint (or reuse) the ref for an element and register it for resolution.\n * Only ever called for elements that are visible AND receive pointer events.\n */\nexport function refFor(el: Element, role: string, name: string): ElementRef {\n const key = `${role} ${name}`;\n\n let entry = entries.get(el);\n if (!entry || entry.key !== key) {\n entry = { id: `e${++counter}`, key, gen: generation };\n entries.set(el, entry);\n } else {\n // Same node, same identity \u2014 carry it into the current generation so a fresh\n // snapshot re-validates a still-present element rather than orphaning it.\n entry.gen = generation;\n }\n\n registry.set(entry.id, el);\n return entry.id;\n}\n\n/**\n * Turn a ref back into an element.\n *\n * Three ways this returns null, each deliberate:\n * - unknown id (never minted, or from a cleared generation) \u2192 not in the registry;\n * - the element left the page \u2192 `isConnected` is false. A detached node still\n * answers every question (role, name, a zero box), so without this an action\n * would silently no-op against a ghost;\n * - the ref is from an OLDER generation \u2192 its entry.gen has been superseded. This is\n * what stops a recycled-node retarget: the agent is told the handle is stale and\n * must re-snapshot, rather than acting on the wrong row.\n */\nexport function resolveRef(ref: ElementRef): Element | null {\n const el = registry.get(ref);\n if (!el) return null;\n if (!el.isConnected) {\n registry.delete(ref);\n return null;\n }\n const entry = entries.get(el);\n if (!entry || entry.id !== ref || entry.gen !== generation) return null;\n return el;\n}\n\n/** Test-only: reset counters so refs are deterministic per test. */\nexport function __resetRefs(): void {\n counter = 0;\n generation = 0;\n registry.clear();\n}\n", "import { isDisabled, isInaccessible } from 'dom-accessibility-api';\n\nimport { isPrivate, redact } from '../context';\nimport {\n createStyleCache,\n hasLayout,\n isInteractive,\n NAME_FROM_CONTENT,\n isOpaque,\n isVisible,\n nameOf,\n receivesPointerEvents,\n roleOf,\n states,\n type StyleOf,\n} from './a11y';\nimport { beginSnapshot, refFor } from './refs';\n\nexport { resolveRef } from './refs';\n\n/**\n * The page, as the agent sees it.\n *\n * We emit Playwright's ARIA-snapshot YAML, and that choice is the point of this\n * file. It is not our format: it is the one the frontier models have seen most, via\n * playwright-mcp, so a model already knows how to read it and already knows that\n * `[ref=e12]` is the thing you hand back to act. Inventing our own dialect here\n * would cost us capability for nothing.\n *\n * - heading \"Orders\" [level=1]\n * - textbox \"Search orders\" [ref=e5]\n * - list:\n * - listitem:\n * - link \"Order #1043\" [ref=e8]\n * - text: \"Unpaid\"\n * - button \"Export CSV\" [ref=e12]\n *\n * Not raw HTML: a real page is tens of thousands of tokens of div soup, gives the\n * model nothing to act with, and is a prompt-injection firehose.\n */\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 budgets \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * These exist because the failure they prevent is not \"the snapshot is big\", it is\n * \"the agent confidently tells the user about a button that does not exist\". A model\n * given a silently-cut-off page has no way to know it was cut off, so it fills the\n * gap. Hence: hard caps, and `truncated: true` travels with the payload so the agent\n * can be TOLD it is not seeing everything.\n *\n * The two caps do different jobs, and conflating them is how you get a bad snapshot:\n *\n * MAX_LINES bounds the MODEL'S CONTEXT. 800 lines of ARIA YAML is ~12 KB, a few\n * thousand tokens \u2014 a dense dashboard, and about as much page as is useful to\n * reason over at once.\n *\n * MAX_NODES bounds the MAIN THREAD. It counts elements *visited*, most of which are\n * the wrapper divs of a modern app and emit nothing at all. Measured in Chrome on a\n * deeply-nested 52k-element table, visiting 4000 nodes costs ~25ms of walk. Set it\n * to 1500 (a tempting round number) and a div-soup page truncates at ~460 lines \u2014\n * we would stop while HALF the line budget was still unspent, and tell the agent it\n * could not see a page we had simply given up on early.\n */\nconst MAX_NODES = 4000;\nconst MAX_LINES = 800;\nconst MAX_NAME = 120;\nconst MAX_TEXT = 120;\n/**\n * Max `<option>`s emitted per `<select>` before the rest is summarised. A country or\n * timezone picker runs to hundreds; the option list is an affordance to show, not a\n * reason to spend the line budget. The selected option is always in the first slice\n * in practice, but if a huge list has its selection past the cap the \"+N more\"\n * marker tells the agent it isn't seeing every choice.\n */\nconst MAX_OPTIONS = 25;\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 model \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\ninterface AriaNode {\n role: string;\n /** Raw accessible name. Redacted and truncated at render time, not here. */\n name: string;\n /** Pre-rendered bracket attributes, `[checked] [ref=e5]`. */\n props: string;\n children: (AriaNode | string)[];\n}\n\ninterface Walk {\n styleOf: StyleOf;\n layout: boolean;\n nodes: number;\n lines: number;\n truncated: boolean;\n /** Called for every element that gets a ref, so a caller can note which are on screen. */\n onRef?: (ref: string, el: Element) => void;\n}\n\n/** Elements that carry no meaning of their own: their children stand in for them. */\nconst TRANSPARENT = new Set(['generic', 'presentation', 'none']);\n\n/**\n * Never walked. `<script>`/`<style>`/`<noscript>` are the obvious ones; `<svg>` is\n * here because its innards are hundreds of `<path>` nodes of pure noise \u2014 any title\n * it carries is already folded into its parent's accessible name by accname.\n */\nconst SKIP_TAGS = new Set([\n 'SCRIPT',\n 'STYLE',\n 'NOSCRIPT',\n 'TEMPLATE',\n 'SVG',\n 'HEAD',\n 'LINK',\n 'META',\n 'BASE',\n]);\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 walking \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** False once any budget is spent \u2014 the caller stops and we mark the snapshot truncated. */\nfunction withinBudget(w: Walk): boolean {\n if (w.nodes >= MAX_NODES || w.lines >= MAX_LINES) {\n w.truncated = true;\n return false;\n }\n return true;\n}\n\n/**\n * Is this element ours?\n *\n * The widget must never appear in its own snapshot: the agent describing its own\n * chat window back to itself is both useless and a lovely little feedback loop.\n */\nfunction isOurs(el: Element): boolean {\n return el.id === 'matterfact-embed' || el.hasAttribute('data-mf-embed');\n}\n\n/**\n * Hidden from assistive tech \u2014 and therefore from us.\n *\n * This is `isInaccessible()`'s rule set applied ONE NODE AT A TIME, top-down.\n * `isInaccessible()` itself walks every ancestor on every call, which over a whole\n * tree is the O(n\u00B7depth) blow-up the budget forbids; because we descend from the\n * root and prune the entire subtree the moment a node is hidden, the composition of\n * these local checks is exactly equivalent and costs O(1) per node. (We still call\n * the real thing once, on the root, as a backstop.)\n */\nfunction isHidden(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n if (el.getAttribute('aria-hidden') === 'true') return true;\n if (el.hasAttribute('hidden') || el.hasAttribute('inert')) return true;\n return !isVisible(el, style, layout);\n}\n\n/**\n * The nodes a parent should walk.\n *\n * An open shadow root REPLACES its host's light children \u2014 those only reach the\n * screen by being slotted, and we pick them up when we hit the `<slot>` that pulls\n * them in. Walking both would emit every web component's contents twice. A closed\n * shadow root is opaque to us by design, exactly as it is to the rest of the page.\n */\nfunction childrenOf(el: Element): ArrayLike<Node> {\n if (el.shadowRoot) return el.shadowRoot.childNodes;\n if (el.tagName === 'SLOT') {\n const assigned = (el as HTMLSlotElement).assignedNodes({ flatten: true });\n // An unfilled slot renders its own fallback content.\n if (assigned.length) return assigned;\n }\n return el.childNodes;\n}\n\n/** ArrayLike + index loop, not for-of: a NodeList needs `DOM.Iterable`, and copying one to iterate it allocates an array per element for nothing. */\nfunction visitChildren(\n el: Element,\n parent: AriaNode,\n style: CSSStyleDeclaration,\n w: Walk,\n): void {\n const children = childrenOf(el);\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child) visitNode(child, parent, style, w);\n }\n}\n\nfunction visitText(node: Text, parent: AriaNode, w: Walk): void {\n const text = (node.nodeValue ?? '').replace(/\\s+/g, ' ').trim();\n if (!text) return;\n\n // The text of a button, a link or a heading IS its accessible name \u2014 we already\n // emitted it on the parent's line, and repeating it as a child would double the\n // tokens and imply a second, separate thing on the page. Decided by ROLE, never by\n // string-matching against the name (see NAME_FROM_CONTENT).\n if (NAME_FROM_CONTENT.has(parent.role)) return;\n\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(text);\n}\n\n/**\n * A native `<select>`, expanded into its options.\n *\n * The generic walk can't do this: a closed select's `<option>`s have no layout box,\n * so isVisible would prune them. Yet the options are exactly the affordance the agent\n * needs \u2014 \"what can I set this to\" \u2014 and, unlike an `<input>` value, they are a\n * bounded, author-defined set rather than free text the user typed. So we emit them,\n * and mark the selected one: it names one of the choices we are ALREADY showing, so\n * it reveals nothing a human looking at the control wouldn't see. Labels are redacted\n * at render time like every other name; the list is capped; a select the host deems\n * sensitive is hidden the usual way (`data-mf-private`) and never reaches here.\n *\n * `.options` is the flat HTMLOptionsCollection, so `<optgroup>` nesting is already\n * flattened for us; `<select multiple>` (role listbox) works through the same path.\n */\n/** One option, in Playwright's shape: `- option \"label\" [disabled] [selected]`. The\n * name is trimmed so a whitespace-only option renders `- option` (no \"\"). Disabled is\n * `:disabled` (which catches an <optgroup disabled> that isDisabled/opt.disabled miss)\n * OR isDisabled (which adds aria-disabled). Bracket order matches states(): [disabled]\n * before [selected]. */\nfunction optionNode(opt: HTMLOptionElement): AriaNode {\n const disabled = opt.matches(':disabled') || isDisabled(opt);\n return {\n role: 'option',\n name: (opt.label || opt.textContent || '').trim(),\n props:\n (disabled ? ' [disabled]' : '') + (opt.selected ? ' [selected]' : ''),\n children: [],\n };\n}\n\nfunction emitSelectOptions(\n select: HTMLSelectElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const options = select.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n // The selected option IS the field's current value \u2014 the one option the agent most\n // needs. In a long list (country, timezone) the selection can sit past the cap, so\n // the front slice above would show none marked [selected]. Surface any selected\n // option that fell outside the cap regardless, and don't double-count it as hidden.\n let extraSelected = 0;\n const selected = select.selectedOptions;\n for (let i = 0; i < selected.length; i++) {\n const opt = selected[i];\n if (opt && opt.index >= shown && !isPrivate(opt)) {\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(optionNode(opt));\n extraSelected++;\n }\n }\n const remaining = options.length - shown - extraSelected;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`\u2026 (+${remaining} more options)`);\n }\n}\n\n/**\n * An `<input list=\"\u2026\">`'s datalist suggestions.\n *\n * Same affordance as a `<select>`'s options \u2014 a bounded, author-defined set the user\n * can pick \u2014 but surfaced under the (still value-opaque) input, because the\n * `<datalist>` element is display:none, so the generic walk never reaches it. The\n * input's own value stays hidden; only the suggestion labels are emitted (redacted at\n * render like every name, and capped). No [selected] \u2014 a datalist has no current\n * choice, only completions.\n */\nfunction emitDatalistOptions(\n input: HTMLInputElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const list = input.list as HTMLDataListElement | null;\n if (!list) return;\n const options = list.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n const remaining = options.length - shown;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`\u2026 (+${remaining} more options)`);\n }\n}\n\nfunction visitElement(\n el: Element,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (!withinBudget(w)) return;\n if (SKIP_TAGS.has(el.tagName) || isOurs(el)) return;\n\n // Privacy first, before we so much as compute a style: `data-mf-private` and\n // password/hidden inputs take their whole subtree with them.\n if (isPrivate(el)) return;\n\n w.nodes++;\n\n const style = w.styleOf(el);\n if (isHidden(el, style, w.layout)) return;\n\n const role = roleOf(el);\n const transparent = role === null || TRANSPARENT.has(role);\n const interactive = isInteractive(el, role, style, parentStyle);\n\n // A div with a click handler is invisible to us (no getEventListeners), but a div\n // that is FOCUSABLE, or that flips the cursor to a pointer, is announcing itself.\n // Playwright emits those as `- generic [ref=eN]` and so do we: without this, every\n // custom card, chip and icon-button on a modern app would be unreachable.\n if (transparent && !interactive) {\n visitChildren(el, parent, style, w);\n return;\n }\n\n const emittedRole = role === null || TRANSPARENT.has(role) ? 'generic' : role;\n const name = nameOf(el, w.styleOf);\n\n // Refs are for things you can act on. Static text does not get one \u2014 it would be a\n // handle the agent can only ever misuse, and it doubles the size of the snapshot.\n let ref = '';\n if (interactive && receivesPointerEvents(style)) {\n const r = refFor(el, emittedRole, name);\n ref = ` [ref=${r}]`;\n w.onRef?.(r, el);\n }\n\n const state = states(el, emittedRole);\n const node: AriaNode = {\n role: emittedRole,\n name,\n props: (state ? ` ${state}` : '') + ref,\n children: [],\n };\n\n w.lines++;\n parent.children.push(node);\n\n // A native <select>: emit its options \u2014 the affordance the opaque rule used to\n // hide \u2014 instead of walking its (layout-less, hence prune-able) children.\n if (el.tagName === 'SELECT') {\n emitSelectOptions(el as HTMLSelectElement, node, w);\n return;\n }\n\n // An <input list=\"\u2026\">: surface its datalist suggestions (the affordance) under the\n // input, then fall through to the opaque return \u2014 the value itself is never emitted.\n if (el.tagName === 'INPUT' && (el as HTMLInputElement).list) {\n emitDatalistOptions(el as HTMLInputElement, node, w);\n }\n\n // isOpaque: an <input>, <textarea> or contenteditable. Its content IS the user's\n // data, so we do not walk into it \u2014 the value cannot leak because we never go and\n // look at it. See a11y.ts.\n if (isOpaque(el)) return;\n\n visitChildren(el, node, style, w);\n}\n\nfunction visitNode(\n node: Node,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (node.nodeType === 3 /* TEXT_NODE */) {\n visitText(node as Text, parent, w);\n } else if (node.nodeType === 1 /* ELEMENT_NODE */) {\n visitElement(node as Element, parent, parentStyle, w);\n }\n // Comments, CDATA, processing instructions: nothing to say.\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Redact, then truncate \u2014 in that order, and the order is the point.\n *\n * Truncate first and a 130-character line containing an email address gets cut\n * through the middle of it, the regex no longer matches, and you have shipped\n * `jane.doe@acmecorp` to the model. Redaction runs on the whole string, every time,\n * before anything is thrown away.\n */\nfunction sanitize(text: string, max: number): string {\n const collapsed = text.replace(/\\s+/g, ' ').trim();\n const clean = redact(collapsed);\n return clean.length > max ? `${clean.slice(0, max - 1)}\u2026` : clean;\n}\n\nfunction quote(text: string): string {\n return `\"${text.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\nfunction render(\n children: (AriaNode | string)[],\n depth: number,\n out: string[],\n): void {\n const pad = ' '.repeat(depth);\n for (const child of children) {\n if (typeof child === 'string') {\n out.push(`${pad}- text: ${quote(sanitize(child, MAX_TEXT))}`);\n continue;\n }\n const name = child.name ? ` ${quote(sanitize(child.name, MAX_NAME))}` : '';\n const head = `${pad}- ${child.role}${name}${child.props}`;\n if (child.children.length) {\n out.push(`${head}:`);\n render(child.children, depth + 1, out);\n } else {\n out.push(head);\n }\n }\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 entry \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Walk the page and render it. Called by context.ts, which redacts the result a\n * second time on the way out \u2014 the belt to this file's braces.\n */\nfunction walk(\n root: Element,\n onRef?: (ref: string, el: Element) => void,\n): { yaml: string; truncated: boolean } {\n const styleOf = createStyleCache();\n const w: Walk = {\n styleOf,\n layout: hasLayout(),\n nodes: 0,\n lines: 0,\n truncated: false,\n onRef,\n };\n\n // The one call to the real isInaccessible(): a cheap backstop on the root, where\n // the ancestor walk costs nothing.\n if (isInaccessible(root, { getComputedStyle: styleOf })) {\n return { yaml: '', truncated: false };\n }\n\n const tree: AriaNode = { role: '', name: '', props: '', children: [] };\n visitChildren(root, tree, styleOf(root), w);\n\n const lines: string[] = [];\n render(tree.children, 0, lines);\n\n // An in-band marker, not just the out-of-band `truncated` flag. The YAML is what\n // lands in the prompt; a backend template that injects the tree but forgets to\n // surface the flag would hand the model a page that simply stops, and the model\n // fills the gap. This line is inside the payload, so it cannot be dropped on the\n // way to the prompt. (Depth-first, so what is missing is the BOTTOM of the page.)\n //\n // It REPLACES the last emitted line rather than appending \u2014 the marker is part of\n // the line budget, not an exemption from it. The final line was a truncated node\n // anyway (see MAX_LINES), so nothing meaningful is lost.\n if (w.truncated && lines.length) {\n lines[lines.length - 1] =\n '- text: \"\u2026 (snapshot truncated \u2014 more of the page is below)\"';\n }\n\n return { yaml: lines.join('\\n'), truncated: w.truncated };\n}\n\n/**\n * The full page. Mints a fresh generation of refs (beginSnapshot), so any ref the\n * agent held from a previous snapshot is now stale and resolves to null \u2014 which is\n * correct: the page may have changed under it.\n *\n * `visibleRefs` is the viewport slice \u2014 the refs whose element is actually on screen.\n * That is the \"where is your attention\" signal, and it lets the focus context name\n * the handful of things in view out of the whole tree.\n */\nexport function snapshot(): {\n yaml: string;\n truncated: boolean;\n visibleRefs: string[];\n} {\n const root = document.body;\n if (!root) return { yaml: '', truncated: false, visibleRefs: [] };\n\n beginSnapshot();\n\n const visibleRefs: string[] = [];\n const vh = window.innerHeight || 0;\n const vw = window.innerWidth || 0;\n const result = walk(root, (ref, el) => {\n const r = el.getBoundingClientRect();\n // On screen = its box intersects the viewport. Cheap; the walk already forced\n // layout, so getBoundingClientRect here is reading a warm value.\n if (r.bottom > 0 && r.top < vh && r.right > 0 && r.left < vw) {\n visibleRefs.push(ref);\n }\n });\n\n return { ...result, visibleRefs };\n}\n\n/**\n * Zoom in on one ref \u2014 the a11y sub-tree under it.\n *\n * This is the pull half: the agent has the focus context and a shallow page, and when\n * it wants the detail of a specific table or form it asks for that region rather than\n * us re-sending the whole page. It does NOT call beginSnapshot \u2014 that would clear the\n * ref map and invalidate the very ref being asked about \u2014 so the refs it mints join\n * the current generation.\n */\nexport function snapshotRegion(root: Element): {\n yaml: string;\n truncated: boolean;\n} {\n if (!root.isConnected) return { yaml: '', truncated: false };\n return walk(root);\n}\n"],
5
- "mappings": "gDAIA,IAAM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C,EAEmB,YAAA6B,CAAY,CAClC,CAWO,SAASG,GAAeb,EAG7B,CACA,OAAKA,EAAK,YACHD,GAAKC,CAAI,EADc,CAAE,KAAM,GAAI,UAAW,EAAM,CAE7D",
6
- "names": ["toStr", "Object", "prototype", "toString", "isCallable", "fn", "call", "toInteger", "value", "number", "Number", "isNaN", "isFinite", "Math", "floor", "abs", "maxSafeInteger", "pow", "toLength", "len", "min", "max", "arrayFrom", "arrayLike", "mapFn", "C", "Array", "items", "TypeError", "length", "A", "k", "kValue", "SetLike", "items", "arguments", "length", "undefined", "_classCallCheck", "_defineProperty", "_createClass", "key", "value", "has", "push", "previousLength", "filter", "item", "callbackfn", "_this", "forEach", "indexOf", "get", "SetLike_default", "Set", "getLocalName", "element", "_element$localName", "localName", "tagName", "toLowerCase", "localNameToRoleMappings", "article", "aside", "button", "datalist", "dd", "details", "dialog", "dt", "fieldset", "figure", "form", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "html", "legend", "li", "math", "main", "menu", "nav", "ol", "optgroup", "option", "output", "progress", "section", "summary", "table", "tbody", "textarea", "tfoot", "td", "th", "thead", "tr", "ul", "prohibitedAttributes", "caption", "Set", "code", "deletion", "emphasis", "generic", "insertion", "none", "paragraph", "presentation", "strong", "subscript", "superscript", "hasGlobalAriaAttributes", "role", "some", "attributeName", "_prohibitedAttributes", "hasAttribute", "has", "ignorePresentationalRole", "implicitRole", "getRole", "explicitRole", "getExplicitRole", "presentationRoles", "indexOf", "getImplicitRole", "mappedByTag", "undefined", "getAttribute", "_ref", "type", "size", "trim", "split", "length", "presentationRoles", "isElement", "node", "nodeType", "ELEMENT_NODE", "isHTMLTableCaptionElement", "getLocalName", "isHTMLInputElement", "isHTMLOptGroupElement", "isHTMLSelectElement", "isHTMLTableElement", "isHTMLTextAreaElement", "safeWindow", "_ref", "ownerDocument", "defaultView", "TypeError", "isHTMLFieldSetElement", "isHTMLLegendElement", "isHTMLSlotElement", "isSVGElement", "ownerSVGElement", "undefined", "isSVGSVGElement", "isSVGTitleElement", "queryIdRefs", "attributeName", "hasAttribute", "ids", "getAttribute", "split", "root", "getRootNode", "map", "id", "getElementById", "filter", "element", "hasAnyConcreteRoles", "roles", "indexOf", "getRole", "asFlatString", "s", "trim", "replace", "isHidden", "node", "getComputedStyleImplementation", "isElement", "hasAttribute", "getAttribute", "style", "getPropertyValue", "isControl", "hasAnyConcreteRoles", "hasAbstractRole", "role", "TypeError", "concat", "querySelectorAllSubtree", "element", "selectors", "elements", "ArrayFrom", "querySelectorAll", "queryIdRefs", "forEach", "root", "push", "apply", "querySelectedOptions", "listbox", "isHTMLSelectElement", "selectedOptions", "isMarkedPresentational", "presentationRoles", "isNativeHostLanguageTextAlternativeElement", "isHTMLTableCaptionElement", "allowsNameFromContent", "isDescendantOfNativeHostLanguageTextAlternativeElement", "getValueOfTextbox", "isHTMLInputElement", "isHTMLTextAreaElement", "value", "textContent", "getTextualContent", "declaration", "content", "test", "slice", "isLabelableElement", "localName", "getLocalName", "findLabelableElement", "labelableElement", "childNodes", "childNode", "descendantLabelableElement", "getControlOfLabel", "label", "control", "undefined", "htmlFor", "ownerDocument", "getElementById", "getLabels", "labelsProperty", "labels", "document", "filter", "getSlotContents", "slot", "assignedNodes", "length", "computeTextAlternative", "options", "arguments", "consultedNodes", "SetLike", "computedStyles", "Map", "window", "safeWindow", "_options$compute", "compute", "_options$computedStyl", "computedStyleSupportsPseudoElements", "getComputedStyle", "_options$getComputedS", "uncachedGetComputedStyle", "bind", "_options$hidden", "hidden", "el", "pseudoElement", "Error", "cachedStyles", "get", "set", "computeMiscTextAlternative", "context", "accumulatedText", "pseudoBefore", "beforeContent", "isHTMLSlotElement", "child", "result", "isEmbeddedInLabel", "isReferenced", "recursion", "display", "separator", "pseudoAfter", "afterContent", "useAttribute", "attributeName", "attribute", "getAttributeNode", "has", "add", "computeTooltipAttributeValue", "computeElementTextAlternative", "isHTMLFieldSetElement", "children", "i", "isHTMLLegendElement", "isHTMLTableElement", "isSVGSVGElement", "isSVGTitleElement", "nameFromAlt", "isHTMLOptGroupElement", "nameFromLabel", "type", "nameFromValue", "map", "join", "nameFromTitle", "nameFromSubTree", "current", "labelAttributeNode", "labelElements", "skipToStep2E", "ariaLabel", "elementTextAlternative", "selectedOption", "accumulatedText2F", "nodeType", "TEXT_NODE", "tooltipAttributeValue", "prohibitsNaming", "node", "hasAnyConcreteRoles", "computeAccessibleName", "root", "options", "arguments", "length", "undefined", "computeTextAlternative", "isInaccessible", "element", "_element$ownerDocumen", "options", "arguments", "length", "undefined", "_options$getComputedS", "getComputedStyle", "ownerDocument", "defaultView", "_options$isSubtreeIna", "isSubtreeInaccessible", "isSubtreeInaccessibleImpl", "TypeError", "visibility", "currentElement", "parentElement", "_element$ownerDocumen2", "_options$getComputedS2", "hidden", "getAttribute", "display", "elementsSupportingDisabledAttribute", "Set", "isDisabled", "element", "localName", "getLocalName", "has", "hasAttribute", "getAttribute", "createStyleCache", "cache", "el", "pseudo", "style", "hasLayout", "isVisible", "layout", "display", "visibility", "box", "receivesPointerEvents", "INTERACTIVE_ROLES", "INTERACTIVE_TAGS", "isEditable", "v", "isInteractive", "role", "parentStyle", "tag", "tabindex", "NAME_FROM_CONTENT", "VALUE_ROLES", "OPAQUE_TAGS", "isOpaque", "isFilled", "ariaFlag", "attr", "states", "out", "checked", "isDisabled", "expanded", "details", "aria", "level", "pressed", "roleOf", "getRole", "UNTRUSTED_CONTENT", "nameIsUntrusted", "labelledby", "id", "ref", "nameOf", "styleOf", "name", "computeAccessibleName", "counter", "generation", "entries", "registry", "beginSnapshot", "refFor", "el", "role", "name", "key", "entry", "resolveRef", "ref", "MAX_NODES", "MAX_LINES", "MAX_NAME", "MAX_TEXT", "MAX_OPTIONS", "TRANSPARENT", "SKIP_TAGS", "withinBudget", "w", "isOurs", "el", "isHidden", "style", "layout", "isVisible", "childrenOf", "assigned", "visitChildren", "parent", "children", "i", "child", "visitNode", "visitText", "node", "text", "NAME_FROM_CONTENT", "optionNode", "opt", "disabled", "isDisabled", "emitSelectOptions", "select", "options", "shown", "isPrivate", "extraSelected", "selected", "remaining", "emitDatalistOptions", "input", "list", "visitElement", "parentStyle", "role", "roleOf", "transparent", "interactive", "isInteractive", "emittedRole", "name", "nameOf", "ref", "receivesPointerEvents", "r", "refFor", "state", "states", "isOpaque", "sanitize", "max", "collapsed", "clean", "redact", "quote", "render", "depth", "out", "pad", "head", "walk", "root", "onRef", "styleOf", "createStyleCache", "hasLayout", "isInaccessible", "tree", "lines", "snapshot", "beginSnapshot", "visibleRefs", "vh", "vw", "snapshotRegion"]
4
+ "sourcesContent": ["/**\n * @source {https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill}\n * but without thisArg (too hard to type, no need to `this`)\n */\nconst toStr = Object.prototype.toString;\nfunction isCallable(fn: unknown): boolean {\n\treturn typeof fn === \"function\" || toStr.call(fn) === \"[object Function]\";\n}\nfunction toInteger(value: unknown): number {\n\tconst number = Number(value);\n\tif (isNaN(number)) {\n\t\treturn 0;\n\t}\n\tif (number === 0 || !isFinite(number)) {\n\t\treturn number;\n\t}\n\treturn (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));\n}\nconst maxSafeInteger = Math.pow(2, 53) - 1;\nfunction toLength(value: unknown): number {\n\tconst len = toInteger(value);\n\treturn Math.min(Math.max(len, 0), maxSafeInteger);\n}\n/**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n */\nexport default function arrayFrom<T>(iterable: Iterable<T> | ArrayLike<T>): T[];\n/**\n * Creates an array from an iterable object.\n * @param iterable An iterable object to convert to an array.\n * @param mapfn A mapping function to call on every element of the array.\n * @param thisArg Value of 'this' used to invoke the mapfn.\n */\nexport default function arrayFrom<T, U>(\n\tarrayLike: Iterable<T> | ArrayLike<T>,\n\tmapFn?: (v: T, k: number) => U,\n): U[] {\n\t// 1. Let C be the this value.\n\t// edit(@eps1lon): we're not calling it as Array.from\n\tconst C = Array;\n\n\t// 2. Let items be ToObject(arrayLike).\n\tconst items = Object(arrayLike);\n\n\t// 3. ReturnIfAbrupt(items).\n\tif (arrayLike == null) {\n\t\tthrow new TypeError(\n\t\t\t\"Array.from requires an array-like object - not null or undefined\",\n\t\t);\n\t}\n\n\t// 4. If mapfn is undefined, then let mapping be false.\n\t// const mapFn = arguments.length > 1 ? arguments[1] : void undefined;\n\n\tif (typeof mapFn !== \"undefined\") {\n\t\t// 5. else\n\t\t// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n\t\tif (!isCallable(mapFn)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Array.from: when provided, the second argument must be a function\",\n\t\t\t);\n\t\t}\n\t}\n\n\t// 10. Let lenValue be Get(items, \"length\").\n\t// 11. Let len be ToLength(lenValue).\n\tconst len = toLength(items.length);\n\n\t// 13. If IsConstructor(C) is true, then\n\t// 13. a. Let A be the result of calling the [[Construct]] internal method\n\t// of C with an argument list containing the single item len.\n\t// 14. a. Else, Let A be ArrayCreate(len).\n\tconst A = isCallable(C) ? Object(new C(len)) : new Array(len);\n\n\t// 16. Let k be 0.\n\tlet k = 0;\n\t// 17. Repeat, while k < len… (also steps a - h)\n\tlet kValue;\n\twhile (k < len) {\n\t\tkValue = items[k];\n\t\tif (mapFn) {\n\t\t\tA[k] = mapFn(kValue, k);\n\t\t} else {\n\t\t\tA[k] = kValue;\n\t\t}\n\t\tk += 1;\n\t}\n\t// 18. Let putStatus be Put(A, \"length\", len, true).\n\tA.length = len;\n\t// 20. Return A.\n\treturn A;\n}\n", "declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown,\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n", "// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html\n\nimport { presentationRoles } from \"./util\";\n\n/**\n * Safe Element.localName for all supported environments\n * @param element\n */\nexport function getLocalName(element: Element): string {\n\treturn (\n\t\t// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName\n\t\telement.localName ??\n\t\t// eslint-disable-next-line no-restricted-properties -- required for the fallback\n\t\telement.tagName.toLowerCase()\n\t);\n}\n\nconst localNameToRoleMappings: Record<string, string | undefined> = {\n\tarticle: \"article\",\n\taside: \"complementary\",\n\tbutton: \"button\",\n\tdatalist: \"listbox\",\n\tdd: \"definition\",\n\tdetails: \"group\",\n\tdialog: \"dialog\",\n\tdt: \"term\",\n\tfieldset: \"group\",\n\tfigure: \"figure\",\n\t// WARNING: Only with an accessible name\n\tform: \"form\",\n\tfooter: \"contentinfo\",\n\th1: \"heading\",\n\th2: \"heading\",\n\th3: \"heading\",\n\th4: \"heading\",\n\th5: \"heading\",\n\th6: \"heading\",\n\theader: \"banner\",\n\thr: \"separator\",\n\thtml: \"document\",\n\tlegend: \"legend\",\n\tli: \"listitem\",\n\tmath: \"math\",\n\tmain: \"main\",\n\tmenu: \"list\",\n\tnav: \"navigation\",\n\tol: \"list\",\n\toptgroup: \"group\",\n\t// WARNING: Only in certain context\n\toption: \"option\",\n\toutput: \"status\",\n\tprogress: \"progressbar\",\n\t// WARNING: Only with an accessible name\n\tsection: \"region\",\n\tsummary: \"button\",\n\ttable: \"table\",\n\ttbody: \"rowgroup\",\n\ttextarea: \"textbox\",\n\ttfoot: \"rowgroup\",\n\t// WARNING: Only in certain context\n\ttd: \"cell\",\n\tth: \"columnheader\",\n\tthead: \"rowgroup\",\n\ttr: \"row\",\n\tul: \"list\",\n};\n\nconst prohibitedAttributes: Record<string, Set<string>> = {\n\tcaption: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tcode: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tdeletion: new Set([\"aria-label\", \"aria-labelledby\"]),\n\temphasis: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tgeneric: new Set([\"aria-label\", \"aria-labelledby\", \"aria-roledescription\"]),\n\tinsertion: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tnone: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tparagraph: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tpresentation: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tstrong: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tsubscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tsuperscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n};\n\n/**\n *\n * @param element\n * @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.\n */\nfunction hasGlobalAriaAttributes(element: Element, role: string): boolean {\n\t// https://rawgit.com/w3c/aria/stable/#global_states\n\t// commented attributes are deprecated\n\treturn [\n\t\t\"aria-atomic\",\n\t\t\"aria-busy\",\n\t\t\"aria-controls\",\n\t\t\"aria-current\",\n\t\t\"aria-description\",\n\t\t\"aria-describedby\",\n\t\t\"aria-details\",\n\t\t// \"disabled\",\n\t\t\"aria-dropeffect\",\n\t\t// \"errormessage\",\n\t\t\"aria-flowto\",\n\t\t\"aria-grabbed\",\n\t\t// \"haspopup\",\n\t\t\"aria-hidden\",\n\t\t// \"invalid\",\n\t\t\"aria-keyshortcuts\",\n\t\t\"aria-label\",\n\t\t\"aria-labelledby\",\n\t\t\"aria-live\",\n\t\t\"aria-owns\",\n\t\t\"aria-relevant\",\n\t\t\"aria-roledescription\",\n\t].some((attributeName) => {\n\t\treturn (\n\t\t\telement.hasAttribute(attributeName) &&\n\t\t\t!prohibitedAttributes[role]?.has(attributeName)\n\t\t);\n\t});\n}\n\nfunction ignorePresentationalRole(\n\telement: Element,\n\timplicitRole: string,\n): boolean {\n\t// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none\n\treturn hasGlobalAriaAttributes(element, implicitRole);\n}\n\nexport default function getRole(element: Element): string | null {\n\tconst explicitRole = getExplicitRole(element);\n\tif (explicitRole === null || presentationRoles.indexOf(explicitRole) !== -1) {\n\t\tconst implicitRole = getImplicitRole(element);\n\t\tif (\n\t\t\tpresentationRoles.indexOf(explicitRole || \"\") === -1 ||\n\t\t\tignorePresentationalRole(element, implicitRole || \"\")\n\t\t) {\n\t\t\treturn implicitRole;\n\t\t}\n\t}\n\n\treturn explicitRole;\n}\n\nfunction getImplicitRole(element: Element): string | null {\n\tconst mappedByTag = localNameToRoleMappings[getLocalName(element)];\n\tif (mappedByTag !== undefined) {\n\t\treturn mappedByTag;\n\t}\n\n\tswitch (getLocalName(element)) {\n\t\tcase \"a\":\n\t\tcase \"area\":\n\t\tcase \"link\":\n\t\t\tif (element.hasAttribute(\"href\")) {\n\t\t\t\treturn \"link\";\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"img\":\n\t\t\tif (\n\t\t\t\telement.getAttribute(\"alt\") === \"\" &&\n\t\t\t\t!ignorePresentationalRole(element, \"img\")\n\t\t\t) {\n\t\t\t\treturn \"presentation\";\n\t\t\t}\n\t\t\treturn \"img\";\n\t\tcase \"input\": {\n\t\t\tconst { type } = element as HTMLInputElement;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"button\":\n\t\t\t\tcase \"image\":\n\t\t\t\tcase \"reset\":\n\t\t\t\tcase \"submit\":\n\t\t\t\t\treturn \"button\";\n\t\t\t\tcase \"checkbox\":\n\t\t\t\tcase \"radio\":\n\t\t\t\t\treturn type;\n\t\t\t\tcase \"range\":\n\t\t\t\t\treturn \"slider\";\n\t\t\t\tcase \"email\":\n\t\t\t\tcase \"tel\":\n\t\t\t\tcase \"text\":\n\t\t\t\tcase \"url\":\n\t\t\t\t\tif (element.hasAttribute(\"list\")) {\n\t\t\t\t\t\treturn \"combobox\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"textbox\";\n\n\t\t\t\tcase \"search\":\n\t\t\t\t\tif (element.hasAttribute(\"list\")) {\n\t\t\t\t\t\treturn \"combobox\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"searchbox\";\n\t\t\t\tcase \"number\":\n\t\t\t\t\treturn \"spinbutton\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tcase \"select\":\n\t\t\tif (\n\t\t\t\telement.hasAttribute(\"multiple\") ||\n\t\t\t\t(element as HTMLSelectElement).size > 1\n\t\t\t) {\n\t\t\t\treturn \"listbox\";\n\t\t\t}\n\t\t\treturn \"combobox\";\n\t}\n\treturn null;\n}\n\nfunction getExplicitRole(element: Element): string | null {\n\tconst role = element.getAttribute(\"role\");\n\tif (role !== null) {\n\t\tconst explicitRole = role.trim().split(\" \")[0];\n\t\t// String.prototype.split(sep, limit) will always return an array with at least one member\n\t\t// as long as limit is either undefined or > 0\n\t\tif (explicitRole.length > 0) {\n\t\t\treturn explicitRole;\n\t\t}\n\t}\n\n\treturn null;\n}\n", "export { getLocalName } from \"./getRole\";\nimport getRole, { getLocalName } from \"./getRole\";\n\nexport const presentationRoles = [\"presentation\", \"none\"];\n\nexport function isElement(node: Node | null): node is Element {\n\treturn node !== null && node.nodeType === node.ELEMENT_NODE;\n}\n\nexport function isHTMLTableCaptionElement(\n\tnode: Node | null,\n): node is HTMLTableCaptionElement {\n\treturn isElement(node) && getLocalName(node) === \"caption\";\n}\n\nexport function isHTMLInputElement(\n\tnode: Node | null,\n): node is HTMLInputElement {\n\treturn isElement(node) && getLocalName(node) === \"input\";\n}\n\nexport function isHTMLOptGroupElement(\n\tnode: Node | null,\n): node is HTMLOptGroupElement {\n\treturn isElement(node) && getLocalName(node) === \"optgroup\";\n}\n\nexport function isHTMLSelectElement(\n\tnode: Node | null,\n): node is HTMLSelectElement {\n\treturn isElement(node) && getLocalName(node) === \"select\";\n}\n\nexport function isHTMLTableElement(\n\tnode: Node | null,\n): node is HTMLTableElement {\n\treturn isElement(node) && getLocalName(node) === \"table\";\n}\n\nexport function isHTMLTextAreaElement(\n\tnode: Node | null,\n): node is HTMLTextAreaElement {\n\treturn isElement(node) && getLocalName(node) === \"textarea\";\n}\n\nexport function safeWindow(node: Node): Window {\n\tconst { defaultView } =\n\t\tnode.ownerDocument === null ? (node as Document) : node.ownerDocument;\n\n\tif (defaultView === null) {\n\t\tthrow new TypeError(\"no window available\");\n\t}\n\treturn defaultView;\n}\n\nexport function isHTMLFieldSetElement(\n\tnode: Node | null,\n): node is HTMLFieldSetElement {\n\treturn isElement(node) && getLocalName(node) === \"fieldset\";\n}\n\nexport function isHTMLLegendElement(\n\tnode: Node | null,\n): node is HTMLLegendElement {\n\treturn isElement(node) && getLocalName(node) === \"legend\";\n}\n\nexport function isHTMLSlotElement(node: Node | null): node is HTMLSlotElement {\n\treturn isElement(node) && getLocalName(node) === \"slot\";\n}\n\nexport function isSVGElement(node: Node | null): node is SVGElement {\n\treturn isElement(node) && (node as SVGElement).ownerSVGElement !== undefined;\n}\n\nexport function isSVGSVGElement(node: Node | null): node is SVGSVGElement {\n\treturn isElement(node) && getLocalName(node) === \"svg\";\n}\n\nexport function isSVGTitleElement(node: Node | null): node is SVGTitleElement {\n\treturn isSVGElement(node) && getLocalName(node) === \"title\";\n}\n\n/**\n *\n * @param {Node} node -\n * @param {string} attributeName -\n * @returns {Element[]} -\n */\nexport function queryIdRefs(node: Node, attributeName: string): Element[] {\n\tif (isElement(node) && node.hasAttribute(attributeName)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check\n\t\tconst ids = node.getAttribute(attributeName)!.split(\" \");\n\n\t\t// Browsers that don't support shadow DOM won't have getRootNode\n\t\tconst root = node.getRootNode\n\t\t\t? (node.getRootNode() as Document | ShadowRoot)\n\t\t\t: node.ownerDocument;\n\n\t\treturn ids\n\t\t\t.map((id) => root.getElementById(id))\n\t\t\t.filter(\n\t\t\t\t(element: Element | null): element is Element => element !== null,\n\t\t\t\t// TODO: why does this not narrow?\n\t\t\t) as Element[];\n\t}\n\n\treturn [];\n}\n\nexport function hasAnyConcreteRoles(\n\tnode: Node,\n\troles: Array<string | null>,\n): node is Element {\n\tif (isElement(node)) {\n\t\treturn roles.indexOf(getRole(node)) !== -1;\n\t}\n\treturn false;\n}\n", "/**\n * implements https://w3c.github.io/accname/\n */\nimport ArrayFrom from \"./polyfills/array.from\";\nimport SetLike from \"./polyfills/SetLike\";\nimport {\n\thasAnyConcreteRoles,\n\tisElement,\n\tisHTMLTableCaptionElement,\n\tisHTMLInputElement,\n\tisHTMLSelectElement,\n\tisHTMLTextAreaElement,\n\tsafeWindow,\n\tisHTMLFieldSetElement,\n\tisHTMLLegendElement,\n\tisHTMLOptGroupElement,\n\tisHTMLTableElement,\n\tisHTMLSlotElement,\n\tisSVGSVGElement,\n\tisSVGTitleElement,\n\tqueryIdRefs,\n\tgetLocalName,\n\tpresentationRoles,\n} from \"./util\";\n\n/**\n * A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup.\n */\ntype FlatString = string & {\n\t__flat: true;\n};\ntype GetComputedStyle = typeof window.getComputedStyle;\n\n/**\n * interface for an options-bag where `window.getComputedStyle` can be mocked\n */\nexport interface ComputeTextAlternativeOptions {\n\tcompute?: \"description\" | \"name\";\n\t/**\n\t * Set to true if window.computedStyle supports the second argument.\n\t * This should be false in JSDOM. Otherwise JSDOM will log console errors.\n\t */\n\tcomputedStyleSupportsPseudoElements?: boolean;\n\t/**\n\t * mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n\t */\n\tgetComputedStyle?: GetComputedStyle;\n\t/**\n\t * Set to `true` if you want to include hidden elements in the accessible name and description computation.\n\t * Skips 2A in https://w3c.github.io/accname/#computation-steps.\n\t * @default false\n\t */\n\thidden?: boolean;\n}\n\n/**\n *\n * @param {string} string -\n * @returns {FlatString} -\n */\nfunction asFlatString(s: string): FlatString {\n\treturn s.trim().replace(/\\s\\s+/g, \" \") as FlatString;\n}\n\n/**\n *\n * @param node -\n * @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`\n * @returns {boolean} -\n */\nfunction isHidden(\n\tnode: Node,\n\tgetComputedStyleImplementation: GetComputedStyle,\n): node is Element {\n\tif (!isElement(node)) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tnode.hasAttribute(\"hidden\") ||\n\t\tnode.getAttribute(\"aria-hidden\") === \"true\"\n\t) {\n\t\treturn true;\n\t}\n\n\tconst style = getComputedStyleImplementation(node);\n\treturn (\n\t\tstyle.getPropertyValue(\"display\") === \"none\" ||\n\t\tstyle.getPropertyValue(\"visibility\") === \"hidden\"\n\t);\n}\n\n/**\n * @param {Node} node -\n * @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te\n */\nfunction isControl(node: Node): boolean {\n\treturn (\n\t\thasAnyConcreteRoles(node, [\"button\", \"combobox\", \"listbox\", \"textbox\"]) ||\n\t\thasAbstractRole(node, \"range\")\n\t);\n}\n\nfunction hasAbstractRole(node: Node, role: string): node is Element {\n\tif (!isElement(node)) {\n\t\treturn false;\n\t}\n\n\tswitch (role) {\n\t\tcase \"range\":\n\t\t\treturn hasAnyConcreteRoles(node, [\n\t\t\t\t\"meter\",\n\t\t\t\t\"progressbar\",\n\t\t\t\t\"scrollbar\",\n\t\t\t\t\"slider\",\n\t\t\t\t\"spinbutton\",\n\t\t\t]);\n\t\tdefault:\n\t\t\tthrow new TypeError(\n\t\t\t\t`No knowledge about abstract role '${role}'. This is likely a bug :(`,\n\t\t\t);\n\t}\n}\n\n/**\n * element.querySelectorAll but also considers owned tree\n * @param element\n * @param selectors\n */\nfunction querySelectorAllSubtree(\n\telement: Element,\n\tselectors: string,\n): Element[] {\n\tconst elements = ArrayFrom(element.querySelectorAll(selectors));\n\n\tqueryIdRefs(element, \"aria-owns\").forEach((root) => {\n\t\t// babel transpiles this assuming an iterator\n\t\telements.push.apply(elements, ArrayFrom(root.querySelectorAll(selectors)));\n\t});\n\n\treturn elements;\n}\n\nfunction querySelectedOptions(listbox: Element): ArrayLike<Element> {\n\tif (isHTMLSelectElement(listbox)) {\n\t\t// IE11 polyfill\n\t\treturn (\n\t\t\tlistbox.selectedOptions || querySelectorAllSubtree(listbox, \"[selected]\")\n\t\t);\n\t}\n\treturn querySelectorAllSubtree(listbox, '[aria-selected=\"true\"]');\n}\n\nfunction isMarkedPresentational(node: Node): node is Element {\n\treturn hasAnyConcreteRoles(node, presentationRoles);\n}\n\n/**\n * Elements specifically listed in html-aam\n *\n * We don't need this for `label` or `legend` elements.\n * Their implicit roles already allow \"naming from content\".\n *\n * sources:\n *\n * - https://w3c.github.io/html-aam/#table-element\n */\nfunction isNativeHostLanguageTextAlternativeElement(\n\tnode: Node,\n): node is Element {\n\treturn isHTMLTableCaptionElement(node);\n}\n\n/**\n * https://w3c.github.io/aria/#namefromcontent\n */\nfunction allowsNameFromContent(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"button\",\n\t\t\"cell\",\n\t\t\"checkbox\",\n\t\t\"columnheader\",\n\t\t\"gridcell\",\n\t\t\"heading\",\n\t\t\"label\",\n\t\t\"legend\",\n\t\t\"link\",\n\t\t\"menuitem\",\n\t\t\"menuitemcheckbox\",\n\t\t\"menuitemradio\",\n\t\t\"option\",\n\t\t\"radio\",\n\t\t\"row\",\n\t\t\"rowheader\",\n\t\t\"switch\",\n\t\t\"tab\",\n\t\t\"tooltip\",\n\t\t\"treeitem\",\n\t]);\n}\n\n/**\n * TODO https://github.com/eps1lon/dom-accessibility-api/issues/100\n */\nfunction isDescendantOfNativeHostLanguageTextAlternativeElement(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet\n\tnode: Node,\n): boolean {\n\treturn false;\n}\n\nfunction getValueOfTextbox(element: Element): string {\n\tif (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {\n\t\treturn element.value;\n\t}\n\t// https://github.com/eps1lon/dom-accessibility-api/issues/4\n\treturn element.textContent || \"\";\n}\n\nfunction getTextualContent(declaration: CSSStyleDeclaration): string {\n\tconst content = declaration.getPropertyValue(\"content\");\n\tif (/^[\"'].*[\"']$/.test(content)) {\n\t\treturn content.slice(1, -1);\n\t}\n\treturn \"\";\n}\n\n/**\n * https://html.spec.whatwg.org/multipage/forms.html#category-label\n * TODO: form-associated custom elements\n * @param element\n */\nfunction isLabelableElement(element: Element): boolean {\n\tconst localName = getLocalName(element);\n\n\treturn (\n\t\tlocalName === \"button\" ||\n\t\t(localName === \"input\" && element.getAttribute(\"type\") !== \"hidden\") ||\n\t\tlocalName === \"meter\" ||\n\t\tlocalName === \"output\" ||\n\t\tlocalName === \"progress\" ||\n\t\tlocalName === \"select\" ||\n\t\tlocalName === \"textarea\"\n\t);\n}\n\n/**\n * > [...], then the first such descendant in tree order is the label element's labeled control.\n * -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control\n * @param element\n */\nfunction findLabelableElement(element: Element): Element | null {\n\tif (isLabelableElement(element)) {\n\t\treturn element;\n\t}\n\tlet labelableElement: Element | null = null;\n\telement.childNodes.forEach((childNode) => {\n\t\tif (labelableElement === null && isElement(childNode)) {\n\t\t\tconst descendantLabelableElement = findLabelableElement(childNode);\n\t\t\tif (descendantLabelableElement !== null) {\n\t\t\t\tlabelableElement = descendantLabelableElement;\n\t\t\t}\n\t\t}\n\t});\n\n\treturn labelableElement;\n}\n\n/**\n * Polyfill of HTMLLabelElement.control\n * https://html.spec.whatwg.org/multipage/forms.html#labeled-control\n * @param label\n */\nfunction getControlOfLabel(label: HTMLLabelElement): Element | null {\n\tif (label.control !== undefined) {\n\t\treturn label.control;\n\t}\n\n\tconst htmlFor = label.getAttribute(\"for\");\n\tif (htmlFor !== null) {\n\t\treturn label.ownerDocument.getElementById(htmlFor);\n\t}\n\n\treturn findLabelableElement(label);\n}\n\n/**\n * Polyfill of HTMLInputElement.labels\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels\n * @param element\n */\nfunction getLabels(element: Element): HTMLLabelElement[] | null {\n\tconst labelsProperty = (element as HTMLInputElement).labels as\n\t\t| HTMLInputElement[\"labels\"]\n\t\t| undefined;\n\n\tif (labelsProperty === null) {\n\t\treturn labelsProperty;\n\t}\n\tif (labelsProperty !== undefined) {\n\t\treturn ArrayFrom(labelsProperty);\n\t}\n\n\t// polyfill\n\tif (!isLabelableElement(element)) {\n\t\treturn null;\n\t}\n\tconst document = element.ownerDocument;\n\n\treturn ArrayFrom(document.querySelectorAll(\"label\")).filter((label) => {\n\t\treturn getControlOfLabel(label) === element;\n\t});\n}\n\n/**\n * Gets the contents of a slot used for computing the accname\n * @param slot\n */\nfunction getSlotContents(slot: HTMLSlotElement): Node[] {\n\t// Computing the accessible name for elements containing slots is not\n\t// currently defined in the spec. This implementation reflects the\n\t// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.\n\tconst assignedNodes = slot.assignedNodes();\n\tif (assignedNodes.length === 0) {\n\t\t// if no nodes are assigned to the slot, it displays the default content\n\t\treturn ArrayFrom(slot.childNodes);\n\t}\n\treturn assignedNodes;\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_te\n * @param root\n * @param options\n * @returns\n */\nexport function computeTextAlternative(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {},\n): string {\n\tconst consultedNodes = new SetLike<Node>();\n\tconst computedStyles =\n\t\ttypeof Map === \"undefined\"\n\t\t\t? undefined\n\t\t\t: new Map<Element, CSSStyleDeclaration>();\n\n\tconst window = safeWindow(root);\n\tconst {\n\t\tcompute = \"name\",\n\t\tcomputedStyleSupportsPseudoElements = options.getComputedStyle !==\n\t\t\tundefined,\n\t\t// This might be overengineered. I don't know what happens if I call\n\t\t// window.getComputedStyle(elementFromAnotherWindow) or if I don't bind it\n\t\t// the type declarations don't require a `this`\n\t\t// eslint-disable-next-line no-restricted-properties\n\t\tgetComputedStyle: uncachedGetComputedStyle = window.getComputedStyle.bind(\n\t\t\twindow,\n\t\t),\n\t\thidden = false,\n\t} = options;\n\tconst getComputedStyle: GetComputedStyle = (\n\t\tel,\n\t\tpseudoElement,\n\t): CSSStyleDeclaration => {\n\t\t// We don't cache the pseudoElement styles and calls with psuedo elements\n\t\t// should use the uncached version instead\n\t\tif (pseudoElement !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"use uncachedGetComputedStyle directly for pseudo elements\",\n\t\t\t);\n\t\t}\n\t\t// If Map is not available, it is probably faster to just use the uncached\n\t\t// version since a polyfill lookup would be O(n) instead of O(1) and\n\t\t// the getComputedStyle function in those environments(e.g. IE11) is fast\n\t\tif (computedStyles === undefined) {\n\t\t\treturn uncachedGetComputedStyle(el);\n\t\t}\n\t\tconst cachedStyles = computedStyles.get(el);\n\t\tif (cachedStyles) {\n\t\t\treturn cachedStyles;\n\t\t}\n\t\tconst style = uncachedGetComputedStyle(el, pseudoElement);\n\t\tcomputedStyles.set(el, style);\n\t\treturn style;\n\t};\n\n\t// 2F.i\n\tfunction computeMiscTextAlternative(\n\t\tnode: Node,\n\t\tcontext: { isEmbeddedInLabel: boolean; isReferenced: boolean },\n\t): string {\n\t\tlet accumulatedText = \"\";\n\t\tif (isElement(node) && computedStyleSupportsPseudoElements) {\n\t\t\tconst pseudoBefore = uncachedGetComputedStyle(node, \"::before\");\n\t\t\tconst beforeContent = getTextualContent(pseudoBefore);\n\t\t\taccumulatedText = `${beforeContent} ${accumulatedText}`;\n\t\t}\n\n\t\t// FIXME: Including aria-owns is not defined in the spec\n\t\t// But it is required in the web-platform-test\n\t\tconst childNodes = isHTMLSlotElement(node)\n\t\t\t? getSlotContents(node)\n\t\t\t: ArrayFrom(node.childNodes).concat(queryIdRefs(node, \"aria-owns\"));\n\t\tchildNodes.forEach((child) => {\n\t\t\tconst result = computeTextAlternative(child, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t\trecursion: true,\n\t\t\t});\n\t\t\t// TODO: Unclear why display affects delimiter\n\t\t\t// see https://github.com/w3c/accname/issues/3\n\t\t\tconst display = isElement(child)\n\t\t\t\t? getComputedStyle(child).getPropertyValue(\"display\")\n\t\t\t\t: \"inline\";\n\t\t\tconst separator = display !== \"inline\" ? \" \" : \"\";\n\t\t\t// trailing separator for wpt tests\n\t\t\taccumulatedText += `${separator}${result}${separator}`;\n\t\t});\n\t\tif (isElement(node) && computedStyleSupportsPseudoElements) {\n\t\t\tconst pseudoAfter = uncachedGetComputedStyle(node, \"::after\");\n\t\t\tconst afterContent = getTextualContent(pseudoAfter);\n\t\t\taccumulatedText = `${accumulatedText} ${afterContent}`;\n\t\t}\n\n\t\treturn accumulatedText.trim();\n\t}\n\n\t/**\n\t *\n\t * @param element\n\t * @param attributeName\n\t * @returns A string non-empty string or `null`\n\t */\n\tfunction useAttribute(\n\t\telement: Element,\n\t\tattributeName: string,\n\t): string | null {\n\t\tconst attribute = element.getAttributeNode(attributeName);\n\t\tif (\n\t\t\tattribute !== null &&\n\t\t\t!consultedNodes.has(attribute) &&\n\t\t\tattribute.value.trim() !== \"\"\n\t\t) {\n\t\t\tconsultedNodes.add(attribute);\n\t\t\treturn attribute.value;\n\t\t}\n\t\treturn null;\n\t}\n\n\tfunction computeTooltipAttributeValue(node: Node): string | null {\n\t\tif (!isElement(node)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn useAttribute(node, \"title\");\n\t}\n\n\tfunction computeElementTextAlternative(node: Node): string | null {\n\t\tif (!isElement(node)) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// https://w3c.github.io/html-aam/#fieldset-and-legend-elements\n\t\tif (isHTMLFieldSetElement(node)) {\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isHTMLLegendElement(child)) {\n\t\t\t\t\treturn computeTextAlternative(child, {\n\t\t\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isHTMLTableElement(node)) {\n\t\t\t// https://w3c.github.io/html-aam/#table-element\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isHTMLTableCaptionElement(child)) {\n\t\t\t\t\treturn computeTextAlternative(child, {\n\t\t\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isSVGSVGElement(node)) {\n\t\t\t// https://www.w3.org/TR/svg-aam-1.0/\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isSVGTitleElement(child)) {\n\t\t\t\t\treturn child.textContent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} else if (getLocalName(node) === \"img\" || getLocalName(node) === \"area\") {\n\t\t\t// https://w3c.github.io/html-aam/#area-element\n\t\t\t// https://w3c.github.io/html-aam/#img-element\n\t\t\tconst nameFromAlt = useAttribute(node, \"alt\");\n\t\t\tif (nameFromAlt !== null) {\n\t\t\t\treturn nameFromAlt;\n\t\t\t}\n\t\t} else if (isHTMLOptGroupElement(node)) {\n\t\t\tconst nameFromLabel = useAttribute(node, \"label\");\n\t\t\tif (nameFromLabel !== null) {\n\t\t\t\treturn nameFromLabel;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tisHTMLInputElement(node) &&\n\t\t\t(node.type === \"button\" ||\n\t\t\t\tnode.type === \"submit\" ||\n\t\t\t\tnode.type === \"reset\")\n\t\t) {\n\t\t\t// https://w3c.github.io/html-aam/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-description-computation\n\t\t\tconst nameFromValue = useAttribute(node, \"value\");\n\t\t\tif (nameFromValue !== null) {\n\t\t\t\treturn nameFromValue;\n\t\t\t}\n\n\t\t\t// TODO: l10n\n\t\t\tif (node.type === \"submit\") {\n\t\t\t\treturn \"Submit\";\n\t\t\t}\n\t\t\t// TODO: l10n\n\t\t\tif (node.type === \"reset\") {\n\t\t\t\treturn \"Reset\";\n\t\t\t}\n\t\t}\n\n\t\tconst labels = getLabels(node);\n\t\tif (labels !== null && labels.length !== 0) {\n\t\t\tconsultedNodes.add(node);\n\t\t\treturn ArrayFrom(labels)\n\t\t\t\t.map((element) => {\n\t\t\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t\t\tisEmbeddedInLabel: true,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: true,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.filter((label) => {\n\t\t\t\t\treturn label.length > 0;\n\t\t\t\t})\n\t\t\t\t.join(\" \");\n\t\t}\n\n\t\t// https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation\n\t\t// TODO: wpt test consider label elements but html-aam does not mention them\n\t\t// We follow existing implementations over spec\n\t\tif (isHTMLInputElement(node) && node.type === \"image\") {\n\t\t\tconst nameFromAlt = useAttribute(node, \"alt\");\n\t\t\tif (nameFromAlt !== null) {\n\t\t\t\treturn nameFromAlt;\n\t\t\t}\n\n\t\t\tconst nameFromTitle = useAttribute(node, \"title\");\n\t\t\tif (nameFromTitle !== null) {\n\t\t\t\treturn nameFromTitle;\n\t\t\t}\n\n\t\t\t// TODO: l10n\n\t\t\treturn \"Submit Query\";\n\t\t}\n\n\t\tif (hasAnyConcreteRoles(node, [\"button\"])) {\n\t\t\t// https://www.w3.org/TR/html-aam-1.0/#button-element\n\t\t\tconst nameFromSubTree = computeMiscTextAlternative(node, {\n\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t\tif (nameFromSubTree !== \"\") {\n\t\t\t\treturn nameFromSubTree;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfunction computeTextAlternative(\n\t\tcurrent: Node,\n\t\tcontext: {\n\t\t\tisEmbeddedInLabel: boolean;\n\t\t\tisReferenced: boolean;\n\t\t\trecursion: boolean;\n\t\t},\n\t): string {\n\t\tif (consultedNodes.has(current)) {\n\t\t\treturn \"\";\n\t\t}\n\t\t// 2A\n\t\tif (\n\t\t\t!hidden &&\n\t\t\tisHidden(current, getComputedStyle) &&\n\t\t\t!context.isReferenced\n\t\t) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn \"\" as FlatString;\n\t\t}\n\n\t\t// 2B\n\t\tconst labelAttributeNode = isElement(current)\n\t\t\t? current.getAttributeNode(\"aria-labelledby\")\n\t\t\t: null;\n\t\t// TODO: Do we generally need to block query IdRefs of attributes we have already consulted?\n\t\tconst labelElements =\n\t\t\tlabelAttributeNode !== null && !consultedNodes.has(labelAttributeNode)\n\t\t\t\t? queryIdRefs(current, \"aria-labelledby\")\n\t\t\t\t: [];\n\t\tif (\n\t\t\tcompute === \"name\" &&\n\t\t\t!context.isReferenced &&\n\t\t\tlabelElements.length > 0\n\t\t) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Can't be null here otherwise labelElements would be empty\n\t\t\tconsultedNodes.add(labelAttributeNode!);\n\n\t\t\treturn labelElements\n\t\t\t\t.map((element) => {\n\t\t\t\t\t// TODO: Chrome will consider repeated values i.e. use a node multiple times while we'll bail out in computeTextAlternative.\n\t\t\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\t\t\tisReferenced: true,\n\t\t\t\t\t\t// this isn't recursion as specified, otherwise we would skip\n\t\t\t\t\t\t// `aria-label` in\n\t\t\t\t\t\t// <input id=\"myself\" aria-label=\"foo\" aria-labelledby=\"myself\"\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.join(\" \");\n\t\t}\n\n\t\t// 2C\n\t\t// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64\n\t\t// spec says we should only consider skipping if we have a non-empty label\n\t\tconst skipToStep2E =\n\t\t\tcontext.recursion && isControl(current) && compute === \"name\";\n\t\tif (!skipToStep2E) {\n\t\t\tconst ariaLabel = (\n\t\t\t\t(isElement(current) && current.getAttribute(\"aria-label\")) ||\n\t\t\t\t\"\"\n\t\t\t).trim();\n\t\t\tif (ariaLabel !== \"\" && compute === \"name\") {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn ariaLabel;\n\t\t\t}\n\n\t\t\t// 2D\n\t\t\tif (!isMarkedPresentational(current)) {\n\t\t\t\tconst elementTextAlternative = computeElementTextAlternative(current);\n\t\t\t\tif (elementTextAlternative !== null) {\n\t\t\t\t\tconsultedNodes.add(current);\n\t\t\t\t\treturn elementTextAlternative;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// special casing, cheating to make tests pass\n\t\t// https://github.com/w3c/accname/issues/67\n\t\tif (hasAnyConcreteRoles(current, [\"menu\"])) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn \"\";\n\t\t}\n\n\t\t// 2E\n\t\tif (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {\n\t\t\tif (hasAnyConcreteRoles(current, [\"combobox\", \"listbox\"])) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\tconst selectedOptions = querySelectedOptions(current);\n\t\t\t\tif (selectedOptions.length === 0) {\n\t\t\t\t\t// defined per test `name_heading_combobox`\n\t\t\t\t\treturn isHTMLInputElement(current) ? current.value : \"\";\n\t\t\t\t}\n\t\t\t\treturn ArrayFrom(selectedOptions)\n\t\t\t\t\t.map((selectedOption) => {\n\t\t\t\t\t\treturn computeTextAlternative(selectedOption, {\n\t\t\t\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\t\trecursion: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.join(\" \");\n\t\t\t}\n\t\t\tif (hasAbstractRole(current, \"range\")) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\tif (current.hasAttribute(\"aria-valuetext\")) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard\n\t\t\t\t\treturn current.getAttribute(\"aria-valuetext\")!;\n\t\t\t\t}\n\t\t\t\tif (current.hasAttribute(\"aria-valuenow\")) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard\n\t\t\t\t\treturn current.getAttribute(\"aria-valuenow\")!;\n\t\t\t\t}\n\t\t\t\t// Otherwise, use the value as specified by a host language attribute.\n\t\t\t\treturn current.getAttribute(\"value\") || \"\";\n\t\t\t}\n\t\t\tif (hasAnyConcreteRoles(current, [\"textbox\"])) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn getValueOfTextbox(current);\n\t\t\t}\n\t\t}\n\n\t\t// 2F: https://w3c.github.io/accname/#step2F\n\t\tif (\n\t\t\tallowsNameFromContent(current) ||\n\t\t\t(isElement(current) && context.isReferenced) ||\n\t\t\tisNativeHostLanguageTextAlternativeElement(current) ||\n\t\t\tisDescendantOfNativeHostLanguageTextAlternativeElement(current)\n\t\t) {\n\t\t\tconst accumulatedText2F = computeMiscTextAlternative(current, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t\tif (accumulatedText2F !== \"\") {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn accumulatedText2F;\n\t\t\t}\n\t\t}\n\n\t\tif (current.nodeType === current.TEXT_NODE) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn current.textContent || \"\";\n\t\t}\n\n\t\tif (context.recursion) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn computeMiscTextAlternative(current, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t}\n\n\t\tconst tooltipAttributeValue = computeTooltipAttributeValue(current);\n\t\tif (tooltipAttributeValue !== null) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn tooltipAttributeValue;\n\t\t}\n\n\t\t// TODO should this be reachable?\n\t\tconsultedNodes.add(current);\n\t\treturn \"\";\n\t}\n\n\treturn asFlatString(\n\t\tcomputeTextAlternative(root, {\n\t\t\tisEmbeddedInLabel: false,\n\t\t\t// by spec computeAccessibleDescription starts with the referenced elements as roots\n\t\t\tisReferenced: compute === \"description\",\n\t\t\trecursion: false,\n\t\t}),\n\t);\n}\n", "import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { hasAnyConcreteRoles } from \"./util\";\n\n/**\n * https://w3c.github.io/aria/#namefromprohibited\n */\nfunction prohibitsNaming(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"caption\",\n\t\t\"code\",\n\t\t\"deletion\",\n\t\t\"emphasis\",\n\t\t\"generic\",\n\t\t\"insertion\",\n\t\t\"none\",\n\t\t\"paragraph\",\n\t\t\"presentation\",\n\t\t\"strong\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t]);\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_name\n * @param root\n * @param options\n * @returns\n */\nexport function computeAccessibleName(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {},\n): string {\n\tif (prohibitsNaming(root)) {\n\t\treturn \"\";\n\t}\n\n\treturn computeTextAlternative(root, options);\n}\n", "export interface IsInaccessibleOptions {\n\tgetComputedStyle?: typeof window.getComputedStyle;\n\t/**\n\t * Can be used to return cached results from previous isSubtreeInaccessible calls.\n\t */\n\tisSubtreeInaccessible?: (element: Element) => boolean;\n}\n\n/**\n * Partial implementation https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion\n * which should only be used for elements with a non-presentational role i.e.\n * `role=\"none\"` and `role=\"presentation\"` will not be excluded.\n *\n * Implements aria-hidden semantics (i.e. parent overrides child)\n * Ignores \"Child Presentational: True\" characteristics\n *\n * @param element\n * @param options\n * @returns {boolean} true if excluded, otherwise false\n */\nexport function isInaccessible(\n\telement: Element,\n\toptions: IsInaccessibleOptions = {},\n): boolean {\n\tconst {\n\t\tgetComputedStyle = element.ownerDocument.defaultView?.getComputedStyle,\n\t\tisSubtreeInaccessible: isSubtreeInaccessibleImpl = isSubtreeInaccessible,\n\t} = options;\n\tif (typeof getComputedStyle !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Owner document of the element needs to have an associated window.\",\n\t\t);\n\t}\n\t// since visibility is inherited we can exit early\n\tif (getComputedStyle(element).visibility === \"hidden\") {\n\t\treturn true;\n\t}\n\n\tlet currentElement: Element | null = element;\n\twhile (currentElement) {\n\t\tif (isSubtreeInaccessibleImpl(currentElement, { getComputedStyle })) {\n\t\t\treturn true;\n\t\t}\n\n\t\tcurrentElement = currentElement.parentElement;\n\t}\n\n\treturn false;\n}\n\nexport interface IsSubtreeInaccessibleOptions {\n\tgetComputedStyle?: typeof window.getComputedStyle;\n}\n\n/**\n *\n * @param element\n * @param options\n * @returns {boolean} - `true` if every child of the element is inaccessible\n */\nexport function isSubtreeInaccessible(\n\telement: Element,\n\toptions: IsSubtreeInaccessibleOptions = {},\n): boolean {\n\tconst {\n\t\tgetComputedStyle = element.ownerDocument.defaultView?.getComputedStyle,\n\t} = options;\n\tif (typeof getComputedStyle !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Owner document of the element needs to have an associated window.\",\n\t\t);\n\t}\n\n\tif ((element as HTMLElement).hidden === true) {\n\t\treturn true;\n\t}\n\n\tif (element.getAttribute(\"aria-hidden\") === \"true\") {\n\t\treturn true;\n\t}\n\n\tif (getComputedStyle(element).display === \"none\") {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n", "import { getLocalName } from \"./getRole\";\n\nconst elementsSupportingDisabledAttribute = new Set([\n\t\"button\",\n\t\"fieldset\",\n\t\"input\",\n\t\"optgroup\",\n\t\"option\",\n\t\"select\",\n\t\"textarea\",\n]);\n\n/**\n * Check if an element is disabled\n * https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings\n * https://www.w3.org/TR/wai-aria-1.1/#aria-disabled\n *\n * @param element\n * @returns {boolean} true if disabled, otherwise false\n */\nexport function isDisabled(element: Element): boolean {\n\tconst localName = getLocalName(element);\n\treturn elementsSupportingDisabledAttribute.has(localName) &&\n\t\telement.hasAttribute(\"disabled\")\n\t\t? true\n\t\t: element.getAttribute(\"aria-disabled\") === \"true\";\n}\n", "import {\n computeAccessibleName,\n getRole,\n isDisabled,\n} from 'dom-accessibility-api';\n\n/**\n * Role, name, visibility, interactability, state.\n *\n * WHAT WE ADOPTED: role and accessible name come from `dom-accessibility-api`\n * (MIT, zero deps) \u2014 the engine behind testing-library's `getByRole`. Accessible\n * name is a genuinely hard spec (accname walks aria-labelledby graphs, ::before\n * content, <label> associations, alt/title fallbacks, and recursive\n * name-from-content) and a hand-rolled version is wrong in ways you only discover\n * on a customer's page.\n *\n * WHAT WE BUILT: everything below that. Visibility and pointer-events are ~20 lines\n * from first principles (see `isVisible`/`receivesPointerEvents`) and the state\n * reads are direct DOM/ARIA reads, so we vendored nothing and took on no\n * Apache-2.0 attribution obligation.\n */\n\n/** A memoised `getComputedStyle`, shaped to be passed straight to accname. */\nexport type StyleOf = typeof window.getComputedStyle;\n\n/**\n * One computed style per element per snapshot.\n *\n * Not a micro-optimisation: `computeAccessibleName` calls back into\n * getComputedStyle for every descendant it walks while building a name from\n * content, so on a page of nested divs the uncached cost is quadratic-ish. The\n * cache is per-snapshot (a fresh WeakMap each walk), so it can never go stale\n * across snapshots.\n */\nexport function createStyleCache(): StyleOf {\n const cache = new WeakMap<Element, CSSStyleDeclaration>();\n return ((el: Element, pseudo?: string | null): CSSStyleDeclaration => {\n // Pseudo-element lookups are rare and must not poison the element cache.\n if (pseudo) return window.getComputedStyle(el, pseudo);\n let style = cache.get(el);\n if (!style) {\n style = window.getComputedStyle(el);\n cache.set(el, style);\n }\n return style;\n }) as StyleOf;\n}\n\n/**\n * Does this environment do layout at all?\n *\n * In a browser the root element always has a box. In jsdom \u2014 which has no layout\n * engine \u2014 *everything* reports zero client rects, so a box-based visibility check\n * would hide the entire page and our tests would assert on an empty snapshot. So we\n * feature-detect layout once per walk and fall back to style-only visibility when\n * there is none. This is a test-environment concession, stated out loud rather than\n * hidden behind a mock.\n */\nexport function hasLayout(): boolean {\n return document.documentElement.getClientRects().length > 0;\n}\n\n/**\n * Visible enough to be worth telling the agent about.\n *\n * `display` and `visibility` are read from the computed style, which already\n * accounts for inheritance \u2014 and because the walk is top-down and prunes whole\n * subtrees, we never pay for an ancestor walk. `display: contents` is the one\n * subtlety: such an element generates no box of its own but its children do, so it\n * must not be treated as invisible or we would drop a real subtree.\n */\nexport function isVisible(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n const display = style.display;\n if (display === 'none') return false;\n\n const visibility = style.visibility;\n if (visibility === 'hidden' || visibility === 'collapse') return false;\n\n // `opacity: 0` is a standard \"hide from sight, keep for a11y\" technique. It still\n // reports a box, so the area check below misses it. We treat fully-transparent as\n // hidden; a partially-transparent element is genuinely on screen.\n if (Number(style.opacity) === 0) return false;\n\n // A `display: contents` element generates no box of its own but its children do,\n // so it must not be judged by its own (nonexistent) geometry \u2014 we let it through\n // and test each child on its own merits.\n if (layout && display !== 'contents') {\n // Area, not merely \"has a box\": `width:0;height:0;overflow:hidden` is one of the\n // commonest ways to hide a thing, and such an element still reports a client\n // rect. This is the check Playwright's own isVisible() makes.\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return false;\n\n // The sr-only / visually-hidden family: `clip: rect(0 0 0 0)` and its modern\n // `clip-path: inset(50%)` shrink the element to nothing while keeping a 1px box,\n // and `position:absolute; left:-9999px` parks it far off any real page. All three\n // are \"screen-reader only\" idioms \u2014 present for a11y, not for sight \u2014 so an agent\n // reading the page should skip them too. (getClientRects().length === 0 catches\n // the clipped ones; the far-offscreen check catches the parked ones.)\n if (el.getClientRects().length === 0) return false;\n if (box.right < -2000 || box.bottom < -2000) return false;\n }\n\n return true;\n}\n\n/**\n * Can a pointer actually reach it?\n *\n * `pointer-events` is an INHERITED property, so the computed value on the element\n * already encodes every ancestor's `pointer-events: none` \u2014 and correctly honours a\n * descendant that opts back in with `pointer-events: auto`. That is the whole check:\n * no ancestor walk, no hit-test. We deliberately do NOT test for occlusion (is\n * something painted on top of it) the way Playwright's actionability check does \u2014\n * we are describing the page, not clicking it, and an element under a sticky header\n * is still worth telling the agent about.\n */\nexport function receivesPointerEvents(style: CSSStyleDeclaration): boolean {\n return style.pointerEvents !== 'none';\n}\n\n/** Roles that are inherently operable. */\nconst INTERACTIVE_ROLES = new Set([\n 'button',\n 'checkbox',\n 'combobox',\n 'link',\n 'listbox',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'searchbox',\n 'slider',\n 'spinbutton',\n 'switch',\n 'tab',\n 'textbox',\n 'treeitem',\n]);\n\n/** Tags that are operable regardless of what role they compute to. */\nconst INTERACTIVE_TAGS = new Set([\n 'BUTTON',\n 'INPUT',\n 'SELECT',\n 'TEXTAREA',\n 'SUMMARY',\n]);\n\n/** `contenteditable` \u2014 present and not explicitly \"false\" (covers \"\", \"true\", \"plaintext-only\"). */\nexport function isEditable(el: Element): boolean {\n const v = el.getAttribute('contenteditable');\n return v !== null && v !== 'false';\n}\n\n/**\n * Is this element something the user can operate?\n *\n * THIS IS THE INTERESTING FUNCTION, so here is the reasoning in full.\n *\n * The obvious way to answer it \u2014 ask the DOM what event listeners are attached \u2014\n * IS NOT AVAILABLE. `getEventListeners()` exists only inside DevTools (and via CDP).\n * We are ordinary page JS on a customer's website, so every `addEventListener` a\n * React, Vue or Svelte app ever registered is, to us, completely invisible. This is\n * precisely where the browser-use style of in-page DOM extraction degrades on real\n * apps: it cannot see a single handler, so it either misses the app's controls or\n * guesses wildly. We therefore never ask \"does it have a handler\"; we ask \"does it\n * PRESENT ITSELF as operable\", in four descending tiers of confidence:\n *\n * 1. TAG SEMANTICS (certain). button, input, select, textarea, summary, a[href].\n * 2. COMPUTED ROLE (certain). role=button|link|checkbox|\u2026 whether implicit or\n * author-supplied. A div with role=\"button\" is a\n * button as far as the platform, a screen reader,\n * and the user are concerned.\n * 3. FOCUSABILITY (strong). tabindex >= 0, or contenteditable. An app that\n * made a div keyboard-reachable did so on purpose.\n * 4. `cursor: pointer` (WEAK). Last resort, and the reason for the guard below.\n *\n * Tier 4 needs care, because `cursor` is INHERITED: a card with `cursor: pointer`\n * makes every span, every icon and every text node inside it report `pointer` too,\n * and a naive check would mint a ref for each of them and drown the snapshot. So we\n * only count the element that *introduced* the pointer cursor \u2014 the one whose parent\n * did not already have it. That is almost exactly the clickable card itself.\n */\nexport function isInteractive(\n el: Element,\n role: string | null,\n style: CSSStyleDeclaration,\n parentStyle: CSSStyleDeclaration | null,\n): boolean {\n const tag = el.tagName;\n\n // 1. tag semantics\n // An <a href> is interactive, but a hrefless <a> is NOT a dead end \u2014 it may be a\n // JS-nav link, an <a role=\"button\">, or a Bootstrap `.btn` anchor. So href is a\n // positive signal, not a gate: fall through to the role/tabindex/cursor tiers\n // rather than returning false and dropping every SPA link.\n if (tag === 'A' && el.hasAttribute('href')) return true;\n if (INTERACTIVE_TAGS.has(tag)) return true;\n\n // 2. computed role\n if (role !== null && INTERACTIVE_ROLES.has(role)) return true;\n\n // 3. focusability\n const tabindex = el.getAttribute('tabindex');\n if (tabindex !== null && Number(tabindex) >= 0) return true;\n if (isEditable(el)) return true;\n\n // 4. cursor: pointer, but only where it originates (see above)\n if (style.cursor === 'pointer' && parentStyle?.cursor !== 'pointer')\n return true;\n\n return false;\n}\n\n/**\n * Roles whose accessible name IS their text content (ARIA \"Name From: contents\").\n *\n * This is the exact list from the ARIA spec, and it earns its place: it is what tells\n * the walk that the \"Export CSV\" inside `<button>Export CSV</button>` has ALREADY been\n * emitted, as the button's name, and must not be repeated as a child text node.\n *\n * The tempting shortcut \u2014 \"skip any text that appears inside the parent's name\" \u2014 is\n * wrong, and wrong in a way that silently deletes content: a card labelled\n * `aria-label=\"Acme Corp order\"` containing the text \"Acme Corp\" would lose it,\n * because one is a substring of the other by coincidence. Ask the role, not the string.\n */\nexport const NAME_FROM_CONTENT = new Set([\n 'button',\n 'cell',\n 'checkbox',\n 'columnheader',\n 'gridcell',\n 'heading',\n 'link',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'row',\n 'rowheader',\n 'switch',\n 'tab',\n 'tooltip',\n 'treeitem',\n]);\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** Roles whose content IS the user's data. We report that a value exists, never what it is. */\nconst VALUE_ROLES = new Set(['textbox', 'searchbox', 'spinbutton']);\n\n/**\n * Roles we refuse to descend into, because their children/content ARE the value.\n *\n * A `<textarea>`'s child text node is literally what the user typed; a\n * contenteditable's subtree is the document they are writing. Refusing to walk in is\n * how \"never emit a value\" is enforced STRUCTURALLY, rather than by remembering to\n * filter at every emit site.\n *\n * `<select>` is deliberately NOT here. Its options are a bounded, author-defined\n * enumeration \u2014 the affordance the agent most needs (\"what can I set this to\"), not\n * the free-text user data the opaque rule exists to contain. The snapshot emits them\n * directly instead (capped, selected one marked): see emitSelectOptions in\n * snapshot.ts.\n */\nconst OPAQUE_TAGS = new Set(['INPUT', 'TEXTAREA']);\n\nexport function isOpaque(el: Element): boolean {\n return OPAQUE_TAGS.has(el.tagName) || isEditable(el);\n}\n\n/**\n * Has the user put something in this field?\n *\n * `.value` is read and immediately thrown away \u2014 only its LENGTH escapes. This is\n * the single most useful bit about a form (\"is the email box already filled in?\")\n * and the single most dangerous string on the page, so it is reduced to one bit at\n * the point of reading and never travels.\n */\nfunction isFilled(el: Element, role: string): boolean {\n const tag = el.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA') {\n if (!VALUE_ROLES.has(role)) return false; // checkbox.value is \"on\" \u2014 meaningless\n return ((el as HTMLInputElement).value ?? '').length > 0;\n }\n if (isEditable(el)) return (el.textContent ?? '').trim().length > 0;\n return false;\n}\n\nfunction ariaFlag(el: Element, attr: string): 'true' | 'mixed' | null {\n const v = el.getAttribute(attr);\n if (v === 'true') return 'true';\n if (v === 'mixed') return 'mixed';\n return null;\n}\n\n/**\n * The bracketed attributes, in Playwright's order:\n * [checked] [disabled] [expanded] [level=N] [pressed] [selected]\n * plus our one addition, [filled] \u2014 see isFilled. `[ref=eN]` is appended by the\n * caller and always comes last.\n */\nexport function states(el: Element, role: string): string {\n const out: string[] = [];\n const tag = el.tagName;\n\n // checked\n if (tag === 'INPUT' && (role === 'checkbox' || role === 'radio')) {\n if ((el as HTMLInputElement).checked) out.push('[checked]');\n } else {\n const checked = ariaFlag(el, 'aria-checked');\n if (checked === 'mixed') out.push('[checked=mixed]');\n else if (checked === 'true') out.push('[checked]');\n }\n\n // disabled \u2014 dom-accessibility-api handles fieldset/optgroup inheritance and aria-disabled\n if (isDisabled(el)) out.push('[disabled]');\n\n // expanded \u2014 <summary> reflects its parent <details>, which has no ARIA attribute\n const expanded = el.getAttribute('aria-expanded');\n if (expanded === 'true' || expanded === 'false') {\n if (expanded === 'true') out.push('[expanded]');\n } else if (tag === 'SUMMARY') {\n const details = el.parentElement;\n if (\n details?.tagName === 'DETAILS' &&\n (details as HTMLDetailsElement).open\n ) {\n out.push('[expanded]');\n }\n }\n\n // level\n if (role === 'heading') {\n const aria = el.getAttribute('aria-level');\n const level = aria ? Number(aria) : Number(tag[1]);\n if (Number.isFinite(level) && level > 0) out.push(`[level=${level}]`);\n }\n\n // pressed\n const pressed = ariaFlag(el, 'aria-pressed');\n if (pressed === 'mixed') out.push('[pressed=mixed]');\n else if (pressed === 'true') out.push('[pressed]');\n\n // selected\n if (el.getAttribute('aria-selected') === 'true') out.push('[selected]');\n\n // filled (ours \u2014 a boolean, never the value)\n if (isFilled(el, role)) out.push('[filled]');\n\n return out.join(' ');\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 role & name \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * The computed role, with one correction.\n *\n * `getRole` follows HTML-AAM and returns null for a contenteditable div \u2014 but every\n * real browser exposes it to assistive tech as a textbox, and that is what it is to\n * the user and to the agent. We say textbox.\n */\nexport function roleOf(el: Element): string | null {\n if (isEditable(el)) return 'textbox';\n return getRole(el);\n}\n\n/**\n * Selector for anything whose CONTENT is the user's data \u2014 a form control, a\n * contenteditable, a valued widget, or a host-marked private region.\n */\nconst UNTRUSTED_CONTENT =\n 'input,textarea,select,[contenteditable=\"\"],[contenteditable=\"true\"],[aria-valuetext],[data-mf-private]';\n\n/**\n * Would computing this element's ACCESSIBLE NAME read the user's data?\n *\n * This is the leak the structural `isOpaque` walk cannot see. `computeAccessibleName`\n * runs its OWN descendant walk, inside dom-accessibility-api, that knows nothing about\n * our opaque set or `data-mf-private` \u2014 it will happily read `input.value`,\n * `aria-valuetext`, a contenteditable's text, or a private subtree, and fold it into\n * the name of a name-from-content ANCESTOR or any `aria-labelledby` referrer. So a\n * value our walk refuses to enter re-enters through the parent's name.\n *\n * Two vectors, both handled:\n * - name-from-content: the name is built from descendant text. If any descendant is\n * untrusted, the name is tainted.\n * - aria-labelledby: the name is pulled from a referenced element. If any referent\n * is (or contains) untrusted content, the name is tainted.\n *\n * `aria-label` and `title` are author-written static strings; a site that copies its\n * own secret into one is exposing it deliberately and we cannot defend that. The\n * automatic-computation vectors are the ones we must close.\n */\nfunction nameIsUntrusted(el: Element): boolean {\n const labelledby = el.getAttribute('aria-labelledby');\n if (labelledby) {\n for (const id of labelledby.split(/\\s+/)) {\n if (!id) continue;\n const ref = el.ownerDocument.getElementById(id);\n if (!ref) continue;\n if (\n ref.matches(UNTRUSTED_CONTENT) ||\n ref.querySelector(UNTRUSTED_CONTENT)\n ) {\n return true;\n }\n }\n return false;\n }\n // No explicit label attributes \u2192 the name, if any, is name-from-content.\n if (el.hasAttribute('aria-label')) return false;\n return el.querySelector(UNTRUSTED_CONTENT) !== null;\n}\n\nexport function nameOf(el: Element, styleOf: StyleOf): string {\n const name = computeAccessibleName(el, {\n getComputedStyle: styleOf,\n // jsdom logs a console error if you claim pseudo-element support it doesn't have.\n computedStyleSupportsPseudoElements: false,\n });\n if (!name) return '';\n\n // A tainted name would leak a value or a private string. Drop it entirely and let\n // the element stand on its role + ref. Losing a name costs the agent a little\n // context; keeping a leaked one is a breach. The trade is not close.\n if (nameIsUntrusted(el)) {\n // Preserve an explicit author label if one exists and is not itself the taint \u2014\n // aria-labelledby taints were already caught above, so any aria-label here is safe.\n return el.getAttribute('aria-label') || '';\n }\n return name;\n}\n", "import type { ElementRef } from '../protocol';\n\n/**\n * Element handles.\n *\n * The mechanism is Playwright's, deliberately (see protocol.ts): the agent never\n * learns a selector, it learns `e12`, and `e12` is turned back into an element\n * HERE, in the page, by us.\n *\n * Three properties matter and all are load-bearing:\n *\n * 1. THE MAP IS A WeakMap, NOT AN EXPANDO ON THE ELEMENT. An earlier version\n * stamped `el._mfRef`. Non-enumerable, so invisible to `Object.keys`/spreads/\n * `JSON.stringify` \u2014 but STILL reachable via `Object.getOwnPropertyNames` and\n * `Reflect.ownKeys`, and, worse, it parked the element's accessible name on the\n * customer's live DOM node indefinitely. A `WeakMap<Element, RefEntry>` mutates\n * nothing on their objects, is invisible to every enumeration and serialization\n * API without exception, cannot collide with a property the host already has,\n * and still gives us node-identity survival across GC for free.\n *\n * 2. A REF IS REGENERATED WHEN ROLE OR NAME CHANGES. Frameworks recycle DOM nodes:\n * a virtualised list scrolls, and the <button> that said \"Approve\" is the very\n * same node that now says \"Delete\". Keying the ref on (role, name) means that\n * node gets a NEW id and the old id resolves to nothing.\n *\n * 3. A REF IS SCOPED TO ONE SNAPSHOT GENERATION. (2) is necessary but not\n * sufficient: two icon-only \"Delete\" buttons in a virtualised table have the\n * SAME (role, name), so a recycled node whose role+name are unchanged would keep\n * its ref and silently retarget a different logical row. So a ref also carries\n * the generation it was minted in, and resolveRef refuses a ref from an older\n * generation \u2014 the agent must re-snapshot to get a fresh, valid handle. Loud\n * staleness beats silent retargeting.\n */\n\ninterface RefEntry {\n id: ElementRef;\n /** role + name at mint time. Changes here invalidate the ref. */\n key: string;\n /** The snapshot generation this ref belongs to. */\n gen: number;\n}\n\n/**\n * Monotonic across snapshots, never reused \u2014 like Playwright's. An id is only ever\n * handed out once in a page's lifetime, so a stale ref can never be *silently*\n * correct by colliding with a newer element; it just resolves to null.\n */\nlet counter = 0;\n\n/** Bumped once per full snapshot. A ref is only valid within its own generation. */\nlet generation = 0;\n\n/**\n * Element identity, off the host's objects entirely. Keyed by element so a recycled\n * node is recognised across snapshots; the entry carries the (role,name) key and the\n * generation for the two staleness checks above.\n */\nconst entries = new WeakMap<Element, RefEntry>();\n\n/** id -> element, for resolution. Rebuilt each generation from exactly what was emitted. */\nconst registry = new Map<ElementRef, Element>();\n\n/** Called once per FULL snapshot, before the walk. A region read does NOT call this. */\nexport function beginSnapshot(): void {\n generation++;\n registry.clear();\n}\n\n/**\n * Mint (or reuse) the ref for an element and register it for resolution.\n * Only ever called for elements that are visible AND receive pointer events.\n */\nexport function refFor(el: Element, role: string, name: string): ElementRef {\n const key = `${role} ${name}`;\n\n let entry = entries.get(el);\n if (!entry || entry.key !== key) {\n entry = { id: `e${++counter}`, key, gen: generation };\n entries.set(el, entry);\n } else {\n // Same node, same identity \u2014 carry it into the current generation so a fresh\n // snapshot re-validates a still-present element rather than orphaning it.\n entry.gen = generation;\n }\n\n registry.set(entry.id, el);\n return entry.id;\n}\n\n/**\n * Turn a ref back into an element.\n *\n * Three ways this returns null, each deliberate:\n * - unknown id (never minted, or from a cleared generation) \u2192 not in the registry;\n * - the element left the page \u2192 `isConnected` is false. A detached node still\n * answers every question (role, name, a zero box), so without this an action\n * would silently no-op against a ghost;\n * - the ref is from an OLDER generation \u2192 its entry.gen has been superseded. This is\n * what stops a recycled-node retarget: the agent is told the handle is stale and\n * must re-snapshot, rather than acting on the wrong row.\n */\nexport function resolveRef(ref: ElementRef): Element | null {\n const el = registry.get(ref);\n if (!el) return null;\n if (!el.isConnected) {\n registry.delete(ref);\n return null;\n }\n const entry = entries.get(el);\n if (!entry || entry.id !== ref || entry.gen !== generation) return null;\n return el;\n}\n\n/** Test-only: reset counters so refs are deterministic per test. */\nexport function __resetRefs(): void {\n counter = 0;\n generation = 0;\n registry.clear();\n}\n\n/**\n * Drop every ref's resolvability, without touching `counter`/`generation` \u2014 an old\n * id must never come back valid after this (unlike `__resetRefs`, which is test-only\n * determinism and would let ids collide again). Called from `context.ts`'s `stop()`\n * so a ref minted before a `pageContext:false` opt-out (or before an unmount) can't\n * be resolved afterward \u2014 belt-and-suspenders alongside `sendRegion`'s own\n * `pageContextOn` gate, in case a stale ref is ever replayed.\n */\nexport function clearRefs(): void {\n registry.clear();\n}\n", "import { isDisabled, isInaccessible } from 'dom-accessibility-api';\n\nimport { isPrivate, redact } from '../context';\nimport {\n createStyleCache,\n hasLayout,\n isInteractive,\n NAME_FROM_CONTENT,\n isOpaque,\n isVisible,\n nameOf,\n receivesPointerEvents,\n roleOf,\n states,\n type StyleOf,\n} from './a11y';\nimport { beginSnapshot, refFor } from './refs';\n\nexport { resolveRef, clearRefs } from './refs';\n\n/**\n * The page, as the agent sees it.\n *\n * We emit Playwright's ARIA-snapshot YAML, and that choice is the point of this\n * file. It is not our format: it is the one the frontier models have seen most, via\n * playwright-mcp, so a model already knows how to read it and already knows that\n * `[ref=e12]` is the thing you hand back to act. Inventing our own dialect here\n * would cost us capability for nothing.\n *\n * - heading \"Orders\" [level=1]\n * - textbox \"Search orders\" [ref=e5]\n * - list:\n * - listitem:\n * - link \"Order #1043\" [ref=e8]\n * - text: \"Unpaid\"\n * - button \"Export CSV\" [ref=e12]\n *\n * Not raw HTML: a real page is tens of thousands of tokens of div soup, gives the\n * model nothing to act with, and is a prompt-injection firehose.\n */\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 budgets \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * These exist because the failure they prevent is not \"the snapshot is big\", it is\n * \"the agent confidently tells the user about a button that does not exist\". A model\n * given a silently-cut-off page has no way to know it was cut off, so it fills the\n * gap. Hence: hard caps, and `truncated: true` travels with the payload so the agent\n * can be TOLD it is not seeing everything.\n *\n * The two caps do different jobs, and conflating them is how you get a bad snapshot:\n *\n * MAX_LINES bounds the MODEL'S CONTEXT. 800 lines of ARIA YAML is ~12 KB, a few\n * thousand tokens \u2014 a dense dashboard, and about as much page as is useful to\n * reason over at once.\n *\n * MAX_NODES bounds the MAIN THREAD. It counts elements *visited*, most of which are\n * the wrapper divs of a modern app and emit nothing at all. Measured in Chrome on a\n * deeply-nested 52k-element table, visiting 4000 nodes costs ~25ms of walk. Set it\n * to 1500 (a tempting round number) and a div-soup page truncates at ~460 lines \u2014\n * we would stop while HALF the line budget was still unspent, and tell the agent it\n * could not see a page we had simply given up on early.\n */\nconst MAX_NODES = 4000;\nconst MAX_LINES = 800;\nconst MAX_NAME = 120;\nconst MAX_TEXT = 120;\n/**\n * Max `<option>`s emitted per `<select>` before the rest is summarised. A country or\n * timezone picker runs to hundreds; the option list is an affordance to show, not a\n * reason to spend the line budget. The selected option is always in the first slice\n * in practice, but if a huge list has its selection past the cap the \"+N more\"\n * marker tells the agent it isn't seeing every choice.\n */\nconst MAX_OPTIONS = 25;\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 model \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\ninterface AriaNode {\n role: string;\n /** Raw accessible name. Redacted and truncated at render time, not here. */\n name: string;\n /** Pre-rendered bracket attributes, `[checked] [ref=e5]`. */\n props: string;\n children: (AriaNode | string)[];\n}\n\ninterface Walk {\n styleOf: StyleOf;\n layout: boolean;\n nodes: number;\n lines: number;\n truncated: boolean;\n /** Called for every element that gets a ref, so a caller can note which are on screen. */\n onRef?: (ref: string, el: Element) => void;\n}\n\n/** Elements that carry no meaning of their own: their children stand in for them. */\nconst TRANSPARENT = new Set(['generic', 'presentation', 'none']);\n\n/**\n * Never walked. `<script>`/`<style>`/`<noscript>` are the obvious ones; `<svg>` is\n * here because its innards are hundreds of `<path>` nodes of pure noise \u2014 any title\n * it carries is already folded into its parent's accessible name by accname.\n */\nconst SKIP_TAGS = new Set([\n 'SCRIPT',\n 'STYLE',\n 'NOSCRIPT',\n 'TEMPLATE',\n 'SVG',\n 'HEAD',\n 'LINK',\n 'META',\n 'BASE',\n]);\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 walking \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** False once any budget is spent \u2014 the caller stops and we mark the snapshot truncated. */\nfunction withinBudget(w: Walk): boolean {\n if (w.nodes >= MAX_NODES || w.lines >= MAX_LINES) {\n w.truncated = true;\n return false;\n }\n return true;\n}\n\n/**\n * Is this element ours?\n *\n * The widget must never appear in its own snapshot: the agent describing its own\n * chat window back to itself is both useless and a lovely little feedback loop.\n */\nfunction isOurs(el: Element): boolean {\n return el.id === 'matterfact-embed' || el.hasAttribute('data-mf-embed');\n}\n\n/**\n * Hidden from assistive tech \u2014 and therefore from us.\n *\n * This is `isInaccessible()`'s rule set applied ONE NODE AT A TIME, top-down.\n * `isInaccessible()` itself walks every ancestor on every call, which over a whole\n * tree is the O(n\u00B7depth) blow-up the budget forbids; because we descend from the\n * root and prune the entire subtree the moment a node is hidden, the composition of\n * these local checks is exactly equivalent and costs O(1) per node. (We still call\n * the real thing once, on the root, as a backstop.)\n */\nfunction isHidden(\n el: Element,\n style: CSSStyleDeclaration,\n layout: boolean,\n): boolean {\n if (el.getAttribute('aria-hidden') === 'true') return true;\n if (el.hasAttribute('hidden') || el.hasAttribute('inert')) return true;\n return !isVisible(el, style, layout);\n}\n\n/**\n * The nodes a parent should walk.\n *\n * An open shadow root REPLACES its host's light children \u2014 those only reach the\n * screen by being slotted, and we pick them up when we hit the `<slot>` that pulls\n * them in. Walking both would emit every web component's contents twice. A closed\n * shadow root is opaque to us by design, exactly as it is to the rest of the page.\n */\nfunction childrenOf(el: Element): ArrayLike<Node> {\n if (el.shadowRoot) return el.shadowRoot.childNodes;\n if (el.tagName === 'SLOT') {\n const assigned = (el as HTMLSlotElement).assignedNodes({ flatten: true });\n // An unfilled slot renders its own fallback content.\n if (assigned.length) return assigned;\n }\n return el.childNodes;\n}\n\n/** ArrayLike + index loop, not for-of: a NodeList needs `DOM.Iterable`, and copying one to iterate it allocates an array per element for nothing. */\nfunction visitChildren(\n el: Element,\n parent: AriaNode,\n style: CSSStyleDeclaration,\n w: Walk,\n): void {\n const children = childrenOf(el);\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child) visitNode(child, parent, style, w);\n }\n}\n\nfunction visitText(node: Text, parent: AriaNode, w: Walk): void {\n const text = (node.nodeValue ?? '').replace(/\\s+/g, ' ').trim();\n if (!text) return;\n\n // The text of a button, a link or a heading IS its accessible name \u2014 we already\n // emitted it on the parent's line, and repeating it as a child would double the\n // tokens and imply a second, separate thing on the page. Decided by ROLE, never by\n // string-matching against the name (see NAME_FROM_CONTENT).\n if (NAME_FROM_CONTENT.has(parent.role)) return;\n\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(text);\n}\n\n/**\n * A native `<select>`, expanded into its options.\n *\n * The generic walk can't do this: a closed select's `<option>`s have no layout box,\n * so isVisible would prune them. Yet the options are exactly the affordance the agent\n * needs \u2014 \"what can I set this to\" \u2014 and, unlike an `<input>` value, they are a\n * bounded, author-defined set rather than free text the user typed. So we emit them,\n * and mark the selected one: it names one of the choices we are ALREADY showing, so\n * it reveals nothing a human looking at the control wouldn't see. Labels are redacted\n * at render time like every other name; the list is capped; a select the host deems\n * sensitive is hidden the usual way (`data-mf-private`) and never reaches here.\n *\n * `.options` is the flat HTMLOptionsCollection, so `<optgroup>` nesting is already\n * flattened for us; `<select multiple>` (role listbox) works through the same path.\n */\n/** One option, in Playwright's shape: `- option \"label\" [disabled] [selected]`. The\n * name is trimmed so a whitespace-only option renders `- option` (no \"\"). Disabled is\n * `:disabled` (which catches an <optgroup disabled> that isDisabled/opt.disabled miss)\n * OR isDisabled (which adds aria-disabled). Bracket order matches states(): [disabled]\n * before [selected]. */\nfunction optionNode(opt: HTMLOptionElement): AriaNode {\n const disabled = opt.matches(':disabled') || isDisabled(opt);\n return {\n role: 'option',\n name: (opt.label || opt.textContent || '').trim(),\n props:\n (disabled ? ' [disabled]' : '') + (opt.selected ? ' [selected]' : ''),\n children: [],\n };\n}\n\nfunction emitSelectOptions(\n select: HTMLSelectElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const options = select.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n // The selected option IS the field's current value \u2014 the one option the agent most\n // needs. In a long list (country, timezone) the selection can sit past the cap, so\n // the front slice above would show none marked [selected]. Surface any selected\n // option that fell outside the cap regardless, and don't double-count it as hidden.\n let extraSelected = 0;\n const selected = select.selectedOptions;\n for (let i = 0; i < selected.length; i++) {\n const opt = selected[i];\n if (opt && opt.index >= shown && !isPrivate(opt)) {\n if (!withinBudget(w)) return;\n w.lines++;\n parent.children.push(optionNode(opt));\n extraSelected++;\n }\n }\n const remaining = options.length - shown - extraSelected;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`\u2026 (+${remaining} more options)`);\n }\n}\n\n/**\n * An `<input list=\"\u2026\">`'s datalist suggestions.\n *\n * Same affordance as a `<select>`'s options \u2014 a bounded, author-defined set the user\n * can pick \u2014 but surfaced under the (still value-opaque) input, because the\n * `<datalist>` element is display:none, so the generic walk never reaches it. The\n * input's own value stays hidden; only the suggestion labels are emitted (redacted at\n * render like every name, and capped). No [selected] \u2014 a datalist has no current\n * choice, only completions.\n */\nfunction emitDatalistOptions(\n input: HTMLInputElement,\n parent: AriaNode,\n w: Walk,\n): void {\n const list = input.list as HTMLDataListElement | null;\n if (!list) return;\n const options = list.options;\n const shown = Math.min(options.length, MAX_OPTIONS);\n for (let i = 0; i < shown; i++) {\n if (!withinBudget(w)) return;\n const opt = options[i];\n if (!opt || isPrivate(opt)) continue;\n w.lines++;\n parent.children.push(optionNode(opt));\n }\n const remaining = options.length - shown;\n if (remaining > 0 && withinBudget(w)) {\n w.lines++;\n parent.children.push(`\u2026 (+${remaining} more options)`);\n }\n}\n\nfunction visitElement(\n el: Element,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (!withinBudget(w)) return;\n if (SKIP_TAGS.has(el.tagName) || isOurs(el)) return;\n\n // Privacy first, before we so much as compute a style: `data-mf-private` and\n // password/hidden inputs take their whole subtree with them.\n if (isPrivate(el)) return;\n\n w.nodes++;\n\n const style = w.styleOf(el);\n if (isHidden(el, style, w.layout)) return;\n\n const role = roleOf(el);\n const transparent = role === null || TRANSPARENT.has(role);\n const interactive = isInteractive(el, role, style, parentStyle);\n\n // A div with a click handler is invisible to us (no getEventListeners), but a div\n // that is FOCUSABLE, or that flips the cursor to a pointer, is announcing itself.\n // Playwright emits those as `- generic [ref=eN]` and so do we: without this, every\n // custom card, chip and icon-button on a modern app would be unreachable.\n if (transparent && !interactive) {\n visitChildren(el, parent, style, w);\n return;\n }\n\n const emittedRole = role === null || TRANSPARENT.has(role) ? 'generic' : role;\n const name = nameOf(el, w.styleOf);\n\n // Refs are for things you can act on. Static text does not get one \u2014 it would be a\n // handle the agent can only ever misuse, and it doubles the size of the snapshot.\n let ref = '';\n if (interactive && receivesPointerEvents(style)) {\n const r = refFor(el, emittedRole, name);\n ref = ` [ref=${r}]`;\n w.onRef?.(r, el);\n }\n\n const state = states(el, emittedRole);\n const node: AriaNode = {\n role: emittedRole,\n name,\n props: (state ? ` ${state}` : '') + ref,\n children: [],\n };\n\n w.lines++;\n parent.children.push(node);\n\n // A native <select>: emit its options \u2014 the affordance the opaque rule used to\n // hide \u2014 instead of walking its (layout-less, hence prune-able) children.\n if (el.tagName === 'SELECT') {\n emitSelectOptions(el as HTMLSelectElement, node, w);\n return;\n }\n\n // An <input list=\"\u2026\">: surface its datalist suggestions (the affordance) under the\n // input, then fall through to the opaque return \u2014 the value itself is never emitted.\n if (el.tagName === 'INPUT' && (el as HTMLInputElement).list) {\n emitDatalistOptions(el as HTMLInputElement, node, w);\n }\n\n // isOpaque: an <input>, <textarea> or contenteditable. Its content IS the user's\n // data, so we do not walk into it \u2014 the value cannot leak because we never go and\n // look at it. See a11y.ts.\n if (isOpaque(el)) return;\n\n visitChildren(el, node, style, w);\n}\n\nfunction visitNode(\n node: Node,\n parent: AriaNode,\n parentStyle: CSSStyleDeclaration | null,\n w: Walk,\n): void {\n if (node.nodeType === 3 /* TEXT_NODE */) {\n visitText(node as Text, parent, w);\n } else if (node.nodeType === 1 /* ELEMENT_NODE */) {\n visitElement(node as Element, parent, parentStyle, w);\n }\n // Comments, CDATA, processing instructions: nothing to say.\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Redact, then truncate \u2014 in that order, and the order is the point.\n *\n * Truncate first and a 130-character line containing an email address gets cut\n * through the middle of it, the regex no longer matches, and you have shipped\n * `jane.doe@acmecorp` to the model. Redaction runs on the whole string, every time,\n * before anything is thrown away.\n */\nfunction sanitize(text: string, max: number): string {\n const collapsed = text.replace(/\\s+/g, ' ').trim();\n const clean = redact(collapsed);\n return clean.length > max ? `${clean.slice(0, max - 1)}\u2026` : clean;\n}\n\nfunction quote(text: string): string {\n return `\"${text.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\nfunction render(\n children: (AriaNode | string)[],\n depth: number,\n out: string[],\n): void {\n const pad = ' '.repeat(depth);\n for (const child of children) {\n if (typeof child === 'string') {\n out.push(`${pad}- text: ${quote(sanitize(child, MAX_TEXT))}`);\n continue;\n }\n const name = child.name ? ` ${quote(sanitize(child.name, MAX_NAME))}` : '';\n const head = `${pad}- ${child.role}${name}${child.props}`;\n if (child.children.length) {\n out.push(`${head}:`);\n render(child.children, depth + 1, out);\n } else {\n out.push(head);\n }\n }\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 entry \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Walk the page and render it. Called by context.ts, which redacts the result a\n * second time on the way out \u2014 the belt to this file's braces.\n */\nfunction walk(\n root: Element,\n onRef?: (ref: string, el: Element) => void,\n): { yaml: string; truncated: boolean } {\n const styleOf = createStyleCache();\n const w: Walk = {\n styleOf,\n layout: hasLayout(),\n nodes: 0,\n lines: 0,\n truncated: false,\n onRef,\n };\n\n // The one call to the real isInaccessible(): a cheap backstop on the root, where\n // the ancestor walk costs nothing.\n if (isInaccessible(root, { getComputedStyle: styleOf })) {\n return { yaml: '', truncated: false };\n }\n\n const tree: AriaNode = { role: '', name: '', props: '', children: [] };\n visitChildren(root, tree, styleOf(root), w);\n\n const lines: string[] = [];\n render(tree.children, 0, lines);\n\n // An in-band marker, not just the out-of-band `truncated` flag. The YAML is what\n // lands in the prompt; a backend template that injects the tree but forgets to\n // surface the flag would hand the model a page that simply stops, and the model\n // fills the gap. This line is inside the payload, so it cannot be dropped on the\n // way to the prompt. (Depth-first, so what is missing is the BOTTOM of the page.)\n //\n // It REPLACES the last emitted line rather than appending \u2014 the marker is part of\n // the line budget, not an exemption from it. The final line was a truncated node\n // anyway (see MAX_LINES), so nothing meaningful is lost.\n if (w.truncated && lines.length) {\n lines[lines.length - 1] =\n '- text: \"\u2026 (snapshot truncated \u2014 more of the page is below)\"';\n }\n\n return { yaml: lines.join('\\n'), truncated: w.truncated };\n}\n\n/**\n * The full page. Mints a fresh generation of refs (beginSnapshot), so any ref the\n * agent held from a previous snapshot is now stale and resolves to null \u2014 which is\n * correct: the page may have changed under it.\n *\n * `visibleRefs` is the viewport slice \u2014 the refs whose element is actually on screen.\n * That is the \"where is your attention\" signal, and it lets the focus context name\n * the handful of things in view out of the whole tree.\n */\nexport function snapshot(): {\n yaml: string;\n truncated: boolean;\n visibleRefs: string[];\n} {\n const root = document.body;\n if (!root) return { yaml: '', truncated: false, visibleRefs: [] };\n\n beginSnapshot();\n\n const visibleRefs: string[] = [];\n const vh = window.innerHeight || 0;\n const vw = window.innerWidth || 0;\n const result = walk(root, (ref, el) => {\n const r = el.getBoundingClientRect();\n // On screen = its box intersects the viewport. Cheap; the walk already forced\n // layout, so getBoundingClientRect here is reading a warm value.\n if (r.bottom > 0 && r.top < vh && r.right > 0 && r.left < vw) {\n visibleRefs.push(ref);\n }\n });\n\n return { ...result, visibleRefs };\n}\n\n/**\n * Zoom in on one ref \u2014 the a11y sub-tree under it.\n *\n * This is the pull half: the agent has the focus context and a shallow page, and when\n * it wants the detail of a specific table or form it asks for that region rather than\n * us re-sending the whole page. It does NOT call beginSnapshot \u2014 that would clear the\n * ref map and invalidate the very ref being asked about \u2014 so the refs it mints join\n * the current generation.\n */\nexport function snapshotRegion(root: Element): {\n yaml: string;\n truncated: boolean;\n} {\n if (!root.isConnected) return { yaml: '', truncated: false };\n return walk(root);\n}\n"],
5
+ "mappings": "gDAIA,IAAMA,GAAQC,OAAOC,UAAUC,SAC/B,SAASC,GAAWC,EAAsB,CACzC,OAAO,OAAOA,GAAO,YAAcL,GAAMM,KAAKD,CAAE,IAAM,mBACvD,CACA,SAASE,GAAUC,EAAwB,CAC1C,IAAMC,EAASC,OAAOF,CAAK,EAC3B,OAAIG,MAAMF,CAAM,EACR,EAEJA,IAAW,GAAK,CAACG,SAASH,CAAM,EAC5BA,GAEAA,EAAS,EAAI,EAAI,IAAMI,KAAKC,MAAMD,KAAKE,IAAIN,CAAM,CAAC,CAC3D,CACA,IAAMO,GAAiBH,KAAKI,IAAI,EAAG,EAAE,EAAI,EACzC,SAASC,GAASV,EAAwB,CACzC,IAAMW,EAAMZ,GAAUC,CAAK,EAC3B,OAAOK,KAAKO,IAAIP,KAAKQ,IAAIF,EAAK,CAAC,EAAGH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,KAAM,GAAI,KAAM,GAAI,MAAO,GAAI,SAAU,CAAC,CAAE,EACrE5D,EAAcsD,EAAMM,EAAMJ,EAAQF,CAAI,EAAG/D,CAAC,EAE1C,IAAMsE,EAAkB,CAAC,EACzB,OAAAb,GAAOY,EAAK,SAAU,EAAGC,CAAK,EAW1BtE,EAAE,WAAasE,EAAM,SACvBA,EAAMA,EAAM,OAAS,CAAC,EACpB,0EAGG,CAAE,KAAMA,EAAM,KAAK;AAAA,CAAI,EAAG,UAAWtE,EAAE,SAAU,CAC1D,CAWO,SAASuE,IAId,CACA,IAAMR,EAAO,SAAS,KACtB,GAAI,CAACA,EAAM,MAAO,CAAE,KAAM,GAAI,UAAW,GAAO,YAAa,CAAC,CAAE,EAEhES,GAAc,EAEd,IAAMC,EAAwB,CAAC,EACzBC,EAAK,OAAO,aAAe,EAC3BC,EAAK,OAAO,YAAc,EAUhC,MAAO,CAAE,GATMb,GAAKC,EAAM,CAACnB,EAAK1C,IAAO,CACrC,IAAM4C,EAAI5C,EAAG,sBAAsB,EAG/B4C,EAAE,OAAS,GAAKA,EAAE,IAAM4B,GAAM5B,EAAE,MAAQ,GAAKA,EAAE,KAAO6B,GACxDF,EAAY,KAAK7B,CAAG,CAExB,CAAC,EAEmB,YAAA6B,CAAY,CAClC,CAWO,SAASG,GAAeb,EAG7B,CACA,OAAKA,EAAK,YACHD,GAAKC,CAAI,EADc,CAAE,KAAM,GAAI,UAAW,EAAM,CAE7D",
6
+ "names": ["toStr", "Object", "prototype", "toString", "isCallable", "fn", "call", "toInteger", "value", "number", "Number", "isNaN", "isFinite", "Math", "floor", "abs", "maxSafeInteger", "pow", "toLength", "len", "min", "max", "arrayFrom", "arrayLike", "mapFn", "C", "Array", "items", "TypeError", "length", "A", "k", "kValue", "SetLike", "items", "arguments", "length", "undefined", "_classCallCheck", "_defineProperty", "_createClass", "key", "value", "has", "push", "previousLength", "filter", "item", "callbackfn", "_this", "forEach", "indexOf", "get", "SetLike_default", "Set", "getLocalName", "element", "_element$localName", "localName", "tagName", "toLowerCase", "localNameToRoleMappings", "article", "aside", "button", "datalist", "dd", "details", "dialog", "dt", "fieldset", "figure", "form", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "html", "legend", "li", "math", "main", "menu", "nav", "ol", "optgroup", "option", "output", "progress", "section", "summary", "table", "tbody", "textarea", "tfoot", "td", "th", "thead", "tr", "ul", "prohibitedAttributes", "caption", "Set", "code", "deletion", "emphasis", "generic", "insertion", "none", "paragraph", "presentation", "strong", "subscript", "superscript", "hasGlobalAriaAttributes", "role", "some", "attributeName", "_prohibitedAttributes", "hasAttribute", "has", "ignorePresentationalRole", "implicitRole", "getRole", "explicitRole", "getExplicitRole", "presentationRoles", "indexOf", "getImplicitRole", "mappedByTag", "undefined", "getAttribute", "_ref", "type", "size", "trim", "split", "length", "presentationRoles", "isElement", "node", "nodeType", "ELEMENT_NODE", "isHTMLTableCaptionElement", "getLocalName", "isHTMLInputElement", "isHTMLOptGroupElement", "isHTMLSelectElement", "isHTMLTableElement", "isHTMLTextAreaElement", "safeWindow", "_ref", "ownerDocument", "defaultView", "TypeError", "isHTMLFieldSetElement", "isHTMLLegendElement", "isHTMLSlotElement", "isSVGElement", "ownerSVGElement", "undefined", "isSVGSVGElement", "isSVGTitleElement", "queryIdRefs", "attributeName", "hasAttribute", "ids", "getAttribute", "split", "root", "getRootNode", "map", "id", "getElementById", "filter", "element", "hasAnyConcreteRoles", "roles", "indexOf", "getRole", "asFlatString", "s", "trim", "replace", "isHidden", "node", "getComputedStyleImplementation", "isElement", "hasAttribute", "getAttribute", "style", "getPropertyValue", "isControl", "hasAnyConcreteRoles", "hasAbstractRole", "role", "TypeError", "concat", "querySelectorAllSubtree", "element", "selectors", "elements", "ArrayFrom", "querySelectorAll", "queryIdRefs", "forEach", "root", "push", "apply", "querySelectedOptions", "listbox", "isHTMLSelectElement", "selectedOptions", "isMarkedPresentational", "presentationRoles", "isNativeHostLanguageTextAlternativeElement", "isHTMLTableCaptionElement", "allowsNameFromContent", "isDescendantOfNativeHostLanguageTextAlternativeElement", "getValueOfTextbox", "isHTMLInputElement", "isHTMLTextAreaElement", "value", "textContent", "getTextualContent", "declaration", "content", "test", "slice", "isLabelableElement", "localName", "getLocalName", "findLabelableElement", "labelableElement", "childNodes", "childNode", "descendantLabelableElement", "getControlOfLabel", "label", "control", "undefined", "htmlFor", "ownerDocument", "getElementById", "getLabels", "labelsProperty", "labels", "document", "filter", "getSlotContents", "slot", "assignedNodes", "length", "computeTextAlternative", "options", "arguments", "consultedNodes", "SetLike", "computedStyles", "Map", "window", "safeWindow", "_options$compute", "compute", "_options$computedStyl", "computedStyleSupportsPseudoElements", "getComputedStyle", "_options$getComputedS", "uncachedGetComputedStyle", "bind", "_options$hidden", "hidden", "el", "pseudoElement", "Error", "cachedStyles", "get", "set", "computeMiscTextAlternative", "context", "accumulatedText", "pseudoBefore", "beforeContent", "isHTMLSlotElement", "child", "result", "isEmbeddedInLabel", "isReferenced", "recursion", "display", "separator", "pseudoAfter", "afterContent", "useAttribute", "attributeName", "attribute", "getAttributeNode", "has", "add", "computeTooltipAttributeValue", "computeElementTextAlternative", "isHTMLFieldSetElement", "children", "i", "isHTMLLegendElement", "isHTMLTableElement", "isSVGSVGElement", "isSVGTitleElement", "nameFromAlt", "isHTMLOptGroupElement", "nameFromLabel", "type", "nameFromValue", "map", "join", "nameFromTitle", "nameFromSubTree", "current", "labelAttributeNode", "labelElements", "skipToStep2E", "ariaLabel", "elementTextAlternative", "selectedOption", "accumulatedText2F", "nodeType", "TEXT_NODE", "tooltipAttributeValue", "prohibitsNaming", "node", "hasAnyConcreteRoles", "computeAccessibleName", "root", "options", "arguments", "length", "undefined", "computeTextAlternative", "isInaccessible", "element", "_element$ownerDocumen", "options", "arguments", "length", "undefined", "_options$getComputedS", "getComputedStyle", "ownerDocument", "defaultView", "_options$isSubtreeIna", "isSubtreeInaccessible", "isSubtreeInaccessibleImpl", "TypeError", "visibility", "currentElement", "parentElement", "_element$ownerDocumen2", "_options$getComputedS2", "hidden", "getAttribute", "display", "elementsSupportingDisabledAttribute", "Set", "isDisabled", "element", "localName", "getLocalName", "has", "hasAttribute", "getAttribute", "createStyleCache", "cache", "el", "pseudo", "style", "hasLayout", "isVisible", "layout", "display", "visibility", "box", "receivesPointerEvents", "INTERACTIVE_ROLES", "INTERACTIVE_TAGS", "isEditable", "v", "isInteractive", "role", "parentStyle", "tag", "tabindex", "NAME_FROM_CONTENT", "VALUE_ROLES", "OPAQUE_TAGS", "isOpaque", "isFilled", "ariaFlag", "attr", "states", "out", "checked", "isDisabled", "expanded", "details", "aria", "level", "pressed", "roleOf", "getRole", "UNTRUSTED_CONTENT", "nameIsUntrusted", "labelledby", "id", "ref", "nameOf", "styleOf", "name", "computeAccessibleName", "counter", "generation", "entries", "registry", "beginSnapshot", "refFor", "el", "role", "name", "key", "entry", "resolveRef", "ref", "clearRefs", "registry", "MAX_NODES", "MAX_LINES", "MAX_NAME", "MAX_TEXT", "MAX_OPTIONS", "TRANSPARENT", "SKIP_TAGS", "withinBudget", "w", "isOurs", "el", "isHidden", "style", "layout", "isVisible", "childrenOf", "assigned", "visitChildren", "parent", "children", "i", "child", "visitNode", "visitText", "node", "text", "NAME_FROM_CONTENT", "optionNode", "opt", "disabled", "isDisabled", "emitSelectOptions", "select", "options", "shown", "isPrivate", "extraSelected", "selected", "remaining", "emitDatalistOptions", "input", "list", "visitElement", "parentStyle", "role", "roleOf", "transparent", "interactive", "isInteractive", "emittedRole", "name", "nameOf", "ref", "receivesPointerEvents", "r", "refFor", "state", "states", "isOpaque", "sanitize", "max", "collapsed", "clean", "redact", "quote", "render", "depth", "out", "pad", "head", "walk", "root", "onRef", "styleOf", "createStyleCache", "hasLayout", "isInaccessible", "tree", "lines", "snapshot", "beginSnapshot", "visibleRefs", "vh", "vw", "snapshotRegion"]
7
7
  }