import{M as g}from"./MkPagination-DzUgufpZ.js";import{aA as I,b as n,M as k,bl as N,o as $,d as D,at as S,r as V,P as E,_ as F}from"./app-QjDgb7aF.js";import{_ as h}from"./MkAvatars.vue_vue_type_style_index_0_lang-C9VK6yA5.js";import{b as H,f as v,E as u,j as r,g as T,i as a,k as t,q as o,J as p,D as c,u as y,p as d,F as x,G as M,a as b}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const q={class:"_title"},J={class:"_content"},L={class:"_title"},W={class:"_content"},z={class:"_footer"},K=H({__name:"index",setup(O){const _=b("owned"),m=b("joined"),w={endpoint:"users/groups/owned",limit:10},C={endpoint:"users/groups/joined",limit:10},P=v(()=>[{icon:"ph-plus ph-bold ph-lg",text:n.ts.createGroup,handler:f}]);I(v(()=>({title:n.ts.groups,icon:"ph-users-three ph-bold ph-lg"})));async function f(){const{canceled:i,result:s}=await $({title:n.ts.groupName});i||(await D("users/groups/create",{name:s}),_.value.reload(),S())}async function j(i){const{canceled:s}=await V({type:"warning",text:n.t("leaveGroupConfirm",{name:i.name})});s||E("users/groups/leave",{groupId:i.id}).then(()=>{m.value.reload()})}return(i,s)=>{const B=u("MkPageHeader"),G=u("MkA"),A=u("MkSpacer");return r(),T(N,null,{header:a(()=>[t(B,{actions:P.value,"display-back-button":!0},null,8,["actions"])]),default:a(()=>[t(A,{"content-max":800,"margin-min":20},{default:a(()=>[t(k,{primary:"",style:{margin:"0 auto var(--margin) auto"},onClick:f},{default:a(()=>[s[0]||(s[0]=o("i",{class:"ph-plus ph-bold ph-lg"},null,-1)),p(" "+c(y(n).ts.createGroup),1)]),_:1}),t(g,{ref_key:"owned",ref:_,pagination:w},{default:a(({items:l})=>[(r(!0),d(x,null,M(l,e=>(r(),d("div",{key:e.id,class:"_card"},[o("div",q,[t(G,{to:`/my/groups/${e.id}`,class:"_link"},{default:a(()=>[p(c(e.name),1)]),_:2},1032,["to"])]),o("div",J,[t(h,{"user-ids":e.userIds},null,8,["user-ids"])])]))),128))]),_:1},512),t(g,{ref_key:"joined",ref:m,pagination:C},{default:a(({items:l})=>[(r(!0),d(x,null,M(l,e=>(r(),d("div",{key:e.id,class:"_card"},[o("div",L,c(e.name),1),o("div",W,[t(h,{"user-ids":e.userIds},null,8,["user-ids"])]),o("div",z,[t(k,{danger:"",onClick:Q=>j(e)},{default:a(()=>[p(c(y(n).ts.leaveGroup),1)]),_:1},8,["onClick"])])]))),128))]),_:1},512)]),_:1})]),_:1})}}}),te=F(K,[["__scopeId","data-v-ab46d8ba"]]);export{te as default};
//# sourceMappingURL=index-Bfovra_S.js.map
