1import{k as R,d as g,q as T,o as a,e as l,F as E,i as O,a as o,n as L,t as h,g as F,h as r,f as k,y as V,M as A,I as B,b as D,L as S,l as j,w as I,c as M,T as H,C as W,x as Y,P as z,j as P,B as N,H as G}from"./app.1c75f29f.js";import{_ as U}from"./_plugin-vue_export-helper.cdc0426e.js";import Z from"./Create.ac22d674.js";import J from"./Details.28c3fbc0.js";import"./Modal.f4449063.js";import"./Recorder.02e86d32.js";import"./RightSidebar.de901178.js";import"./Checkbox.ed02ab8f.js";import"./Message.77946d87.js";import"./AudioPlayer.51f92bc4.js";import"./Search.20accddc.js";import"./EmptyState.32308625.js";const K=["onClick"],Q={class:"flex items-center gap-3"},X={class:"h-12 w-12 bg-indigo-10 rounded-full flex-shrink-0 overflow-hidden grid grid-cols-2 grid-rows-2"},ee=["src"],se={class:"flex-grow"},te={class:"flex justify-between flex-shrink-0 flex-grow"},oe={key:0,class:"text-12-regular text-white flex items-center justify-center mt-1 h-6 w-6 bg-lime-60 rounded-full"},ae={key:1,class:"text-sm text-gray-60 mt-1"},re={key:0,class:"text-gray-60 text-sm"},le={key:0},ie={key:0,class:"mx-6 border-b border-gray-30 my-2"},ne={__name:"SidebarChatCard",props:{chat_rooms:{type:Object,required:!0},typingDetails:{type:Object,required:!0}},emits:["click"],setup(u,{emit:f}){const d=u,n=R().props.value.user,v=R().props.value.locale;let p="You";p=v==="fa"?"\u0634\u0645\u0627":v==="ps"?"\u062A\u0627\u0633\u0648":"You";const c=g(null),b=y=>{y.user_can_chat?(y.unread_messages_count=0,c.value=y.id,f("click",y)):alert("You can not open a chat that you declined the invitation.")};return T(()=>{d.chat_rooms.data.length&&b(d.chat_rooms.data[0])}),(y,$)=>(a(),l("div",null,[(a(!0),l(E,null,O(u.chat_rooms.data,i=>{var w,C,e,s;return a(),l("div",{key:i.id},[o("div",{class:L(["hover:bg-white px-6 py-3 cursor-pointer transition-all duration-200",r(c)==i.id?"bg-white":""]),onClick:t=>b(i)},[o("div",Q,[o("div",X,[(a(!0),l(E,null,O(i.avatar,(t,m)=>(a(),l("img",{key:m,src:t,alt:"",class:L(["w-full object-cover h-full",m==0?"col-span-2":""])},null,10,ee))),128))]),o("div",se,[o("div",te,[o("div",{class:L(["flex-grow",i.unread_messages_count>0?"text-18-medium":"text-18-regular"])},h(i.name.length>25?i.name.substring(0,25)+"...":i.name),3),i.unread_messages_count?(a(),l("span",oe,h(i.unread_messages_count),1)):(a(),l("span",ae,h(i.last_message_time),1))]),u.typingDetails.typing&&u.typingDetails.chatroom==i.id?(a(),l("span",re,[F(h(`${u.typingDetails.user} is typing`)+" ",1),(a(),l(E,null,O(3,(t,m)=>o("span",{key:t,class:"h-[3px] w-[3px] mr-0.5 rounded-full inline-block circle bg-gray-60"})),64))])):(a(),l("div",{key:1,class:L(["text-gray-60 text-sm mt-0.5",i.unread_messages_count>0?"font-medium":""])},[i.last_message?(a(),l("span",le,h(((C=(w=i.last_message)==null?void 0:w.sender_info)==null?void 0:C.full_name)==r(n).full_name?r(p):(s=(e=i.last_message)==null?void 0:e.sender_info)==null?void 0:s.full_name),1)):k("",!0),F(" "+h(i.last_message_text),1)],2))])])],10,K),u.chat_rooms.data.length>1&&u.chat_rooms.data.indexOf(i)!==u.chat_rooms.data.length-1?(a(),l("div",ie)):k("",!0)])}),128))]))}},ce={},de=o("div",{class:"h-12 w-12 bg-gray-30 rounded-full animate-pulse"},null,-1),ue=o("div",{class:"flex-grow"},[o("div",{class:"w-1/3 h-4 mb-2 bg-gray-30 rounded animate-pulse"}),o("div",{class:"w-2/3 h-4 bg-gray-30 rounded animate-pulse"})],-1),me=[de,ue];function _e(u,f){return a(),l("div",null,[(a(),l(E,null,O(5,d=>o("div",{key:d,class:"px-6 py-4 flex items-center gap-3 border-b border-gray-30 last:border-b-0"},me)),64))])}const he=U(ce,[["render",_e]]),ge={class:"w-[360px] bg-gray-10 flex flex-col h-screen flex-shrink-0 overflow-hidden"},fe={class:"border-b-2 border-white py-8 px-6 flex items-center justify-between"},pe=["src"],be={key:0,class:"absolute bg-white p-1 text-14-regular border border-gray-10 w-24 rounded-md top-20 ltr:left-72 z-10 rtl:right-72 w-40"},ve=o("i",{class:"icon-category text-lg"},null,-1),ye=o("i",{class:"icon-profile text-lg"},null,-1),we=o("i",{class:"icon-logout text-lg"},null,-1),xe={class:"py-5 flex flex-col flex-grow overflow-auto"},ke={class:"flex items-center justify-between border-b border-gray-30 pb-4 mb-4 mx-6 gap-2 relative"},Ce={class:"text-20-medium flex-grow"},$e=o("i",{class:"icon-filter flex"},null,-1),De=[$e],je=o("i",{class:"icon-edit-square flex"},null,-1),Le=[je],Ee={key:1,class:"absolute w-full flex items-center gap-2"},Fe={class:"relative flex-grow flex items-center"},Me=["placeholder"],Re=o("span",{class:"icon-search text-gray-50 absolute left-2.5 text-lg flex"},null,-1),Se=o("circle",{cx:"20",cy:"20",r:"20",fill:"white"},null,-1),Ie=o("path",{d:"M25.8337 15.342L24.6587 14.167L20.0003 18.8253L15.342 14.167L14.167 15.342L18.8253 20.0003L14.167 24.6587L15.342 25.8337L20.0003 21.1753L24.6587 25.8337L25.8337 24.6587L21.1753 20.0003L25.8337 15.342Z",fill:"#393A37"},null,-1),Oe=[Se,Ie],Te={class:"px-6 mb-2"},qe=o("div",{class:"bg-white rounded-full h-10 w-10 flex items-center justify-center"},[o("i",{class:"icon-edit-square flex"})],-1),Ae={class:"text-20-medium"},Ne={__name:"Sidebar",props:{chat_rooms:{type:Object,required:!0},typingDetails:{type:Object,required:!0}},emits:["showCreate","openChat"],setup(u,{emit:f}){const d=u,n=R().props.value.user,v=g(!1),p=g({...d.chat_rooms}),c=g(""),b=()=>{f("showCreate")},y=s=>{A.get(`discussion-boards/${s.id}`).then(t=>{f("openChat",t.data)}).catch(t=>{console.log(t)})};V(c,_.debounce(s=>{A.get(route("discussion-boards.search",{term:s})).then(t=>{p.value.data=t.data.data}).catch(t=>{console.log(t)})},500));const $=g(!1),i=()=>{$.value=!1,c.value=""},w=g(!1);let C=g(null);T(()=>{new IntersectionObserver(t=>t.forEach(m=>m.isIntersecting&&e(),{rootMargin:"-150px 0px 0px 0px"})).observe(C.value)});const e=()=>{d.chat_rooms.links.next&&(v.value=!0,B.Inertia.get(d.chat_rooms.links.next,{},{preserveState:!0,preserveScroll:!0,onSuccess:s=>{p.value.data=[...Object.values(p.value.data),...s.props.chat_rooms.data],v.value=!1}}))};return(s,t)=>{const m=z("tooltip");return a(),l("div",ge,[o("div",fe,[D(r(S),{as:"img",href:s.route("website.home"),src:"/images/logo.png",alt:"",width:"80",class:"cursor-pointer"},null,8,["href"]),j(o("img",{src:r(n).profile_photo_url,class:"h-12 w-12 rounded-full border border-white object-cover cursor-pointer",onFocusout:t[0]||(t[0]=x=>w.value=!1),onClick:t[1]||(t[1]=x=>w.value=!r(w)),tabindex:"0"},null,40,pe),[[m,s.__("chatRoom.left_sidebar.show_menu")]]),D(H,{name:"fade"},{default:I(()=>[r(w)?(a(),l("ul",be,[s.$page.props.is_admin?(a(),M(r(S),{key:0,as:"li",href:s.route("dashboard"),
1class:"px-2 py-1.5 hover:bg-gray-10 hover:text-14-medium hover:text-indigo-60 rounded-md transition-all duration-200 cursor-pointer block"},{default:I(()=>[ve,F(" "+h(s.__("commonWords.dashboard")),1)]),_:1},8,["href"])):(a(),M(r(S),{key:1,as:"li",href:s.route("profile.show"),class:L(["px-2 py-1.5 hover:bg-gray-10 hover:text-14-medium hover:text-indigo-60 rounded-md transition-all duration-200 cursor-pointer block",s.route().current("profile.show")?"bg-indigo-10":""])},{default:I(()=>[ye,F(" "+h(s.__("commonWords.profile")),1)]),_:1},8,["href","class"])),D(r(S),{as:"li",href:s.route("logout"),method:"post",class:"px-2 py-1.5 hover:bg-gray-10 hover:text-14-medium hover:text-indigo-60 rounded-md transition-all duration-200 cursor-pointer block"},{default:I(()=>[we,F(" "+h(s.__("header.nav.logout")),1)]),_:1},8,["href"])])):k("",!0)]),_:1})]),o("div",xe,[o("div",ke,[o("h6",Ce,h(s.__("chatRoom.left_sidebar.chats")),1),j((a(),l("button",{onClick:t[2]||(t[2]=x=>$.value=!0),class:"bg-white flex-shrink-0 rounded-full h-10 w-10 flex items-center justify-center"},De)),[[m,s.__("chatRoom.left_sidebar.search_chatrooms")]]),r(n).roles[0].name=="Admin"||r(n).roles[0].name=="Group_manager"?j((a(),l("button",{key:0,onClick:t[3]||(t[3]=x=>b()),class:"bg-white flex-shrink-0 rounded-full h-10 w-10 flex items-center justify-center"},Le)),[[m,s.__("chatRoom.left_sidebar.create_chatroom")]]):k("",!0),r($)?(a(),l("div",Ee,[o("div",Fe,[j(o("input",{type:"text","onUpdate:modelValue":t[4]||(t[4]=x=>Y(c)?c.value=x:null),placeholder:s.__("chatRoom.left_sidebar.search_chats"),class:"h-full w-full input bg-white pl-10"},null,8,Me),[[W,r(c)]]),Re]),j((a(),l("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:"flex-shrink-0 cursor-pointer",onClick:i},Oe)),[[m,s.__("chatRoom.left_sidebar.close_search")]])])):k("",!0)]),o("div",Te,[!u.chat_rooms.data.length>0?(a(),l("button",{key:0,onClick:t[5]||(t[5]=x=>b()),class:"flex items-center justify-center gap-4 bg-indigo-10 w-full py-4 rounded-lg"},[qe,o("h6",Ae,h(s.__("chatRoom.left_sidebar.create_chat")),1)])):k("",!0)]),D(ne,{typingDetails:u.typingDetails,chat_rooms:r(p),onClick:y},null,8,["typingDetails","chat_rooms"]),o("span",{ref_key:"loadMoreIntersect",ref:C},null,512),r(v)?(a(),M(he,{key:0})):k("",!0)])])}}},Be={class:"min-h-screen flex"},Ve={class:"flex-grow bg-white flex items-center"},He={key:0,class:"container"},We={key:1,class:"flex items-center flex-col h-full justify-center"},Ye=o("img",{src:"/images/chat-artwork.svg",alt:"chat artwork",class:"mb-6"},null,-1),ze={class:"text-20-medium"},as={__name:"List",setup(u){const f=g(!1),d=g(null),n=g({}),v=g(null),p=g({}),c=P(()=>R().props.value.chat_rooms),b=R().props.value.user,y=e=>{v.value=e.data.id,d.value=e.data,n.value=e.messages,e.data.unread_messages_count>0&&$(e.data.id)},$=e=>{setTimeout(()=>{B.Inertia.patch(route("discussion-boards.message.read",e))},1e3)};window.Echo.private("chat_room_actions").listen(".ChatRoomActionEvent",async e=>{if(e.action==="Send"){const s=c.value.data.find(t=>t.id==e.chat_room.id);s.last_message_text=e.chat_room.last_message_text,s.last_message_time=e.chat_room.last_message_time,s.last_message=e.chat_room.last_message,s.id==v.value?n.value.length==0?n.value={today:[{message:e.chat_room.last_message.message,sender_info:e.chat_room.creator,sent_at:e.chat_room.last_message.sent_at}]}:n.value[Object.keys(n.value)[Object.keys(n.value).length-1]].push(e.chat_room.last_message):s.unread_messages_count=s.unread_messages_count+1,N(()=>{var x,q;const t=document.querySelector("#chat-list");if(t.scrollTop=t.scrollHeight,((q=(x=e.chat_room)==null?void 0:x.last_message)==null?void 0:q.sender_info.id)!=b.id){var m=new Audio("/sounds/chat-sound.mp3");m.play()}})}e.action==="Created chat room"&&e.chat_room.members.map(s=>s.profile.id).includes(b.id)&&c.value.data.push(e.chat_room),e.action==="Invite"&&b.id!==e.chat_room.creator.id&&e.member&&b.id===e.member&&c.value.data.push(e.chat_room),e.action==="Removed member"&&(c.value.data.members=e.chat_room.members,e.member&&b.id===e.member&&(c.value.data=c.value.data.filter(s=>s.id!==e.chat_room.id))),e.action==="Delete chat room"&&(c.value.data=c.value.data.filter(s=>s.id!==e.chat_room.id))}),window.Echo.private("chat_room_actions").listenForWhisper("typing",e=>{p.value=e}),T(()=>{window.Echo.join("chat_room_actions").here(e=>{e&&e.length>0&&e.forEach(s=>{const t=d.value&&d.value.members.find(m=>m.profile.id==s.user);t&&(t.is_online=!0)})}).joining(e=>{d.value.members.find(s=>s.profile.id==e.user?s.is_online=!0:!1)}).leaving(e=>{d.value.members.find(s=>s.profile.id==e.user?s.is_online=!1:!0)})});const i=e=>{n.value={...e,...n.value}},w=e=>{n.value={...n.value,...e}},C=e=>{n.value=e.messages,N(()=>{const s=document.getElementById(e.message),t=document.createElement("a");t.setAttribute("href",`chat_room#${e.message}`),t.click(),s&&(s.style.transition="all .2s ease",s.style.background="#FFF5D5",s.style.borderColor="#FC9595",
1setTimeout(()=>{s.style.background="#EDECFF",s.style.borderColor="#EDECFF"},1e3))})};return(e,s)=>(a(),l(E,null,[D(r(G),{title:e.__("header.nav.discussion")},null,8,["title"]),o("div",Be,[D(Ne,{typingDetails:r(p),chat_rooms:r(c),onShowCreate:s[0]||(s[0]=t=>f.value=!0),onOpenChat:y},null,8,["typingDetails","chat_rooms"]),o("div",Ve,[r(f)||e.$page.props.chat_rooms.data.length==0?(a(),l("div",He,[r(f)?(a(),M(Z,{key:0,onClose:s[1]||(s[1]=t=>f.value=!1)})):e.$page.props.chat_rooms.data.length==0?(a(),l("div",We,[Ye,o("p",ze,h(e.__("chatRoom.list.please_create_chat")),1),o("button",{class:"btn btn-secondary mt-8",onClick:s[2]||(s[2]=t=>f.value=!0)},h(e.__("chatRoom.list.create")),1)])):k("",!0)])):r(d)?(a(),M(J,{key:1,onShowFoundMessages:C,onAddNewMessages:i,onAddNewMessagesToEnd:w,typingDetails:r(p),chat:r(d),messages:r(n)},null,8,["typingDetails","chat","messages"])):k("",!0)])])],64))}};export{as as default};
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.