{"version":3,"file":"mail-channel.mjs","names":[],"sources":["../../../../../../../notifications/src/channels/mail-channel.ts"],"sourcesContent":["/**\n * `mailChannel` — wraps `@warlock.js/core` `sendMail`.\n *\n * Route is `notifiable.email` by convention; override via `config.route`\n * when the column is named differently or computed.\n *\n * The renderer's payload is forwarded verbatim (`subject`, `html`, `text`,\n * `cc`). `from` is set once at channel-config time; per-send overrides go\n * through the payload itself (you can include `from` in `MailPayload` if\n * you extend the registry — but the convention is one channel = one\n * sender identity).\n *\n * @example\n *   // src/config/notifications.ts\n *   channels: {\n *     mail: mailChannel({ from: \"no-reply@store.com\" }),\n *   }\n *\n *   // anywhere\n *   await notify.mail(user, { subject: \"Welcome\", html: \"<p>Hi!</p>\" });\n */\nimport { sendMail } from \"@warlock.js/core\";\nimport type { Channel } from \"../contracts\";\nimport { defineChannel } from \"../dispatch/define-channel\";\nimport type { MailPayload, Notifiable } from \"../types\";\n\nexport type MailChannelConfig = {\n  /** Default `from` address for every send through this channel. */\n  from?: string;\n  /** Route resolver. Defaults to `notifiable.get(\"email\")`. */\n  route?: (notifiable: Notifiable) => string;\n};\n\nexport function mailChannel(config: MailChannelConfig = {}): Channel<MailPayload> {\n  const resolveRoute = config.route ?? ((n) => n.get(\"email\") as string);\n\n  return defineChannel<MailPayload>({\n    name: \"mail\",\n    route: (notifiable) => resolveRoute(notifiable),\n    async send({ payload, route }) {\n      await sendMail({\n        to: route as string,\n        from: config.from,\n        ...payload,\n      });\n    },\n  });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,YAAY,SAA4B,CAAC,GAAyB;CAChF,MAAM,eAAe,OAAO,WAAW,MAAM,EAAE,IAAI,OAAO;CAE1D,OAAO,cAA2B;EAChC,MAAM;EACN,QAAQ,eAAe,aAAa,UAAU;EAC9C,MAAM,KAAK,EAAE,SAAS,SAAS;GAC7B,MAAM,SAAS;IACb,IAAI;IACJ,MAAM,OAAO;IACb,GAAG;GACL,CAAC;EACH;CACF,CAAC;AACH"}