3 lines
31 KiB
JavaScript
3 lines
31 KiB
JavaScript
|
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-fFnFILYR.js","assets/vendor-react-YMhRUmcb.js","assets/vendor-BD_zwJK7.css"])))=>i.map(i=>d[i]);
|
||
|
|
import{a as n,j as e}from"./vendor-react-YMhRUmcb.js";import{g as Y,D as de,E as q,B as _,p as ee,a as M,d as b,u as A,l as O,L as te,_ as se,h as ue,i as K,C as W}from"./index-D2uzyr9g.js";import{u as re,a as ae,b as H}from"./vendor-tanstack-CoFNL2zy.js";import{L as V,I as ne}from"./input-DL1WY4HG.js";import{S as me}from"./Select-So_RP28r.js";import{u as T}from"./chatStore-VE5eaeTh.js";import{z as oe,g as he,U as xe,a8 as pe,a9 as fe,l as ge,T as ye,aa as be,ab as F,a0 as ve,j as je,S as ie,X as Q,ac as we,ad as B,ae as ke,af as Ne,ag as Ce,ah as Se,A as J}from"./vendor-icons-DINCNwpk.js";import{D as _e,a as Ee,b as Re,c as G,u as De}from"./useIsRateLimited-C43yhDlJ.js";import{C as Z}from"./confirmation-dialog-O1mUMh9e.js";import{D as ze,T as le,E as Te}from"./vendor-fFnFILYR.js";import"./vendor-router-DX94Iu-2.js";import"./vendor-utils-4BWoYre8.js";import"./dropdown-DLDDI8f2.js";function Le({open:t,onClose:l}){const[a,o]=n.useState(""),[m,c]=n.useState("public"),[d,s]=n.useState(!1),[i,u]=n.useState(null),[f,p]=n.useState(null),[r,v]=n.useState(0),g=n.useRef(null),w=Y(),{addConversation:E,setCurrentConversation:R}=T(),D=async()=>{if(u(null),p(null),!a.trim()){u("Room name is required");return}const k=a.trim(),x=m,j=async()=>{const S=await M.post("/conversations",{name:k,type:x}),N={id:S.data.id||S.data.conversation?.id,name:S.data.name||S.data.conversation?.name,type:S.data.type||S.data.conversation?.type||x,participants:S.data.participants||[],unread_count:0};E(N),R(N.id),w.success("Room created successfully"),o(""),c("public"),p(null),v(0),g.current=null,l()};g.current=j,s(!0);try{await j()}catch(S){const N=ee(S);p(new Error(N.message))}finally{s(!1)}},P=async()=>{if(!(!g.current||r>=3)){v(k=>k+1),s(!0);try{await g.current()}catch{}finally{s(!1)}}};return e.jsx(de,{open:t,onClose:l,title:"Create New Room",variant:"default",size:"md",children:e.jsxs("div",{className:"space-y-4",children:[f&&e.jsx(q,{error:f,variant:"banner",severity:"error",context:{action:"creating room",resource:"conversation"},onRetry:r<3?P:void 0,onDismiss:()=>{p(null),v(0),g.current=null}}),i&&e.jsx(q,{error:i,variant:"inline",severity:"error",size:"sm",dismissible:!1}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"room-name",children:"Room Name"}),e.jsx(ne,{id:"room-name",value:a,onChange:k=>{o(k.target.value),u(null)},placeholder:"Enter room name",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"room-type",children:"Room Type"}),e.jsx(me,{options:[{value:"public",label:"Public"},{value:"private",label:"Private"}],value:m,onChange:k=>c(Array.isArray(k)?k[0]:k),name:"room-type"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(_,{variant:"outline",onClick:l,disabled:d,children:"Cancel"}),e.jsx(_,{onClick:D,disabled:d||!a.trim(),children:d?"Creating...":"Create Room"})]})]})})}function Me(t,l,a){const{data:o,isLoading:m,error:c}=re({queryKey:["chatConversations",t],queryFn:async()=>{if(!t)return[];const s=(await M.get("/conversations")).data,i=Array.isArray(s)?s:s?.conversations??[];return Array.isArray(i)?i:[]},enabled:!!t});return n.useEffect(()=>{o&&o.forEach(d=>{a.some(s=>s.id===d.id)||l({id:d.id,name:d.name,type:d.type??"direct",participants:Array.isArray(d.participants)?d.participants:[],unread_count:0})})},[o,a,l]),{data:o??[],isLoading:m,error:c}}function Pe({count:t,className:l}){return e.jsx("div",{className:b("p-4 border-b border-white/5 bg-white/2 backdrop-blur-sm",l),children:e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("h2",{className:"text-sm font-bold text-foreground tracking-wide uppercase flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-muted-foreground"}),"Active Channels"]}),e.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:t})]})})}function Ae({className:t}){return e.jsxs("div",{className:b("text-muted-foreground/70 text-sm p-4 text-center italic border border-dashed border-border rounded-xl m-2",t),children:["No active frequencies det
|