import{j as e,d as T,r as C,ek as k,b as M,a as R,jQ as H,jR as w,B as r,T as n,W,J as v,M as q,gT as B,jS as E}from"./index-d2b25495.js";import{L as Y}from"./List-863f013e.js";import{C as D}from"./Chip-75fd9653.js";import{A as U}from"./Avatar-9337c33f.js";import{u as F}from"./index-38f860bc.js";import{T as J}from"./TextField-e155d2be.js";import"./createSvgIcon-e39ae511.js";import"./useMediaQuery-b1fbc166.js";import"./useControlled-8d737f13.js";import"./FormControl-73683015.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./InputLabel-bb6ab40e.js";import"./Select-ef36a2b2.js";import"./Menu-337a466b.js";import"./Grow-8719411b.js";const N=F.createSvgIcon([e.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),e.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime"),P=T(Y)(({theme:i})=>({maxHeight:"300px",marginTop:"15px",overflowY:"auto",padding:"0 8px","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-thumb":{backgroundColor:i.palette.primary.main,borderRadius:"8px"}})),le=()=>{const[i,d]=C.useState(""),{id:l}=k(),p=M(),{bq_comments:{bq_commentList:x,pageParams:a,bq_commentCount:S,loading:_}}=R(s=>H(s)),z=()=>{d("")},A=()=>{p(E({data:{lead_id:l||"",comment:i},params:a,hide:z}))};return C.useMemo(()=>{p(w({...a,lead:l,search:"",page:1,page_size:10}))},[]),e.jsxs(r,{sx:{bgcolor:"background.paper",borderRadius:3,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",overflow:"hidden"},children:[e.jsx(r,{sx:{p:3,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",color:"white"},children:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsx(n,{variant:"h5",sx:{fontWeight:700},children:"💬 Comments"}),e.jsx(D,{label:S,size:"small",sx:{bgcolor:"rgba(255,255,255,0.2)",color:"white",fontWeight:600}})]})}),e.jsxs(r,{sx:{p:3},children:[e.jsxs(P,{onScroll:s=>{const{target:t}=s;Math.ceil((t==null?void 0:t.scrollTop)+(t==null?void 0:t.offsetHeight))==(t==null?void 0:t.scrollHeight)&&a.page<a.no_of_pages&&p(w({...a,page:(a==null?void 0:a.page)+1,page_size:10}))},children:[x&&x.map((s,t)=>{var c,h,m;return e.jsx(W,{elevation:0,sx:{p:2.5,mb:2,borderRadius:2,bgcolor:"grey.50",border:"1px solid",borderColor:"grey.200",transition:"all 0.3s ease","&:hover":{transform:"translateY(-2px)",boxShadow:"0 4px 20px rgba(0,0,0,0.1)",borderColor:"primary.main"}},children:e.jsxs(r,{sx:{display:"flex",gap:2},children:[e.jsx(U,{sx:{height:40,width:40,bgcolor:"primary.main",fontWeight:600},children:(()=>{var g,b,u,f,j,y;const o=((b=(g=s==null?void 0:s.created_by)==null?void 0:g.fullname)==null?void 0:b.split(" "))||[],I=((f=(u=o[0])==null?void 0:u.charAt(0))==null?void 0:f.toUpperCase())||"",L=((y=(j=o[o.length-1])==null?void 0:j.charAt(0))==null?void 0:y.toUpperCase())||"";return I+(o.length>1?L:"")})()}),e.jsxs(r,{sx:{flex:1},children:[e.jsxs(r,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[e.jsx(r,{children:e.jsxs(n,{component:"h5",sx:{mb:"8px",color:"grey.700",fontWeight:500,fontSize:"13px"},children:[(c=s==null?void 0:s.created_by)==null?void 0:c.fullname," ","(",(h=s==null?void 0:s.created_by)==null?void 0:h.username,")"]})}),e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(N,{sx:{fontSize:12,color:"text.secondary"}}),e.jsx(n,{variant:"caption",sx:{color:"text.secondary"},children:(m=s==null?void 0:s.created_on)==null?void 0:m.toLocaleString()})]})]}),e.jsx(n,{variant:"body2",sx:{color:"text.primary",lineHeight:1.6,whiteSpace:"pre-wrap"},children:s.comment})]})]})},t)}),_&&e.jsx(r,{textAlign:"center",mt:"12px",children:e.jsx(v,{size:"small",sx:{"& > svg":{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}},startIcon:e.jsx(q,{size:16,style:{marginRight:"6px",animation:"spin 1.5s linear infinite"}}),children:"Load More"})})]}),e.jsxs(r,{sx:{border:"1px solid divider",borderRadius:"5px",mt:"28px"},children:[e.jsx(J,{id:"outlined-multiline-static",placeholder:"Your Comment...",rows:3,multiline:!0,fullWidth:!0,value:i,onChange:s=>d(s.target.value)}),e.jsxs(r,{sx:{p:"8px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r,{}),e.jsx(v,{variant:"contained",startIcon:e.jsx(B,{size:16}),onClick:A,disabled:!i,size:"medium",color:"secondary",children:"Submit"})]})]})]})]})};export{le as default};
