1"use strict";(globalThis.webpackChunkbixjet_ai=globalThis.webpackChunkbixjet_ai||[]).push([[6223],{70143(e,t,i){i.d(t,{A:()=>q});var o=i(9950),r=i(93230),n=i(16491),s=i(82053),l=i(46639),a=i(25333),d=i(83274),c=i(72362),x=i(41413),h=i(66699),u=i(8145),p=i(10226),g=i(63464),m=i(28170),f=i(79739),b=i(40033),j=i(24516),v=i(71525),A=i(79693),y=i(43293),S=i(78214),w=i(96319),z=i(12563),k=i(31800),C=i(22476),W=i(37415),R=i(86580),_=i(72661),I=i(63045),D=i(26547),M=i(14758),$=i(97913),E=i(62534),F=i(69888),B=i(54087),P=i(16243),T=i(24921),H=i(36669),L=i(44414);const O="#0A66C2",Y="background.paper",N=["\ud83d\udc4d","\u2764\ufe0f","\ud83d\ude02","\ud83d\ude2e","\ud83d\ude22","\ud83d\ude4f"];function V(e){let{fromSelf:t}=e;const i=t?"rgba(255,255,255,0.5)":"rgba(0,0,0,0.32)",o=t?"rgba(255,255,255,0.7)":"rgba(0,0,0,0.45)",l=t?"rgba(255,255,255,0.5)":"rgba(0,0,0,0.3)";return(0,L.jsxs)(r.A,{direction:"row",alignItems:"center",spacing:1,sx:{py:.25,minWidth:180},children:[(0,L.jsx)(n.A,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:(0,L.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,L.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),(0,L.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),(0,L.jsxs)(n.A,{children:[(0,L.jsx)(s.A,{sx:{fontSize:13,fontStyle:"italic",color:o,lineHeight:1.35},children:"This message isn't available."}),(0,L.jsx)(s.A,{sx:{fontSize:11,color:l,lineHeight:1.3,mt:.1},children:"Open LinkedIn to view this content."})]})]})}function U(e){var t,i,o,r,a;let{file:d,fromSelf:c}=e;const x=(null===(t=d.filename)||void 0===t||null===(i=t.split(".").pop())||void 0===i?void 0:i.toLowerCase())||"",h=(null===(o=d.mimetype)||void 0===o?void 0:o.startsWith("image/"))||["jpg","jpeg","png","gif","webp","svg"].includes(x),u=(null===(r=d.mimetype)||void 0===r?void 0:r.startsWith("audio/"))||["mp3","wav","ogg","m4a","aac"].includes(x),p=(null===(a=d.mimetype)||void 0===a?void 0:a.startsWith("video/"))||["mp4","mov","webm","mkv","avi"].includes(x);return d.url?h?(0,L.jsx)(n.A,{sx:{mt:1},children:(0,L.jsx)("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",children:(0,L.jsx)("img",{src:d.url,alt:d.filename,style:{maxWidth:280,maxHeight:280,borderRadius:12,display:"block",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"}})})}):u?(0,L.jsx)(n.A,{sx:{mt:1},children:(0,L.jsx)("audio",{controls:!0,src:d.url,style:{maxWidth:280,height:36}})}):p?(0,L.jsx)(n.A,{sx:{mt:1},children:(0,L.jsx)("video",{controls:!0,src:d.url,style:{maxWidth:280,borderRadius:12}})}):(0,L.jsxs)(n.A,{component:"a",href:d.url,target:"_blank",rel:"noopener noreferrer",sx:{mt:1,display:"inline-flex",alignItems:"center",gap:1,px:1.25,py:.85,borderRadius:2,border:"1px solid",borderColor:c?"rgba(255,255,255,0.35)":"rgba(0,0,0,0.1)",bgcolor:c?"rgba(255,255,255,0.18)":"background.paper",textDecoration:"none",color:c?"#fff":"rgba(0,0,0,0.85)","&:hover":{bgcolor:c?"rgba(255,255,255,0.28)":"rgba(0,0,0,0.04)"}},children:[(0,L.jsx)(z.A,{sx:{fontSize:18,color:c?"#fff":O}}),(0,L.jsx)(s.A,{sx:{fontSize:12,fontWeight:600},children:d.filename})]}):(0,L.jsxs)(n.A,{sx:{mt:1,display:"flex",alignItems:"center",gap:1,fontSize:12,opacity:.75},children:[(0,L.jsx)(l.A,{size:12,sx:{color:c?"#fff":O}}),(0,L.jsxs)(s.A,{variant:"caption",children:["Loading ",d.filename,"\u2026"]})]})}function G(e){let{file:t,onRemove:i,kind:o}=e;const r="voice"===o?C.A:"video"===o?W.A:z.A;return(0,L.jsxs)(n.A,{sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.25,py:.6,borderRadius:999,border:"1px solid",borderColor:"divider",bgcolor:"action.hover",maxWidth:220},children:[(0,L.jsx)(r,{sx:{fontSize:14,color:O}}),(0,L.jsx)(s.A,{sx:{fontSize:12,fontWeight:500,flex:1,minWidth:0},noWrap:!0,children:t.name}),(0,L.jsx)(a.A,{size:"small",onClick:i,sx:{p:.25,"&:hover":{bgcolor:"rgba(0,0,0,0.08)"}},children:(0,L.jsx)(w.A,{sx:{fontSize:13}})})]})}function K(e){var t;let{m:i,isStacked:l,onReact:x}=e;const h=!!i.is_sender,[u,p]=(0,o.useState)(!1),[g,m]=(0,o.useState)(null),f=(i.message||"").includes("Unipile cannot display this type of message");return(0,L.jsxs)(n.A,{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),sx:{display:"flex",flexDirection:"column",alignItems:h?"flex-end":"flex-start"},children:[(0,L.jsx)(n.A,{sx:{height:34,mb:.4,visibility:u?"visible":"hidden",opacity:u?1:0,transition:"opacity .15s",display:"flex",alignItems:"center",justifyContent:h?"flex-end":"flex-start"},children:(0,L.jsxs)(r.A,{direction:"row",spacing:.25,sx:{bgcolor:"background.paper",borderRadius:999,border:"1px solid",boxShadow:"0 2px 8px rgba(0,0,0,0.12)",px:.75,py:.35},children:[N.map(e=>(0,L.jsx)(d.A,{title:e,arrow:!0,children:(0,L.jsx)(a.A,{size:"small",onClick:()=>x(i.message_id,e),sx:{fontSize:15,width:26,height:26,"&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:e})},e)),(0,L.jsx)(d.A,{title:"More",arrow:!0,children:(0,L.jsx)(a.A,{size:"small",onClick:e=>m(e.currentTarget),sx:{width:26,height:26,"&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:(0,L.jsx)(I.A,{sx:{fontSize:15,color:"rgba(0,0,0,0.5)"}})})})]})}),(0,L.jsxs)(n.A,{sx:{maxWidth:"78%",bgcolor:h?O:"action.selected",color:h?"#fff":"rgba(0,0,0,0.9)",px:1.75,py:1.1,borderRadius:h?`18px 18px ${l?4:18}px 18px`:`18px 18px 18px ${l?4:18}px`,boxShadow:h?"none":"0 1px 1px rgba(0,0,0,0.04)"},children:[f?(0,L.jsx)(V,{fromSelf:h}):i.message&&(0,L.jsx)(s.A,{sx:{fontSize:14,lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i.message}),(i.attachments||[]).map(e=>(0,L.jsx)(U,{file:e,fromSelf:h},e.attachmentid)),i.timestamp&&(0,L.jsx)(r.A,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:.5,sx:{mt:.4},children:(0,L.jsx)(s.A,{sx:{fontSize:10.5,color:h?"rgba(255,255,255,0.65)":"rgba(0,0,0,0.5)",fontWeight:500},children:(0,$.A)(i.timestamp).format("h:mm A")})})]}),(null===(t=i.reactions)||void 0===t?void 0:t.length)>0&&(0,L.jsx)(r.A,{direction:"row",flexWrap:"wrap",gap:.5,sx:{mt:.5,justifyContent:h?"flex-end":"flex-start"},children:i.reactions.map((e,t)=>(0,L.jsx)(d.A,{title:e.sender||"",arrow:!0,children:(0,L.jsx)(n.A,{sx:{display:"inline-flex",alignItems:"center",gap:.4,px:.85,py:.25,borderRadius:999,bgcolor:"background.paper",border:"1px solid",boxShadow:"0 1px 2px rgba(0,0,0,0.08)"},children:(0,L.jsx)(s.A,{sx:{fontSize:13,lineHeight:1},children:e.value||e.emoji||e})})},t))}),(0,L.jsx)(c.Ay,{open:Boolean(g),anchorEl:g,onClose:()=>m(null),anchorOrigin:{vertical:"top",horizontal:h?"right":"left"},transformOrigin:{vertical:"bottom",horizontal:h?"right":"left"},PaperProps:{sx:{borderRadius:2,overflow:"hidden"}},children:(0,L.jsx)(M.Ay,{onEmojiClick:e=>{x(i.message_id,e.emoji),m(null)},height:350,width:320})})]})}function q(e){let{chat:t,accountId:i,onClose:I,onMessageSent:N,onProfileOpen:V}=e;const[U,q]=(0,o.useState)([]),[X,J]=(0,o.useState)(!1),[Q,Z]=(0,o.useState)(!1),[ee,te]=(0,o.useState)(!1),[ie,oe]=(0,o.useState)(""),[re,ne]=(0,o.useState)(!1),[se,le]=(0,o.useState)(null),[ae,de]=(0,o.useState)(!1),[ce,xe]=(0,o.useState)("general"),[he,ue]=(0,o.useState)([]),[pe,ge]=(0,o.useState)([]),[me,fe]=(0,o.useState)([]),[be,je]=(0,o.useState)(!1),[ve,Ae]=(0,o.useState)(!1),[ye,Se]=(0,o.useState)(null),[we,ze]=(0,o.useState)(null),ke=(0,o.useRef)(null),Ce=(0,o.useRef)(null),We=(0,o.useRef)(null),Re=(0,o.useRef)(!1),_e=(0,o.useMemo)(()=>"boolean"===typeof(null===t||void 0===t?void 0:t.isGroup)?t.isGroup:"number"===typeof(null===t||void 0===t?void 0:t.attendeeCount)?t.attendeeCount>1:Array.isArray(null===t||void 0===t?void 0:t.attendees)&&t.attendees.length>1,[t]),Ie=e=>{for(const i of e){var t;if(null!==(t=i.attachments)&&void 0!==t&&t.length)for(const e of i.attachments)(0,F.jX)({messageId:i.message_id,attachmentId:e.attachmentid}).then(t=>{q(o=>o.map(o=>o.message_id!==i.message_id?o:{...o,attachments:o.attachments.map(i=>i.attachmentid===e.attachmentid?{...i,url:t}:i)}))}).catch(()=>{})}};(0,o.useEffect)(()=>{(async()=>
1{if(null!==t&&void 0!==t&&t.chatid){J(!0);try{const{items:e}=await(0,F.lj)({chatId:t.chatid});q(e),Ie(e)}catch(e){(0,E.D)((null===e||void 0===e?void 0:e.message)||"Failed to load messages","error")}finally{J(!1)}}else q([])})()},[null===t||void 0===t?void 0:t.chatid]),(0,o.useEffect)(()=>{Ae(!1),Se(null)},[null===t||void 0===t?void 0:t.chatid]),(0,o.useEffect)(()=>{Ce.current&&(Ce.current.scrollTop=Ce.current.scrollHeight)},[U,X]);const De=(0,o.useMemo)(()=>{const e=[];for(const t of U){if(t.deleted)continue;const i=t.timestamp?(0,$.A)(t.timestamp):(0,$.A)();if(!i.isValid())continue;const o=e[e.length-1];o&&(0,$.A)(o.date).isSame(i,"day")?o.messages.push(t):e.push({date:t.timestamp||(new Date).toISOString(),messages:[t]})}return e},[U]),Me=e=>{const t=(0,$.A)(e),i=(0,$.A)();return t.isSame(i,"day")?"Today":t.isSame(i.clone().subtract(1,"day"),"day")?"Yesterday":t.isSame(i,"week")?t.format("dddd"):t.isSame(i,"year")?t.format("MMMM D"):t.format("MMMM D, YYYY")},$e=e=>{xe(e),le(null),de(!0)},Ee=async()=>{if(!Re.current)if(ie.trim()||he.length||pe.length||me.length)if(null!==t&&void 0!==t&&t.provider_id){Re.current=!0,te(!0);try{const s=ie.trim(),l=he,a=pe,d=me,c=await(0,F._z)({accountId:t.account_id||i,attendeeProviderId:t.provider_id,text:s,files:l,voiceFiles:a,videoFiles:d}),x=`local-${Date.now()}`,h=[...l.map((e,t)=>({attachmentid:`local-att-${Date.now()}-${t}`,filename:e.name,mimetype:e.type||"application/octet-stream",url:URL.createObjectURL(e)})),...a.map((e,t)=>({attachmentid:`local-voice-${Date.now()}-${t}`,filename:e.name,mimetype:e.type||"audio/webm",url:URL.createObjectURL(e)})),...d.map((e,t)=>({attachmentid:`local-video-${Date.now()}-${t}`,filename:e.name,mimetype:e.type||"video/mp4",url:URL.createObjectURL(e)}))];if(q(e=>[...e,{message_id:x,message:s,is_sender:!0,timestamp:(new Date).toISOString(),reactions:[],attachments:h,message_type:"text",deleted:!1}]),null!==c&&void 0!==c&&c.message_id)try{const t=await(0,F.ub)(c.message_id);if(t){var e,o,r,n;const i={message_id:t.id,chat_id:t.chat_id,message:null!==(e=t.text)&&void 0!==e?e:s,is_sender:!0,subject:null!==(o=t.subject)&&void 0!==o?o:"",reactions:Array.isArray(t.reactions)?t.reactions:[],timestamp:null!==(r=t.timestamp)&&void 0!==r?r:(new Date).toISOString(),message_type:null!==(n=t.message_type)&&void 0!==n?n:"text",deleted:!1,attachments:(t.attachments||[]).map(e=>({attachmentid:e.id,filename:e.file_name,mimetype:e.type,url:null}))};q(e=>e.map(e=>e.message_id===x?i:e)),Ie([i])}}catch{}oe(""),ue([]),ge([]),fe([]),xe("general"),null===N||void 0===N||N(s)}catch(a){var s,l;(0,E.D)((null===a||void 0===a||null===(s=a.response)||void 0===s||null===(l=s.data)||void 0===l?void 0:l.detail)||(null===a||void 0===a?void 0:a.message)||"Failed to send","error")}finally{Re.current=!1,te(!1)}}else(0,E.D)("Recipient not resolved yet \u2014 try syncing the chat list","error");else(0,E.D)("Please enter a message or attach a file","error")},Fe=async(e,t)=>{try{await async function(e,t){await(0,T.e6)(P.A.baseURLApi,{query:"\n mutation uniReactMessage($messageId: String!, $reaction: String!) {\n uniReactMessage(messageId: $messageId, reaction: $reaction)\n }\n",variables:{messageId:e,reaction:t}})}(e,t),q(i=>i.map(i=>{if(i.message_id!==e)return i;const o=i.reactions||[];return o.find(e=>(e.value||e.emoji||e)===t)?i:{...i,reactions:[...o,{value:t}]}}))}catch(i){(0,E.D)((null===i||void 0===i?void 0:i.message)||"Failed to react","error")}},Be=e=>{const i=e||t;Se(i),Ae(!0),null===V||void 0===V||V(i)};if(!t)return(0,L.jsxs)(n.A,{sx:{display:"flex",height:{md:620},alignItems:"center",justifyContent:"center",flexDirection:"column",bgcolor:Y,color:"text.secondary",px:4,textAlign:"center"},children:[(0,L.jsx)(n.A,{sx:{width:72,height:72,borderRadius:"50%",bgcolor:`${O}10`,mb:2,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,L.jsx)(_.A,{sx:{fontSize:32,color:O}})}),(0,L.jsx)(s.A,{sx:{fontSize:16,fontWeight:700,color:"rgba(0,0,0,0.85)",mb:.5},children:"Pick a conversation"}),(0,L.jsx)(s.A,{sx:{fontSize:13,color:"rgba(0,0,0,0.55)",maxWidth:280},children:"Select a chat from the left to read and reply."})]});const Pe=he.length>0||pe.length>0||me.length>0,Te=pe.length>0||me.length>0,He=he.length>0||me.length>0,Le=he.length>0||pe.length>0;return(0,L.jsxs)(n.A,{sx:{display:"flex",flexDirection:"column",height:{md:620},minHeight:0,bgcolor:Y},children:[(0,L.jsxs)(r.A,{direction:"row",alignItems:"center",spacing:1.5,sx:{px:2.25,py:1.5,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper",flexShrink:0},children:[I&&(0,L.jsx)(H.A,{label:"Back to Inbox",onClick:I}),(0,L.jsx)(n.A,{onClick:()=>Be(t),sx:{cursor:"pointer",flexShrink:0},children:t.picture?(0,L.jsx)(x.A,{src:t.picture,sx:{width:44,height:44,border:"1px solid","&:hover":{opacity:.85}}}):(0,L.jsx)(x.A,{sx:{width:44,height:44,fontSize:15,fontWeight:700,bgcolor:_e?"rgba(0,0,0,0.08)":`${O}1A`,color:_e?"rgba(0,0,0,0.55)":O,border:"1px solid","&:hover":{opacity:.85}},children:_e?(0,L.jsx)(D.A,{sx:{fontSize:20}}):(0,F.bB)(t.name)})}),(0,L.jsxs)(n.A,{sx:{flex:1,minWidth:0},children:[(0,L.jsx)(s.A,{onClick:()=>Be(t),noWrap:!0,sx:{fontSize:15,fontWeight:700,lineHeight:1.3,color:"rgba(0,0,0,0.9)",cursor:"pointer","&:hover":{color:O,textDecoration:"underline"}},children:t.name||"\u2014"}),_e?(0,L.jsx)(s.A,{onClick:e=>ze(e.currentTarget),sx:{fontSize:12,color:"rgba(0,0,0,0.6)",lineHeight:1.3,cursor:"pointer",width:"fit-content","&:hover":{color:O,textDecoration:"underline"}},noWrap:!0,children:t.attendeeCount?`${t.attendeeCount} members`:"Group"}):t.occupation&&(0,L.jsx)(s.A,{sx:{fontSize:12,color:"rgba(0,0,0,0.6)",lineHeight:1.3},noWrap:!0,children:t.occupation})]}),(0,L.jsx)(d.A,{title:Q?"Syncing\u2026":"Sync messages",children:(0,L.jsx)("span",{children:(0,L.jsx)(a.A,{size:"small",onClick:async()=>
1{if(null!==t&&void 0!==t&&t.chatid&&!Q&&!X){Z(!0);try{const{items:e}=await(0,F.lj)({chatId:t.chatid});q(e),Ie(e)}catch(e){(0,E.D)((null===e||void 0===e?void 0:e.message)||"Failed to sync","error")}finally{Z(!1)}}},disabled:Q||X,sx:{border:"1px solid",borderColor:Q?"primary.light":"divider",borderRadius:2,bgcolor:Q?"rgba(10,102,194,0.06)":"transparent","&:hover:not(:disabled)":{borderColor:O,bgcolor:`${O}0d`},"&.Mui-disabled":{opacity:.6}},children:Q?(0,L.jsx)(l.A,{size:16,thickness:4,sx:{color:O}}):(0,L.jsx)(R.A,{sx:{fontSize:16,color:O}})})})})]}),(X||Q)&&(0,L.jsx)(h.A,{sx:{height:2,flexShrink:0,bgcolor:`${O}14`,"& .MuiLinearProgress-bar":{bgcolor:O}}}),_e&&(0,L.jsxs)(c.Ay,{open:Boolean(we),anchorEl:we,onClose:()=>ze(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{borderRadius:2,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",minWidth:240,maxWidth:320}},children:[(0,L.jsx)(n.A,{sx:{px:2,py:1.25,borderBottom:"1px solid #F0F0F0"},children:(0,L.jsx)(s.A,{sx:{fontSize:13,fontWeight:700},children:t.attendeeCount?`${t.attendeeCount} members`:"Members"})}),(0,L.jsx)(n.A,{sx:{maxHeight:320,overflowY:"auto",py:.5},children:0===(t.attendees||[]).length?(0,L.jsx)(s.A,{sx:{fontSize:13,color:"text.secondary",px:2,py:1.5},children:"No member details available."}):Array.from(new Map((t.attendees||[]).map(e=>[e.provider_id||e.id,e])).values()).map((e,i)=>{const o=(e.name||"").trim()||"Private",n="Private"===o;return(0,L.jsxs)(r.A,{direction:"row",alignItems:"center",spacing:1.25,onClick:()=>{ze(null),Be({...t,provider_id:e.provider_id,name:o,picture:e.picture_url||null,occupation:null})},sx:{px:2,py:.85,cursor:n?"default":"pointer","&:hover":n?{}:{bgcolor:`${O}08`}},children:[e.picture_url?(0,L.jsx)(x.A,{src:e.picture_url,sx:{width:32,height:32}}):(0,L.jsx)(x.A,{sx:{width:32,height:32,fontSize:12,fontWeight:700,bgcolor:n?"rgba(0,0,0,0.07)":`${O}1A`,color:n?"rgba(0,0,0,0.4)":O},children:n?"?":(0,F.bB)(o)}),(0,L.jsx)(s.A,{noWrap:!0,sx:{fontSize:13,fontWeight:600,color:n?"rgba(0,0,0,0.4)":"rgba(0,0,0,0.85)",fontStyle:n?"italic":"normal"},children:o})]},e.provider_id||i)})})]}),(0,L.jsx)(n.A,{ref:Ce,sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,bgcolor:Y,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-thumb":{bgcolor:"rgba(0,0,0,0.18)",borderRadius:3}},children:X&&0===U.length?(0,L.jsx)(n.A,{sx:{textAlign:"center",py:8},children:(0,L.jsx)(l.A,{size:24,sx:{color:O}})}):0===U.length?(0,L.jsxs)(n.A,{sx:{textAlign:"center",py:8},children:[(0,L.jsx)(s.A,{sx:{fontSize:14,fontWeight:600,mb:.5},children:"No messages yet"}),(0,L.jsx)(s.A,{variant:"caption",color:"text.secondary",children:"Say hi \ud83d\udc4b to start the conversation."})]}):(0,L.jsx)(r.A,{spacing:2.5,children:De.map((e,t)=>(0,L.jsxs)(n.A,{children:[(0,L.jsxs)(n.A,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1.25,my:2},children:[(0,L.jsx)(n.A,{sx:{flex:1,height:1,bgcolor:"rgba(0,0,0,0.08)"}}),(0,L.jsx)(s.A,{sx:{color:"rgba(0,0,0,0.55)",fontSize:11,fontWeight:700,letterSpacing:.4,textTransform:"uppercase"},children:Me(e.date)}),(0,L.jsx)(n.A,{sx:{flex:1,height:1,bgcolor:"rgba(0,0,0,0.08)"}})]}),(0,L.jsx)(r.A,{spacing:.85,children:e.messages.map((t,i)=>{const o=!!t.is_sender,r=i>0?e.messages[i-1]:null,n=r&&!!r.is_sender===o&&Math.abs((0,$.A)(t.timestamp).diff((0,$.A)(r.timestamp),"minutes"))<5;return(0,L.jsx)(K,{m:t,isStacked:n,onReact:Fe},t.message_id)})})]},`${e.date}-${t}`))})}),Pe&&(0,L.jsxs)(n.A,{sx:{px:2,py:1.25,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.default",display:"flex",flexWrap:"wrap",gap:.75},children:[he.map((e,t)=>(0,L.jsx)(G,{file:e,kind:"general",onRemove:()=>ue(e=>e.filter((e,i)=>i!==t))},`f-${t}`)),pe.map((e,t)=>(0,L.jsx)(G,{file:e,kind:"voice",onRemove:()=>ge(e=>e.filter((e,i)=>i!==t))},`v-${t}`)),me.map((e,t)=>(0,L.jsx)(G,{file:e,kind:"video",onRemove:()=>fe(e=>e.filter((e,i)=>i!==t))},`vi-${t}`))]}),(0,L.jsxs)(n.A,{sx:{borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",px:1.75,pt:1.25,pb:1,flexShrink:0},children:[(0,L.jsx)(u.A,{inputRef:We,fullWidth:!0,multiline:!0,minRows:1,maxRows:5,size:"small",placeholder:"Write a message\u2026",value:ie,onChange:e=>oe(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),Ee())},variant:"standard",InputProps:{disableUnderline:!0},sx:{"& .MuiInputBase-root":{fontSize:14,p:0}}}),(0,L.jsxs)(r.A,{direction:"row",alignItems:"center",spacing:.25,sx:{mt:.75},children:[(0,L.jsx)(d.A,{title:"Attach a file",children:(0,L.jsx)(a.A,{size:"small",onClick:e=>le(e.currentTarget),sx:{"&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}
1,children:(0,L.jsx)(S.A,{sx:{fontSize:20,color:"rgba(0,0,0,0.6)"}})})}),(0,L.jsx)(c.Ay,{open:Boolean(se),anchorEl:se,onClose:()=>le(null),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},PaperProps:{sx:{borderRadius:2,boxShadow:"0 4px 16px rgba(0,0,0,0.12)"}},children:(0,L.jsxs)(r.A,{direction:"row",spacing:1,sx:{p:1.5},children:[(0,L.jsx)(d.A,{title:Te?"Already attaching another type":"Photos / Documents",children:(0,L.jsx)("span",{children:(0,L.jsx)(a.A,{disabled:Te,onClick:()=>$e("general"),sx:{border:"1px solid",borderColor:"divider",borderRadius:99,width:40,height:40,"&:hover:not(:disabled)":{bgcolor:`${O}10`,borderColor:O}},children:(0,L.jsx)(k.A,{sx:{fontSize:18}})})})}),(0,L.jsx)(d.A,{title:He?"Already attaching another type":"Voice",children:(0,L.jsx)("span",{children:(0,L.jsx)(a.A,{disabled:He,onClick:()=>$e("audio"),sx:{border:"1px solid",borderColor:"divider",borderRadius:99,width:40,height:40,"&:hover:not(:disabled)":{bgcolor:`${O}10`,borderColor:O}},children:(0,L.jsx)(C.A,{sx:{fontSize:18}})})})}),(0,L.jsx)(d.A,{title:Le?"Already attaching another type":"Video",children:(0,L.jsx)("span",{children:(0,L.jsx)(a.A,{disabled:Le,onClick:()=>$e("video"),sx:{border:"1px solid",borderColor:"divider",borderRadius:99,width:40,height:40,"&:hover:not(:disabled)":{bgcolor:`${O}10`,borderColor:O}},children:(0,L.jsx)(W.A,{sx:{fontSize:18}})})})})]})}),(0,L.jsx)(d.A,{title:"Emoji",children:(0,L.jsx)(a.A,{size:"small",onClick:()=>ne(e=>!e),sx:{"&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:(0,L.jsx)(y.A,{sx:{fontSize:20,color:"rgba(0,0,0,0.6)"}})})}),(0,L.jsx)(n.A,{sx:{flex:1}}),(0,L.jsx)(d.A,{title:"Send (Enter)",children:(0,L.jsx)("span",{children:(0,L.jsx)(p.A,{onClick:Ee,disabled:ee||!ie.trim()&&!Pe,disableElevation:!0,variant:"contained",size:"small",endIcon:ee?(0,L.jsx)(l.A,{size:14,sx:{color:"#fff"}}):(0,L.jsx)(A.A,{sx:{fontSize:16}}),sx:{borderRadius:999,textTransform:"none",fontWeight:700,fontSize:13,px:2,height:32,bgcolor:O,"&:hover":{bgcolor:"#004182"},"&.Mui-disabled":{bgcolor:"rgba(0,0,0,0.08)",color:"rgba(0,0,0,0.38)"}},children:"Send"})})})]})]}),(0,L.jsxs)(g.A,{open:re,onClose:()=>ne(!1),maxWidth:"xs",PaperProps:{sx:{borderRadius:3,overflow:"hidden"}},children:[(0,L.jsx)(m.A,{sx:{p:1},children:(0,L.jsx)(M.Ay,{onEmojiClick:e=>{oe(t=>t+((null===e||void 0===e?void 0:e.emoji)||"")),ne(!1)},width:"100%"})}),(0,L.jsx)(f.A,{sx:{pb:1.5,pr:2},children:(0,L.jsx)(p.A,{onClick:()=>ne(!1),size:"small",variant:"outlined",sx:{borderRadius:999,textTransform:"none",fontWeight:600},children:"Close"})})]}),(0,L.jsxs)(g.A,{open:ae,onClose:()=>de(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:3}},children:[(0,L.jsxs)(b.A,{sx:{pr:5,fontSize:16,fontWeight:700},children:["Add ","audio"===ce?"voice":"video"===ce?"video":"file"," attachment",(0,L.jsx)(a.A,{onClick:()=>de(!1),sx:{position:"absolute",right:12,top:12},children:(0,L.jsx)(w.A,{fontSize:"small"})})]}),(0,L.jsxs)(m.A,{sx:{pt:1},children:[(0,L.jsxs)(n.A,{onClick:()=>{var e;return null===(e=ke.current)||void 0===e?void 0:e.click()},sx:{border:"2px dashed",borderColor:"rgba(0,0,0,0.15)",borderRadius:2,py:5,px:3,textAlign:"center",cursor:"pointer","&:hover":{borderColor:O,bgcolor:`${O}08`}},children:[(0,L.jsx)(n.A,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:`${O}12`,mx:"auto",mb:1.5,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,L.jsx)(z.A,{sx:{fontSize:24,color:O}})}),(0,L.jsx)(s.A,{sx:{fontSize:14,fontWeight:600},children:"Click to select a file"}),(0,L.jsx)(s.A,{variant:"caption",sx:{color:"rgba(0,0,0,0.55)",display:"block",mt:.5},children:"audio"===ce?"Audio files only \xb7 max 40 MB":"video"===ce?"Video files only \xb7 max 40 MB":"Image, PDF, or document \xb7 max 40 MB"})]}),(0,L.jsx)("input",{ref:ke,type:"file",multiple:"general"===ce,accept:"audio"===ce?"audio/*":"video"===ce?"video/*":"image/*,application/pdf,.doc,.docx,.txt,.ppt,.pptx,.xls,.xlsx,.csv",hidden:!0,onChange:e=>{const t=Array.from(e.target.files||[]);if(t.length){if(t.find(e=>e.size>41943040))return je(!0),void(e.target.value="");je(!1),"audio"===ce?ge(t):"video"===ce?fe(t):ue(t),de(!1),e.target.value=""}}}),be&&(0,L.jsx)(j.A,{error:!0,sx:{mt:1.25,fontSize:12},children:"File size should not be greater than 40 MB."})]})]}),(0,L.jsxs)(v.Ay,{anchor:"right",open:ve,onClose:()=>Ae(!1),disableScrollLock:!0,ModalProps:{keepMounted:!1},sx:{zIndex:1400,"& .MuiDrawer-paper":{width:{xs:"100%",sm:360},borderRadius:"16px 0 0 16px",overflow:"hidden",boxShadow:"-4px 0 32px rgba(0,0,0,0.18)"}},children:[(0,L.jsxs)(n.A,{sx:{display:"flex",alignItems:"center",px:2,py:1.5,borderBottom:"1px solid #E0E0E0",flexShrink:0},children:[(0,L.jsx)(H.A,{label:"Back to Conversation",onClick:()=>Ae(!1)}),(0,L.jsx)(s.A,{sx:{fontWeight:700,fontSize:15,flex:1,ml:1},children:"Profile"}),(0,L.jsx)(a.A,{size:"small",onClick:()=>Ae(!1),sx:{"&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:(0,L.jsx)(w.A,{sx:{fontSize:18}})})]}),(0,L.jsx)(n.A,{sx:{overflowY:"auto",flex:1,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-thumb":{bgcolor:"rgba(0,0,0,0.18)",borderRadius:3}},children:(0,L.jsx)(B.A,{chat:ye||t,accountId:i})})]})]})}},54087(e,t,i){i.d(t,{A:()=>A});var o=i(9950),r=i(16491),n=i(93230),s=i(25333),l=i(46639),a=i(41413),d=i(82053),c=i(10226),x=i(74745),h=i(8808),u=i(50521),p=i(69755),g=i(28217),m=i(18844),f=i(96319),b=i(69888),j=i(44414);const v="#0A66C2";function A(e){let{chat:t,accountId:i,onClose:A}=e;const[y,S]=(0,o.useState)(null),[w,z]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{null!==t&&void 0!==t&&t.provider_id&&i?(z(!0),(0,b.eO)({accountId:i,providerId:t.provider_id}).then(e=>S(e)).catch(()=>S(null)).finally(()=>z(!1))):S(null)},[null===t||void 0===t?void 0:t.provider_id,i]),!t)return null;
1const k=y&&`${y.first_name||""} ${y.last_name||""}`.trim()||t.name;return(0,j.jsxs)(r.A,{sx:{p:2,height:{md:540},overflowY:"auto"},children:[A&&(0,j.jsx)(n.A,{direction:"row",alignItems:"center",justifyContent:"flex-end",sx:{mb:.5},children:(0,j.jsx)(s.A,{size:"small",onClick:A,children:(0,j.jsx)(f.A,{sx:{fontSize:18}})})}),w?(0,j.jsx)(r.A,{sx:{textAlign:"center",py:6},children:(0,j.jsx)(l.A,{size:22})}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(n.A,{alignItems:"center",spacing:1,sx:{mb:2},children:[null!==y&&void 0!==y&&y.profile_picture_url||t.picture?(0,j.jsx)(a.A,{src:(null===y||void 0===y?void 0:y.profile_picture_url)||t.picture,sx:{width:96,height:96}}):(0,j.jsx)(a.A,{sx:{width:96,height:96,fontSize:28,fontWeight:700,bgcolor:"rgba(10,102,194,0.10)",color:v},children:(0,b.bB)(k)}),(0,j.jsx)(d.A,{sx:{fontSize:16,fontWeight:700,textAlign:"center"},children:k||"\u2014"}),(null===y||void 0===y?void 0:y.description)&&(0,j.jsx)(d.A,{variant:"body2",color:"text.secondary",sx:{textAlign:"center"},children:y.description}),(null===y||void 0===y?void 0:y.public_identifier)&&(0,j.jsx)(c.A,{size:"small",variant:"outlined",startIcon:(0,j.jsx)(u.A,{sx:{fontSize:16}}),endIcon:(0,j.jsx)(h.A,{sx:{fontSize:14}}),href:`https://www.linkedin.com/in/${y.public_identifier}`,target:"_blank",rel:"noopener",sx:{borderRadius:99,textTransform:"none",mt:1,color:v,borderColor:v},children:"View on LinkedIn"})]}),((null===y||void 0===y?void 0:y.email)||(null===y||void 0===y?void 0:y.location)||null!=(null===y||void 0===y?void 0:y.connections_count))&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.A,{sx:{my:2}}),(0,j.jsxs)(n.A,{spacing:1,children:[y.email&&(0,j.jsxs)(n.A,{direction:"row",alignItems:"center",spacing:1.25,children:[(0,j.jsx)(p.A,{sx:{fontSize:16,color:"text.secondary"}}),(0,j.jsx)(d.A,{variant:"body2",component:"a",href:`mailto:${y.email}`,sx:{color:v,textDecoration:"none","&:hover":{textDecoration:"underline"}},children:y.email})]}),y.location&&(0,j.jsxs)(n.A,{direction:"row",alignItems:"center",spacing:1.25,children:[(0,j.jsx)(g.A,{sx:{fontSize:16,color:"text.secondary"}}),(0,j.jsx)(d.A,{variant:"body2",color:"text.secondary",children:y.location})]}),null!=y.connections_count&&(0,j.jsxs)(n.A,{direction:"row",alignItems:"center",spacing:1.25,children:[(0,j.jsx)(m.A,{sx:{fontSize:16,color:"text.secondary"}}),(0,j.jsxs)(d.A,{variant:"body2",color:"text.secondary",children:[y.connections_count.toLocaleString()," connections"]})]})]})]}),((null===y||void 0===y?void 0:y.latest_company)||(null===y||void 0===y?void 0:y.latest_position))&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.A,{sx:{my:2}}),(0,j.jsx)(d.A,{sx:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:.5,color:"text.secondary",mb:1},children:"Current Role"}),y.latest_position&&(0,j.jsx)(d.A,{sx:{fontSize:13.5,fontWeight:600},children:y.latest_position}),y.latest_company&&(0,j.jsx)(d.A,{variant:"body2",color:"text.secondary",children:y.latest_company})]})]})]})}},39353(e,t,i){i.d(t,{A:()=>ge});var o=i(9950),r=i(16491),n=i(46639),s=i(82053),l=i(93230),a=i(83274),d=i(25333),c=i(72362),x=i(46589),h=i(41413),u=i(25277),p=i(24516),g=i(8145),m=i(63464),f=i(28170),b=i(79739),j=i(10226),v=i(14857),A=i(79693),y=i(78214),S=i(43293),w=i(22476),z=i(27835),k=i(96319),C=i(31800),W=i(68178),R=i(643),_=i(93437),I=i(12563),D=i(86580),M=i(92613),$=i(26547),E=i(87899),F=i(17932),B=i(79708),P=i(29635),T=i(36089),H=i(26592),L=i(63045),O=i(14758),Y=i(97913),N=i(62534),V=i(92408),U=(i(16243),i(36669)),G=i(44414);const K="#25D366",q="#1ea854",X="#EFEAE2",J=20971520,Q="image/*",Z=["\ud83d\udc4d","\u2764\ufe0f","\ud83d\ude02","\ud83d\ude2e","\ud83d\ude22","\ud83d\ude4f"],ee=e=>"img"===e||"string"===typeof e&&e.startsWith("image/"),te=e=>"video"===e||"string"===typeof e&&e.startsWith("video/"),ie=e=>"audio"===e||"string"===typeof e&&e.startsWith("audio/"),oe=e=>{const t=String(e||"").trim();if(!t)return!1;if(t.includes("@"))return!1;if(!/^\+?[0-9\s\-().]{6,18}$/.test(t))return!1;const i=t.replace(/\D/g,"");return i.length>=6&&i.length<=15},re=e=>null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1048576).toFixed(1)} MB`,ne=e=>{const t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,"0")}`},se=e=>{var t,i;switch(null===e||void 0===e||null===(t=e.split("."))||void 0===t||null===(i=t.pop())||void 0===i?void 0:i.toLowerCase()){case"pdf":return"\ud83d\udcc4";case"txt":return"\ud83d\udcdd";case"doc":case"docx":return"\ud83d\udcd1";case"xls":case"xlsx":return"\ud83d\udcca";case"ppt":case"pptx":return"\ud83d\udcfd\ufe0f";default:return"\ud83d\udcce"}},le=e=>{var t;const i=null===e||void 0===e||null===(t=e.response)||void 0===t?void 0:t.data;return null!==i&&void 0!==i&&i.detail?i.detail:null!==i&&void 0!==i&&i.title?i.title:(null===e||void 0===e?void 0:e.message)||"Something went wrong"},ae=e=>{var t;if(!e)return{displayName:"Private",phone:null};const i=(e.name||"").trim(),o=((null===e||void 0===e||null===(t=e.specifics)||void 0===t?void 0:t.phone_number)||(null===e||void 0===e?void 0:e.public_identifier)||"").replace(/@.*$/,"").trim(),r
1=oe(o)?o:null,n=i||r||"Private";return{displayName:n,phone:r&&r!==n?r:null}},de=(e,t)=>{if(!e)return null;const i=String(e).trim();if(t.has(i))return t.get(i).displayName;const o=i.replace(/@.*$/,"").trim();if(o&&t.has(o))return t.get(o).displayName;const r=o.replace(/\D/g,"");return r&&t.has(r)?t.get(r).displayName:i.includes("@")||/^\d{8,}$/.test(o)?"Private":o||"Private"};function ce(e){let{messageId:t,attachment:i,fromSelf:l}=e;const{attachmentid:a,filename:d,mimetype:c}=i,[x,h]=(0,o.useState)(null),[u,p]=(0,o.useState)(!1),[g,m]=(0,o.useState)(!1),f=(0,o.useCallback)(async()=>{if(x||u)return;p(!0);const e=await async function(e,t){try{return await(0,V.aO)(e,t)}catch(i){return console.error("Failed to fetch attachment:",t,i),null}}(t,a);h(e),p(!1),m(!0)},[x,u,t,a]);if(g&&x)return ee(c)?(0,G.jsx)(r.A,{sx:{mt:1},children:(0,G.jsx)(r.A,{component:"img",src:x,alt:d,sx:{maxWidth:"100%",maxHeight:{xs:180,md:200},borderRadius:1,display:"block",cursor:"pointer"},onClick:()=>window.open(x,"_blank")})}):te(c)?(0,G.jsx)(r.A,{sx:{mt:1},children:(0,G.jsx)(r.A,{component:"video",src:x,controls:!0,sx:{maxWidth:"100%",maxHeight:{xs:200,md:240},borderRadius:1,display:"block"}})}):ie(c)?(0,G.jsx)(r.A,{sx:{mt:1},children:(0,G.jsx)(r.A,{component:"audio",controls:!0,sx:{width:{xs:"100%",md:250},height:36},children:(0,G.jsx)("source",{src:x})})}):(0,G.jsx)(r.A,{sx:{mt:1},children:(0,G.jsxs)(r.A,{component:"a",href:x,download:d,target:"_blank",rel:"noreferrer",sx:{display:"inline-flex",alignItems:"center",gap:1,px:1.25,py:.75,borderRadius:1.5,bgcolor:"action.hover",border:"1px solid rgba(0,0,0,0.08)",textDecoration:"none",color:"rgba(0,0,0,0.8)",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"action.selected"}},children:[(0,G.jsx)("span",{style:{fontSize:16},children:se(d)}),(0,G.jsx)("span",{children:d||"Download"}),(0,G.jsx)(P.A,{sx:{fontSize:14,opacity:.6}})]})});const b=ee(c),j=te(c),v=ie(c),A=b?W.A:j?R.A:v?_.A:C.A,y=b?"Photo":j?"Video":v?"Audio":d||"File",S=l?q:"#475569";return(0,G.jsxs)(r.A,{onClick:f,sx:{mt:1,display:"inline-flex",alignItems:"center",gap:1,px:1.5,py:1,borderRadius:1.5,cursor:"pointer",bgcolor:l?"rgba(37,211,102,0.12)":"rgba(0,0,0,0.05)",border:"1px solid",borderColor:l?"rgba(37,211,102,0.3)":"rgba(0,0,0,0.10)","&:hover":{bgcolor:l?"rgba(37,211,102,0.2)":"rgba(0,0,0,0.09)"},transition:"background .15s"},children:[u?(0,G.jsx)(n.A,{size:16,sx:{color:S}}):(0,G.jsx)(A,{sx:{fontSize:18,color:S}}),(0,G.jsx)(s.A,{sx:{fontSize:12.5,fontWeight:600,color:S},children:u?"Loading\u2026":y}),!u&&(0,G.jsx)(B.A,{sx:{fontSize:14,color:S,opacity:.6}})]})}async function xe(e){var t,i,o;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Map;const n=e.id||e.message_id,s=(e.attachments||[]).map(e=>({attachmentid:e.attachmentid||e.id,filename:e.filename||e.file_name||e.name||"",mimetype:e.mimetype||e.type||"application/octet-stream",url:e.url||null})),l=(null===(t=e.sender_attendee)||void 0===t?void 0:t.name)||(null===(i=e.sender)||void 0===i?void 0:i.name)||de(e.sender_id,r)||de(null===(o=e.sender_attendee)||void 0===o?void 0:o.provider_id,r)||de(e.attendee_id,r)||de(e.from,r)||null,a=(e.reactions||[]).map(e=>({emoji:e.emoji||e.reaction||"",sender:de(e.sender_id||e.sender||e.from,r)||"Private"})).filter(e=>e.emoji),d=e.message||e.text||"",c=d.includes("Unipile cannot display this type of message");return{id:n||`${e.timestamp}-${Math.random()}`,text:c?"":d,isUnsupported:c,mine:Boolean(e.is_sender),timestamp:e.timestamp?new Date(e.timestamp).getTime():null,seen:e.seen,delivered:e.delivered,deleted:e.deleted||!1,edited:e.edited||!1,senderName:l,attachments:s,reactions:a}}function he(e){let{fromSelf:t}=e;const i=t?"rgba(0,0,0,0.38)":"rgba(0,0,0,0.30)",o=t?"rgba(0,0,0,0.48)":"rgba(0,0,0,0.38)",n=t?"rgba(0,0,0,0.32)":"rgba(0,0,0,0.26)";return(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",spacing:1,sx:{py:.25,minWidth:180},children:[(0,G.jsx)(r.A,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:(0,G.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,G.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),(0,G.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),(0,G.jsxs)(r.A,{children:[(0,G.jsx)(s.A,{sx:{fontSize:13.5,fontStyle:"italic",color:o,lineHeight:1.35},children:"This message isn't available."}),(0,G.jsx)(s.A,{sx:{fontSize:11,color:n,lineHeight:1.3,mt:.1},children:"Open WhatsApp to view this content."})]})]})}function ue(e){var t;let{m:i,isStacked:n,showSenderLabel:x,isGroup:h,allMessages:u,onEdit:p,onDelete:g,onReact:m}=e;const f=!!i.mine,[b,j]=(0,o.useState)(!1),[v,A]=(0,o.useState)(null);return(0,G.jsxs)(r.A,{onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),sx:{display:"flex",flexDirection:"column",alignItems:f?"flex-end":"flex-start"},children:[(0,G.jsx)(r.A,{sx:{height:34,mb:.4,visibility:b?"visible":"hidden",opacity:b?1:0,transition:"opacity .15s",display:"flex",alignItems:"center",justifyContent:f?"flex-end":"flex-start"},children:(0,G.jsxs)(l.A,{direction:"row",spacing:.25,sx:{bgcolor:"background.paper",borderRadius:999,border:"1px solid rgba(0,0,0,0.10)",boxShadow:"0 2px 8px rgba(0,0,0,0.12)",px:.75,py:.35},children:[Z.map(e=>(0,G.jsx)(a.A,{title:e,arrow:!0,children:(0,G.jsx)(d.A,{size:"small",onClick:()=>m(i.id,e),sx:{fontSize:15,width:26,height:26,"&:hover":{bgcolor:"action.selected"}},children:e})},e)),(0,G.jsx)(a.A,{title:"More",arrow:!0,children:(0,G.jsx)(d.A,{size:"small",onClick:e=>A(e.currentTarget),sx:{width:26,height:26,"&:hover":{bgcolor:"action.selected"}},children:(0,G.jsx)(L.A,{sx:{fontSize:15,color:"rgba(0,0,0,0.5)"}})})}),f&&(0,G.jsx)(a.A,{title:"Edit",arrow:!0,children:(0,G.jsx)(d.A,{size:"small",onClick:()=>p(i),sx:{width:26,height:26,"&:hover":{bgcolor:"action.selected"}},children:(0,G.jsx)(T.A,{sx:{fontSize:15,color:"rgba(0,0,0,0.5)"}})})}),(0,G.jsx)(a.A,{title:"Delete",arrow:!0,children:(0,G.jsx)(d.A,{size:"small",onClick:()=>g(i),sx:{width:26,height:26,"&:hover":{bgcolor:"action.selected"}},children:(0,G.jsx)(H.A,{sx:{fontSize:15,color:"#ef4444"}})})})]})}),(0,G.jsxs)(r.A,{sx:{maxWidth:{xs:"90%",md:"78%"},bgcolor:f?"#D9FDD3":"#FFFFFF",color:"rgba(0,0,0,0.9)",px:{xs:1.25,md:1.5},py:{xs:.7,md:.85},borderRadius:f?`8px 8px ${n?4:8}px 8px`:`8px 8px 8px ${n?4:8}px`,boxShadow:"0 1px 0.5px rgba(0,0,0,0.13)",cursor:"default"},children:[x&&(0,G.jsx)(s.A,{sx:{fontSize:12,fontWeight:700,color:q,mb:.25},children:i.senderName}),i.isUnsupported?(0,G.jsx)(he,{fromSelf:f}):i.text&&(0,G.jsx)(s.A,{sx:{fontSize:{xs:13.5,md:14},lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word",color:"rgba(0,0,0,0.87)"},children:i.text}),(i.attachments||[]).map(e=>(0,G.jsx)(ce,{messageId:i.id,attachment:e,fromSelf:f},e.attachmentid)),i.timestamp&&(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:.5,sx:{mt:.25}
1,children:[i.edited&&(0,G.jsx)(s.A,{sx:{fontSize:10,color:"rgba(0,0,0,0.4)",fontStyle:"italic"},children:"edited"}),(0,G.jsx)(s.A,{sx:{fontSize:10.5,color:"rgba(0,0,0,0.45)",fontVariantNumeric:"tabular-nums"},children:(0,Y.A)(i.timestamp).format("h:mm A")}),f&&(i.seen?(0,G.jsx)(F.A,{sx:{fontSize:14,color:"#2196f3"}}):i.delivered?(0,G.jsx)(F.A,{sx:{fontSize:14,color:"rgba(0,0,0,0.4)"}}):(0,G.jsx)(E.A,{sx:{fontSize:14,color:"rgba(0,0,0,0.4)"}}))]})]}),(null===(t=i.reactions)||void 0===t?void 0:t.length)>0&&(0,G.jsx)(l.A,{direction:"row",flexWrap:"wrap",gap:.5,sx:{mt:.5,justifyContent:f?"flex-end":"flex-start"},children:i.reactions.map((e,t)=>(0,G.jsx)(a.A,{title:e.sender,arrow:!0,children:(0,G.jsxs)(r.A,{sx:{display:"inline-flex",alignItems:"center",gap:.4,px:.9,py:.3,borderRadius:999,bgcolor:"background.paper",border:"1px solid rgba(0,0,0,0.10)",boxShadow:"0 1px 2px rgba(0,0,0,0.08)",cursor:"default"},children:[(0,G.jsx)(s.A,{sx:{fontSize:14,lineHeight:1},children:e.emoji}),(0,G.jsx)(s.A,{sx:{fontSize:10.5,fontWeight:600,color:"rgba(0,0,0,0.55)"},children:e.sender})]})},t))}),(0,G.jsx)(c.Ay,{open:Boolean(v),anchorEl:v,onClose:()=>A(null),anchorOrigin:{vertical:"top",horizontal:f?"right":"left"},transformOrigin:{vertical:"bottom",horizontal:f?"right":"left"},PaperProps:{sx:{borderRadius:2,overflow:"hidden"}},children:(0,G.jsx)(O.Ay,{onEmojiClick:e=>{m(i.id,e.emoji),A(null),j(!1)},height:350,width:320})})]})}function pe(e){let{editMsg:t,onCancel:i}=e;return t?(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",spacing:1,sx:{px:2,py:1,borderTop:"1px solid #E0E0E0",bgcolor:"background.paper",flexShrink:0},children:[(0,G.jsx)(T.A,{sx:{fontSize:18,color:"#F59E0B",flexShrink:0}}),(0,G.jsxs)(r.A,{sx:{flex:1,minWidth:0,borderLeft:"3px solid #F59E0B",pl:1},children:[(0,G.jsx)(s.A,{sx:{fontSize:11.5,fontWeight:700,color:"#B45309"},children:"Editing message"}),(0,G.jsx)(s.A,{noWrap:!0,sx:{fontSize:12,color:"rgba(0,0,0,0.6)"},children:t.text})]}),(0,G.jsx)(d.A,{size:"small",onClick:i,children:(0,G.jsx)(k.A,{sx:{fontSize:16}})})]}):null}function ge(e){let{chat:t,onClose:i,onMessageSent:F}=e;const B=(0,v.A)(),P=(0,x.A)(B.breakpoints.down("md")),[T,H]=(0,o.useState)([]),[L,Z]=(0,o.useState)(!1),[ee,te]=(0,o.useState)(!1),[ie,se]=(0,o.useState)(""),[de,ce]=(0,o.useState)([]),[he,ge]=(0,o.useState)(null),[me,fe]=(0,o.useState)(!1),[be,je]=(0,o.useState)(!1),[ve,Ae]=(0,o.useState)(!1),[ye,Se]=(0,o.useState)(0),[we,ze]=(0,o.useState)(null),[ke,Ce]=(0,o.useState)(null),[We,Re]=(0,o.useState)(null),[_e,Ie]=(0,o.useState)(!1),[De,Me]=(0,o.useState)(!1),[$e,Ee]=(0,o.useState)(null),[Fe,Be]=(0,o.useState)(null),Pe=(0,o.useRef)(null),Te=(0,o.useRef)(Q),He=(0,o.useRef)(null),Le=(0,o.useRef)(null),Oe=(0,o.useRef)([]),Ye=(0,o.useRef)(null),Ne=(0,o.useRef)(null),Ve=(0,o.useRef)(null),Ue=(0,o.useRef)(!1),Ge=(0,o.useRef)(0),Ke=(0,o.useRef)(null),qe=(e=>"boolean"===typeof(null===e||void 0===e?void 0:e.isGroup)?e.isGroup:"number"===typeof(null===e||void 0===e?void 0:e.attendeeCount)?e.attendeeCount>1:Array.isArray(null===e||void 0===e?void 0:e.attendees)&&e.attendees.length>1)(t),Xe=(0,o.useMemo)(()=>function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=new Map;for(const r of e){var i,o;const e=ae(r);r.provider_id&&t.set(r.provider_id,e);const n=(r.provider_id||"").replace(/@.*$/,"").trim();n&&t.set(n,e),r.public_identifier&&t.set(r.public_identifier,e);const s=(r.public_identifier||"").replace(/@.*$/,"").trim();s&&t.set(s,e);const l=((null===r||void 0===r||null===(i=r.specifics)||void 0===i?void 0:i.phone_number)||"").replace(/\D/g,"");l&&t.set(l,e);const a=((null===r||void 0===r||null===(o=r.specifics)||void 0===o?void 0:o.phone_number)||"").trim();a&&t.set(a,e)}return t}((null===t||void 0===t?void 0:t.attendees)||[]),[null===t||void 0===t?void 0:t.attendees]),Je=async e=>{if(!e)return H([]),Re(null),void Ie(!1);Z(!0);try{const t=await(0,V.lj)({chatId:e}),i=((null===t||void 0===t?void 0:t.items)||[]).slice().reverse(),o=await Promise.all(i.map(e=>xe(e,Xe)));H(o.filter(e=>!e.deleted)),Re((null===t||void 0===t?void 0:t.cursor)||null),Ie(Boolean(null===t||void 0===t?void 0:t.cursor))}catch(t){(0,N.D)((null===t||void 0===t?void 0:t.message)||"Failed to load messages","error")}finally{Z(!1)}};(0,o.useEffect)(()=>{H([]),Ce(null),Re(null),Ie(!1),Ee(null),Je(null===t||void 0===t?void 0:t.chatid)},[null===t||void 0===t?void 0:t.chatid]),(0,o.useEffect)(()=>{const e=Ve.current;e&&(Ue.current?(e.scrollTop=e.scrollHeight-Ge.current,Ue.current=!1):e.scrollTop=e.scrollHeight)},[T,L]),(0,o.useEffect)(()=>()=>{Ye.current&&clearInterval(Ye.current);try{var e;"inactive"!==(null===(e=He.current)||void 0===e?void 0:e.state)&&He.current.stop()}catch{}
1Le.current&&(Le.current.getTracks().forEach(e=>e.stop()),Le.current=null)},[null===t||void 0===t?void 0:t.chatid]),(0,o.useEffect)(()=>{var e;$e&&(se($e.text||""),null===(e=Ke.current)||void 0===e||e.focus())},[$e]);const Qe=(0,o.useMemo)(()=>{const e=[];for(const t of T){const i=t.timestamp?(0,Y.A)(t.timestamp):(0,Y.A)();if(!i.isValid())continue;const o=e[e.length-1];o&&(0,Y.A)(o.date).isSame(i,"day")?o.messages.push(t):e.push({date:t.timestamp||Date.now(),messages:[t]})}return e},[T]),Ze=e=>{const t=(0,Y.A)(e),i=(0,Y.A)();return t.isSame(i,"day")?"Today":t.isSame(i.clone().subtract(1,"day"),"day")?"Yesterday":t.isSame(i,"week")?t.format("dddd"):t.isSame(i,"year")?t.format("MMMM D"):t.format("MMMM D, YYYY")},et=e=>{Te.current=e,ge(null),setTimeout(()=>{var e;return null===(e=Pe.current)||void 0===e?void 0:e.click()},0)},tt=async()=>{if(!ve){ge(null);try{ze(null);const e=await navigator.mediaDevices.getUserMedia({audio:!0});let t;Le.current=e;try{t=new MediaRecorder(e,{mimeType:"audio/webm"})}catch{t=new MediaRecorder(e)}He.current=t,Oe.current=[],t.ondataavailable=e=>{var t;(null===(t=e.data)||void 0===t?void 0:t.size)>0&&Oe.current.push(e.data)},t.onstop=()=>{var e;const i=(null===(e=Oe.current[0])||void 0===e?void 0:e.type)||t.mimeType||"audio/webm",o=new Blob(Oe.current,{type:i});o.size>0&&ze(o),Le.current&&(Le.current.getTracks().forEach(e=>e.stop()),Le.current=null)},t.start(),Ne.current=Date.now(),Se(0),Ae(!0),Ye.current=setInterval(()=>Se(Date.now()-(Ne.current||Date.now())),200)}catch(e){(0,N.D)((null===e||void 0===e?void 0:e.message)||"Could not access microphone","error")}}},it=async()=>{if(null===t||void 0===t||!t.chatid)return;if($e){const e=ie.trim();if(!e)return;try{await async function(e,t){return(0,V.u_)(e,t)}($e.id,e),H(t=>t.map(t=>t.id===$e.id?{...t,text:e,edited:!0}:t)),(0,N.D)("Message updated","success")}catch(n){(0,N.D)(le(n),"error")}return se(""),void Ee(null)}const e=ie.trim(),i=[...de];if(we){const e=(we.type||"").includes("mp4")?"m4a":"webm";i.push(new File([we],`voice-${Date.now()}.${e}`,{type:we.type||"audio/webm"}))}if(e||i.length){te(!0);try{var o,r;await(0,V._z)({chatId:t.chatid,text:e,files:i});const n=[];e&&n.push(e),i.length&&n.push(i.map(e=>{var t;return null!==(t=e.type)&&void 0!==t&&t.startsWith("audio/")?"\ud83c\udfa4 Voice note":`\ud83d\udcce ${e.name}`}).join("\n"));const s={id:`local-${Date.now()}`,text:n.join("\n"),mine:!0,timestamp:Date.now(),attachments:[],reactions:[]};H(e=>[...e,s]),se(""),ce([]),ze(null),Se(0),je(!1),null===F||void 0===F||F(e||(null!==(o=null===(r=i[0])||void 0===r?void 0:r.name)&&void 0!==o?o:"attachment"))}catch(n){(0,N.D)((null===n||void 0===n?void 0:n.message)||"Failed to send","error")}finally{te(!1)}}},ot=async(e,t)=>{try{await async function(e,t){return(0,V.$A)(e,t)}(e,t),H(i=>i.map(i=>{if(i.id!==e)return i;const o=i.reactions||[];return o.find(e=>e.emoji===t&&"You"===e.sender)?i:{...i,reactions:[...o,{emoji:t,sender:"You"}]}}))}catch(i){(0,N.D)((null===i||void 0===i?void 0:i.message)||"Failed to react","error")}},rt=e=>{Ee(e)},nt=e=>Be(e);if(!t)return(0,G.jsxs)(r.A,{sx:{display:"flex",height:"100%",minHeight:{xs:300,md:620},alignItems:"center",justifyContent:"center",flexDirection:"column",bgcolor:X,color:"text.secondary",px:4,textAlign:"center"},children:[(0,G.jsx)(r.A,{sx:{width:72,height:72,borderRadius:"50%",bgcolor:`${K}1A`,mb:2,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,G.jsx)(M.A,{sx:{fontSize:34,color:K}})}),(0,G.jsx)(s.A,{sx:{fontSize:16,fontWeight:700,color:"rgba(0,0,0,0.85)",mb:.5},children:"Pick a conversation"}),(0,G.jsx)(s.A,{sx:{fontSize:13,color:"rgba(0,0,0,0.55)",maxWidth:280},children:"Select a chat from the left to read and reply."})]});const st=Boolean(ie.trim()||de.length>0||we);return(0,G.jsxs)(r.A,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,bgcolor:X},children:[(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",spacing:{xs:1,md:1.5},sx:{px:{xs:1.5,md:2.25},py:{xs:1,md:1.5},borderBottom:"1px solid #E0E0E0",bgcolor:"background.paper",flexShrink:0},children:[i&&(0,G.jsx)(U.A,{label:"Back to Inbox",onClick:i}),(0,G.jsxs)(r.A,{sx:{position:"relative",flexShrink:0},children:[t.picture?(0,G.jsx)(h.A,{src:t.picture,sx:{width:{xs:38,md:44},height:{xs:38,md:44},border:"1px solid rgba(0,0,0,0.06)"}}):(0,G.jsx)(h.A,{sx:{width:{xs:38,md:44},height:{xs:38,md:44},fontSize:{xs:13,md:15},fontWeight:700,bgcolor:qe?"rgba(0,0,0,0.08)":`${K}1A`,color:qe?"rgba(0,0,0,0.55)":K,border:"1px solid rgba(0,0,0,0.06)"},children:qe?(0,G.jsx)($.A,{sx:{fontSize:20}}):(0,V.bB)(t.name)}),qe&&(0,G.jsx)(r.A,{sx:{position:"absolute",bottom:-2,right:-2,width:16,height:16,borderRadius:"50%",bgcolor:K,border:"2px s
1olid #fff",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,G.jsx)($.A,{sx:{fontSize:10,color:"#fff"}})})]}),(0,G.jsxs)(r.A,{sx:{flex:1,minWidth:0},children:[(0,G.jsx)(s.A,{sx:{fontSize:{xs:14,md:15},fontWeight:700,lineHeight:1.3,color:"rgba(0,0,0,0.9)"},noWrap:!0,children:t.name||"\u2014"}),qe?(0,G.jsx)(s.A,{onClick:e=>{e.stopPropagation(),Ce(e.currentTarget)},sx:{fontSize:{xs:11,md:12},color:"rgba(0,0,0,0.6)",lineHeight:1.3,cursor:"pointer",width:"fit-content","&:hover":{color:q,textDecoration:"underline"}},noWrap:!0,children:t.attendeeCount?`${t.attendeeCount} participants`:"Group"}):oe(t.phone)&&(0,G.jsx)(s.A,{sx:{fontSize:{xs:11,md:12},color:"rgba(0,0,0,0.6)",lineHeight:1.3},noWrap:!0,children:t.phone})]}),(0,G.jsx)(a.A,{title:"Sync messages",children:(0,G.jsx)(d.A,{size:"small",onClick:()=>Je(null===t||void 0===t?void 0:t.chatid),sx:{border:"1px solid",borderColor:"divider",borderRadius:2,"&:hover":{borderColor:K,bgcolor:`${K}0d`}},children:(0,G.jsx)(D.A,{sx:{fontSize:16,color:K}})})})]}),qe&&(0,G.jsxs)(c.Ay,{open:Boolean(ke),anchorEl:ke,onClose:()=>Ce(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{borderRadius:2,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",mt:.5,minWidth:240,maxWidth:320}},children:[(0,G.jsx)(r.A,{sx:{px:2,py:1.25,borderBottom:"1px solid #F0F0F0"},children:(0,G.jsx)(s.A,{sx:{fontSize:13,fontWeight:700},children:t.attendeeCount?`${t.attendeeCount} participants`:"Participants"})}),(0,G.jsx)(r.A,{sx:{maxHeight:320,overflowY:"auto",py:.5},children:0===(t.attendees||[]).length?(0,G.jsx)(s.A,{sx:{fontSize:13,color:"text.secondary",px:2,py:1.5},children:"No participant details available."}):Array.from(new Map((t.attendees||[]).map(e=>[e.provider_id||e.id,e])).values()).map((e,t)=>{const{displayName:i,phone:o}=ae(e),n="Private"===i;return(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",spacing:1.25,sx:{px:2,py:.85},children:[e.picture_url?(0,G.jsx)(h.A,{src:e.picture_url,sx:{width:32,height:32}}):(0,G.jsx)(h.A,{sx:{width:32,height:32,fontSize:12,fontWeight:700,bgcolor:n?"rgba(0,0,0,0.07)":`${K}1A`,color:n?"rgba(0,0,0,0.4)":K},children:n?"?":(0,V.bB)(i)}),(0,G.jsxs)(r.A,{sx:{minWidth:0},children:[(0,G.jsx)(s.A,{noWrap:!0,sx:{fontSize:13,fontWeight:600,color:n?"rgba(0,0,0,0.4)":"rgba(0,0,0,0.85)",fontStyle:n?"italic":"normal"},children:i}),o&&(0,G.jsx)(s.A,{noWrap:!0,sx:{fontSize:11.5,color:"rgba(0,0,0,0.5)"},children:o})]})]},e.provider_id||t)})})]}),(0,G.jsx)(r.A,{ref:Ve,onScroll:()=>{const e=Ve.current;e&&!L&&e.scrollTop<60&&_e&&!De&&(async()=>{if(null===t||void 0===t||!t.chatid||!We||De)return;const e=Ve.current;Ue.current=!0,Ge.current=(null===e||void 0===e?void 0:e.scrollHeight)||0,Me(!0);try{const e=await(0,V.lj)({chatId:t.chatid,cursor:We}),i=((null===e||void 0===e?void 0:e.items)||[]).slice().reverse(),o=(await Promise.all(i.map(e=>xe(e,Xe)))).filter(e=>!e.deleted);H(e=>{const t=new Set(e.map(e=>e.id));return[...o.filter(e=>!t.has(e.id)),...e]}),Re((null===e||void 0===e?void 0:e.cursor)||null),Ie(Boolean(null===e||void 0===e?void 0:e.cursor))}catch(i){Ue.current=!1,(0,N.D)((null===i||void 0===i?void 0:i.message)||"Failed to load older messages","error")}finally{Me(!1)}})()},sx:{flex:1,minHeight:0,overflowY:"auto",overflow:"hidden auto",px:{xs:1.5,md:2.5},py:2,bgcolor:X,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-thumb":{bgcolor:"rgba(0,0,0,0.18)",borderRadius:3}},children:L&&0===T.length?(0,G.jsx)(r.A,{sx:{textAlign:"center",py:8},children:(0,G.jsx)(n.A,{size:24,sx:{color:K}})}):0===T.length?(0,G.jsxs)(r.A,{sx:{textAlign:"center",py:8},children:[(0,G.jsx)(s.A,{sx:{fontSize:14,fontWeight:600,mb:.5},children:"No messages yet"}),(0,G.jsx)(s.A,{variant:"caption",color:"text.secondary",children:"Say hi \ud83d\udc4b to start the conversation."})]}):(0,G.jsxs)(l.A,{spacing:2.5,children:[De&&(0,G.jsx)(r.A,{sx:{textAlign:"center",py:1},children:(0,G.jsx)(n.A,{size:18,sx:{color:K}})}),Qe.map((e,t)=>(0,G.jsxs)(r.A,{children:[(0,G.jsxs)(r.A,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1.25,my:2},children:[(0,G.jsx)(r.A,{sx:{flex:1,height:1,bgcolor:"action.selected"}}),(0,G.jsx)(s.A,{sx:{color:"rgba(0,0,0,0.55)",fontSize:11,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",bgcolor:"background.paper",px:1,py:.25,borderRadius:999,boxShadow:"0 1px 1px rgba(0,0,0,0.04)",whiteSpace:"nowrap"},children:Ze(e.date)}),(0,G.jsx)(r.A,{sx:{flex:1,height:1,bgcolor:"action.selected"}})]}),(0,G.jsx)(l.A,{spacing:.75,children:e.messages.map((t,i)=>{const o=!!t.mine,r=i>0?e.messages[i-1]:null,n=r&&!!r.mine===o&&Math.abs((0,Y.A)(t.timestamp).diff((0,Y.A)(r.timestamp),"minutes"))<5,s=qe&&!o&&t.senderName&&!(n&&(null===r||void 0===r?void 0:r.senderName)===t.senderName);return(0,G.jsx)(ue,{m:t,isStacked:n,showSenderLabel:s,isGroup:qe,allMessages:T,onEdit:rt,onDelete:nt,onReact:ot},t.id)})})]},`${e.date}-${t}`))]})}),de.length>0&&!ve&&(0,G.jsx)(l.A,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",sx:{px:{xs:1.5,md:2},py:1.25,borderTop:"1px solid #E0E0E0",bgcolor:"background.paper",flexShrink:0},children:de.map((e,t)=>{var i,o,r;const n=null!==(i=e.type)&&void 0!==i&&i.startsWith("image/")?W.A:null!==(o=e.type)&&void 0!==o&&o.startsWith("video/")?R.A:null!==(r=e.type)&&void 0!==r&&r.startsWith("audio/")?_.A:I.A;return(0,G.jsx)(u.A,{icon:(0,G.jsx)(n,{sx:{fontSize:16,color:q}}),label:`${e.name} \xb7 ${re(e.size)}`,onDelete:()=>{return e=t,ce(t=>t.filter((t,i)=>i!==e));var e},size:"small",sx:{fontSize:11.5,fontWeight:600,maxWidth:{xs:180,md:240},borderRadius:999,bgcolor:"background.paper",border:"1px solid rgba(0,0,0,0.1)","& .MuiChip-label":{textOverflow:"ellipsis",overflow:"hidden"},"& .MuiChip-deleteIcon":{color:"rgba(0,0,0,0.45)","&:hover":{color:"rgba(0,0,0,0.75)"}}}},t)})}),be&&(0,G.jsx)(p.A,{error:!0,sx:{px:2,py:.5,bgcolor:"background.paper",borderTop:"1px solid #FCE7B6",fontSize:12,flexShrink:0},children:"File size should not be greater than 20 MB."}),we&&!ve&&(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",spacing:1.25,sx:{px:{xs:1.5,md:2},py:1.25,borderTop:"1px solid #E0E0E0",bgcolor:`${K}10`,flexShrink:0},children:[(0,G.jsx)(r.A,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:K,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,G.jsx)(_.A,{sx:{fontSize:20}})}),(0,G.jsxs)(r.A,{sx:{flex:1,minWidth:0},children:[(0,G.jsx)(s.A,{sx:{fontSize:13,fontWeight:700},children:"Voice message ready"}),(0,G.jsxs)(s.A,{sx:{fontSize:11.5,color:"rgba(0,0,0,0.6)"},children:[ne(ye)," \xb7 ",re(we.size)]})]}),(0,G.jsx)(a.A,{title:"Discard recording",children:(0,G.jsx)(d.A,{size:"small",onClick:()=>{ze(null),Se(0)},children:(0,G.jsx)(k.A,{sx:{fontSize:18}})})})]}),(0,G.jsx)(pe,{editMsg:$e,onCancel:()=>{Ee(null),se("")}}),ve?(0,G.jsxs)(l.A,{direction:"row",alignItems:"center",spacing:1.5,sx:{px:{xs:1.5,md:2},py:1.5,borderTop:"1px solid #E0E0E0",bgcolor:"background.paper",flexShrink:0},children:[(0,G.jsx)(r.A,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:"#dc2626",flexShrink:0,animation:"blink 1.2s infinite","@keyframes blink":{"0%":{opacity:1},"50%":{opacity:.25},"100%":{opacity:1}}}}),(0,G.jsxs)(s.A,{sx:{fontSize:13,fontWeight:700,fontVariantNumeric:"tabular-nums"},children:["Recording \xb7 ",ne(ye)]}),(0,G.jsx)(r.A,{sx:{flex:1}}),(0,G.jsx)(a.A,{title:"Discard",children:(0,G.jsx)(d.A,{size:"small",onClick:()=>{Ye.current&&(clearInterval(Ye.current),Ye.current=null);try{var e;"inactive"!==(null===(e=He.current)||void 0===e?void 0:e.state)&&He.current.stop()}catch{}
1Le.current&&(Le.current.getTracks().forEach(e=>e.stop()),Le.current=null),Ae(!1),ze(null),Se(0),Oe.current=[]},children:(0,G.jsx)(k.A,{sx:{fontSize:20}})})}),(0,G.jsx)(a.A,{title:"Stop & preview",children:(0,G.jsx)(d.A,{size:"small",onClick:()=>{Ye.current&&(clearInterval(Ye.current),Ye.current=null);try{var e;"inactive"!==(null===(e=He.current)||void 0===e?void 0:e.state)&&He.current.stop()}catch{}Ae(!1)},sx:{bgcolor:"#dc2626",color:"#fff","&:hover":{bgcolor:"#b91c1c"}},children:(0,G.jsx)(z.A,{sx:{fontSize:18}})})})]}):(0,G.jsxs)(r.A,{sx:{borderTop:"1px solid #E0E0E0",bgcolor:"background.paper",px:{xs:1,md:1.5},py:{xs:.75,md:1},display:"flex",alignItems:"center",gap:{xs:.25,md:.5},flexShrink:0},children:[(0,G.jsx)(a.A,{title:"Emoji",children:(0,G.jsx)(d.A,{size:"small",onClick:()=>fe(e=>!e),children:(0,G.jsx)(S.A,{sx:{fontSize:{xs:20,md:22},color:"rgba(0,0,0,0.55)"}})})}),(0,G.jsx)(a.A,{title:"Attach",children:(0,G.jsx)(d.A,{size:"small",onClick:e=>ge(e.currentTarget),children:(0,G.jsx)(y.A,{sx:{fontSize:{xs:20,md:22},color:"rgba(0,0,0,0.55)"}})})}),(0,G.jsx)(c.Ay,{open:Boolean(he),anchorEl:he,onClose:()=>ge(null),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},PaperProps:{sx:{borderRadius:2,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",mt:-1}},children:(0,G.jsxs)(l.A,{direction:"row",spacing:1,sx:{p:1.5},children:[(0,G.jsx)(a.A,{title:"Photos",children:(0,G.jsx)(d.A,{onClick:()=>et(Q),sx:{width:44,height:44,borderRadius:"50%",bgcolor:"#BF59CF",color:"#fff","&:hover":{bgcolor:"#a44ab2"}},children:(0,G.jsx)(W.A,{sx:{fontSize:20}})})}),(0,G.jsx)(a.A,{title:"Video",children:(0,G.jsx)(d.A,{onClick:()=>et("video/*"),sx:{width:44,height:44,borderRadius:"50%",bgcolor:"#5F66CD",color:"#fff","&:hover":{bgcolor:"#4f56b8"}},children:(0,G.jsx)(R.A,{sx:{fontSize:20}})})}),(0,G.jsx)(a.A,{title:"Document",children:(0,G.jsx)(d.A,{onClick:()=>et("application/pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv"),sx:{width:44,height:44,borderRadius:"50%",bgcolor:"#5157AE",color:"#fff","&:hover":{bgcolor:"#454aa0"}},children:(0,G.jsx)(C.A,{sx:{fontSize:20}})})}),(0,G.jsx)(a.A,{title:"Voice message",children:(0,G.jsx)(d.A,{onClick:tt,sx:{width:44,height:44,borderRadius:"50%",bgcolor:K,color:"#fff","&:hover":{bgcolor:q}},children:(0,G.jsx)(w.A,{sx:{fontSize:20}})})})]})}),(0,G.jsx)("input",{ref:Pe,type:"file",multiple:!0,hidden:!0,onChange:e=>{const t=Array.from(e.target.files||[]);if(!t.length)return;const i=t.find(e=>e.size>J);i?(je(!0),(0,N.D)(`"${i.name}" is over 20 MB`,"error")):je(!1),ce(e=>[...e,...t.filter(e=>e.size<=J)]),e.target&&(e.target.value="")},accept:Te.current}),(0,G.jsx)(g.A,{inputRef:Ke,fullWidth:!0,multiline:!0,maxRows:5,size:"small",placeholder:$e?"Edit message\u2026":we?"Add a caption (optional)\u2026":"Type a message",value:ie,onChange:e=>se(e.target.value),disabled:ee,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),it()),"Escape"===e.key&&(Ee(null),se(""))},sx:{mx:.5,"& .MuiOutlinedInput-root":{borderRadius:999,bgcolor:$e?"#FFFDE7":"#FFFFFF",fontSize:{xs:13.5,md:14},py:.5,"& fieldset":{borderColor:"transparent"},"&:hover fieldset":{borderColor:"transparent"},"&.Mui-focused fieldset":{borderColor:"transparent"}}}}),st?(0,G.jsx)(a.A,{title:$e?"Save (Enter)":"Send (Enter)",children:(0,G.jsx)("span",{children:(0,G.jsx)(d.A,{onClick:it,disabled:ee,sx:{bgcolor:$e?"#F59E0B":K,color:"#fff",width:36,height:36,"&:hover":{bgcolor:$e?"#D97706":q},"&.Mui-disabled":{bgcolor:"action.selected"}},children:ee?(0,G.jsx)(n.A,{size:16,sx:{color:"#fff"}}):$e?(0,G.jsx)(E.A,{sx:{fontSize:18}}):(0,G.jsx)(A.A,{sx:{fontSize:18}})})})}):(0,G.jsx)(a.A,{title:"Record voice message",children:(0,G.jsx)("span",{children:(0,G.jsx)(d.A,{onClick:tt,disabled:ee,sx:{bgcolor:K,color:"#fff",width:36,height:36,"&:hover":{bgcolor:q},"&.Mui-disabled":{bgcolor:"action.selected"}},children:(0,G.jsx)(w.A,{sx:{fontSize:18}})})})})]}),(0,G.jsxs)(m.A,{open:me,onClose:()=>fe(!1),fullScreen:P,maxWidth:"xs",PaperProps:{sx:{borderRadius:P?0:3,overflow:"hidden"}},children:[(0,G.jsx)(f.A,{sx:{p:1},children:(0,G.jsx)(O.Ay,{onEmojiClick:e=>{se(t=>t+((null===e||void 0===e?void 0:e.emoji)||"")),fe(!1)},width:"100%"})}),(0,G.jsx)(b.A,{sx:{pb:1.5,pr:2},children:(0,G.jsx)(j.A,{onClick:()=>fe(!1),size:"small",variant:"outlined",sx:{borderRadius:999,textTransform:"none",fontWeight:600,borderColor:K,color:q,"&:hover":{borderColor:q,bgcolor:`${K}10`}},children:"Close"})})]}),(0,G.jsx)(m.A,{open:Boolean(Fe),onClose:()=>Be(null),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:2.5}},children:(0,G.jsxs)(r.A,{sx:{p:2.5},children:[(0,G.jsx)(s.A,{sx:{fontWeight:700,fontSize:15,mb:.75},children:"Delete message?"}),(null===Fe||void 0===Fe?void 0:Fe.text)&&(0,G.jsx)(r.A,{sx:{mb:1.5,p:1.25,borderRadius:1.5,bgcolor:"action.hover",border:"1px solid rgba(0,0,0,0.08)"},children:(0,G.jsx)(s.A,{sx:{fontSize:13,color:"rgba(0,0,0,0.7)",lineHeight:1.45},noWrap:!0,children:Fe.text})}),(0,G.jsx)(s.A,{sx:{fontSize:13,color:"rgba(0,0,0,0.55)",mb:2},children:"This cannot be undone."}),(0,G.jsxs)(l.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,G.jsx)(j.A,{variant:"outlined",onClick:()=>Be(null),sx:{borderRadius:1.5,textTransform:"none",fontWeight:600},children:"Cancel"}),(0,G.jsx)(j.A,{variant:"contained",color:"error",onClick:async()=>
1{if(Fe){try{await async function(e){return(0,V.RC)(e)}(Fe.id),H(e=>e.filter(e=>e.id!==Fe.id)),(0,N.D)("Message deleted","success")}catch(e){(0,N.D)(le(e),"error")}Be(null)}},sx:{borderRadius:1.5,textTransform:"none",fontWeight:700,boxShadow:"none"},children:"Delete"})]})]})})]})}}}]);
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.