1var Ee=Object.defineProperty,Be=Object.defineProperties;var He=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable;var ce=(s,t,l)=>t in s?Ee(s,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[t]=l,v=(s,t)=>{for(var l in t||(t={}))qe.call(t,l)&&ce(s,l,t[l]);if(oe)for(var l of oe(t))$e.call(t,l)&&ce(s,l,t[l]);return s},w=(s,t)=>Be(s,He(t));var u=(s,t,l)=>new Promise((x,r)=>{var g=c=>{try{n(l.next(c))}catch(h){r(h)}},p=c=>{try{n(l.throw(c))}catch(h){r(h)}},n=c=>c.done?x(c.value):Promise.resolve(c.value).then(g,p);n((l=l.apply(s,t)).next())});import{r as i,j as e}from"./react-vendor-BaX8wFxW.js";import{w as Q,by as Te,a1 as G,d as $,T as me,h as xe,a0 as De,H as ge,R as L,bd as Re,S as be,bi as ue,au as Me}from"./icons-hi2-zdK1GiMw.js";import{i as pe,u as fe,am as X,n as Y}from"./index-CLYH3Hla.js";import{a as E}from"./announcementService-Bopt98gH.js";import"./icons-other-B4wTEEQh.js";import"./data-vendor-B9G6AmzB.js";import"./charts-vendor-BEN4kyo5.js";import"./motion-vendor-C9lJIqxK.js";const Ie=[{labelKey:"admin.color_brown",value:"#5f381d"},{labelKey:"admin.color_purple",value:"#4c2fa3"},{labelKey:"admin.color_blue",value:"#1a4f73"},{labelKey:"admin.color_red",value:"#8b1a1a"},{labelKey:"admin.color_black",value:"#1a1a2e"}],Ke=(s,t)=>{const l=new Date;return s.isActive?s.startAt&&new Date(s.startAt)>l?{label:t("admin.banner_status_scheduled"),color:"text-amber-600 bg-amber-50 dark:bg-amber-900/20"}:s.endAt&&new Date(s.endAt)<l?{label:t("admin.banner_status_expired"),color:"text-red-500 bg-red-50 dark:bg-red-900/20"}:{label:t("admin.banner_status_live"),color:"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/20"}:{label:t("admin.banner_status_off"),color:"text-slate-400 bg-slate-100 dark:bg-slate-800"}},J=s=>s?new Date(s).toLocaleString("vi-VN",{dateStyle:"short",timeStyle:"short"}):"",he=s=>{if(!s)return"";const t=new Date(s),l=x=>String(x).padStart(2,"0");return`${t.getFullYear()}-${l(t.getMonth()+1)}-${l(t.getDate())}T${l(t.getHours())}:${l(t.getMinutes())}`},Fe=({banner:s,onClose:t,onSave:l})=>{var B;const{showToast:x}=pe(),{t:r}=fe(),[g,p]=i.useState(!1),[n,c]=i.useState({content:(s==null?void 0:s.content)||"",link:(s==null?void 0:s.link)||"",bgColor:(s==null?void 0:s.bgColor)||"#5f381d",
1isActive:(B=s==null?void 0:s.isActive)!=null?B:!1,startAtLocal:he(s==null?void 0:s.startAt),endAtLocal:he(s==null?void 0:s.endAt)}),h=o=>u(null,null,function*(){var m,N;if(o.preventDefault(),!((m=n.content)!=null&&m.trim())){x(r("toast.admin_content_required"),"warning");return}try{p(!0);const k={content:n.content.trim(),link:((N=n.link)==null?void 0:N.trim())||void 0,bgColor:n.bgColor,isActive:n.isActive,startAt:n.startAtLocal?new Date(n.startAtLocal).toISOString():void 0,endAt:n.endAtLocal?new Date(n.endAtLocal).toISOString():void 0};s?(yield E.updateBanner(s._id,k),x(r("toast.admin_banner_updated"),"success")):(yield E.createBanner(k),x(r("toast.admin_banner_created"),"success")),l(),t()}catch(k){x(r("toast.admin_generic_error"),"error")}finally{p(!1)}});return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg bg-white dark:bg-slate-800 rounded-2xl shadow-2xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-slate-100 dark:border-slate-700",children:[e.jsxs("h2",{className:"font-bold text-slate-800 dark:text-white flex items-center gap-2",children:[e.jsx(Q,{className:"w-5 h-5 text-amber-500"}),r(s?"admin.banner_modal_edit":"admin.banner_modal_create")]}),e.jsx("button",{"data-ui-close-button":!0,onClick:t,className:"flex items-center justify-center p-2 rounded-xl hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors",children:e.jsx(ge,{className:"w-5 h-5 text-slate-500"})})]}),e.jsxs("form",{onSubmit:h,className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-1.5",children:[r("admin.banner_content_label")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:n.content,onChange:o=>c(m=>w(v({},m),{content:o.target.value})),rows:3,maxLength:300,required:!0,placeholder:r("admin.banner_content_placeholder"),className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 resize-none text-sm"}),e.jsxs("p",{className:"text-right text-[11px] text-slate-400 mt-1",children:[(n.content||"").length,"/300"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-1.5",children:r("admin.banner_link_label")}),e.jsxs("div",{className:"relative",children:[e.jsx(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",value:n.link,onChange:o=>c(m=>w(v({},m),{link:o.target.value})),placeholder:r("admin.banner_link_placeholder"),className:"w-full pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-sm"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-1.5",children:r("admin.banner_bg_label")}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Ie.map(o=>e.jsx("button",{type:"button",title:r(o.labelKey),onClick:()=>c(m=>w(v({},m),{bgColor:o.value})),className:"w-7 h-7 rounded-full border-2 transition-transform hover:scale-110",style:{backgroundColor:o.value,borderColor:n.bgColor===o.value?"white":"transparent",outline:n.bgColor===o.value?`2px solid ${o.value}`:"none"}},o.value)),e.jsx("input",{type:"color",value:n.bgColor,onChange:o=>c(m=>w(v({},m),{bgColor:o.target.value})),className:"w-7 h-7 rounded-full cursor-pointer border border-slate-200",title:r("admin.banner_custom_color")}),e.jsx("span",{className:"text-xs text-slate-400 font-mono",children:n.bgColor})]}),e.jsx("div",{className:"mt-2 h-8 rounded-lg flex items-center px-4 overflow-hidden",style:{backgroundColor:n.bgColor||"#5f381d"},children:e.jsx("span",{className:"text-white text-[11px] font-bold truncate",children:n.content||r("admin.banner_preview_placeholder")})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-1.5",children:r("admin.banner_start_optional")}),e.jsx("input",{type:"datetime-local",value:n.startAtLocal,onCh
1ange:o=>c(m=>w(v({},m),{startAtLocal:o.target.value})),className:"w-full px-3 py-2.5 rounded-xl border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-1.5",children:r("admin.banner_end_optional")}),e.jsx("input",{type:"datetime-local",value:n.endAtLocal,onChange:o=>c(m=>w(v({},m),{endAtLocal:o.target.value})),className:"w-full px-3 py-2.5 rounded-xl border border-slate-200 dark:border-slate-600 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-xs"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-slate-50 dark:bg-slate-900/50 border border-slate-200 dark:border-slate-600",children:[e.jsx("button",{type:"button",onClick:()=>c(o=>w(v({},o),{isActive:!o.isActive})),className:`relative w-11 h-6 rounded-full transition-colors flex-shrink-0 ${n.isActive?"bg-emerald-500":"bg-slate-300 dark:bg-slate-600"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 rounded-full bg-white shadow-sm transition-transform ${n.isActive?"translate-x-5":"translate-x-0"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-700 dark:text-slate-300",children:n.isActive?r("admin.banner_activate_now"):r("admin.banner_save_draft")}),e.jsx("p",{className:"text-xs text-slate-400",children:n.isActive?r("admin.banner_activate_hint"):r("admin.banner_draft_hint")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2 border-t border-slate-100 dark:border-slate-700",children:[e.jsx("button",{type:"button",onClick:t,className:"px-5 py-2.5 rounded-xl text-muted hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors font-bold text-sm",children:r("common.cancel")}),e.jsxs("button",{type:"submit",disabled:g,className:"px-6 py-2.5 rounded-xl bg-blue-600 hover:bg-blue-700 text-white font-bold shadow-lg shadow-blue-500/30 transition-all disabled:opacity-50 flex items-center gap-2 text-sm",children:[g?e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsx(Me,{className:"w-4 h-4"}),r(s?"admin.common_update":"admin.banner_create_btn")]})]})]})]})})},Qe=()=>{const{showToast:s}=pe(),{t}=fe(),[l,x]=i.useState("banner"),[r,g]=i.useState([]),[p,n]=i.useState(!1),[c,h]=i.useState(!1),[B,o]=i.useState(null),[m,N]=i.useState(null),[k,W]=i.useState(null),[T,D]=i.useState(""),[Z,R]=i.useState(""),[M,ee]=i.useState(!1),[I,je]=i.useState([]),[K,te]=i.useState(!1),[y,F]=i.useState(""),[C,O]=i.useState(""),[H,P]=i.useState(""),[U,ae]=i.useState(!1),[f,se]=i.useState("broadcast"),[z,_e]=i.useState(""),[le,ve]=i.useState([]),[we,re]=i.useState(!1),[S,ne]=i.useState([]),[j,V]=i.useState(null),de=i.useCallback(a=>u(null,null,function*(){try{re(!0);const d=yield X.getUsers({page:1,limit:100,q:a.trim()||void 0,status:"active"});ve(d.users||[])}catch(d){s(t("toast.admin_recipients_load_error"),"error")}finally{re(!1)}}),[s,t]);i.useEffect(()=>{if(l!=="email"||f!=="targeted")return;const a=setTimeout(()=>{de(z)},250);return()=>clearTimeout(a)},[l,f,z,de]);const ke=a=>{ne(d=>d.includes(a)?d.filter(_=>_!==a):[...d,a])},ie=()=>{F(""),O(""),P("")},Ne=a=>u(null,null,function*(){var d,_;if(a.preventDefault(),!y.trim()){s(t("toast.admin_email_subject_required"),"warning");return}if(!C.trim()){s(t("toast.admin_email_body_required"),"warning");return}if(f==="targeted"&&S.length===0){s(t("toast.admin_recipients_required"),"warning");return}try{if(ae(!0),f==="broadcast"){if(!window.confirm(t("toast.confirm_broadcast_email_all")))return;const b=yield X.sendBroadcastEmail(y.trim(),C.trim(),H.trim()||void 0);s(t("toast.admin_email_queued",{count:b.emailCount}),"success"),ie(),V(null)}else{if(!window.confirm(t("toast.confirm_broadcast_email_selected",{count:S.length})))return;const b=yield X.sendTargetedEmail(y.trim(),C.trim(),S,H.trim()||void 0);V(b),s(t("toast.admin_email_queued_short",{count:b.enqueuedCount}),"success"),ie()}}catch(b){const Le=((_=(d=b.response)==null?void 0:d.data)==null?void 0:_.message)||t("toast.admin_email_failed");s(Le,"error")}finally{ae(!1)}}),q=i.useCallback(()=>u(null,null,function*(){n(!0);try{const a=yield E.listBanners();a.success&&g(a.data)}catch(a){s(t("toast.admin_banners_load_error"),"error")}finally{n(!1)}}),[s,t]),A=i.useCallback(()=>u(null,null,function*(){te(!0);try{const a=yield Y.getBroadcastHistory();a.success&&je(a.data)}catch(a){}finally{te(!1)}}),[]);i.useEffect(()=>{q(),A()},[q,A]);const ye=a=>u(null,null,function*(){N(a);try{const d=yield E.toggleBanner(a);d.success&&(g(_=>_.map(b=>b._id===a?d.data:b)),s(d.data.isActive?t("toast.admin_banner_on"):t("toast.admin_banner_off"),"success"))}catch(d){s(t("toast.admin_action_failed"),"error")}finally{N(null)}}),Ce=a=>u(null,null,function*(){if(window.confirm(t("toast.confirm_delete_banner"))){W(a);try{(yield E.deleteBanner(a)).success&&(g(_=>_.filter(b=>b._id!==a)),s(t("toast.admin_banner_deleted"),"success"))}catch(d){s(t("toast.admin_delete_failed"),"error")}finally{W(null)}}}),Se=a=>u(null,null,function*(){if(a.preventDefault(),!T.trim()){s(t("toast.admin_content_required"),"warning");return}if(window.confirm(t("toast.confirm_broadcast_notif_all")))try{ee(!0),(yield Y.sendBroadcast(T,Z)).success&&(s(t("toast.admin_broadcast_ok"),"success"),D(""),R(""),A())}catch(d){s(t("toast.admin_send_failed"),"error")}finally{ee(!1)}}),Ae=a=>u(null,null,function*(){if(window.confirm(t("toast.confirm_recall_broadcast")))try{(yield Y.cancelBroadcast(a)).success&&(s(t("toast.admin_recall_ok"),"success"),A())}catch(d){s(t("toast.admin_recall_failed"),"error")}});return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"p-3 bg-blue-100 dar
1k:bg-blue-900/20 rounded-xl",children:e.jsx(Q,{className:"w-6 h-6 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 dark:text-white",children:t("admin.broadcast_page_title")}),e.jsx("p",{className:"text-muted text-sm mt-0.5",children:t("admin.broadcast_page_subtitle")})]})]}),e.jsxs("div",{className:"flex gap-1 mb-6 p-1 bg-slate-100 dark:bg-slate-800 rounded-xl w-fit",children:[e.jsxs("button",{onClick:()=>x("banner"),className:`px-5 py-2 rounded-lg text-sm font-bold transition-all flex items-center gap-2 ${l==="banner"?"bg-white dark:bg-slate-700 text-blue-600 dark:text-blue-400 shadow-sm":"text-muted hover:text-slate-700 dark:hover:text-slate-200"}`,children:[e.jsx(Te,{className:"w-4 h-4"}),t("admin.tab_banner")]}),e.jsxs("button",{onClick:()=>x("broadcast"),className:`px-5 py-2 rounded-lg text-sm font-bold transition-all flex items-center gap-2 ${l==="broadcast"?"bg-white dark:bg-slate-700 text-blue-600 dark:text-blue-400 shadow-sm":"text-muted hover:text-slate-700 dark:hover:text-slate-200"}`,children:[e.jsx(G,{className:"w-4 h-4"}),t("admin.tab_inbox")]}),e.jsxs("button",{onClick:()=>x("email"),className:`px-5 py-2 rounded-lg text-sm font-bold transition-all flex items-center gap-2 ${l==="email"?"bg-white dark:bg-slate-700 text-blue-600 dark:text-blue-400 shadow-sm":"text-muted hover:text-slate-700 dark:hover:text-slate-200"}`,children:[e.jsx($,{className:"w-4 h-4"}),t("admin.tab_email")]})]}),l==="banner"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"font-bold text-slate-800 dark:text-white flex items-center gap-2 text-base",children:[e.jsx(me,{className:"w-5 h-5 text-slate-400"}),t("admin.banner_list_title",{count:r.length})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:q,disabled:p,className:"flex items-center justify-center p-2 text-slate-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-all",children:e.jsx(xe,{className:`w-4 h-4 ${p?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{o(null),h(!0)},className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-700 text-white text-sm font-bold transition-all shadow-lg shadow-blue-500/30",children:[e.jsx(De,{className:"w-4 h-4"}),t("admin.banner_create_new")]})]})]}),p&&r.length===0?Array.from({length:3}).map((a,d)=>e.jsx("div",{className:"h-24 bg-white dark:bg-slate-800 rounded-2xl border border-slate-100 dark:border-slate-700 animate-pulse"},d)):r.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-slate-800 rounded-2xl border border-dashed border-slate-200 dark:border-slate-700",children:[e.jsx(Q,{className:"w-10 h-10 text-disabled mx-auto mb-3"}),e.jsx("p",{className:"font-bold text-muted",children:t("admin.banner_empty")}),e.jsx("p",{className:"text-sm text-slate-400 mt-1",children:t("admin.banner_empty_hint")})]}):r.map(a=>{const d=Ke(a,t);return e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"h-8 flex items-center px-4 overflow-hidden relative",style:{backgroundColor:a.bgColor},children:[e.jsx("span",{className:"text-white text-[11px] font-bold truncate pr-8",children:a.content}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center justify-center w-5 h-5 rounded-full bg-white/25",children:e.jsx(ge,{className:"w-3 h-3 text-white"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 p-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:`text-[11px] font-bold px-2 py-0.5 rounded-full ${d.color}`,children:d.label}),a.link&&e.jsxs("span",{className:"text-[11px] text-blue-500 flex items-center gap-1 truncate max-w-[200px]",children:[e.jsx(L,{className:"w-3 h-3 flex-shrink-0"}),a.link]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-slate-400",children:[a.startAt&&e.jsx("span",{children:t("admin.banner_from",{datetime:J(a.startAt)})}),a.endAt&&e.jsx("span",{children:t("admin.banner_to",{datetime:J(a.endAt)})}),e.jsx("span",{children:t("admin.banner_created",{datetime:J(a.createdAt)})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ye(a._id),disabled:m===a._id,title:a.isActive?t("admin.banner_turn_off"):t("admin.banner_turn_on"),className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 disabled:opacity-50 ${a.isActive?"bg-emerald-500":"bg-slate-300 dark:bg-slate-600"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${a.isActive?"translate-x-5":"translate-x-0"}`})}),e.jsx("button",{onClick:()=>{o(a),h(!0)},className:"p-2 text-slate-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-all",title:t("common.edit"),children:e.jsx(Re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Ce(a._id),disabled:k===a._id,className:"p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-all disabled:opacity-50",title:t("common.delete"),children:k===a._id?e.jsx("div",{className:"w-4 h-4 border-2 border-red-300 border-t-red-500 rounded-full animate-spin"}):e.jsx(be,{className:"w-4 h-4"})})]})]})]},a._id)})]}),l==="broadcast"&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 overflow-hidden shadow-sm",children:[e.jsx("div",{className:"p-4 border-b border-slate-100 dar
1k:border-slate-700 bg-slate-50/50 dark:bg-slate-800/50",children:e.jsxs("h2",{className:"font-bold text-slate-800 dark:text-white flex items-center gap-2",children:[e.jsx(G,{className:"w-5 h-5 text-blue-500"}),t("admin.inbox_compose_title")]})}),e.jsxs("form",{onSubmit:Se,className:"p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-2",children:t("admin.inbox_content_label")}),e.jsx("textarea",{value:T,onChange:a=>D(a.target.value),rows:4,required:!0,placeholder:t("admin.inbox_content_placeholder"),className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 resize-none transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-2",children:t("admin.inbox_link_label")}),e.jsxs("div",{className:"relative group",children:[e.jsx(L,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 h-5 w-5 text-slate-400"}),e.jsx("input",{type:"text",value:Z,onChange:a=>R(a.target.value),placeholder:t("admin.inbox_link_placeholder"),className:"w-full pl-11 pr-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-slate-100 dark:border-slate-700",children:[e.jsx("button",{type:"button",onClick:()=>{D(""),R("")},className:"px-6 py-2.5 rounded-xl text-muted hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors font-bold text-sm",children:t("admin.common_refresh")}),e.jsxs("button",{type:"submit",disabled:M,className:"px-8 py-2.5 rounded-xl bg-blue-600 hover:bg-blue-700 text-white font-bold shadow-lg shadow-blue-500/30 transition-all disabled:opacity-50 flex items-center gap-2",children:[M?e.jsx("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsx(G,{className:"w-5 h-5"}),t(M?"admin.processing":"admin.inbox_send_now")]})]})]})]}),e.jsxs("div",{className:"p-4 bg-orange-50 dark:bg-orange-900/10 rounded-xl border border-orange-200 dark:border-orange-800 flex gap-3 text-orange-800 dark:text-orange-400",children:[e.jsx(ue,{className:"w-6 h-6 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-bold mb-1",children:t("admin.inbox_rules_title")}),e.jsxs("ul",{className:"list-disc ml-4 space-y-1 opacity-90",children:[e.jsx("li",{children:t("admin.inbox_rule_1")}),e.jsx("li",{children:t("admin.inbox_rule_2")}),e.jsx("li",{children:t("admin.inbox_rule_3")})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h2",{className:"font-bold text-slate-800 dark:text-white flex items-center gap-2",children:[e.jsx(me,{className:"w-5 h-5 text-slate-400"}),t("admin.inbox_history_title")]}),e.jsx("button",{onClick:A,disabled:K,className:"flex items-center justify-center p-1.5 text-slate-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-all",children:e.jsx(xe,{className:`w-4 h-4 ${K?"animate-spin":""}`})})]}),e.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto pr-1",children:K&&I.length===0?Array.from({length:3}).map((a,d)=>e.jsx("div",{className:"h-24 bg-white dark:bg-slate-800 rounded-xl border border-slate-100 dark:border-slate-700 animate-pulse"},d)):I.length===0?e.jsx("div",{className:"text-center py-10 bg-white dark:bg-slate-800 rounded-xl border border-dashed border-slate-200 dark:border-slate-700",children:e.jsx("p",{className:"text-sm text-slate-400",children:t("admin.inbox_history_empty")})}):I.map(a=>e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-4 rounded-xl border border-slate-200 dark:border-slate-700 shadow-sm hover:border-blue-500/30 transition-all group",children:[e.jsxs("div",{className:"flex justify-between items-start gap-2 mb-2",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 dark:text-white line-clamp-2 leading-snug",children:a.content}),e.jsx("button",{onClick:()=>Ae(a._id),className:"p-1.5 text-slate-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-all",title:t("admin.inbox_recall"),children:e.jsx(be,{className:"w-4 h-4"})})]}),a.link&&e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-blue-500 font-medium mb-2 truncate",children:[e.jsx(L,{className:"w-3 h-3"}),a.link]}),e.jsxs("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-slate-50 dark:border-slate-700/50",children:[e.jsx("span",{className:"text-[10px] text-slate-400 font-medium",children:new Date(a.createdAt).toLocaleStr
1ing("vi-VN")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 bg-slate-100 dark:bg-slate-700 text-muted rounded",children:t("admin.inbox_sent_count",{count:a.count})}),e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 bg-green-100 dark:bg-green-900/20 text-green-600 dark:text-green-400 rounded",children:t("admin.inbox_read_pct",{pct:a.count>0?Math.round(a.readCount/a.count*100):0})})]})]})]},a._id))})]})]}),l==="email"&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"lg:col-span-3 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 overflow-hidden shadow-sm",children:[e.jsx("div",{className:"p-4 border-b border-slate-100 dark:border-slate-700 bg-slate-50/50 dark:bg-slate-800/50",children:e.jsxs("h2",{className:"font-bold text-slate-800 dark:text-white flex items-center gap-2",children:[e.jsx($,{className:"w-5 h-5 text-blue-500"}),t(f==="broadcast"?"admin.email_compose_broadcast":"admin.email_compose_targeted")]})}),e.jsx("div",{className:"px-4 pb-3 flex justify-end",children:e.jsxs("div",{className:"flex gap-1 p-1 bg-slate-200/70 dark:bg-slate-700 rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>{se("broadcast"),V(null)},className:`px-3 py-1.5 rounded-md text-xs font-bold transition ${f==="broadcast"?"bg-white dark:bg-slate-800 text-blue-600 shadow-sm":"text-slate-500 dark:text-slate-300"}`,children:t("admin.email_mode_broadcast")}),e.jsx("button",{type:"button",onClick:()=>se("targeted"),className:`px-3 py-1.5 rounded-md text-xs font-bold transition ${f==="targeted"?"bg-white dark:bg-slate-800 text-blue-600 shadow-sm":"text-slate-500 dark:text-slate-300"}`,children:t("admin.email_mode_targeted")})]})}),e.jsxs("form",{onSubmit:Ne,className:"p-6 space-y-5",children:[f==="targeted"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-2",children:[t("admin.email_select_recipients")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:z,onChange:a=>_e(a.target.value),placeholder:t("admin.email_search_users"),className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all"})]}),e.jsx("div",{className:"border border-slate-200 dark:border-slate-700 rounded-xl overflow-hidden",children:e.jsx("div",{className:"max-h-56 overflow-y-auto divide-y divide-slate-100 dark:divide-slate-700",children:we?e.jsx("div",{className:"p-4 text-sm text-slate-500",children:t("admin.email_loading_users")}):le.length===0?e.jsx("div",{className:"p-4 text-sm text-slate-500",children:t("admin.email_no_users")}):le.map(a=>{const d=S.includes(a._id);return e.jsxs("label",{className:"flex items-start gap-3 p-3 hover:bg-slate-50 dark:hover:bg-slate-800/40 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:()=>ke(a._id),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-800 dark:text-slate-200 truncate",children:a.displayName||a.username}),e.jsx("p",{className:"text-xs text-slate-500 truncate",children:a.email})]})]},a._id)})})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-500",children:[e.jsx("span",{children:t("admin.email_selected_count",{count:S.length})}),e.jsx("button",{type:"button",onClick:()=>ne([]),className:"font-semibold text-blue-600 hover:underline",children:t("admin.email_clear_selection")})]}),j&&e.jsxs("div",{className:"rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 p-3 text-xs text-secondary",children:[e.jsx("p",{className:"font-bold text-slate-700 dark:text-slate-200 mb-2",children:t("admin.email_last_result")}),e.jsx("p",{children:t("admin.email_result_line1",{requested:j.requestedCount,resolved:j.resolvedCount,enqueued:j.enqueuedCount})}),e.jsx("p",{children:t("admin.email_result_line2",{optOut:j.skipped.optedOutCount,inactive:j.skipped.inactiveOrBannedCount,missing:j.skipped.missingEmailCount,notFound:j.skipped.notFoundCount})})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-2",children:[t("admin.email_subject_label")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:y,onChange:a=>F(a.target.value),required:!0,placeholder:t("admin.email_subject_placeholder"),className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all font-medium"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-2",children:[t("admin.email_body_label")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:C,onChange:a=>O(a.target.value),rows:8,required:!0,placeholder:t("admin.email_body_placeholder"),className:"w-full px-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 resize-y transition-all text-sm leading-relaxed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-bold text-slate-700 dark:text-slate-300 mb-2",children:t("admin.email_cta_label")}),e.jsxs("div",{className:"relative group",children:[e.jsx(L,{className:"absolute left-3.5 to
1p-1/2 -translate-y-1/2 h-5 w-5 text-slate-400"}),e.jsx("input",{type:"text",value:H,onChange:a=>P(a.target.value),placeholder:t("admin.email_cta_placeholder"),className:"w-full pl-11 pr-4 py-3 rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 text-slate-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all"})]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1.5 ml-1",children:t("admin.email_cta_hint")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-slate-100 dark:border-slate-700",children:[e.jsx("button",{type:"button",onClick:()=>{F(""),O(""),P("")},className:"px-6 py-2.5 rounded-xl text-muted hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors font-bold text-sm",children:t("admin.common_refresh")}),e.jsxs("button",{type:"submit",disabled:U,className:"px-8 py-2.5 rounded-xl bg-blue-600 hover:bg-blue-700 text-white font-bold shadow-lg shadow-blue-500/30 transition-all disabled:opacity-50 flex items-center gap-2",children:[U?e.jsx("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsx($,{className:"w-5 h-5"}),t(U?"admin.email_sending_bulk":"admin.email_send_now")]})]})]})]}),e.jsxs("div",{className:"p-4 bg-amber-50 dark:bg-amber-900/10 rounded-xl border border-amber-200 dark:border-amber-800 flex gap-3 text-amber-800 dark:text-amber-400",children:[e.jsx(ue,{className:"w-6 h-6 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-bold mb-1",children:t("admin.email_notes_title")}),e.jsxs("ul",{className:"list-disc ml-4 space-y-1 opacity-90",children:[e.jsx("li",{children:t("admin.email_note_1")}),e.jsx("li",{children:t("admin.email_note_2")}),e.jsx("li",{children:t("admin.email_note_3")})]})]})]})]}),e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs("h2",{className:"font-bold text-slate-800 dark:text-white flex items-center gap-2 text-base",children:[e.jsx($,{className:"w-5 h-5 text-slate-400"}),t("admin.email_preview_title")]}),e.jsx("div",{className:"border border-slate-200 dark:border-slate-700 rounded-2xl overflow-hidden bg-slate-100 dark:bg-slate-900/60 p-4 lg:p-6 flex justify-center",children:e.jsxs("div",{className:"w-full max-w-[500px] shadow-lg rounded-xl overflow-hidden bg-white text-slate-800 font-sans",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-600 to-blue-800 py-8 px-6 text-center",children:[e.jsxs("div",{className:"text-2xl font-black text-white tracking-tight",children:["Flip",e.jsx("span",{className:"opacity-60",children:"Lab"})]}),e.jsx("div",{className:"text-[10px] text-blue-200 uppercase tracking-widest mt-1.5 font-bold",children:t("admin.email_preview_badge")})]}),e.jsxs("div",{className:"p-8",children:[e.jsx("h3",{className:"text-slate-900 font-bold text-lg mb-4 leading-tight",children:y.trim()||t("admin.email_preview_subject_ph")}),e.jsx("div",{className:"text-slate-600 text-sm leading-relaxed whitespace-pre-wrap break-words",children:C.trim()||t("admin.email_preview_body_ph")}),H.trim()&&e.jsx("div",{className:"text-center mt-6",children:e.jsx("span",{className:"inline-block bg-blue-600 text-white px-8 py-3 rounded-lg font-bold text-sm shadow-md hover:bg-blue-700 transition-all cursor-pointer",children:t("admin.email_view_details")})})]}),e.jsxs("div",{className:"bg-slate-50 py-4 px-6 text-center border-t border-slate-100 text-[11px] text-slate-400 leading-normal",children:[e.jsx("p",{className:"m-0",children:t("admin.email_footer_1")}),e.jsx("p",{className:"mt-1",children:t("admin.email_footer_2")})]})]})})]})]}),c&&e.jsx(Fe,{banner:B,onClose:()=>{h(!1),o(null)},onSave:q})]})};export{Qe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.