// Generated by config/scripts/protected-copy-keys.mjs from security surfaces, destructive // confirmations, native message boxes and `// @protected-copy` files. import protectedCopy from './protected-copy-keys.json' const PROTECTED_COPY_KEYS: ReadonlySet = new Set(protectedCopy.keys) const PROTECTED_COPY_PREFIXES: readonly string[] = protectedCopy.prefixes const PLURAL_SUFFIX_RE = /_(?:zero|one|two|few|many|other)$/ /** True when `path` (or a plural form or child of it) is a protected copy key. */ export function isProtectedCopyPath(path: string): boolean { if (PROTECTED_COPY_PREFIXES.some((prefix) => path.startsWith(prefix))) { return true } let candidate = path while (candidate) { if ( PROTECTED_COPY_KEYS.has(candidate) || PROTECTED_COPY_KEYS.has(candidate.replace(PLURAL_SUFFIX_RE, '')) ) { return true } const parent = candidate.lastIndexOf('.') candidate = parent === -1 ? '' : candidate.slice(0, parent) } return false } /** The generated keys, for tests that pin specific trust copy. */ export function protectedCopyKeys(): ReadonlySet { return PROTECTED_COPY_KEYS }