module.exports=[22279,a=>{"use strict";a.s(["getClientApiBaseUrl",0,function(){let a="https://api.aiyard.net".trim();if(!a)throw Error("Missing NEXT_PUBLIC_API_URL for browser API requests");return a.replace(/\/$/,"")}])},67453,a=>{"use strict";let b=(0,a.i(70106).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);a.s(["CheckCircle2",0,b],67453)},5750,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(76267),e=a.i(40695),f=a.i(5522),g=a.i(92258),h=a.i(92759),i=a.i(96221),j=a.i(67453),k=a.i(6835),l=a.i(22279),m=a.i(23292),n=a.i(7489);a.s(["default",0,function(){let{getToken:a}=(0,d.useAuth)(),[o,p]=(0,c.useState)(""),[q,r]=(0,c.useState)(""),[s,t]=(0,c.useState)(!1),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(!1),y=async()=>{if(!o.trim()||!q.trim())return void m.toast.error("Please enter a subject and content.");t(!0);try{let b=await a(),c=await fetch(`${(0,l.getClientApiBaseUrl)()}/api/admin/newsletter/broadcast`,{method:"POST",headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"},body:JSON.stringify({subject:o,htmlContent:q})});if(c.ok)v(!0),p(""),r(""),m.toast.success("Broadcast started successfully.");else{let a=await c.json();m.toast.error(a.error||"Failed to start broadcast.")}}catch{m.toast.error("Network error.")}finally{t(!1)}};return(0,b.jsxs)("div",{className:"max-w-4xl mx-auto py-10 px-4",children:[(0,b.jsxs)("div",{className:"mb-8 border-b border-border/50 pb-6",children:[(0,b.jsxs)("h1",{className:"text-3xl font-bold tracking-tight text-foreground flex items-center gap-3",children:[(0,b.jsx)(g.Mail,{className:"w-8 h-8 text-primary"})," Newsletter Broadcast"]}),(0,b.jsx)("p",{className:"text-muted-foreground mt-2",children:"Compose and send emails to all active subscribers. This runs in the background."})]}),u?(0,b.jsxs)("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-2xl p-10 text-center animate-in fade-in slide-in-from-bottom-4",children:[(0,b.jsx)("div",{className:"w-16 h-16 bg-emerald-500/20 text-emerald-500 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,b.jsx)(j.CheckCircle2,{className:"w-8 h-8"})}),(0,b.jsx)("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Broadcast Started!"}),(0,b.jsx)("p",{className:"text-emerald-600 dark:text-emerald-400 mb-6",children:"Your server is now sending emails to all subscribers in the background. You can safely leave this page."}),(0,b.jsx)(e.Button,{variant:"outline",onClick:()=>v(!1),children:"Write Another Email"})]}):(0,b.jsxs)("div",{className:"bg-card border border-border rounded-xl shadow-sm p-6 space-y-6",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"text-sm font-semibold text-foreground mb-1 block",children:"Email Subject"}),(0,b.jsx)(f.Input,{placeholder:"e.g. 5 New AI Tools You Need to See This Week...",value:o,onChange:a=>p(a.target.value),className:"font-semibold text-lg h-12"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"text-sm font-semibold text-foreground mb-1 block",children:"Email Body (HTML)"}),(0,b.jsx)("div",{className:"border border-border/50 rounded-xl overflow-hidden shadow-sm",children:(0,b.jsx)(k.default,{content:q,onChange:r})}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Tip: Keep it clean. Hyperlinks and basic formatting work best in email clients."})]}),(0,b.jsx)("div",{className:"pt-4 border-t border-border/50 flex justify-end",children:(0,b.jsx)(e.Button,{onClick:()=>x(!0),disabled:s||!o||!q,className:"h-12 px-8 bg-primary hover:bg-primary/90 text-white font-bold text-base shadow-md",children:s?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Loader2,{className:"w-5 h-5 mr-2 animate-spin"})," Starting Broadcast..."]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(h.Send,{className:"w-5 h-5 mr-2"})," Send to All Subscribers"]})})})]}),(0,b.jsx)(n.default,{open:w,onOpenChange:x,title:"Send newsletter broadcast?",description:"This will send the newsletter to all active subscribers.",confirmLabel:"Yes, Send",onConfirm:()=>{x(!1),y()},isLoading:s})]})}])}];

//# sourceMappingURL=_01-yq3.._.js.map