/**
 * community blueprint · wiring seam for `@platform-modules/mail`.
 *
 * Adapter-minimalism (CLAUDE.md §4): wrap a capture adapter in createMail. In THIS blueprint mail is
 * consumed indirectly — it backs the 'email' channel of `@platform-modules/notifications` (see
 * wiring/notifications.ts), proving notifications composes ABOVE mail rather than beside it. The
 * capture array lets the composition test assert an email was actually emitted past both gates.
 *
 * (Structurally identical to saas-admin/wiring/mail.ts — another two-blueprint convergence signal.)
 */
import { createMail, type MailAdapter, type MailMessage } from '@platform-modules/mail'

export type CaptureMail = {
  mail: ReturnType<typeof createMail>
  sent: MailMessage[]
}

export function createCaptureMail(): CaptureMail {
  const sent: MailMessage[] = []
  const adapter: MailAdapter = {
    async send(msg) {
      sent.push(msg)
      return { id: `cap-${sent.length}`, provider: 'capture' }
    },
  }
  return { mail: createMail(adapter), sent }
}
