import{bs as l,bt as b,r as f,bu as E,_ as u,b as c,F as n}from"./index-BiWH3VAt.js";const D=()=>{const e=l(),r=b(o=>{var t,s;return(s=(t=o==null?void 0:o.user)==null?void 0:t.data)==null?void 0:s.userId});f.useEffect(()=>{if(!r)return;const o=`${E}/erp-crm/v1/notifications/stream?userId=${r}`;let t=null;try{t=new EventSource(o)}catch{return}return t.onmessage=s=>{try{const a=JSON.parse(s.data);if((a==null?void 0:a.type)==="PING")return}catch{}e(u.util.invalidateTags(["Notification","SalesTask"]))},t.onerror=()=>{},()=>{t==null||t.close()}},[r,e])},C={PENDING:"#f59e0b",IN_PROGRESS:"#3b82f6",COMPLETED:"#10b981",CANCELLED:"#6b7280",OVERDUE:"#ef4444"},p={LOW:"#6b7280",MEDIUM:"#3b82f6",HIGH:"#f59e0b",URGENT:"#ef4444"},O=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#6b7280"],i=e=>(e||"").replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase()),I=({status:e,overdue:r})=>{const o=r&&e!=="COMPLETED"&&e!=="CANCELLED"?"OVERDUE":e||"PENDING",t=C[o]||"#6b7280";return c(n,{label:i(o),size:"small",sx:{bgcolor:`${t}1a`,color:t,fontWeight:600,border:`1px solid ${t}55`}})},N=({priority:e})=>{const r=p[e||"MEDIUM"]||"#3b82f6";return c(n,{label:i(e),size:"small",variant:"outlined",sx:{color:r,fontWeight:600,borderColor:`${r}88`}})},d=e=>e?new Date(e).toLocaleDateString():"—";export{O as C,N as P,I as S,d as f,D as u};
