1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[687],{4474:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/[chatId]",function(){return l(8101)}])},7735:(e,t,l)=>{"use strict";l.d(t,{A:()=>u});var s=l(4848),r=l(6540),a=l(7292),n=l(9748),i=l(2506),d=l(9409),o=l(187),c=l(8963);let u=function(e){let{onSend:t,isLoadingSend:l,hasPermissionToSendFiles:u,text:f,loadingAnswer:x}=e,m=(0,r.useRef)(null),h=(0,r.useRef)(null),{isAuthenticated:v}=(0,d.P)(),[p,g]=(0,r.useState)(!1),j=(0,c.KN)(e=>{var t;return null===(t=e.user)||void 0===t?void 0:t.isAvailableEloxChat}),w=()=>{if(!v){(0,i.i)();return}if(!j){g(!0);return}m.current&&m.current.value.trim().length>=1&&(t({files:[],message:m.current.value}),m.current.value="",setTimeout(()=>{var e;null===(e=m.current)||void 0===e||e.focus()},1))};return(0,r.useEffect)(()=>{f&&m.current&&(m.current.value=f)},[f]),(0,s.jsxs)("div",{className:"w-full flex items-center gap-4 py-5 px-4 md:py-6 md:px-5 bg-white border-t border-slate-100",children:[(0,s.jsx)(o.C,{onCancel:()=>g(!1),isOpen:p}),(0,s.jsx)("input",{type:"file",accept:"image/*",hidden:!0,ref:h,multiple:!1,onChange:e=>{var l;let s=null===(l=e.target.files)||void 0===l?void 0:l[0];s&&t({files:[s],message:""})}}),u?(0,s.jsx)(n.$,{variant:"ghost",onClick:()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.click()},children:(0,s.jsx)(a.A,{className:"w-4 h-4 md:w-6 md:h-6 stroke-1 text-slate-500 mx-3"})}):null,(0,s.jsxs)("div",{className:"overflow-hidden bg-white relative rounded-full w-full border border-slate-200",children:[(0,s.jsx)("input",{ref:m,disabled:l||x,className:"py-2.5 px-5 w-full h-full rounded-full text-base md:text-base font-light placeholder:text-muted-foreground hover:border-none focus:border-none focus:outline-none disabled:text-gray-300 focus:zoom-in-0",placeholder:"Escreva sua mensagem",onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())}}),(0,s.jsx)(n.$,{variant:"ghost",className:"absolute right-0 top-0 flex items-center text-base justify-center max-w-full max-h-full hover:bg-transparent hover:text-xl transition-all duration-200",onClick:w,children:l||x?(0,s.jsx)("i",{className:"ri-checkbox-blank-fill"}):(0,s.jsx)("i",{className:"ri-send-plane-2-fill"})})]})]})}},8101:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>O});var s=l(4848),r=l(7735),a=l(4353),n=l.n(a),i=l(6540),d=l(8727);function o(e){let{image:t}=e;return(0,s.jsx)(d.eu,{children:(0,s.jsx)(d.BK,{src:t})})}l(4840);var c=l(4674),u=l(2918),f=l(8013),x=l(1911),m=l(3383);function h(e){let{text:t}=e;return(0,s.jsx)(c.o,{remarkPlugins:[m.A],rehypePlugins:[x.A,[u.A,{detect:!0}],[f.A,{showLineNumbers:!0}]],children:t})}var v=l(7004),p=l(548),g=l(7980);let j=g.w.token("colors.red.600"),w=g.w.token("colors.purple.500"),y=g.w.token("colors.gray.500"),b=function(e){let{message:t}=e;return t.error?(0,s.jsx)(v._Sh,{color:j,fontSize:14}):t.received?(0,s.jsx)(p.wNL,{color:w,fontSize:14}):t.sent?(0,s.jsx)(p.vbi,{color:y,fontSize:14}):t.pending?(0,s.jsx)(v.Hwb,{color:y,fontSize:14}):null},N={src:"/_next/static/media/user-placeholder.e95632dc.png"};var A=l(780);function k(e){var t,l,r;let{message:a,showTicks:i=!0,showName:c=!0,user:u}=e;if(!(null==a?void 0:null===(t=a.sender)||void 0===t?void 0:t.id)||!(null==a?void 0:a.id))return null;let f=a.sender.id===(null==u?void 0:u.id);return(0,s.jsxs)("div",{className:(0,A.cn)("flex gap-4",a.system?"justify-center":"justify-start",f?"flex-row-reverse":"flex-row"),children:[!a.system&&!f&&(0,s.jsx)(d.eu,{className:"hidden md:flex shadow-sm",children:(0,s.jsx)(d.BK,{src:null!==(r=a.sender.avatar)&&void 0!==r?r:N.src})}),(0,s.jsx)("div",{className:"flex-shrink min-w-[220px] max-w-[66%]",children:(0,s.jsxs)("div",{className:(0,A.cn)("flex flex-col flex-1 rounded-lg px-3 py-1.5 gap-0.5 shadow-sm",f?"rounded-tr-none":"rounded-tl-none",a.system?"bg-transparent text-gray-900":"bg-white text-gray-700"),children:[!f&&c&&(0,s.jsx)("div",{className:"flex",children:(0,s.jsx)("div",{className:"flex flex-1 gap-2",children:(0,s.jsx)("p",{className:"font-bold truncate",children:null===(l=a.sender.name)||void 0===l?void 0:l.split(" ").slice(0,2).join(" ")})})}),(0,s.jsxs)("div",{className:(0,A.cn)("flex flex-col gap-1 text-sm text-gray-700",a.system&&"text-center"),children:[a.content&&(0,s.jsx)(h,{text:a.content}),!a.deletedAt&&a.image&&(0,s.jsx)(o,{image:a.image})]}),!a.system&&(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("span",{className:"text-gray-500 text-sm",children:n()(a.createdAt).format("HH:mm")}
1),f&&i&&(0,s.jsx)("div",{className:"w-3.5",children:i&&(0,s.jsx)(b,{message:a})})]})]})})]})}var _=l(9010);function E(){return(0,s.jsxs)("div",{className:"flex px-2 mb-2 relative top-[-2px] gap-2 ".concat("flex-row"," justify-start"),children:[(0,s.jsx)("div",{className:"w-[40px] h-[30px] opacity-0 rounded-full bg-gray-100 bg-no-repeat bg-center bg-auto"}),(0,s.jsx)("div",{className:"flex flex-col w-[70px] h-[48px] rounded-lg shadow-sm py-1 bg-white items-center justify-center",children:(0,s.jsx)("span",{className:"scale-[0.35] p-0 absolute bg-transparent",children:(0,s.jsx)(_.A,{className:"p-0 m-0",size:28,color:"rgba(0, 40, 60, 0.35)"})})})]})}var C=l(9409);function S(e){let{messages:t}=e,{data:l}=(0,C.P)(),r=(0,i.useRef)(null),{messagesGroupedByDate:a,isLoading:d}=(0,i.useMemo)(()=>{let e=new Map,s=!1,r=[...t].sort((e,t)=>n()(e.createdAt).diff(n()(t.createdAt))),a=r[r.length-1];for(let t of r){var i;s=!0;let l=n()(t.createdAt).format("DD/MM/YYYY");e.has(l)||e.set(l,{date:l,items:[]}),null===(i=e.get(l))||void 0===i||i.items.push(t)}return{messagesGroupedByDate:[...e].map(e=>{let[,t]=e;return{...t,items:[...t.items]}}).sort((e,t)=>n()(t.date,"DD/MM/YYYY").diff(n()(e.date,"DD/MM/YYYY"))),isLoading:s&&a&&a.sender.id===(null==l?void 0:l.id)}},[t,null==l?void 0:l.id]);return(0,i.useEffect)(()=>{r.current&&r.current.scrollTo({top:r.current.scrollHeight,behavior:"smooth"})},[t]),(0,s.jsx)("div",{className:"flex flex-1 h-full overflow-hidden px-4 flex-col-reverse",children:(0,s.jsxs)("div",{ref:r,className:"w-full overflow-y-auto scrollbar-hide flex flex-col",children:[a.map(e=>(0,s.jsxs)("div",{className:"w-full my-3 flex flex-col gap-3",children:[(0,s.jsx)(Y,{children:e.date}),e.items.map(e=>(0,s.jsx)(k,{message:e,user:l,showTicks:!1,showName:!1},e.id))]},e.date)),d&&(0,s.jsx)(E,{})]})})}function Y(e){let{children:t}=e;return(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("div",{className:"shadow-sm text-xs md:text-sm leading-6 font-light text-gray-500 px-4 py-2 bg-white rounded-full",children:t})})}var D=l(4135),M=l(3886),P=l(1884),z=l(1303),B=l(8963);async function H(e,t,l,s){let r=(0,P.rJ)(D.kA,"chats"),a=(0,P.H9)(r,t),n={sender:{avatar:e.avatar||null,name:e.name,id:e.id,type:"user"},content:l,createdAt:(0,P.O5)(),updatedAt:(0,P.O5)(),type:"text"},i=(0,P.rJ)(a,"messages");s(!0),await (0,P.BN)((0,P.H9)(i,(0,z.A)()),n)}function K(e){let{chatId:t}=e,{loading:l,messages:a,sendMessage:d,loadingAnswer:o}=function(e){let t=(0,i.useRef)(null),{data:l}=(0,C.P)(),[s,r]=(0,i.useState)([]),[a,d]=(0,i.useState)(!1),[o,c]=(0,i.useState)(!1),[u,f]=(0,i.useState)(null),x=(0,B.KN)(e=>{var t;return null===(t=e.user)||void 0===t?void 0:t.isAvailableEloxChat}),m=(0,i.useCallback)(async()=>{d(!0),f(null);try{var s,a;null===(s=t.current)||void 0===s||s.call(t);let i=await M.L.get("api/chats/".concat(e)).json();r(i),t.current=function(e,t,l,s){let r=(0,P.P)((0,P.rJ)(D.kA,"chats",e,"messages"),(0,P._M)("updatedAt",">",new Date));return(0,P.aQ)(r,e=>
1{e.docChanges().forEach(e=>{if("added"===e.type){var r;let a=e.doc.data();a.id=e.doc.id,a.createdAt=null===(r=a.createdAt)||void 0===r?void 0:r.toDate(),a.sender.id!==l&&s(!1),t(a)}})})}(e,e=>{r(t=>t.some(t=>t.id===e.id)?t.sort((e,t)=>n()(e.createdAt).isBefore(t.createdAt)?1:-1):[...t,e].sort((e,t)=>n()(e.createdAt).isBefore(t.createdAt)?1:-1))},null!==(a=null==l?void 0:l.id)&&void 0!==a?a:"",c)}catch(e){f(e.message)}finally{d(!1)}},[e,null==l?void 0:l.id]);return(0,i.useEffect)(()=>{if(r([]),e)return m(),()=>{var e;null===(e=t.current)||void 0===e||e.call(t),t.current=null}},[e]),{loading:a,error:u,messages:s,loadingAnswer:o,sendMessage:(0,i.useCallback)(t=>{l&&!x&&H(l,e,t,c)},[e,l])}}(t);return(0,s.jsxs)("div",{className:"w-full flex flex-col h-full max-w-full max-h-full",children:[(0,s.jsx)(S,{messages:a}),(0,s.jsx)(r.A,{onSend:e=>{let{message:t}=e;d(t)},loadingAnswer:o,isLoadingSend:l})]})}var L=l(6715);function O(){let e=(0,L.useRouter)().query.chatId;return(0,s.jsx)(K,{chatId:e})}}},e=>{var t=t=>e(e.s=t);e.O(0,[765,996,636,593,792],()=>t(4474)),_N_E=e.O()}]);
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.