import{d as R,a8 as E,k as F,E as S,c as t,a as s,t as d,F as h,e as x,n as A,r as m,o,w as N,f as V,am as f,z as $,g as B,i as D,x as L}from"./index-BhMpD06x.js";import{u as P}from"./useCommunityApiClient-CDo7XB-D.js";const j={class:"h-full overflow-y-auto p-6"},z={key:0,class:"text-sm text-slate-400"},K={key:1,class:"text-sm text-rose-300"},q={key:0,class:"mb-3 text-sm text-rose-300"},G={class:"space-y-2"},H=["onClick"],J={class:"truncate text-sm font-medium text-slate-100"},O={class:"truncate text-xs text-slate-400"},Q=["disabled","onClick"],T={key:0,class:"text-sm text-slate-400"},X=R({__name:"CommunitySettingsMembersView",props:{communityId:{}},setup(_){const a=_,y=P(()=>a.communityId),g=E(),w=D(),k=B(()=>g.canDeleteCommunityMember(a.communityId,y.serverDomain())),v=m(!1),l=m(null),i=m([]),b=m(null),c=m(null);async function p(){v.value=!0,l.value=null;try{const e=await y.client().getCommunityMembers(a.communityId);i.value=e.profiles}catch(e){l.value=e instanceof Error?e.message:"Failed to load members",i.value=[]}finally{v.value=!1}}function C(e){w.push({name:"community-settings-members-edit",params:{communityId:a.communityId,userRef:f(e.user)}})}async function M(e){if(!window.confirm("Remove this member from the community?"))return;const r=f(e.user);b.value=r,c.value=null;try{await y.client().deleteCommunityMember(a.communityId,r),await p()}catch(u){c.value=u instanceof Error?u.message:"Failed to remove member"}finally{b.value=null}}return F(()=>a.communityId,()=>{p()}),S(()=>{p()}),(e,r)=>{const u=L("FontAwesomeIcon");return o(),t("section",j,[r[0]||(r[0]=s("header",{class:"mb-4"},[s("p",{class:"text-xs uppercase tracking-wide text-slate-400"},"Community settings"),s("h1",{class:"mt-1 text-2xl font-semibold text-slate-100"},"Members")],-1)),v.value?(o(),t("p",z,"Loading members...")):l.value?(o(),t("p",K,d(l.value),1)):(o(),t(h,{key:2},[c.value?(o(),t("p",q,d(c.value),1)):x("",!0),s("ul",G,[(o(!0),t(h,null,A(i.value,n=>(o(),t("li",{key:`${n.user.username}@${n.user.homeServer}`,class:"flex items-center gap-2 rounded-lg border border-slate-800 bg-slate-900/70 px-3 py-2"},[s("button",{type:"button",class:"min-w-0 flex-1 cursor-pointer text-left",onClick:I=>C(n)},[s("p",J,d(n.user.username),1),s("p",O,d(n.user.homeServer),1)],8,H),s("button",{type:"button",class:"flex h-8 w-8 shrink-0 items-center justify-center rounded border border-rose-400/50 text-rose-200 transition hover:bg-rose-500/20 disabled:cursor-not-allowed disabled:opacity-50",title:"Remove member","aria-label":"Remove member",disabled:!k.value||b.value===V(f)(n.user),onClick:N(I=>{M(n)},["stop"])},[$(u,{class:"h-3.5 w-3.5",icon:["fas","trash"]})],8,Q)]))),128)),i.value.length===0?(o(),t("li",T,"No members found.")):x("",!0)])],64))])}}});export{X as default};
//# sourceMappingURL=CommunitySettingsMembersView-DiW1sWBq.js.map
