import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Cg as t,Cp as n,Eg as r,Fg as i,Gy as a,Hy as o,Ly as s,Sg as c,Td as l,Tg as u,Zv as d,ap as f,dg as p,dv as m,gv as h,hv as g,jg as _,lh as v,m_ as y,mv as b,pv as x,td as S,ty as C,wg as w,xg as T}from"./index-DDwwBb9e.js";import{t as E}from"./useActivePlan-DFB_ziHo.js";import{t as D}from"./WithPermissionGuard-wX0IC3VF.js";import{t as O}from"./SettingsLayout-DkhRoxt1.js";import{t as k}from"./ContactSalesBlock-DMO-yge2.js";var A=e(a()),j=n(),M=o();function N(e){return e===`ADMIN`?`red`:e===`MEMBER`?`blue`:e===`VIEWER`?`gray`:`purple`}function P(e){return e===j.RoleBindingScopeType.ORGANIZATION?`orange`:e===j.RoleBindingScopeType.TEAM?`teal`:`purple`}function F(e){return e===j.RoleBindingScopeType.ORGANIZATION?`Org`:e===j.RoleBindingScopeType.TEAM?`Team`:`Project`}function I(e){let t=new Map;for(let n of e){let e=n.userId??n.groupId??`unknown`;t.has(e)||t.set(e,{key:e,userId:n.userId,userName:n.userName,userEmail:n.userEmail,groupId:n.groupId,groupName:n.groupName,groupScimSource:n.groupScimSource,bindings:[]}),t.get(e).bindings.push(n)}return[...t.values()].sort((e,t)=>{let n=e.userName??e.groupName??e.userEmail??``,r=t.userName??t.groupName??t.userEmail??``;return n.localeCompare(r)})}function L({principal:e}){return e.userId?(0,M.jsxs)(y,{gap:2,children:[(0,M.jsx)(S,{id:e.userId,name:e.userName??e.userEmail??`?`,size:`xs`}),(0,M.jsxs)(p,{gap:0,align:`start`,children:[e.userName&&(0,M.jsx)(d,{fontWeight:`medium`,fontSize:`sm`,children:e.userName}),(0,M.jsx)(d,{fontSize:`xs`,color:`fg.muted`,children:e.userEmail??``})]})]}):(0,M.jsxs)(y,{gap:2,children:[(0,M.jsx)(s,{width:`6`,height:`6`,borderRadius:`full`,bg:`blue.subtle`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,children:(0,M.jsx)(l,{size:12})}),(0,M.jsxs)(p,{gap:0,align:`start`,children:[(0,M.jsx)(d,{fontWeight:`medium`,fontSize:`sm`,children:e.groupName??`Unknown group`}),e.groupScimSource&&(0,M.jsx)(h,{size:`xs`,colorPalette:`blue`,children:e.groupScimSource.toUpperCase()})]})]})}function R({bindings:e}){return(0,M.jsx)(p,{gap:1,align:`end`,children:e.map(e=>(0,M.jsxs)(y,{gap:1,children:[(0,M.jsx)(h,{colorPalette:N(e.role),size:`sm`,children:e.customRoleName??e.role}),(0,M.jsx)(d,{fontSize:`xs`,color:`fg.muted`,children:`on`}),(0,M.jsxs)(h,{colorPalette:P(e.scopeType),size:`sm`,children:[F(e.scopeType),` · `,e.scopeName??e.scopeId.slice(0,8)+`…`]})]},e.id))})}var z=[{label:`All`,value:`ALL`},{label:`Org`,value:j.RoleBindingScopeType.ORGANIZATION},{label:`Team`,value:j.RoleBindingScopeType.TEAM},{label:`Project`,value:j.RoleBindingScopeType.PROJECT}];function B({active:e,onChange:t}){return(0,M.jsx)(y,{gap:1,children:z.map(n=>(0,M.jsx)(b,{size:`sm`,variant:e===n.value?`subtle`:`ghost`,colorPalette:e===n.value?`blue`:`gray`,onClick:()=>t(n.value),children:n.label},n.value))})}function V(){let{organization:e}=f(),{isEnterprise:n,isLoading:a}=E(),[o,l]=(0,A.useState)(`ALL`),{data:h,isLoading:b}=v.roleBinding.listForOrg.useQuery({organizationId:e?.id??``},{enabled:!!e?.id&&n});if(a||!e)return(0,M.jsx)(O,{children:(0,M.jsx)(g,{})});if(!n)return(0,M.jsx)(O,{children:(0,M.jsx)(s,{width:`full`,children:(0,M.jsx)(k,{})})});let S=I(o===`ALL`?h??[]:(h??[]).filter(e=>e.scopeType===o));return(0,M.jsx)(O,{children:(0,M.jsxs)(p,{align:`start`,gap:6,width:`full`,children:[(0,M.jsxs)(p,{align:`start`,gap:1,width:`full`,children:[(0,M.jsx)(C,{as:`h2`,children:`Role Bindings`}),(0,M.jsx)(d,{color:`fg.muted`,fontSize:`sm`,children:`All role bindings in this organization.`})]}),(0,M.jsx)(i,{}),(0,M.jsxs)(y,{width:`full`,children:[(0,M.jsx)(B,{active:o,onChange:l}),(0,M.jsx)(_,{}),h&&(0,M.jsxs)(d,{fontSize:`sm`,color:`fg.muted`,children:[S.length,` `,S.length===1?`principal`:`principals`]})]}),(0,M.jsx)(x,{width:`full`,overflow:`hidden`,children:(0,M.jsx)(m,{paddingY:0,paddingX:0,children:b?(0,M.jsx)(s,{padding:8,display:`flex`,justifyContent:`center`,children:(0,M.jsx)(g,{})}):S.length===0?(0,M.jsx)(s,{padding:8,textAlign:`center`,children:(0,M.jsx)(d,{color:`fg.muted`,children:`No role bindings found.`})}):(0,M.jsxs)(u,{variant:`line`,size:`md`,width:`full`,children:[(0,M.jsx)(w,{children:(0,M.jsxs)(r,{children:[(0,M.jsx)(t,{width:`240px`,children:`Who`}),(0,M.jsx)(t,{textAlign:`right`,children:`Access`})]})}),(0,M.jsx)(T,{children:S.map(e=>(0,M.jsxs)(r,{children:[(0,M.jsx)(c,{children:(0,M.jsx)(L,{principal:e})}),(0,M.jsx)(c,{children:(0,M.jsx)(R,{bindings:e.bindings})})]},e.key))})]})})})]})})}var H=D(`organization:manage`,{layoutComponent:O})(V);export{H as default};
//# sourceMappingURL=role-bindings-Byrh3QAL.js.map