/** Normalize human-facing template lookup terms so spaces, hyphens, and underscores behave the same. */ export function normalizeTemplateLookupKey(value: string): string { return value.trim().toLowerCase().replace(/[\s_-]+/g, '-') } export function templateIdentifierMatches(query: string, identifiers: readonly string[]): boolean { const normalizedQuery = normalizeTemplateLookupKey(query) return identifiers.some(value => normalizeTemplateLookupKey(value) === normalizedQuery) } export function templateSearchMatches(query: string, values: readonly string[]): boolean { const lowerQuery = query.trim().toLowerCase() const normalizedQuery = normalizeTemplateLookupKey(query) return values.some(value => value.toLowerCase().includes(lowerQuery) || normalizeTemplateLookupKey(value).includes(normalizedQuery), ) }