1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6362],{46362:function(e,s,t){t.r(s),t.d(s,{Thread:function(){return Q},default:function(){return W}});var n=t(85893),a=t(30120),o=t(41664),l=t.n(o),i=t(67294),r=t(86501),d=t(52435),c=t(5628),m=t(69217),u=t(65768),g=t(46594),v=t(37174),x=t(71284),h=t(98860),p=t(71015),f=t(92395),j=t(86294);function b(e){let{editor:s,messages:t,replyToMessageId:a,setReplyToMessageId:o,sendMessage:l,userPickerVisible:i,setUserPickerVisible:r}=e;const d=(0,m.e)(),c=a&&(null===t||void 0===t?void 0:t.find((e=>{let{id:s}=e;return s===a})));let u="";var x,h;(c&&c.senderId===(null===d||void 0===d?void 0:d.id)&&(u="Yourself"),c&&c.senderId!==(null===d||void 0===d?void 0:d.id))&&(u="".concat(null===(x=c.sender)||void 0===x?void 0:x.firstName," ").concat(null===(h=c.sender)||void 0===h?void 0:h.lastName));return(0,n.jsxs)("div",{className:"flex-col items-end gap-x-2 py-2",children:[c&&(0,n.jsxs)("div",{className:"bg-background-20 rounded-t-md p-2 px-3 ",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsxs)("p",{className:"text-sm leading-5",children:[(0,n.jsx)("span",{children:"Replying to "}),(0,n.jsx)("span",{className:"font-semibold",children:u})]}),(0,n.jsx)(k,{onClick:()=>o(void 0)})]}),(0,n.jsx)(y,{className:"prose-sm mt-1 line-clamp-1",json:null===c||void 0===c?void 0:c.valueJson})]}),(0,n.jsx)(p.Kx,{editable:!0,editor:s,textAreaClassName:(0,v.cn)(a&&"mt-0 rounded-t-none"),children:(0,n.jsxs)(p.G3,{children:[(0,n.jsx)(j.$,{editor:s}),(0,n.jsx)(j.zA,{editor:s}),(0,n.jsx)(j.k1,{editor:s}),(0,n.jsx)(j.eD,{editor:s}),(0,n.jsx)(j.Qj,{editor:s}),(0,n.jsx)(j.Km,{editor:s}),(0,n.jsx)(j.py,{editor:s}),(0,n.jsx)(j.c7,{onClick:l})]})}),(0,n.jsx)(g.Z,{userPickerVisible:i,setUserPickerVisible:r})]})}function k(e){let{onClick:s}=e;return(0,n.jsx)("button",{className:"hover:!bg-accent-40 !text-foreground ml-auto flex !h-5 !w-5 items-center justify-center rounded-full !p-0",onClick:s,children:(0,n.jsx)(f.IF3,{className:"pointer-events-none h-4 w-4"})})}const y=e=>{let{className:s,json:t}=e;const a=(0,p.Mu)({placeholder:"What's on your mind?"}),o=(0,x.jE)({content:t,editable:!1,extensions:a}),l=(0,i.useMemo)((()=>{try{return(0,h.a)(t,a)}catch(e){return console.error("ChatBox: failed to generate HTML for message",e),"<p class='text-foreground-20'>Something went wrong. Unable to display this message.</p>"}}),[t,a]),[r,d]=(0,i.useState)(!1);return(0,i.useEffect)((()=>d(!0)),[]),r?(0,n.jsx)("div",{className:(0,v.cn)("prose-li:marker:text-foreground-10 prose-blockquote:border-foreground-20 prose text-foreground prose-a:break-words prose-a:underline prose-p:break-words first:prose-a:mt-0 last:prose-a:mb-0 first:prose-blockquote:mt-0 last:prose-blockquote:mb-0 first:prose-ol:mt-0 last:prose-ol:mb-0 first:prose-ul:mt-0 last:prose-ul:mb-0 first:prose-li:mt-0 last:prose-li:mb-0 first:prose-video:mt-0 last:prose-video:mb-0 first:prose-img:mt-0 last:prose-img:mb-0 first:prose-p:mt-0 last:prose-p:mb-0 overflow-clip break-words text-left leading-6",s),children:(0,n.jsx)(x.kg,{editor:o})}):(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:l},style:{wordBreak:"break-word"},className:(0,v.cn)("prose-li:marker:text-foreground-10 prose-blockquote:border-foreground-20 prose text-foreground prose-a:break-words prose-a:underline prose-p:break-words first:prose-a:mt-0 last:prose-a:mb-0 first:prose-blockquote:mt-0 last:prose-blockquote:mb-0 first:prose-ol:mt-0 last:prose-ol:mb-0 first:prose-ul:mt-0 last:prose-ul:mb-0 first:prose-li:mt-0 last:prose-li:mb-0 first:prose-video:mt-0 last:prose-video:mb-0 first:prose-img:mt-0 last:prose-img:mb-0 first:prose-p:mt-0 last:prose-p:mb-0 overflow-clip break-words text-left leading-6",s)})};var N=t(58611),w=t(18922),M=t(65951),C=t(70385),I=t(13500),S=t(42393),T=t(53402),P=t(26551),E=t(97366),A=t(62472),R=t(2376),B=t(70456),D=t(30665),L=t(58238),U=t(41790),Z=t(17326),O=t(33732),J=t(11163);const F=e=>{let{children:s,onTrigger:t}=e;const a=(0,i.useRef)(null),o=(0,u.S1)(a,{}),l=!!(null===o||void 0===o?void 0:o.isIntersecting);return(0,i.useEffect)((()=>{l&&(console.log("trigger"),t())}),[l,t]),(0,n.jsx)("div",{children:(0,n.jsx)("div",{ref:a,className:"flex h-10 items-center justify-center",children:s})})},V=(0,i.memo)((function(e){let{isGroup:s,messages:t,linkedMessage:a,onDeleteMessageClick:o,onReportMessageClick:l,onReplyToMessageClick:r,onReactToMessageClick:d}=e;const c=(0,m.e)(),[u,g]=(0,i.useState)(),[x,h]=(0,i.useState)(!1);return(0,n.jsx)(n.Fragment,{children:t.map(((e,i)=>{var m,p,f,j,b;const k=t[i-1],y=t[i+1],N=(null===k||void 0===k||null===(m=k.sender)||void 0===m?void 0:m.id)===(null===(p=e.sender)||void 0===p?void 0:p.id),w=(null===y||void 0===y||null===(f=y.sender)||void 0===f?void 0:f.id)===(null===(j=e.sender)||void 0===j?void 0:j.id),M=(null===(b=e.sender)||void 0===b?void 0:b.id)===(null===c||void 0===c?void 0:c.id),C=u===e.id||s&&!w||e.replyTo;return(0,n.jsxs)("div",{className:(0,v.cn)("mt-6 last:mt-3",w?"mt-1":"mt-6"),children:[C&&!e.replyTo&&(0,n.jsx)(K,{message:e,isOwnMessage:M,isSelected:u===e.id}),(0,n.jsx)($,{message:e,isOwnMessage:M}),(0,n.jsxs)(H,{left:!M,children:[(0,n.jsx)(G,{message:e,hide:N}),(0,n.jsx)(Y,{index:i,message:e,editable:x,setEditable:h,isOwnMessage:M,linkedMessage:a,selectedMessageId:u,setSelectedMessageId:g}),u===e.id&&(0,n.jsx)(_,{message:e,onReplyToMessageClick:r,onDeleteMessageClick:o,onReportMessageClick:l,onEditClick:()=>h(!0)})]}),(0,n.jsx)(z,{message:e,isOwnMessage:M,onReactToMessageClick:d})]},e.id)}))})}));function Y(e){let{index:s,message:t,editable:a,setEditable:o,isOwnMessage:l,linkedMessage:i,selectedMessageId:c,setSelectedMessageId:m}=e;var u,g;const v={threadId:t.threadId,limit:50},x=d.S.useUtils(),h=t.valueJson,f=null===h||void 0===h||null===(u=h.content)||void 0===u?void 0:u.some((e=>"youtube"===e.type)),b=null===h||void 0===h||null===(g=h.content)||void 0===g?void 0:g.some((e=>"indyPlayerV2"===e.type)),{mutate:k}=d.S.messages.edit.useMutation({async onMutate(e){await x.messages.getAll.cancel(v);const s=x.messages.getAll.getInfiniteData(v);s&&await x.messages.getAll.setInfiniteData(v,{...s,pages:s.pages.map((s=>{const n=s.messages.map((s=>s.id===t.id?{...s,valueJson:e.valueJson}:s));return{...s,messages:n}}))})},onSettled(){x.invalidate()},onError(){x.invalidate(),r.ZP.error("Something went wrong, please try again later.")}});const N="h-full bg-background-10 text-foreground";return w=t.id,a&&w===c?(0,n.jsx)(q,{index:s,message:t,hasYoutube:f,hasIndyPlayerV2:b,isOwnMessage:l,linkedMessage:i,children:(0,n.jsx)(p.Kx,{content:h,editable:!0,textArea:!1,className:"p-2",children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(p.G3,{className:"bg-background-10 flex w-full p-1",children:[(0,n.jsx)(j.$,{editor:e,className:N}),(0,n.jsx)(j.zA,{editor:e,className:N}),(0,n.jsx)(j.k1,{editor:e,className:N}),(0,n.jsx)(j.eD,{editor:e,className:N}),(0,n.jsx)(j.Qj,{editor:e,className:N}),(0,n.jsx)(j.Km,{editor:e,className:N}),(0,n.jsx)(j.py,{editor:e,className:N})]}),(0,n.jsx)(p.dD,{editor:e}),(0,n.jsxs)(p.G3,{className:"bg-background-10 flex w-full justify-end p-1",children:[(0,n.jsx)(j.qi,{onClick:()=>o(!1),className:N,children:"Cancel"}),(0,n.jsx)(j.qi,{onClick:()=>function(e){if(!e)return;const s=null===e||void 0===e?void 0:e.getText(),n=null===e||void 0===e?void 0:e.getJSON();n&&!(null===e||void 0===e?void 0:e.isEmpty)&&(o(!1),m(void 0),k({id:t.id,value:s||"",valueJson:n}))}(e),className:N,children:"Save"})]})]})})}):(0,n.jsx)(q,{index:s,role:"button",onClick:function(){var e;const s=null===(e=window.getSelection())||void 0===e?void 0:e.toString();s&&s.length>0||a||(c===t.id?m(void 0):m(t.id))},message:t,hasYoutube:f,hasIndyPlayerV2:b,isOwnMessage:l,linkedMessage:i,children:(0,n.jsx)(y,{json:h,className:"p-2"})});var w}function q(e){let{index:s,children:t,role:a,message:o,hasYoutube:l,hasIndyPlayerV2:i,isOwnMessage:r,linkedMessage:d,onClick:c}=e;return(0,n.jsx)("div",{role:a,id:"comment-".concat(o.id),"aria-label":"Show details for message at ".concat(s),onClick:c,className:(0,v.cn)("prose prose-base relative min-w-0 max-w-md overflow-hidden rounded-lg p-0",(l||i)&&"w-full",r?"bg-accent-50 hover:bg-accent-60 dark:bg-background-30 dark:hover:bg-background-20":"bg-background-10 border-background-20 hover:bg-background dark:hover:bg-background-20 border",d==="comment-".concat(o.id)&&"border-accent border-2"),children:t})}function H(e){let{children:s,left:t}=e;return(0,n.jsx)("div",{className:(0,v.cn)("flex gap-x-1.5",t?"flex-row":"flex-row-reverse"),children:s})}function K(e){let{message:s,isOwnMessage:t,isSelected:o=!1,hide:l=!1}=e;return l?null:(0,n.jsxs)("p",{className:(0,v.cn)("text-foreground-20 mb-1 mt-2 text-sm leading-tight",t?"mr-8 text-right":"ml-8"),children:[s.sender&&(0,n.jsx)("span",{className:"font-semibold",children:t?"You":"".concat(s.sender.firstName," ").concat(s.sender.lastName)}),s.editedAt&&(0,n.jsx)(N.pn,{children:(0,n.jsxs)(N.u,{children:[(0,n.jsx)(N.aJ,{children:(0,n.jsx)("span",{className:"text-foreground-20 pl-1",children:" (edited) "})}),(0,n.jsx)(N._v,{variant:"dark",children:(0,n.jsx)("p",{children:a.ou.fromJSDate(s.editedAt).setLocale("en-US").toFormat("MMM dd 'at' HH:mm")}
1)})]})}),o&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"",children:" \u2022 "}),(0,n.jsx)("span",{children:a.ou.fromJSDate(s.createdAt).setLocale("en-US").toFormat("MMM dd 'at' HH:mm")})]})]})}function z(e){let{message:s,isOwnMessage:t,onReactToMessageClick:a}=e;var o;return 0===(null===(o=s.reactions)||void 0===o?void 0:o.length)?null:(0,n.jsxs)("div",{onClick:()=>a(s),className:(0,v.cn)("border-background-20 bg-background-10 max-h-content relative flex h-6 max-w-fit cursor-pointer flex-row rounded-xl border px-1",t?"-left-8 bottom-2 ms-auto":"bottom-2 left-8"),children:[s.reactions.slice(0,3).map((e=>(0,n.jsx)("span",{className:"text-s flex h-6 w-5 flex-shrink-0 items-center justify-center rounded-full",children:(0,U.fC)(e.type)},e.id))),s.reactions.length>3&&(0,n.jsxs)("span",{className:"h-6 w-5 py-1 ps-1 text-xs",children:["+",s.reactions.length-3]})]})}function G(e){let{message:s,hide:t=!1}=e;return!s.sender||t?(0,n.jsx)("div",{className:"h-6 w-6 flex-none"}):(0,n.jsx)(l(),{className:"flex",href:"/user/".concat((0,v.L0)(s.sender)),children:(0,n.jsx)(E.Yt,{className:"h-6 w-6 flex-none self-end",user:s.sender})})}function _(e){let{message:s,onEditClick:t,onReplyToMessageClick:a,onDeleteMessageClick:o,onReportMessageClick:l}=e;const i=(0,m.e)(),u=(0,c.Z)(),g=d.S.useContext(),{mutate:v}=d.S.messages.save.useMutation({onSuccess(){r.ZP.success("Message Saved"),g.messages.getThread.invalidate()},onError(){r.ZP.error("Message could not be saved")}}),{mutate:x}=d.S.messages.unsave.useMutation({onSuccess(){r.ZP.success("Message Unsaved"),g.messages.getThread.invalidate()},onError(){r.ZP.error("Message could not be unsaved")}});async function h(){await u({title:"Confirm deletion",description:"Are you sure? This message will be permanently deleted.",confirmText:"Delete".concat((null===i||void 0===i?void 0:i.role)===C.UserRole.ADMIN?" as admin":"")})&&o(s.id)}async function p(){await u({title:"Are you sure?",description:"Are you sure you want to report this message?",confirmText:"Report"})&&l(s.id)}function j(){(0,I.v)("".concat(window.location.href.split("#")[0],"/#comment-").concat(s.id))}const b=()=>{var e,a,o;return(0,n.jsxs)(n.Fragment,{children:[(null===(e=s.sender)||void 0===e?void 0:e.id)===(null===i||void 0===i?void 0:i.id)?(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.yl5,{}),onClick:()=>t(s.id),children:(0,n.jsx)(P.C.Text,{children:"Edit"})}):null,(null===(a=s.sender)||void 0===a?void 0:a.id)===(null===i||void 0===i?void 0:i.id)||(null===i||void 0===i?void 0:i.role)===C.UserRole.ADMIN?(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.IT9,{}),onClick:h,children:(0,n.jsx)(P.C.Text,{children:"Delete"})}):null,(null===(o=s.sender)||void 0===o?void 0:o.id)!==(null===i||void 0===i?void 0:i.id)&&(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.DpU,{}),onClick:p,children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Report message"})}),(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.vUr,{}),onClick:j,children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Copy link to message"})}),!1===s.savedByMe?(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.BZM,{}),onClick:()=>{v({id:s.id})},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Save message"})}):(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.BZM,{}),onClick:()=>{x({id:s.id})},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Unsave message"})})]})};return(0,n.jsxs)("div",{className:"items center flex",children:[(0,n.jsx)(X,{onClick:()=>a(s.id),children:(0,n.jsx)(f.b8y,{className:"pointer-events-none -translate-x-[1px]"})}),(0,n.jsx)(X,{children:(0,n.jsx)(L.Z,{asIcon:!0,asUser:!0,message:s})}),(0,n.jsx)(M.L,{side:"right",overlay:(0,n.jsx)(b,{}),children:(0,n.jsx)(w.z,{type:"icon",icon:(0,n.jsx)(f.q3n,{})})})]})}function $(e){let{message:s,isOwnMessage:t}=e;return s.replyTo?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:(0,v.cn)("text-foreground-20 mb-1 mt-2 text-sm leading-tight",t?"mr-8 text-right":"ml-8"),children:(0,n.jsxs)("p",{className:(0,v.cn)("text-foreground-20 align-middle",t?"text-right":"text-left"),children:[(0,n.jsx)(f.b8y,{className:"mb-[1px] mr-1 inline h-4 w-4"}),s.sender&&s.replyTo.sender&&(0,n.jsxs)("span",{children:[s.sender.firstName," replied to"," ",s.replyTo.sender.firstName]}),(0,n.jsx)("span",{className:"",children:" \u2022 "}),(0,n.jsx)("span",{children:a.ou.fromJSDate(s.createdAt).setLocale("en-US").toFormat("MMM dd 'at' HH:mm")}
1)]})}),(0,n.jsx)("div",{className:(0,v.cn)("bg-background-20 top-4 mb-1 w-fit max-w-md rounded-md p-2",t?"ml-auto mr-8":"ml-8 mr-auto"),children:(0,n.jsx)(y,{className:"prose-sm line-clamp-2 italic",json:s.replyTo.valueJson})})]}):null}const Q=e=>{let{className:s,threadId:t}=e;var a,o,c;const v=d.S.useContext(),h=(0,m.e)(),j=(0,B.fB)(),k=(0,J.useRouter)(),y=(0,p.Mu)({placeholder:"What's on your mind?",suggestion:j,nodeViews:!1}),[N,I]=(0,i.useState)(!1),[D,L]=(0,i.useState)(!1),Y=(0,x.jE)({extensions:y,content:JSON.parse(window.localStorage.getItem("message-".concat(t))||"{}"),onUpdate:e=>{let{editor:s}=e;const n=JSON.stringify(s.getJSON());window.localStorage.setItem("message-".concat(t),n)},editorProps:{attributes:{class:"ProseMirror max-w-none focus:outline-none prose text-foreground`"}}});(0,i.useEffect)((()=>{const e=JSON.parse(window.localStorage.getItem("message-".concat(t))||"{}");null===Y||void 0===Y||Y.commands.setContent(e)}),[t,Y]);const[q,H]=(0,i.useState)(),[,K]=(0,u._)("activeThreadId",void 0),[z,G]=(0,i.useState)(!1),[_,$]=(0,i.useState)(!1),[Q,W]=(0,i.useState)(""),{data:X,isLoading:ee}=d.S.messages.getThread.useQuery({threadId:t},{enabled:!!t,retry:0,onSuccess(){v.messages.getThreads.invalidate(),K(t)}}),se={threadId:t,limit:50},{data:te,isLoading:ne,hasNextPage:ae,isFetchingNextPage:oe,fetchNextPage:le}=d.S.messages.getAll.useInfiniteQuery(se,{enabled:!!t,getNextPageParam:e=>e.nextCursor,refetchInterval:8e3,retry:0,onSuccess(){v.notifications.getUnreadCount.invalidate()}}),{mutate:ie}=d.S.report.send.useMutation({onSuccess(){r.ZP.success("Message Reported")},onError(){r.ZP.error("Message could not be reported")}}),{mutate:re}=d.S.messages.delete.useMutation({onError(){(0,r.ZP)("Unable to delete message. Please try again later.")},async onMutate(e){let{id:s}=e;await v.messages.getAll.cancel(se);const t=v.messages.getAll.getInfiniteData(se);t&&await v.messages.getAll.setInfiniteData(se,{...t,pages:t.pages.map((e=>({...e,messages:e.messages.filter((e=>e.id!==s))})))})},onSettled(){v.messages.getThread.invalidate({threadId:t}),v.messages.getAll.invalidate(se)}}),{mutate:de}=d.S.messages.updateThread.useMutation({onMutate:async e=>{let{displayName:s,threadId:t}=e;v.messages.getThreads.setData(void 0,(e=>e&&s&&t?e.map((e=>e.id===t?{...e,displayName:s}:e)):e))},onSuccess(){v.messages.getThreads.invalidate(),v.messages.getThread.invalidate({threadId:t})},onError(e){r.ZP.error("Unable to update thread. Please try again later or contact support - ".concat(e.message))}}),{mutate:ce}=d.S.tenantUser.block.useMutation({onSuccess(e){v.invalidate(),e.userIsBlocked?r.ZP.success("User has been blocked"):r.ZP.success("User has been unblocked")}}),me=(0,i.useRef)(null);const ue=((ge=null===X||void 0===X?void 0:X.participants)&&ge.length>1?ge.filter((e=>e.id!=(null===h||void 0===h?void 0:h.id))):ge)||[];var ge;const ve=ue.sort(((e,s)=>e.id===(null===h||void 0===h?void 0:h.id)?1:s.id===(null===h||void 0===h?void 0:h.id)?-1:0));let xe=ue.map((e=>{let{firstName:s,lastName:t}=e;return ue.length>2?s:"".concat(s," ").concat(t)}));const he=(null===X||void 0===X?void 0:X.participants)&&(null===X||void 0===X?void 0:X.participants.length)>2,pe=function(e){let{thread:s,editor:t,replyToId:n,onSent:a}=e;const o=d.S.useContext(),l=(0,m.e)(),i={threadId:null===s||void 0===s?void 0:s.id,limit:50},{mutate:c}=d.S.messages.send.useMutation({async onMutate(e){await o.messages.getAll.cancel(i);const s=o.messages.getAll.getInfiniteData(i),t=null===s||void 0===s?void 0:s.pages.reduce(((e,s)=>[...e,...s.messages||[]]),[]),n=(null===t||void 0===t?void 0:t.find((s=>{let{id:t}=s;return t===e.replyToId})))||null;s&&l&&await o.messages.getAll.setInfiniteData(i,{...s,pages:s.pages.map(((s,t)=>0===t?{...s,messages:[{id:"temp-".concat(Math.random()),senderId:l.id,sender:l,replyToId:e.replyToId||null,replyTo:n,threadId:e.threadId,reactions:[],value:e.value,valueJson:e.valueJson,createdAt:new Date,savedBy:[],savedByMe:!1,editedAt:null},...s.messages]}:{...s}))})},onSettled(e,s,t){let{threadId:n}=t;o.messages.getThreads.invalidate(),o.messages.getThread.invalidate({threadId:n}
1),o.messages.getAll.invalidate(i);const a=document.getElementById("thread-".concat(n));a&&a.scrollTo({top:a.scrollHeight,behavior:"smooth"})},onError(){o.invalidate(),r.ZP.error("Something went wrong, please try again later.")}});return()=>{if(!s)return;const e=null===t||void 0===t?void 0:t.getText(),o=null===t||void 0===t?void 0:t.getJSON();o&&!(null===t||void 0===t?void 0:t.isEmpty)&&function(e,s){var t,n,a;if(!1===(null===s||void 0===s?void 0:s.canBeMessaged))return r.ZP.error("You have disabled messaging. Enable messaging in your profile-settings to send messages"),!1;const o=null===e||void 0===e?void 0:e.participants.sort(((e,t)=>e.id===s.id?1:t.id===s.id?-1:0));if((null===o||void 0===o?void 0:o.length)>1)return!0;if(!1===(null===(t=o[0])||void 0===t?void 0:t.canBeMessaged))return r.ZP.error("Unable to send message. The correspondent has disabled messaging."),!1;if((null===(a=o[0])||void 0===a||null===(n=a.blockedByUsers)||void 0===n?void 0:n.length)>0)return r.ZP.error("You must unblock this user in order to message them"),!1;return!0}(s,l)&&(a(),null===t||void 0===t||t.commands.clearContent(),null===t||void 0===t||t.commands.focus(),c({threadId:s.id,replyToId:n,value:e||"",valueJson:o}))}}({thread:X,editor:Y,replyToId:q,onSent:()=>{H(void 0),window.localStorage.removeItem("message-".concat(t))}});!function(e,s){null===e||void 0===e||e.setOptions({editorProps:{handleDOMEvents:{keydown:(t,n)=>{var a;if("Enter"===n.key&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey)return!(t.state&&"mention$"in t.state&&t.state.mention$&&"object"===typeof t.state.mention$&&"active"in t.state.mention$&&(null===(a=t.state.mention$)||void 0===a?void 0:a.active))&&(n.preventDefault(),s(),!0);if("Enter"===n.key&&n.shiftKey){n.preventDefault();const s=()=>{var s;const{anchor:t}=e.state.selection,n=e.view.state.doc.resolve(t),a=n.index(n.depth),o=a>0&&(null===(s=n.parent)||void 0===s?void 0:s.child(a-1));return o&&"hardBreak"===o.type.name},t=()=>{let s=!1;return e.state.doc.descendants(((t,n)=>{const{from:a,to:o}=e.state.selection;a>=n&&o<=n+t.nodeSize&&"blockquote"===t.type.name&&(s=!0)})),s},a=e.commands.first((e=>{let{commands:s}=e;return[()=>s.newlineInCode(),()=>s.splitListItem("listItem"),()=>s.liftEmptyBlock()]}));if(!a)if(t())if(s()){const{state:s}=e.view,{anchor:t}=s.selection,n=s.doc.resolve(t);let a=n.pos;n.nodeBefore&&"hardBreak"===n.nodeBefore.type.name&&(a=n.pos-n.nodeBefore.nodeSize);let o=s.tr.delete(a,n.pos);e.view.dispatch(o);let{state:l}=e.view,i=l.doc.resolve(o.mapping.map(a)).pos,r=l.tr.setSelection(R.Bs.create(l.doc,i));e.view.dispatch(r),e.commands.splitBlock()}else e.commands.setHardBreak();else e.commands.setHardBreak();return!0}return!!("Enter"===n.key&&n.metaKey||n.ctrlKey&&"Enter"===n.key)&&(n.preventDefault(),e.commands.insertContent({type:"paragraph",content:[]}),!0)}}}})}(Y,pe);const fe=new URL(k.asPath,window.location.href).hash.slice(1),[je,be]=(0,i.useState)(!1);(0,i.useEffect)((()=>{if(!je&&!ee&&!ne&&fe){const e=document.getElementById(fe);e&&(e.scrollIntoView({behavior:"smooth"}),be(!0))}}),[je,ee,fe,ne]);const[ke,ye]=(0,i.useState)(null),Ne=(0,i.useMemo)((()=>(null===te||void 0===te?void 0:te.pages)?te.pages.reduce(((e,s)=>{var t;return[...e,...(null===(t=s.messages)||void 0===t?void 0:t.filter((e=>e.valueJson)))||[]]}),[]):[]),[null===te||void 0===te?void 0:te.pages]),we=(0,i.useCallback)((e=>{ye({reactions:e.reactions})}),[ye]),Me=(0,i.useCallback)((e=>{H(e),null===Y||void 0===Y||Y.commands.focus()}),[H,Y]),Ce=(0,i.useCallback)((e=>{re({id:e})}),[re]),Ie=(0,i.useCallback)((e=>{ie({contentId:e,contentType:"message"})}),[ie]),{mutate:Se}=d.S.messages.leaveGroupThread.useMutation({onSuccess(){r.ZP.success("You have left the group"),v.messages.getAll.invalidate()},onError(e){r.ZP.error(e.message)}});return console.log("THREAD POSTt ".concat(JSON.stringify(null===X||void 0===X?void 0:X.post))),(0,n.jsxs)("div",{className:"".concat(s||""," flex flex-col px-2"),children:[(0,n.jsxs)("div",{className:"flex h-16 items-center gap-x-4",children:[(0,n.jsx)(l(),{className:"stroke-2 sm:hidden",href:"/inbox",children:(0,n.jsx)(w.z,{type:"secondary",icon:(0,n.jsx)(f.ed9,{})})}),ve&&ve.length>1?(0,n.jsxs)("div",{className:"relative mt-[-.6em]",children:[(0,n.jsx)(E.Yt,{user:ve[0],className:"h-6 w-6"}),(0,n.jsx)(E.Yt,{className:"absolute left-2 top-2 h-6 w-6",user:ve[1]})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(E.Yt,{user:null===ve||void 0===ve?void 0:ve[0],className:"h-8 w-8"})}),(0,n.jsxs)("div",{className:"flex flex-col truncate",children:[(null===X||void 0===X?void 0:X.displayName)&&(0,n.jsx)("span",{className:"text-foreground truncate sm:text-base",children:X.displayName}),(0,n.jsx)("span",{className:"text-foreground truncate sm:text-sm",children:xe&&(xe.length<=3?new Intl.ListFormat("en").format(xe):(0,n.jsxs)("span",{children:[xe[0],", ",xe[1]," and"," ",(0,n.jsxs)("button",{onClick:()=>G(!0),className:"underline",children:[xe.length-2," others"]})]}))})]}),(0,n.jsx)("div",{className:"grow"}),(0,n.jsx)(M.L,{align:"end",overlay:(0,n.jsxs)(n.Fragment,{children:[!(null===X||void 0===X?void 0:X.threadForPost)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.yl5,{}),onClick:()=>{W((null===X||void 0===X?void 0:X.displayName)||""),$(!0)},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Rename"})}),(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.SrG,{}),onClick:()=>{L(!0)},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Add/remove members"})}),(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.iSn,{}),onClick:()=>{Se({threadId:(null===X||void 0===X?void 0:X.id)||""})},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Leave chat"})}),(0,n.jsx)(A.i,{}),2===(null===ve||void 0===ve?void 0:ve.length)&&(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f._Go,{}),onClick:()=>{var e;return ce({userId:null===(e=ve[0])||void 0===e?void 0:e.id})},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:(null===(o=ve[0])||void 0===o||null===(a=o.blockedByUsers)||void 0===a?void 0:a.length)>0?"Unblock user":"Block user"})})]}),(null===X||void 0===X?void 0:X.threadForPost)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.iSn,{}),onClick:()=>{Se({threadId:(null===X||void 0===X?void 0:X.id)||""})},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Leave chat"})}),((null===X||void 0===X||null===(c=X.post)||void 0===c?void 0:c.creatorId)===(null===h||void 0===h?void 0:h.id)||(null===h||void 0===h?void 0:h.role)===C.UserRole.ADMIN)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.yl5,{}),onClick:()=>{W((null===X||void 0===X?void 0:X.displayName)||""),$(!0)},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Rename"})}),(0,n.jsx)(M.L.Item,{icon:(0,n.jsx)(f.SrG,{}),onClick:()=>{L(!0)},children:(0,n.jsx)(P.C.Text,{className:"truncate",children:"Add/remove members"})})]})]})]}),children:(0,n.jsx)(w.z,{type:"icon",icon:(0,n.jsx)(f.q3n,{})})})]}),(0,n.jsx)(A.i,{type:"horizontal",className:"mx-1 !w-auto"}),(0,n.jsxs)("div",{id:"thread-".concat(null===X||void 0===X?void 0:X.id),ref:me,className:"flex h-full flex-grow flex-col-reverse overflow-auto",children:[(0,n.jsx)(V,{messages:Ne,linkedMessage:fe,isGroup:Boolean(he),onReactToMessageClick:we,onReplyToMessageClick:Me,onReportMessageClick:Ie,onDeleteMessageClick:Ce}),ae&&(0,n.jsx)(F,{onTrigger:le,children:oe&&(0,n.jsx)(S.T,{active:!0,className:"relative"})}),(0,n.jsx)(S.T,{active:ee||ne})]}),(0,n.jsx)(b,{editor:Y,messages:Ne,replyToMessageId:q,setReplyToMessageId:H,sendMessage:pe,userPickerVisible:N,setUserPickerVisible:I}),(0,n.jsx)(T.Z,{visible:z,onCancel:()=>G(!1),title:"Participants",closable:!0,closeOnBackdropClick:!0,hideFooter:!0,children:(0,n.jsx)("div",{className:"min-h-32 mt-4 flex max-h-[50vh] flex-col gap-y-2 overflow-y-scroll",children:null===X||void 0===X?void 0:X.participants.map((e=>(0,n.jsxs)("div",{className:"flex items-center gap-x-3 capitalize",children:[(0,n.jsx)("div",{className:"flex-shrink-0",children:(0,n.jsx)(E.Yt,{className:"h-8 w-8",user:e})}),(0,n.jsxs)(P.C.Text,{className:"grow truncate text-left",children:[e.firstName," ",e.lastName]})]},e.id)))})}),(0,n.jsx)(T.Z,{visible:_,onCancel:()=>$(!1),onConfirm:async()=>{de({displayName:Q||"",threadId:t}),$(!1)},title:"Rename chat",closable:!0,closeOnBackdropClick:!0,children:(0,n.jsx)(O.Z,{name:"displayName",autoComplete:"false",placeholder:"Enter a new name for this chat",maxLength:190,value:Q||"",onChange:e=>{W(e.target.value)}})}),(null===ke||void 0===ke?void 0:ke.reactions)&&(0,n.jsx)(T.Z,{visible:!!ke.reactions,title:"Reactions",id:"viewingReactionsModal",closable:!0,onCancel:()=>{ye({reactions:void 0})},closeOnBackdropClick:!0,hideFooter:!0,children:(0,n.jsx)("div",{className:"flex flex-col gap-y-2",children:Object.entries((0,U.wl)(ke.reactions)).map((e=>{let[s,t]=e;const n=t[0];if(n)return(0,Z.nq)(n,t,s)}))})}),(0,n.jsx)(g.Z,{userPickerVisible:D,setUserPickerVisible:L,threadId:null===X||void 0===X?void 0:X.id})]})};var W=Q;function X(e){let{children:s,onClick:t}=e;return(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsx)(D.u,{text:"Reply",side:"top",children:(0,n.jsx)("div",{className:"hover:bg-accent-60 dark:hover:bg-background-30 text-foreground flex h-8 w-8 items-center justify-center rounded-full p-0 transition",onClick:t,children:s})})})}}}]);
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.