UNPKG

rebrowser-playwright-core

Version:

A drop-in replacement for playwright-core patched with rebrowser-patches. It allows to pass modern automation detection tests.

7 lines (6 loc) 266 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.source = void 0; const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/injectedScript.ts\nvar injectedScript_exports = {};\n__export(injectedScript_exports, {\n InjectedScript: () => InjectedScript\n});\nmodule.exports = __toCommonJS(injectedScript_exports);\n\n// packages/playwright-core/src/server/injected/xpathSelectorEngine.ts\nvar XPathEngine = {\n queryAll(root, selector) {\n if (selector.startsWith(\"/\") && root.nodeType !== Node.DOCUMENT_NODE)\n selector = \".\" + selector;\n const result = [];\n const document = root.ownerDocument || root;\n if (!document)\n return result;\n const it = document.evaluate(selector, root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);\n for (let node = it.iterateNext(); node; node = it.iterateNext()) {\n if (node.nodeType === Node.ELEMENT_NODE)\n result.push(node);\n }\n return result;\n }\n};\n\n// packages/playwright-core/src/server/injected/domUtils.ts\nvar browserNameForWorkarounds = \"\";\nfunction setBrowserName(name) {\n browserNameForWorkarounds = name;\n}\nfunction isInsideScope(scope, element) {\n while (element) {\n if (scope.contains(element))\n return true;\n element = enclosingShadowHost(element);\n }\n return false;\n}\nfunction parentElementOrShadowHost(element) {\n if (element.parentElement)\n return element.parentElement;\n if (!element.parentNode)\n return;\n if (element.parentNode.nodeType === 11 && element.parentNode.host)\n return element.parentNode.host;\n}\nfunction enclosingShadowRootOrDocument(element) {\n let node = element;\n while (node.parentNode)\n node = node.parentNode;\n if (node.nodeType === 11 || node.nodeType === 9)\n return node;\n}\nfunction enclosingShadowHost(element) {\n while (element.parentElement)\n element = element.parentElement;\n return parentElementOrShadowHost(element);\n}\nfunction closestCrossShadow(element, css, scope) {\n while (element) {\n const closest = element.closest(css);\n if (scope && closest !== scope && (closest == null ? void 0 : closest.contains(scope)))\n return;\n if (closest)\n return closest;\n element = enclosingShadowHost(element);\n }\n}\nfunction getElementComputedStyle(element, pseudo) {\n return element.ownerDocument && element.ownerDocument.defaultView ? element.ownerDocument.defaultView.getComputedStyle(element, pseudo) : void 0;\n}\nfunction isElementStyleVisibilityVisible(element, style) {\n style = style != null ? style : getElementComputedStyle(element);\n if (!style)\n return true;\n if (Element.prototype.checkVisibility && browserNameForWorkarounds !== \"webkit\") {\n if (!element.checkVisibility())\n return false;\n } else {\n const detailsOrSummary = element.closest(\"details,summary\");\n if (detailsOrSummary !== element && (detailsOrSummary == null ? void 0 : detailsOrSummary.nodeName) === \"DETAILS\" && !detailsOrSummary.open)\n return false;\n }\n if (style.visibility !== \"visible\")\n return false;\n return true;\n}\nfunction isElementVisible(element) {\n const style = getElementComputedStyle(element);\n if (!style)\n return true;\n if (style.display === \"contents\") {\n for (let child = element.firstChild; child; child = child.nextSibling) {\n if (child.nodeType === 1 && isElementVisible(child))\n return true;\n if (child.nodeType === 3 && isVisibleTextNode(child))\n return true;\n }\n return false;\n }\n if (!isElementStyleVisibilityVisible(element, style))\n return false;\n const rect = element.getBoundingClientRect();\n return rect.width > 0 && rect.height > 0;\n}\nfunction isVisibleTextNode(node) {\n const range = node.ownerDocument.createRange();\n range.selectNode(node);\n const rect = range.getBoundingClientRect();\n return rect.width > 0 && rect.height > 0;\n}\nfunction elementSafeTagName(element) {\n if (element instanceof HTMLFormElement)\n return \"FORM\";\n return element.tagName.toUpperCase();\n}\n\n// packages/playwright-core/src/utils/isomorphic/stringUtils.ts\nfunction escapeWithQuotes(text, char = \"'\") {\n const stringified = JSON.stringify(text);\n const escapedText = stringified.substring(1, stringified.length - 1).replace(/\\\\\"/g, '\"');\n if (char === \"'\")\n return char + escapedText.replace(/[']/g, \"\\\\'\") + char;\n if (char === '\"')\n return char + escapedText.replace(/[\"]/g, '\\\\\"') + char;\n if (char === \"`\")\n return char + escapedText.replace(/[`]/g, \"`\") + char;\n throw new Error(\"Invalid escape char\");\n}\nfunction toTitleCase(name) {\n return name.charAt(0).toUpperCase() + name.substring(1);\n}\nfunction toSnakeCase(name) {\n return name.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\").replace(/([A-Z])([A-Z][a-z])/g, \"$1_$2\").toLowerCase();\n}\nfunction cssEscape(s) {\n let result = \"\";\n for (let i = 0; i < s.length; i++)\n result += cssEscapeOne(s, i);\n return result;\n}\nfunction quoteCSSAttributeValue(text) {\n return `\"${cssEscape(text).replace(/\\\\ /g, \" \")}\"`;\n}\nfunction cssEscapeOne(s, i) {\n const c = s.charCodeAt(i);\n if (c === 0)\n return \"\\uFFFD\";\n if (c >= 1 && c <= 31 || c >= 48 && c <= 57 && (i === 0 || i === 1 && s.charCodeAt(0) === 45))\n return \"\\\\\" + c.toString(16) + \" \";\n if (i === 0 && c === 45 && s.length === 1)\n return \"\\\\\" + s.charAt(i);\n if (c >= 128 || c === 45 || c === 95 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122)\n return s.charAt(i);\n return \"\\\\\" + s.charAt(i);\n}\nvar normalizedWhitespaceCache;\nfunction cacheNormalizedWhitespaces() {\n normalizedWhitespaceCache = /* @__PURE__ */ new Map();\n}\nfunction normalizeWhiteSpace(text) {\n let result = normalizedWhitespaceCache == null ? void 0 : normalizedWhitespaceCache.get(text);\n if (result === void 0) {\n result = text.replace(/\\u200b/g, \"\").trim().replace(/\\s+/g, \" \");\n normalizedWhitespaceCache == null ? void 0 : normalizedWhitespaceCache.set(text, result);\n }\n return result;\n}\nfunction normalizeEscapedRegexQuotes(source) {\n return source.replace(/(^|[^\\\\])(\\\\\\\\)*\\\\(['\"`])/g, \"$1$2$3\");\n}\nfunction escapeRegexForSelector(re) {\n if (re.unicode || re.unicodeSets)\n return String(re);\n return String(re).replace(/(^|[^\\\\])(\\\\\\\\)*([\"'`])/g, \"$1$2\\\\$3\").replace(/>>/g, \"\\\\>\\\\>\");\n}\nfunction escapeForTextSelector(text, exact) {\n if (typeof text !== \"string\")\n return escapeRegexForSelector(text);\n return `${JSON.stringify(text)}${exact ? \"s\" : \"i\"}`;\n}\nfunction escapeForAttributeSelector(value, exact) {\n if (typeof value !== \"string\")\n return escapeRegexForSelector(value);\n return `\"${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/[\"]/g, '\\\\\"')}\"${exact ? \"s\" : \"i\"}`;\n}\nfunction trimString(input, cap, suffix = \"\") {\n if (input.length <= cap)\n return input;\n const chars = [...input];\n if (chars.length > cap)\n return chars.slice(0, cap - suffix.length).join(\"\") + suffix;\n return chars.join(\"\");\n}\nfunction trimStringWithEllipsis(input, cap) {\n return trimString(input, cap, \"\\u2026\");\n}\nfunction escapeRegExp(s) {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\nfunction longestCommonSubstring(s1, s2) {\n const n = s1.length;\n const m = s2.length;\n let maxLen = 0;\n let endingIndex = 0;\n const dp = Array(n + 1).fill(null).map(() => Array(m + 1).fill(0));\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= m; j++) {\n if (s1[i - 1] === s2[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n if (dp[i][j] > maxLen) {\n maxLen = dp[i][j];\n endingIndex = i;\n }\n }\n }\n }\n return s1.slice(endingIndex - maxLen, endingIndex);\n}\n\n// packages/playwright-core/src/server/injected/roleUtils.ts\nfunction hasExplicitAccessibleName(e) {\n return e.hasAttribute(\"aria-label\") || e.hasAttribute(\"aria-labelledby\");\n}\nvar kAncestorPreventingLandmark = \"article:not([role]), aside:not([role]), main:not([role]), nav:not([role]), section:not([role]), [role=article], [role=complementary], [role=main], [role=navigation], [role=region]\";\nvar kGlobalAriaAttributes = /* @__PURE__ */ new Map([\n [\"aria-atomic\", void 0],\n [\"aria-busy\", void 0],\n [\"aria-controls\", void 0],\n [\"aria-current\", void 0],\n [\"aria-describedby\", void 0],\n [\"aria-details\", void 0],\n // Global use deprecated in ARIA 1.2\n // ['aria-disabled', undefined],\n [\"aria-dropeffect\", void 0],\n // Global use deprecated in ARIA 1.2\n // ['aria-errormessage', undefined],\n [\"aria-flowto\", void 0],\n [\"aria-grabbed\", void 0],\n // Global use deprecated in ARIA 1.2\n // ['aria-haspopup', undefined],\n [\"aria-hidden\", void 0],\n // Global use deprecated in ARIA 1.2\n // ['aria-invalid', undefined],\n [\"aria-keyshortcuts\", void 0],\n [\"aria-label\", /* @__PURE__ */ new Set([\"caption\", \"code\", \"deletion\", \"emphasis\", \"generic\", \"insertion\", \"paragraph\", \"presentation\", \"strong\", \"subscript\", \"superscript\"])],\n [\"aria-labelledby\", /* @__PURE__ */ new Set([\"caption\", \"code\", \"deletion\", \"emphasis\", \"generic\", \"insertion\", \"paragraph\", \"presentation\", \"strong\", \"subscript\", \"superscript\"])],\n [\"aria-live\", void 0],\n [\"aria-owns\", void 0],\n [\"aria-relevant\", void 0],\n [\"aria-roledescription\", /* @__PURE__ */ new Set([\"generic\"])]\n]);\nfunction hasGlobalAriaAttribute(element, forRole) {\n return [...kGlobalAriaAttributes].some(([attr, prohibited]) => {\n return !(prohibited == null ? void 0 : prohibited.has(forRole || \"\")) && element.hasAttribute(attr);\n });\n}\nfunction hasTabIndex(element) {\n return !Number.isNaN(Number(String(element.getAttribute(\"tabindex\"))));\n}\nfunction isFocusable(element) {\n return !isNativelyDisabled(element) && (isNativelyFocusable(element) || hasTabIndex(element));\n}\nfunction isNativelyFocusable(element) {\n const tagName = elementSafeTagName(element);\n if ([\"BUTTON\", \"DETAILS\", \"SELECT\", \"TEXTAREA\"].includes(tagName))\n return true;\n if (tagName === \"A\" || tagName === \"AREA\")\n return element.hasAttribute(\"href\");\n if (tagName === \"INPUT\")\n return !element.hidden;\n return false;\n}\nvar kImplicitRoleByTagName = {\n \"A\": (e) => {\n return e.hasAttribute(\"href\") ? \"link\" : null;\n },\n \"AREA\": (e) => {\n return e.hasAttribute(\"href\") ? \"link\" : null;\n },\n \"ARTICLE\": () => \"article\",\n \"ASIDE\": () => \"complementary\",\n \"BLOCKQUOTE\": () => \"blockquote\",\n \"BUTTON\": () => \"button\",\n \"CAPTION\": () => \"caption\",\n \"CODE\": () => \"code\",\n \"DATALIST\": () => \"listbox\",\n \"DD\": () => \"definition\",\n \"DEL\": () => \"deletion\",\n \"DETAILS\": () => \"group\",\n \"DFN\": () => \"term\",\n \"DIALOG\": () => \"dialog\",\n \"DT\": () => \"term\",\n \"EM\": () => \"emphasis\",\n \"FIELDSET\": () => \"group\",\n \"FIGURE\": () => \"figure\",\n \"FOOTER\": (e) => closestCrossShadow(e, kAncestorPreventingLandmark) ? null : \"contentinfo\",\n \"FORM\": (e) => hasExplicitAccessibleName(e) ? \"form\" : null,\n \"H1\": () => \"heading\",\n \"H2\": () => \"heading\",\n \"H3\": () => \"heading\",\n \"H4\": () => \"heading\",\n \"H5\": () => \"heading\",\n \"H6\": () => \"heading\",\n \"HEADER\": (e) => closestCrossShadow(e, kAncestorPreventingLandmark) ? null : \"banner\",\n \"HR\": () => \"separator\",\n \"HTML\": () => \"document\",\n \"IMG\": (e) => e.getAttribute(\"alt\") === \"\" && !e.getAttribute(\"title\") && !hasGlobalAriaAttribute(e) && !hasTabIndex(e) ? \"presentation\" : \"img\",\n \"INPUT\": (e) => {\n const type = e.type.toLowerCase();\n if (type === \"search\")\n return e.hasAttribute(\"list\") ? \"combobox\" : \"searchbox\";\n if ([\"email\", \"tel\", \"text\", \"url\", \"\"].includes(type)) {\n const list = getIdRefs(e, e.getAttribute(\"list\"))[0];\n return list && elementSafeTagName(list) === \"DATALIST\" ? \"combobox\" : \"textbox\";\n }\n if (type === \"hidden\")\n return null;\n return inputTypeToRole[type] || \"textbox\";\n },\n \"INS\": () => \"insertion\",\n \"LI\": () => \"listitem\",\n \"MAIN\": () => \"main\",\n \"MARK\": () => \"mark\",\n \"MATH\": () => \"math\",\n \"MENU\": () => \"list\",\n \"METER\": () => \"meter\",\n \"NAV\": () => \"navigation\",\n \"OL\": () => \"list\",\n \"OPTGROUP\": () => \"group\",\n \"OPTION\": () => \"option\",\n \"OUTPUT\": () => \"status\",\n \"P\": () => \"paragraph\",\n \"PROGRESS\": () => \"progressbar\",\n \"SECTION\": (e) => hasExplicitAccessibleName(e) ? \"region\" : null,\n \"SELECT\": (e) => e.hasAttribute(\"multiple\") || e.size > 1 ? \"listbox\" : \"combobox\",\n \"STRONG\": () => \"strong\",\n \"SUB\": () => \"subscript\",\n \"SUP\": () => \"superscript\",\n // For <svg> we default to Chrome behavior:\n // - Chrome reports 'img'.\n // - Firefox reports 'diagram' that is not in official ARIA spec yet.\n // - Safari reports 'no role', but still computes accessible name.\n \"SVG\": () => \"img\",\n \"TABLE\": () => \"table\",\n \"TBODY\": () => \"rowgroup\",\n \"TD\": (e) => {\n const table = closestCrossShadow(e, \"table\");\n const role = table ? getExplicitAriaRole(table) : \"\";\n return role === \"grid\" || role === \"treegrid\" ? \"gridcell\" : \"cell\";\n },\n \"TEXTAREA\": () => \"textbox\",\n \"TFOOT\": () => \"rowgroup\",\n \"TH\": (e) => {\n if (e.getAttribute(\"scope\") === \"col\")\n return \"columnheader\";\n if (e.getAttribute(\"scope\") === \"row\")\n return \"rowheader\";\n const table = closestCrossShadow(e, \"table\");\n const role = table ? getExplicitAriaRole(table) : \"\";\n return role === \"grid\" || role === \"treegrid\" ? \"gridcell\" : \"cell\";\n },\n \"THEAD\": () => \"rowgroup\",\n \"TIME\": () => \"time\",\n \"TR\": () => \"row\",\n \"UL\": () => \"list\"\n};\nvar kPresentationInheritanceParents = {\n \"DD\": [\"DL\", \"DIV\"],\n \"DIV\": [\"DL\"],\n \"DT\": [\"DL\", \"DIV\"],\n \"LI\": [\"OL\", \"UL\"],\n \"TBODY\": [\"TABLE\"],\n \"TD\": [\"TR\"],\n \"TFOOT\": [\"TABLE\"],\n \"TH\": [\"TR\"],\n \"THEAD\": [\"TABLE\"],\n \"TR\": [\"THEAD\", \"TBODY\", \"TFOOT\", \"TABLE\"]\n};\nfunction getImplicitAriaRole(element) {\n var _a;\n const implicitRole = ((_a = kImplicitRoleByTagName[elementSafeTagName(element)]) == null ? void 0 : _a.call(kImplicitRoleByTagName, element)) || \"\";\n if (!implicitRole)\n return null;\n let ancestor = element;\n while (ancestor) {\n const parent = parentElementOrShadowHost(ancestor);\n const parents = kPresentationInheritanceParents[elementSafeTagName(ancestor)];\n if (!parents || !parent || !parents.includes(elementSafeTagName(parent)))\n break;\n const parentExplicitRole = getExplicitAriaRole(parent);\n if ((parentExplicitRole === \"none\" || parentExplicitRole === \"presentation\") && !hasPresentationConflictResolution(parent, parentExplicitRole))\n return parentExplicitRole;\n ancestor = parent;\n }\n return implicitRole;\n}\nvar validRoles = [\n \"alert\",\n \"alertdialog\",\n \"application\",\n \"article\",\n \"banner\",\n \"blockquote\",\n \"button\",\n \"caption\",\n \"cell\",\n \"checkbox\",\n \"code\",\n \"columnheader\",\n \"combobox\",\n \"complementary\",\n \"contentinfo\",\n \"definition\",\n \"deletion\",\n \"dialog\",\n \"directory\",\n \"document\",\n \"emphasis\",\n \"feed\",\n \"figure\",\n \"form\",\n \"generic\",\n \"grid\",\n \"gridcell\",\n \"group\",\n \"heading\",\n \"img\",\n \"insertion\",\n \"link\",\n \"list\",\n \"listbox\",\n \"listitem\",\n \"log\",\n \"main\",\n \"mark\",\n \"marquee\",\n \"math\",\n \"meter\",\n \"menu\",\n \"menubar\",\n \"menuitem\",\n \"menuitemcheckbox\",\n \"menuitemradio\",\n \"navigation\",\n \"none\",\n \"note\",\n \"option\",\n \"paragraph\",\n \"presentation\",\n \"progressbar\",\n \"radio\",\n \"radiogroup\",\n \"region\",\n \"row\",\n \"rowgroup\",\n \"rowheader\",\n \"scrollbar\",\n \"search\",\n \"searchbox\",\n \"separator\",\n \"slider\",\n \"spinbutton\",\n \"status\",\n \"strong\",\n \"subscript\",\n \"superscript\",\n \"switch\",\n \"tab\",\n \"table\",\n \"tablist\",\n \"tabpanel\",\n \"term\",\n \"textbox\",\n \"time\",\n \"timer\",\n \"toolbar\",\n \"tooltip\",\n \"tree\",\n \"treegrid\",\n \"treeitem\"\n];\nfunction getExplicitAriaRole(element) {\n const roles = (element.getAttribute(\"role\") || \"\").split(\" \").map((role) => role.trim());\n return roles.find((role) => validRoles.includes(role)) || null;\n}\nfunction hasPresentationConflictResolution(element, role) {\n return hasGlobalAriaAttribute(element, role) || isFocusable(element);\n}\nfunction getAriaRole(element) {\n const explicitRole = getExplicitAriaRole(element);\n if (!explicitRole)\n return getImplicitAriaRole(element);\n if (explicitRole === \"none\" || explicitRole === \"presentation\") {\n const implicitRole = getImplicitAriaRole(element);\n if (hasPresentationConflictResolution(element, implicitRole))\n return implicitRole;\n }\n return explicitRole;\n}\nfunction getAriaBoolean(attr) {\n return attr === null ? void 0 : attr.toLowerCase() === \"true\";\n}\nfunction isElementIgnoredForAria(element) {\n return [\"STYLE\", \"SCRIPT\", \"NOSCRIPT\", \"TEMPLATE\"].includes(elementSafeTagName(element));\n}\nfunction isElementHiddenForAria(element) {\n if (isElementIgnoredForAria(element))\n return true;\n const style = getElementComputedStyle(element);\n const isSlot = element.nodeName === \"SLOT\";\n if ((style == null ? void 0 : style.display) === \"contents\" && !isSlot) {\n for (let child = element.firstChild; child; child = child.nextSibling) {\n if (child.nodeType === 1 && !isElementHiddenForAria(child))\n return false;\n if (child.nodeType === 3 && isVisibleTextNode(child))\n return false;\n }\n return true;\n }\n const isOptionInsideSelect = element.nodeName === \"OPTION\" && !!element.closest(\"select\");\n if (!isOptionInsideSelect && !isSlot && !isElementStyleVisibilityVisible(element, style))\n return true;\n return belongsToDisplayNoneOrAriaHiddenOrNonSlotted(element);\n}\nfunction belongsToDisplayNoneOrAriaHiddenOrNonSlotted(element) {\n let hidden = cacheIsHidden == null ? void 0 : cacheIsHidden.get(element);\n if (hidden === void 0) {\n hidden = false;\n if (element.parentElement && element.parentElement.shadowRoot && !element.assignedSlot)\n hidden = true;\n if (!hidden) {\n const style = getElementComputedStyle(element);\n hidden = !style || style.display === \"none\" || getAriaBoolean(element.getAttribute(\"aria-hidden\")) === true;\n }\n if (!hidden) {\n const parent = parentElementOrShadowHost(element);\n if (parent)\n hidden = belongsToDisplayNoneOrAriaHiddenOrNonSlotted(parent);\n }\n cacheIsHidden == null ? void 0 : cacheIsHidden.set(element, hidden);\n }\n return hidden;\n}\nfunction getIdRefs(element, ref) {\n if (!ref)\n return [];\n const root = enclosingShadowRootOrDocument(element);\n if (!root)\n return [];\n try {\n const ids = ref.split(\" \").filter((id) => !!id);\n const set = /* @__PURE__ */ new Set();\n for (const id of ids) {\n const firstElement = root.querySelector(\"#\" + CSS.escape(id));\n if (firstElement)\n set.add(firstElement);\n }\n return [...set];\n } catch (e) {\n return [];\n }\n}\nfunction trimFlatString(s) {\n return s.trim();\n}\nfunction asFlatString(s) {\n return s.split(\"\\xA0\").map((chunk) => chunk.replace(/\\r\\n/g, \"\\n\").replace(/\\s\\s*/g, \" \")).join(\"\\xA0\").trim();\n}\nfunction queryInAriaOwned(element, selector) {\n const result = [...element.querySelectorAll(selector)];\n for (const owned of getIdRefs(element, element.getAttribute(\"aria-owns\"))) {\n if (owned.matches(selector))\n result.push(owned);\n result.push(...owned.querySelectorAll(selector));\n }\n return result;\n}\nfunction getPseudoContent(element, pseudo) {\n const cache = pseudo === \"::before\" ? cachePseudoContentBefore : cachePseudoContentAfter;\n if (cache == null ? void 0 : cache.has(element))\n return (cache == null ? void 0 : cache.get(element)) || \"\";\n const pseudoStyle = getElementComputedStyle(element, pseudo);\n const content = getPseudoContentImpl(pseudoStyle);\n if (cache)\n cache.set(element, content);\n return content;\n}\nfunction getPseudoContentImpl(pseudoStyle) {\n if (!pseudoStyle || pseudoStyle.display === \"none\" || pseudoStyle.visibility === \"hidden\")\n return \"\";\n const content = pseudoStyle.content;\n if (content[0] === \"'\" && content[content.length - 1] === \"'\" || content[0] === '\"' && content[content.length - 1] === '\"') {\n const unquoted = content.substring(1, content.length - 1);\n const display = pseudoStyle.display || \"inline\";\n if (display !== \"inline\")\n return \" \" + unquoted + \" \";\n return unquoted;\n }\n return \"\";\n}\nfunction getAriaLabelledByElements(element) {\n const ref = element.getAttribute(\"aria-labelledby\");\n if (ref === null)\n return null;\n const refs = getIdRefs(element, ref);\n return refs.length ? refs : null;\n}\nfunction allowsNameFromContent(role, targetDescendant) {\n const alwaysAllowsNameFromContent = [\"button\", \"cell\", \"checkbox\", \"columnheader\", \"gridcell\", \"heading\", \"link\", \"menuitem\", \"menuitemcheckbox\", \"menuitemradio\", \"option\", \"radio\", \"row\", \"rowheader\", \"switch\", \"tab\", \"tooltip\", \"treeitem\"].includes(role);\n const descendantAllowsNameFromContent = targetDescendant && [\"\", \"caption\", \"code\", \"contentinfo\", \"definition\", \"deletion\", \"emphasis\", \"insertion\", \"list\", \"listitem\", \"mark\", \"none\", \"paragraph\", \"presentation\", \"region\", \"row\", \"rowgroup\", \"section\", \"strong\", \"subscript\", \"superscript\", \"table\", \"term\", \"time\"].includes(role);\n return alwaysAllowsNameFromContent || descendantAllowsNameFromContent;\n}\nfunction getElementAccessibleName(element, includeHidden) {\n const cache = includeHidden ? cacheAccessibleNameHidden : cacheAccessibleName;\n let accessibleName = cache == null ? void 0 : cache.get(element);\n if (accessibleName === void 0) {\n accessibleName = \"\";\n const elementProhibitsNaming = [\"caption\", \"code\", \"definition\", \"deletion\", \"emphasis\", \"generic\", \"insertion\", \"mark\", \"paragraph\", \"presentation\", \"strong\", \"subscript\", \"suggestion\", \"superscript\", \"term\", \"time\"].includes(getAriaRole(element) || \"\");\n if (!elementProhibitsNaming) {\n accessibleName = asFlatString(getTextAlternativeInternal(element, {\n includeHidden,\n visitedElements: /* @__PURE__ */ new Set(),\n embeddedInTargetElement: \"self\"\n }));\n }\n cache == null ? void 0 : cache.set(element, accessibleName);\n }\n return accessibleName;\n}\nfunction getElementAccessibleDescription(element, includeHidden) {\n const cache = includeHidden ? cacheAccessibleDescriptionHidden : cacheAccessibleDescription;\n let accessibleDescription = cache == null ? void 0 : cache.get(element);\n if (accessibleDescription === void 0) {\n accessibleDescription = \"\";\n if (element.hasAttribute(\"aria-describedby\")) {\n const describedBy = getIdRefs(element, element.getAttribute(\"aria-describedby\"));\n accessibleDescription = asFlatString(describedBy.map((ref) => getTextAlternativeInternal(ref, {\n includeHidden,\n visitedElements: /* @__PURE__ */ new Set(),\n embeddedInDescribedBy: { element: ref, hidden: isElementHiddenForAria(ref) }\n })).join(\" \"));\n } else if (element.hasAttribute(\"aria-description\")) {\n accessibleDescription = asFlatString(element.getAttribute(\"aria-description\") || \"\");\n } else {\n accessibleDescription = asFlatString(element.getAttribute(\"title\") || \"\");\n }\n cache == null ? void 0 : cache.set(element, accessibleDescription);\n }\n return accessibleDescription;\n}\nfunction getTextAlternativeInternal(element, options) {\n var _a, _b, _c, _d;\n if (options.visitedElements.has(element))\n return \"\";\n const childOptions = {\n ...options,\n embeddedInTargetElement: options.embeddedInTargetElement === \"self\" ? \"descendant\" : options.embeddedInTargetElement\n };\n if (!options.includeHidden) {\n const isEmbeddedInHiddenReferenceTraversal = !!((_a = options.embeddedInLabelledBy) == null ? void 0 : _a.hidden) || !!((_b = options.embeddedInDescribedBy) == null ? void 0 : _b.hidden) || !!((_c = options.embeddedInNativeTextAlternative) == null ? void 0 : _c.hidden) || !!((_d = options.embeddedInLabel) == null ? void 0 : _d.hidden);\n if (isElementIgnoredForAria(element) || !isEmbeddedInHiddenReferenceTraversal && isElementHiddenForAria(element)) {\n options.visitedElements.add(element);\n return \"\";\n }\n }\n const labelledBy = getAriaLabelledByElements(element);\n if (!options.embeddedInLabelledBy) {\n const accessibleName = (labelledBy || []).map((ref) => getTextAlternativeInternal(ref, {\n ...options,\n embeddedInLabelledBy: { element: ref, hidden: isElementHiddenForAria(ref) },\n embeddedInDescribedBy: void 0,\n embeddedInTargetElement: void 0,\n embeddedInLabel: void 0,\n embeddedInNativeTextAlternative: void 0\n })).join(\" \");\n if (accessibleName)\n return accessibleName;\n }\n const role = getAriaRole(element) || \"\";\n const tagName = elementSafeTagName(element);\n if (!!options.embeddedInLabel || !!options.embeddedInLabelledBy || options.embeddedInTargetElement === \"descendant\") {\n const isOwnLabel = [...element.labels || []].includes(element);\n const isOwnLabelledBy = (labelledBy || []).includes(element);\n if (!isOwnLabel && !isOwnLabelledBy) {\n if (role === \"textbox\") {\n options.visitedElements.add(element);\n if (tagName === \"INPUT\" || tagName === \"TEXTAREA\")\n return element.value;\n return element.textContent || \"\";\n }\n if ([\"combobox\", \"listbox\"].includes(role)) {\n options.visitedElements.add(element);\n let selectedOptions;\n if (tagName === \"SELECT\") {\n selectedOptions = [...element.selectedOptions];\n if (!selectedOptions.length && element.options.length)\n selectedOptions.push(element.options[0]);\n } else {\n const listbox = role === \"combobox\" ? queryInAriaOwned(element, \"*\").find((e) => getAriaRole(e) === \"listbox\") : element;\n selectedOptions = listbox ? queryInAriaOwned(listbox, '[aria-selected=\"true\"]').filter((e) => getAriaRole(e) === \"option\") : [];\n }\n if (!selectedOptions.length && tagName === \"INPUT\") {\n return element.value;\n }\n return selectedOptions.map((option) => getTextAlternativeInternal(option, childOptions)).join(\" \");\n }\n if ([\"progressbar\", \"scrollbar\", \"slider\", \"spinbutton\", \"meter\"].includes(role)) {\n options.visitedElements.add(element);\n if (element.hasAttribute(\"aria-valuetext\"))\n return element.getAttribute(\"aria-valuetext\") || \"\";\n if (element.hasAttribute(\"aria-valuenow\"))\n return element.getAttribute(\"aria-valuenow\") || \"\";\n return element.getAttribute(\"value\") || \"\";\n }\n if ([\"menu\"].includes(role)) {\n options.visitedElements.add(element);\n return \"\";\n }\n }\n }\n const ariaLabel = element.getAttribute(\"aria-label\") || \"\";\n if (trimFlatString(ariaLabel)) {\n options.visitedElements.add(element);\n return ariaLabel;\n }\n if (![\"presentation\", \"none\"].includes(role)) {\n if (tagName === \"INPUT\" && [\"button\", \"submit\", \"reset\"].includes(element.type)) {\n options.visitedElements.add(element);\n const value = element.value || \"\";\n if (trimFlatString(value))\n return value;\n if (element.type === \"submit\")\n return \"Submit\";\n if (element.type === \"reset\")\n return \"Reset\";\n const title = element.getAttribute(\"title\") || \"\";\n return title;\n }\n if (tagName === \"INPUT\" && element.type === \"image\") {\n options.visitedElements.add(element);\n const labels = element.labels || [];\n if (labels.length && !options.embeddedInLabelledBy)\n return getAccessibleNameFromAssociatedLabels(labels, options);\n const alt = element.getAttribute(\"alt\") || \"\";\n if (trimFlatString(alt))\n return alt;\n const title = element.getAttribute(\"title\") || \"\";\n if (trimFlatString(title))\n return title;\n return \"Submit\";\n }\n if (!labelledBy && tagName === \"BUTTON\") {\n options.visitedElements.add(element);\n const labels = element.labels || [];\n if (labels.length)\n return getAccessibleNameFromAssociatedLabels(labels, options);\n }\n if (!labelledBy && tagName === \"OUTPUT\") {\n options.visitedElements.add(element);\n const labels = element.labels || [];\n if (labels.length)\n return getAccessibleNameFromAssociatedLabels(labels, options);\n return element.getAttribute(\"title\") || \"\";\n }\n if (!labelledBy && (tagName === \"TEXTAREA\" || tagName === \"SELECT\" || tagName === \"INPUT\")) {\n options.visitedElements.add(element);\n const labels = element.labels || [];\n if (labels.length)\n return getAccessibleNameFromAssociatedLabels(labels, options);\n const usePlaceholder = tagName === \"INPUT\" && [\"text\", \"password\", \"search\", \"tel\", \"email\", \"url\"].includes(element.type) || tagName === \"TEXTAREA\";\n const placeholder = element.getAttribute(\"placeholder\") || \"\";\n const title = element.getAttribute(\"title\") || \"\";\n if (!usePlaceholder || title)\n return title;\n return placeholder;\n }\n if (!labelledBy && tagName === \"FIELDSET\") {\n options.visitedElements.add(element);\n for (let child = element.firstElementChild; child; child = child.nextElementSibling) {\n if (elementSafeTagName(child) === \"LEGEND\") {\n return getTextAlternativeInternal(child, {\n ...childOptions,\n embeddedInNativeTextAlternative: { element: child, hidden: isElementHiddenForAria(child) }\n });\n }\n }\n const title = element.getAttribute(\"title\") || \"\";\n return title;\n }\n if (!labelledBy && tagName === \"FIGURE\") {\n options.visitedElements.add(element);\n for (let child = element.firstElementChild; child; child = child.nextElementSibling) {\n if (elementSafeTagName(child) === \"FIGCAPTION\") {\n return getTextAlternativeInternal(child, {\n ...childOptions,\n embeddedInNativeTextAlternative: { element: child, hidden: isElementHiddenForAria(child) }\n });\n }\n }\n const title = element.getAttribute(\"title\") || \"\";\n return title;\n }\n if (tagName === \"IMG\") {\n options.visitedElements.add(element);\n const alt = element.getAttribute(\"alt\") || \"\";\n if (trimFlatString(alt))\n return alt;\n const title = element.getAttribute(\"title\") || \"\";\n return title;\n }\n if (tagName === \"TABLE\") {\n options.visitedElements.add(element);\n for (let child = element.firstElementChild; child; child = child.nextElementSibling) {\n if (elementSafeTagName(child) === \"CAPTION\") {\n return getTextAlternativeInternal(child, {\n ...childOptions,\n embeddedInNativeTextAlternative: { element: child, hidden: isElementHiddenForAria(child) }\n });\n }\n }\n const summary = element.getAttribute(\"summary\") || \"\";\n if (summary)\n return summary;\n }\n if (tagName === \"AREA\") {\n options.visitedElements.add(element);\n const alt = element.getAttribute(\"alt\") || \"\";\n if (trimFlatString(alt))\n return alt;\n const title = element.getAttribute(\"title\") || \"\";\n return title;\n }\n if (tagName === \"SVG\" || element.ownerSVGElement) {\n options.visitedElements.add(element);\n for (let child = element.firstElementChild; child; child = child.nextElementSibling) {\n if (elementSafeTagName(child) === \"TITLE\" && child.ownerSVGElement) {\n return getTextAlternativeInternal(child, {\n ...childOptions,\n embeddedInLabelledBy: { element: child, hidden: isElementHiddenForAria(child) }\n });\n }\n }\n }\n if (element.ownerSVGElement && tagName === \"A\") {\n const title = element.getAttribute(\"xlink:title\") || \"\";\n if (trimFlatString(title)) {\n options.visitedElements.add(element);\n return title;\n }\n }\n }\n const shouldNameFromContentForSummary = tagName === \"SUMMARY\" && ![\"presentation\", \"none\"].includes(role);\n if (allowsNameFromContent(role, options.embeddedInTargetElement === \"descendant\") || shouldNameFromContentForSummary || !!options.embeddedInLabelledBy || !!options.embeddedInDescribedBy || !!options.embeddedInLabel || !!options.embeddedInNativeTextAlternative) {\n options.visitedElements.add(element);\n const accessibleName = innerAccumulatedElementText(element, childOptions);\n const maybeTrimmedAccessibleName = options.embeddedInTargetElement === \"self\" ? trimFlatString(accessibleName) : accessibleName;\n if (maybeTrimmedAccessibleName)\n return accessibleName;\n }\n if (![\"presentation\", \"none\"].includes(role) || tagName === \"IFRAME\") {\n options.visitedElements.add(element);\n const title = element.getAttribute(\"title\") || \"\";\n if (trimFlatString(title))\n return title;\n }\n options.visitedElements.add(element);\n return \"\";\n}\nfunction innerAccumulatedElementText(element, options) {\n const tokens = [];\n const visit = (node, skipSlotted) => {\n var _a;\n if (skipSlotted && node.assignedSlot)\n return;\n if (node.nodeType === 1) {\n const display = ((_a = getElementComputedStyle(node)) == null ? void 0 : _a.display) || \"inline\";\n let token = getTextAlternativeInternal(node, options);\n if (display !== \"inline\" || node.nodeName === \"BR\")\n token = \" \" + token + \" \";\n tokens.push(token);\n } else if (node.nodeType === 3) {\n tokens.push(node.textContent || \"\");\n }\n };\n tokens.push(getPseudoContent(element, \"::before\"));\n const assignedNodes = element.nodeName === \"SLOT\" ? element.assignedNodes() : [];\n if (assignedNodes.length) {\n for (const child of assignedNodes)\n visit(child, false);\n } else {\n for (let child = element.firstChild; child; child = child.nextSibling)\n visit(child, true);\n if (element.shadowRoot) {\n for (let child = element.shadowRoot.firstChild; child; child = child.nextSibling)\n visit(child, true);\n }\n for (const owned of getIdRefs(element, element.getAttribute(\"aria-owns\")))\n visit(owned, true);\n }\n tokens.push(getPseudoContent(element, \"::after\"));\n return tokens.join(\"\");\n}\nvar kAriaSelectedRoles = [\"gridcell\", \"option\", \"row\", \"tab\", \"rowheader\", \"columnheader\", \"treeitem\"];\nfunction getAriaSelected(element) {\n if (elementSafeTagName(element) === \"OPTION\")\n return element.selected;\n if (kAriaSelectedRoles.includes(getAriaRole(element) || \"\"))\n return getAriaBoolean(element.getAttribute(\"aria-selected\")) === true;\n return false;\n}\nvar kAriaCheckedRoles = [\"checkbox\", \"menuitemcheckbox\", \"option\", \"radio\", \"switch\", \"menuitemradio\", \"treeitem\"];\nfunction getAriaChecked(element) {\n const result = getChecked(element, true);\n return result === \"error\" ? false : result;\n}\nfunction getChecked(element, allowMixed) {\n const tagName = elementSafeTagName(element);\n if (allowMixed && tagName === \"INPUT\" && element.indeterminate)\n return \"mixed\";\n if (tagName === \"INPUT\" && [\"checkbox\", \"radio\"].includes(element.type))\n return element.checked;\n if (kAriaCheckedRoles.includes(getAriaRole(element) || \"\")) {\n const checked = element.getAttribute(\"aria-checked\");\n if (checked === \"true\")\n return true;\n if (allowMixed && checked === \"mixed\")\n return \"mixed\";\n return false;\n }\n return \"error\";\n}\nvar kAriaPressedRoles = [\"button\"];\nfunction getAriaPressed(element) {\n if (kAriaPressedRoles.includes(getAriaRole(element) || \"\")) {\n const pressed = element.getAttribute(\"aria-pressed\");\n if (pressed === \"true\")\n return true;\n if (pressed === \"mixed\")\n return \"mixed\";\n }\n return false;\n}\nvar kAriaExpandedRoles = [\"application\", \"button\", \"checkbox\", \"combobox\", \"gridcell\", \"link\", \"listbox\", \"menuitem\", \"row\", \"rowheader\", \"tab\", \"treeitem\", \"columnheader\", \"menuitemcheckbox\", \"menuitemradio\", \"rowheader\", \"switch\"];\nfunction getAriaExpanded(element) {\n if (elementSafeTagName(element) === \"DETAILS\")\n return element.open;\n if (kAriaExpandedRoles.includes(getAriaRole(element) || \"\")) {\n const expanded = element.getAttribute(\"aria-expanded\");\n if (expanded === null)\n return void 0;\n if (expanded === \"true\")\n return true;\n return false;\n }\n return void 0;\n}\nvar kAriaLevelRoles = [\"heading\", \"listitem\", \"row\", \"treeitem\"];\nfunction getAriaLevel(element) {\n const native = { \"H1\": 1, \"H2\": 2, \"H3\": 3, \"H4\": 4, \"H5\": 5, \"H6\": 6 }[elementSafeTagName(element)];\n if (native)\n return native;\n if (kAriaLevelRoles.includes(getAriaRole(element) || \"\")) {\n const attr = element.getAttribute(\"aria-level\");\n const value = attr === null ? Number.NaN : Number(attr);\n if (Number.isInteger(value) && value >= 1)\n return value;\n }\n return 0;\n}\nvar kAriaDisabledRoles = [\"application\", \"button\", \"composite\", \"gridcell\", \"group\", \"input\", \"link\", \"menuitem\", \"scrollbar\", \"separator\", \"tab\", \"checkbox\", \"columnheader\", \"combobox\", \"grid\", \"listbox\", \"menu\", \"menubar\", \"menuitemcheckbox\", \"menuitemradio\", \"option\", \"radio\", \"radiogroup\", \"row\", \"rowheader\", \"searchbox\", \"select\", \"slider\", \"spinbutton\", \"switch\", \"tablist\", \"textbox\", \"toolbar\", \"tree\", \"treegrid\", \"treeitem\"];\nfunction getAriaDisabled(element) {\n return isNativelyDisabled(element) || hasExplicitAriaDisabled(element);\n}\nfunction isNativelyDisabled(element) {\n const isNativeFormControl = [\"BUTTON\", \"INPUT\", \"SELECT\", \"TEXTAREA\", \"OPTION\", \"OPTGROUP\"].includes(element.tagName);\n return isNativeFormControl && (element.hasAttribute(\"disabled\") || belongsToDisabledFieldSet(element));\n}\nfunction belongsToDisabledFieldSet(element) {\n if (!element)\n return false;\n if (elementSafeTagName(element) === \"FIELDSET\" && element.hasAttribute(\"disabled\"))\n return true;\n return belongsToDisabledFieldSet(element.parentElement);\n}\nfunction hasExplicitAriaDisabled(element) {\n if (!element)\n return false;\n if (kAriaDisabledRoles.includes(getAriaRole(element) || \"\")) {\n const attribute = (element.getAttribute(\"aria-disabled\") || \"\").toLowerCase();\n if (attribute === \"true\")\n return true;\n if (attribute === \"false\")\n return false;\n }\n return hasExplicitAriaDisabled(parentElementOrShadowHost(element));\n}\nfunction getAccessibleNameFromAssociatedLabels(labels, options) {\n return [...labels].map((label) => getTextAlternativeInternal(label, {\n ...options,\n embeddedInLabel: { element: label, hidden: isElementHiddenForAria(label) },\n embeddedInNativeTextAlternative: void 0,\n embeddedInLabelledBy: void 0,\n embeddedInDescribedBy: void 0,\n embeddedInTargetElement: void 0\n })).filter((accessibleName) => !!accessibleName).join(\" \");\n}\nvar cacheAccessibleName;\nvar cacheAccessibleNameHidden;\nvar cacheAccessibleDescription;\nvar cacheAccessibleDescriptionHidden;\nvar cacheIsHidden;\nvar cachePseudoContentBefore;\nvar cachePseudoContentAfter;\nvar cachesCounter = 0;\nfunction beginAriaCaches() {\n ++cachesCounter;\n cacheAccessibleName != null ? cacheAccessibleName : cacheAccessibleName = /* @__PURE__ */ new Map();\n cacheAccessibleNameHidden != null ? cacheAccessibleNameHidden : cacheAccessibleNameHidden = /* @__PURE__ */ new Map();\n cacheAccessibleDescription != null ? cacheAccessibleDescription : cacheAccessibleDescription = /* @__PURE__ */ new Map();\n cacheAccessibleDescriptionHidden != null ? cacheAccessibleDescriptionHidden : cacheAccessibleDescriptionHidden = /* @__PURE__ */ new Map();\n cacheIsHidden != null ? cacheIsHidden : cacheIsHidden = /* @__PURE__ */ new Map();\n cachePseudoContentBefore != null ? cachePseudoContentBefore : cachePseudoContentBefore = /* @__PURE__ */ new Map();\n cachePseudoContentAfter != null ? cachePseudoContentAfter : cachePseudoContentAfter = /* @__PURE__ */ new Map();\n}\nfunction endAriaCaches() {\n if (!--cachesCounter) {\n cacheAccessibleName = void 0;\n cacheAccessibleNameHidden = void 0;\n cacheAccessibleDescription = void 0;\n cacheAccessibleDescriptionHidden = void 0;\n cacheIsHidden = void 0;\n cachePseudoContentBefore = void 0;\n cachePseudoContentAfter = void 0;\n }\n}\nvar inputTypeToRole = {\n \"button\": \"button\",\n \"checkbox\": \"checkbox\",\n \"image\": \"button\",\n \"number\": \"spinbutton\",\n \"radio\": \"radio\",\n \"range\": \"slider\",\n \"reset\": \"button\",\n \"submit\": \"button\"\n};\n\n// packages/playwright-core/src/server/injected/selectorUtils.ts\nfunction matchesComponentAttribute(obj, attr) {\n for (const token of attr.jsonPath) {\n if (obj !== void 0 && obj !== null)\n obj = obj[token];\n }\n return matchesAttributePart(obj, attr);\n}\nfunction matchesAttributePart(value, attr) {\n const objValue = typeof value === \"string\" && !attr.caseSensitive ? value.toUpperCase() : value;\n const attrValue = typeof attr.value === \"string\" && !attr.caseSensitive ? attr.value.toUpperCase() : attr.value;\n if (attr.op === \"<truthy>\")\n return !!objValue;\n if (attr.op === \"=\") {\n if (attrValue instanceof RegExp)\n return typeof objValue === \"string\" && !!objValue.match(attrValue);\n return objValue === attrValue;\n }\n if (typeof objValue !== \"string\" || typeof attrValue !== \"string\")\n return false;\n if (attr.op === \"*=\")\n return objValue.includes(attrValue);\n if (attr.op === \"^=\")\n return objValue.startsWith(attrValue);\n if (attr.op === \"$=\")\n return objValue.endsWith(attrValue);\n if (attr.op === \"|=\")\n return objValue === attrValue || objValue.startsWith(attrValue + \"-\");\n if (attr.op === \"~=\")\n return objValue.split(\" \").includes(attrValue);\n return false;\n}\nfunction shouldSkipForTextMatching(element) {\n const document = element.ownerDocument;\n return element.nodeName === \"SCRIPT\" || element.nodeName === \"NOSCRIPT\" || element.nodeName === \"STYLE\" || document.head && document.head.contains(element);\n}\nfunction elementText(cache, root) {\n let value = cache.get(root);\n if (value === void 0) {\n value = { full: \"\", normalized: \"\", immediate: [] };\n if (!shouldSkipForTextMatching(root)) {\n let currentImmediate = \"\";\n if (root instanceof HTMLInputElement && (root.type === \"submit\" || root.type === \"button\")) {\n value = { full: root.value, normalized: normalizeWhiteSpace(root.value), immediate: [root.value] };\n } else {\n for (let child = root.firstChild; child; child = child.nextSibling) {\n if (child.nodeType === Node.TEXT_NODE) {\n value.full += child.nodeValue || \"\";\n currentImmediate += child.nodeValue || \"\";\n } else {\n if (currentImmediate)\n value.immediate.push(currentImmediate);\n currentImmediate = \"\";\n if (child.nodeType === Node.ELEMENT_NODE)\n value.full += elementText(cache, child).full;\n }\n }\n if (currentImmediate)\n value.immediate.push(currentImmediate);\n if (root.shadowRoot)\n value.full += elementText(cache, root.shadowRoot).full;\n if (value.full)\n value.normalized = normalizeWhiteSpace(value.full);\n }\n }\n cache.set(root, value);\n }\n return value;\n}\nfunction elementMatchesText(cache, element, matcher) {\n if (shouldSkipForTextMatching(element))\n return \"none\";\n if (!matcher(elementText(cache, element)))\n return \"none\";\n for (let child = element.firstChild; child; child = child.nextSibling) {\n if (child.nodeType === Node.ELEMENT_NODE && matcher(elementText(cache, child)))\n return \"selfAndChildren\";\n }\n if (element.shadowRoot && matcher(elementText(cache, element.shadowRoot)))\n return \"selfAndChildren\";\n return \"self\";\n}\nfunction getElementLabels(textCache, element) {\n const labels = getAriaLabelledByElements(element);\n if (labels)\n return labels.map((label) => elementText(textCache, label));\n const ariaLabel = element.getAttribute(\"aria-label\");\n if (ariaLabel !== null && !!ariaLabel.trim())\n return [{ full: ariaLabel, normalized: normalizeWhiteSpace(ariaLabel), immediate: [ariaLabel] }];\n const isNonHiddenInput = element.nodeName === \"INPUT\" && element.type !== \"hidden\";\n if ([\"BUTTON\", \"METER\", \"OUTPUT\", \"PROGRESS\", \"SELECT\", \"TEXTAREA\"].includes(element.nodeName) || isNonHiddenInput) {\n const labels2 = element.labels;\n if (labels2)\n return [...labels2].map((label) => elementText(textCache, label));\n }\n return [];\n}\n\n// packages/playwright-core/src/utils/isomorphic/cssTokenizer.ts\nvar between = function(num, first, last) {\n return num >= first && num <= last;\n};\nfunction digit(code) {\n return between(code, 48, 57);\n}\nfunction hexdigit(code) {\n return digit(code) || between(code, 65, 70) || between(code, 97, 102);\n}\nfunction uppercaseletter(code) {\n return between(code, 65, 90);\n}\nfunction lowercaseletter(code) {\n return between(code, 97, 122);\n}\nfunction letter(code) {\n return uppercaseletter(code) || lowercaseletter(code);\n}\nfunction nonascii(code) {\n return code >= 128;\n}\nfunction namestartchar(code) {\n return letter(code) || nonascii(code) || code === 95;\n}\nfunction namechar(code) {\n return namestartchar(code) || digit(code) || code === 45;\n}\nfunction nonprintable(code) {\n return between(code, 0, 8) || code === 11 || between(code, 14, 31) || code === 127;\n}\nfunction newline(code) {\n return code === 10;\n}\nfunction whitespace(code) {\n return newline(code) || code === 9 || code === 32;\n}\nvar maximumallowedcodepoint = 1114111;\nvar InvalidCharacterError = class extends Error {\n constructor(message) {\n super(message);\n this.name = \"InvalidCharacterError\";\n }\n};\nfunction preprocess(str) {\n const codepoints = [];\n for (let i = 0; i < str.length; i++) {\n let code = str.charCodeAt(i);\n if (code === 13 && str.charCodeAt(i + 1) === 10) {\n code = 10;\n i++;\n }\n if (code === 13 || code === 12)\n code = 10;\n if (code === 0)\n code = 65533;\n if (between(code, 55296, 56319) && between(str.charCodeAt(i + 1), 56320, 57343)) {\n const lead = code - 55296;\n const trail = str.charCodeAt(i + 1) - 56320;\n code = Math.pow(2, 16) + lead * Math.pow(2, 10) + trail;\n i++;\n }\n codepoints.push(code);\n }\n return codepoints;\n}\nfunction stringFromCode(code) {\n if (code <= 65535)\n return String.fromCharCode(code);\n code -= Math.pow(2, 16);\n const lead = Math.floor(code / Math.pow(2, 10)) + 55296;\n const trail = code % Math.pow(2, 10) + 56320;\n return String.fromCharCode(lead) + String.fromCharCode(trail);\n}\nfunction tokenize(str1) {\n const str = preprocess(str1);\n let i = -1;\n const tokens = [];\n let code;\n let line = 0;\n let column = 0;\n let lastLineLength = 0;\n const incrLineno = function() {\n line += 1;\n lastLineLength = column;\n column = 0;\n };\n const locStart = { line, column };\n const codepoint = function(i2) {\n if (i2 >= str.length)\n return -1;\n return str[i2];\n };\n const next = function(num) {\n if (num === void 0)\n num = 1;\n if (num > 3)\n throw \"Spec Error: no more than three codepoints of lookahead.\";\n return codepoint(i + num);\n };\n const consume = function(num) {\n if (num === void 0