import{d as _,o as t,c as s,p as w,e as d,a as r,X as E,f as c,a2 as K,t as a,G as T,D as U,E as z,F as k,n as D,g as C,m as G}from"./index-zfm-9r65.js";import{u as H,r as M,a as X}from"./useCommunityBrowser-BNj_STkI.js";import{u as O}from"./useUserRecruitment-BFGZQEpa.js";const Q={key:0,class:"absolute -right-0.5 -top-0.5 rounded border border-emerald-400/40 bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-emerald-200"},W={class:"flex min-w-0 items-center gap-3 pr-6"},Y={class:"relative h-10 w-10 shrink-0 overflow-hidden rounded-2xl border border-slate-700"},Z=["src","alt"],ee={class:"min-w-0 flex-1 truncate text-base font-semibold text-slate-100"},te={class:"mt-1 text-xs text-slate-400"},oe={key:0},se={key:1,class:"mt-3 line-clamp-3 flex-1 text-sm text-slate-400"},ne={key:2,class:"mt-3 flex-1 text-sm text-slate-500 italic"},ie=["disabled"],ae=_({__name:"CommunityBrowserCommunityCard",props:{community:{},action:{},actionLabel:{},actionButtonClass:{},actionInProgress:{type:Boolean}},emits:["action"],setup(o,{emit:m}){const b=m;return(y,u)=>(t(),s("article",{class:w(["relative flex flex-col rounded-xl border border-slate-800 bg-slate-900/70 p-4",o.action==="member"?"opacity-60":""])},[o.action==="member"?(t(),s("span",Q," Member ")):d("",!0),r("div",W,[r("div",Y,[o.community.icon?(t(),s("img",{key:0,src:o.community.icon,alt:o.community.name,class:"h-full w-full object-cover"},null,8,Z)):(t(),s("span",{key:1,class:"flex h-full w-full items-center justify-center text-xs font-semibold text-white",style:E({backgroundColor:c(K)(o.community.name)})},a(o.community.name.slice(0,2).toUpperCase()),5))]),r("h3",ee,a(o.community.name),1)]),r("p",te,[T(a(o.community.isPrivate?"Private":"Public")+" ",1),o.community.allowsJoinRequests?(t(),s("span",oe," · Join requests")):d("",!0)]),o.community.description?(t(),s("p",se,a(o.community.description),1)):(t(),s("p",ne," No description ")),o.actionLabel?(t(),s("button",{key:3,type:"button",class:w(["mt-4 w-full rounded-md border px-3 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-50",o.actionButtonClass]),disabled:o.actionInProgress,onClick:u[0]||(u[0]=x=>b("action"))},a(o.actionLabel),11,ie)):d("",!0)],2))}}),ce={class:"h-full overflow-y-auto p-6"},re={class:"mb-6"},le={class:"mt-1 text-2xl font-semibold text-slate-100"},me={key:0,class:"text-sm text-slate-400"},ue={key:1,class:"text-sm text-rose-300"},de={key:0,class:"mb-4 rounded-md border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-sm text-rose-200"},be={key:1,class:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"},ye={key:2,class:"text-sm text-slate-400"},xe={key:3,class:"text-sm text-slate-400"},pe=_({__name:"CommunityBrowserHomeView",setup(o){const m=H(),b=O(),y=U(),{communities:u}=z(y),{loading:x,error:f,selectedServer:v,communitiesForSelectedServer:B}=m,{invites:q,requests:$,actionError:h,actionInProgressId:S,acceptInvite:I,withdrawRequest:L,requestJoin:A}=b,F=C(()=>v.value?.label??"Browse communities"),p=C(()=>{const e=new Set(u.value.map(l=>l.id)),n=q.value,i=$.value;return B.value.map(l=>{const g=M(l,e,n,i);return{community:l,action:g,actionKey:X(l,g,n,i)}})});function P(e){return S.value===e}function R(e){const n=m.inviteForCommunity(e);n&&I(n)}function N(e){const n=m.requestForCommunity(e);n&&L(n)}function j(e){switch(e){case"accept-invite":return"Accept invitation";case"cancel-request":return"Cancel request";case"join":return"Join";default:return null}}function J(e){switch(e){case"accept-invite":return"border-emerald-400/50 bg-emerald-500/20 text-emerald-100 hover:bg-emerald-500/30";case"cancel-request":return"border-rose-400/50 bg-rose-500/10 text-rose-100 hover:bg-rose-500/20";default:return"border-blue-400/50 bg-blue-500/20 text-blue-100 hover:bg-blue-500/30"}}function V(e){if(e.action==="accept-invite"){R(e.community.id);return}if(e.action==="cancel-request"){N(e.community.id);return}e.action==="join"&&A(e.community)}return(e,n)=>(t(),s("section",ce,[r("header",re,[n[0]||(n[0]=r("p",{class:"text-xs uppercase tracking-wide text-slate-400"},"Communities",-1)),r("h1",le,a(F.value),1)]),c(x)?(t(),s("p",me,"Loading communities...")):c(f)?(t(),s("p",ue,a(c(f)),1)):(t(),s(k,{key:2},[c(h)?(t(),s("p",de,a(c(h)),1)):d("",!0),p.value.length>0?(t(),s("div",be,[(t(!0),s(k,null,D(p.value,i=>(t(),G(ae,{key:i.community.id,community:i.community,action:i.action,"action-label":j(i.action),"action-button-class":J(i.action),"action-in-progress":P(i.actionKey),onAction:l=>V(i)},null,8,["community","action","action-label","action-button-class","action-in-progress","onAction"]))),128))])):c(v)?(t(),s("p",ye," No communities to browse on this server. ")):(t(),s("p",xe," Select a server in the sidebar to browse its communities. "))],64))]))}});export{pe as default};
//# sourceMappingURL=CommunityBrowserHomeView-C3d7LGFB.js.map
