import{r as p,ct as D,j as e,d as m,A as j,a as F,x as I,K as C,u as P,gk as b,gl as G,gm as $,gd as L}from"./index-Dz5JRQhj.js";import{s as M,p as R}from"./searchAndFilter-DtC_P-vv.js";const B="query",w="auth-method",E="system-identities",Y=[j.TLS,j.OIDC],v=[B,w,E],W=t=>t.type.startsWith("Server certificate")||t.type.startsWith("Metrics certificate"),O=()=>{const[t,i]=D(),r=[{id:1,heading:"Auth method",chips:Y.map(n=>({lead:w,value:n}))},{id:2,heading:"System identities",chips:[{lead:E,value:"hide"}]}],o=n=>{const a=R(n,t,v);a.toString()!==t.toString()&&i(a)};return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"u-off-screen",children:"Search and filter"}),e.jsx(m.SearchAndFilter,{existingSearchData:M(t,v),filterPanelData:r,returnSearchData:o,onExpandChange:()=>{window.dispatchEvent(new CustomEvent("resize",{detail:"search-and-filter"}))},onPanelToggle:()=>{window.dispatchEvent(new CustomEvent("sfp-toggle"))}})]})},q=p.memo(O),K=()=>{const{isFineGrained:t}=F();return{canDeleteIdentity:o=>I(t,"can_delete",o?.access_entitlements),canEditIdentity:o=>I(t,"can_edit",o?.access_entitlements)}},f=({isVisible:t,children:i,className:r})=>t?e.jsx("span",{className:C("tag",r),children:i}):null,k=({isVisible:t})=>t?e.jsxs(m.Notification,{severity:"caution",title:"Self-modification",className:"u-no-margin--bottom",id:"current-user-warning",children:["This action will modify the permissions of the current logged-in identity.",e.jsx("br",{}),e.jsx(f,{className:"u-no-margin--left",isVisible:t,children:"You"})," ","might not be able to reverse this change once you’ve made it."]}):null,U=(t,i)=>{const r=Object.keys(t),o=[];for(const n of r){const a=t[n],s=n===i,h=[],l=[];for(const c of a.added)h.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["+ ",c]},`${n}-${c}-added`));for(const c of a.removed)l.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["- ",e.jsx("span",{className:"removed",children:c})]},`${n}-${c}-removed`));o.push(e.jsxs("tr",{className:"modified-row",children:[e.jsx("td",{children:e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:[a.name,e.jsx(f,{isVisible:s,children:"You"})]})}),e.jsx("td",{children:h.concat(l)})]},n))}return o},Q=(t,i,r)=>{const o=Object.keys(t),n={};r.forEach(s=>n[s.id]=L(s));const a=[];for(const s of o){const h=t[s],l=[],c=[];for(const d of h.added){const g=d===i;l.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["+ ",n[d],e.jsx(f,{isVisible:g,children:"You"})]},`${s}-${d}-added`))}for(const d of h.removed){const g=d===i;c.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["- ",e.jsx("span",{className:"removed",children:n[d]}),e.jsx(f,{isVisible:g,children:"You"})]},`${s}-${d}-removed`))}a.push(e.jsxs("tr",{className:"modified-row",children:[e.jsx("td",{children:e.jsx("p",{className:"u-no-padding--top u-sv-1",children:s})}),e.jsx("td",{children:l.concat(c)})]},s))}return a},J=({groupIdentitiesChangeSummary:t,identityGroupsChangeSummary:i,identities:r,initialGroupBy:o})=>{const{data:n}=P(),a=p.useRef(null),[s,h]=p.useState(o),l=n?.auth_user_name??"",c=l in i,d=()=>{const u=a.current;if(!u)return;u.setAttribute("style","height: auto;");const N=window.innerHeight-64,S=b(".p-modal__header"),T=G("current-user-warning"),A=b(".p-modal__footer"),H=$(u),y=N-T-S-A;if(H>=y){const _=`height: ${y}px;`;u.setAttribute("style",_)}};m.useListener(window,d,"resize",!0),p.useEffect(d,[s]);const g=()=>{h(u=>u==="identity"?"group":"identity")};let x=[];return s==="identity"&&(x=U(i,l)),s==="group"&&(x=Q(t,l,r)),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:a,className:"confirm-table",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{className:"display-by-header",children:[s==="identity"?"Identity":"Group",e.jsx(m.Button,{onClick:g,className:"display-by-button u-no-margin",hasIcon:!0,dense:!0,appearance:"base",children:e.jsx(m.Icon,{name:"change-version"})})]}),e.jsx("th",{children:s==="identity"?"Group":"Identity"})]})}),e.jsx("tbody",{children:x})]})}),e.jsx(k,{isVisible:c})]})};export{w as A,J as G,k as L,q as P,B as Q,E as S,f as T,W as i,K as u};
