import{O as S,b as e,C as _,B as n,q as s,b6 as C,j as l,aI as h,H as x,b7 as b}from"./index-ktJf6c6X.js";import{d as D}from"./History-Bbw9t_Y8.js";import{d as T}from"./PersonAdd-p0BWqGfb.js";import{d as y}from"./EventNote-D_ND7F0e.js";import{d as I}from"./AttachFile-WPbVKLCn.js";import{d as $}from"./TrendingUp-Dz1PaoLK.js";import{d as N}from"./InfoOutlined-BWyQd1yo.js";import{d as O}from"./Cancel-B98IHDtU.js";function j(t){return t==="QC_APPROVED"?e(b,{sx:{fontSize:18}}):t==="QC_REJECTED"?e(O,{sx:{fontSize:18}}):t==="STATUS_CHANGED"?e(D,{sx:{fontSize:18}}):t==="ASSIGNED"||t==="REASSIGNED"?e(T,{sx:{fontSize:18}}):t.startsWith("FOLLOW_UP")?e(y,{sx:{fontSize:18}}):t.startsWith("ATTACHMENT")?e(I,{sx:{fontSize:18}}):t==="LEAD_CREATED"?e($,{sx:{fontSize:18}}):e(N,{sx:{fontSize:18}})}function z(t){return t==="QC_APPROVED"?"#2e7d32":t==="QC_REJECTED"?"#d32f2f":t==="STATUS_CHANGED"?"#7b1fa2":t==="ASSIGNED"?"#196ae5":t==="REASSIGNED"?"#7b1fa2":t.startsWith("FOLLOW_UP")?"#22bb34":t.startsWith("ATTACHMENT")?"#ef6c00":t==="LEAD_CREATED"?"#00880f":"#757575"}const R=(t,r)=>r.palette.mode==="dark"?C(t,.4):t,v=new Set(["id","leadId","activityId","actorId","userId","entityId","tenantId","from","to"]),w=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}[\d:.]*)?Z?$/,W=/^[A-Z][A-Z0-9_]{2,}$/;function P(t){const r=t.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim();return r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()}function d(t){if(t==null||t==="")return null;if(typeof t=="boolean")return t?"Yes":"No";if(Array.isArray(t)){const i=t.map(d).filter(a=>a!==null);return i.length?i.join(", "):null}if(typeof t=="object"){const i=Object.values(t).map(d).filter(a=>a!==null);return i.length?i.join(", "):null}const r=String(t).trim();return r?w.test(r)?x(r):W.test(r)?r.replace(/_/g," "):r:null}function L(t,r){const{payload:i,type:a}=t;return a==="QC_APPROVED"?"QC approved":a==="QC_REJECTED"?"QC rejected":i&&i.from!==void 0&&i.to!==void 0?`Changed from ${d(i.from)??"—"} to ${d(i.to)??"—"}`:r?null:a.replace(/_/g," ")}function Q(t){return t.payload?Object.entries(t.payload).filter(([r])=>!v.has(r)).map(([r,i])=>({label:P(r),value:d(i)})).filter(r=>r.value!==null):[]}const M=({entries:t,loading:r=!1,emptyText:i="No activity yet."})=>{const a=S();return r?e(n,{display:"flex",justifyContent:"center",py:4,children:e(_,{size:32})}):t.length===0?e(n,{py:4,textAlign:"center",children:e(s,{variant:"body2",color:"text.secondary",children:i})}):e(n,{children:t.map((o,A)=>{const f=R(z(o.type),a),E=j(o.type),m=A===t.length-1,c=Q(o),u=L(o,c.length>0);return l(n,{display:"flex",gap:1.5,children:[l(n,{display:"flex",flexDirection:"column",alignItems:"center",width:36,flexShrink:0,children:[e(n,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:h(f,.09),border:`1.5px solid ${h(f,.25)}`,display:"flex",alignItems:"center",justifyContent:"center",color:f,flexShrink:0},children:E}),!m&&e(n,{sx:{width:2,flex:1,minHeight:24,bgcolor:"divider",my:.5}})]}),l(n,{pb:m?0:2.5,flex:1,minWidth:0,children:[l(n,{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,mb:.25,children:[e(s,{variant:"caption",fontWeight:700,color:f,children:o.type.replace(/_/g," ")}),o.actor&&l(s,{variant:"caption",color:"text.secondary",children:["· ",o.actor]}),e(s,{variant:"caption",color:"text.disabled",ml:"auto",children:o.occurredAt?x(o.occurredAt):"—"})]}),u&&e(s,{variant:"body2",color:"text.secondary",sx:{wordBreak:"break-word"},children:u}),c.length>0&&e(n,{display:"flex",flexDirection:"column",gap:.25,mt:u?.5:0,children:c.map(({label:p,value:g})=>l(s,{variant:"caption",color:"text.secondary",sx:{wordBreak:"break-word"},children:[l(n,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[p,":"]})," ",g]},p))})]})]},o.id)})})};export{M as A};
