import { errors } from '@appium/base-driver'; const MAGIC_UNICODE_REPLACEMENT_CHAR = '\uF000'; const BEGIN_OF_STATEMENT_REGEX = '(? regexString = regexString.replaceAll(MAGIC_UNICODE_REPLACEMENT_CHAR, `(?:${MAGIC_UNICODE_REPLACEMENT_CHAR}${section}\\.)?`)); super(`${regexString.replaceAll(MAGIC_UNICODE_REPLACEMENT_CHAR, '')}\\(\\s*${params.map((param) => param.build()).join('\\s*,\\s*')}\\s*\\)`); } } export class PropertyRegexMatcher extends RegexItem { constructor(namespace: string, ...properties: string[]) { assertCorrectNamespace(namespace); const sections = namespace.toLowerCase().split('.'); const mainClass = sections.pop() ?? ''; sections.reverse(); // mutates the actual array let regexString = `${BEGIN_OF_STATEMENT_REGEX}(?:\\b(?:(?:(?:${MAGIC_UNICODE_REPLACEMENT_CHAR}${mainClass}\\.)))|(?:(?:\\[${MAGIC_UNICODE_REPLACEMENT_CHAR}${mainClass}\\]::)))?`; sections.forEach((section) => regexString = regexString.replaceAll(MAGIC_UNICODE_REPLACEMENT_CHAR, `(?:${MAGIC_UNICODE_REPLACEMENT_CHAR}${section}\\.)?`)); super(`${regexString.replaceAll(MAGIC_UNICODE_REPLACEMENT_CHAR, '')}(${properties.length > 0 ? `(?