// The rule the public form uses to find the sender's address: a question whose id or label names email. // Without one, every submission reaches the desk with nowhere to send a reply. const EMAIL_KEYWORDS = ['email', 'e-mail']; type FormItem = { linkId?: string; text?: string; item?: FormItem[] }; export const publicFormAsksForEmail = (items: FormItem[] | undefined): boolean => (items ?? []).some((item) => { const haystack = `${item.linkId ?? ''} ${item.text ?? ''}`.toLowerCase(); return EMAIL_KEYWORDS.some((keyword) => haystack.includes(keyword)) || publicFormAsksForEmail(item.item); });