// @bun
import{W as w}from"../chunk-y5h3n5t8.js";import{X as J}from"../chunk-e4vawn5g.js";import"../chunk-8ty8fefr.js";import"../chunk-2vpsbhpm.js";import{render as G}from"jsx-email";import{jsx as H}from"react/jsx-runtime";class K{from="";to=[];subject="No Subject";cc=[];bcc=[];attachments=[];template;headers={};static async send(q){let k=new this,M=J.use().service.defaultLocale,y=w.use().service,{to:z=k.to,from:O=k.from,subject:A=typeof k.subject==="string"?k.subject:k.subject[q.locale||M],cc:P=k.cc,bcc:Q=k.bcc,attachments:R=k.attachments,data:B,headers:U={}}=q,V={...y.headers??{},...k.headers??{},...U??{}};if(!(await y.filterRecipients(z)).length)return;let[D,W]=await Promise.all([k.render({...B,locale:q.locale}),k.renderText({...B,locale:q.locale})]);if(process.env.EMAIL_DEBUG==="true"){let F=`${process.env.ROOT_DIR}/.debug/emails/${new Date().toISOString()}${A}.html`;await Bun.write(F,D),Bun.spawnSync(["open",F]);return}await w.use().service.driver.send({bcc:Q,cc:P,from:O,subject:A,to:z,attachments:R,html:D,headers:V,text:W})}static async preview(q){return await new this().render({...q.data,locale:q.locale})}async render(q){let k=this.template;return await G(H(k,{...q}))}async renderText(q){let k=this.template;return await G(H(k,{...q}),{plainText:!0})}}export{K as Email};

//# debugId=156B2D7F72969FDB64756E2164756E21
