@fntio/infra-client
Version:
Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.
9 lines • 110 kB
JavaScript
import{b as Ae,e as H}from"./chunk-252EGHSF.js";import{a as Re,i as Pt,k as Ft,p as Bt,x as $t,y as Ot,z as Gt}from"./chunk-SFL4IAVC.js";import{a as Me,b as At}from"./chunk-DEPFCVZL.js";import{a as ce}from"./chunk-GK2T2SMO.js";import{f as Ve}from"./chunk-Y6FHN4DA.js";import{c as ht}from"./chunk-TOO3FEYQ.js";import{a as ke}from"./chunk-6CP7VLN2.js";import{a as se}from"./chunk-KRQ75YR4.js";import{a as Q}from"./chunk-64ITJKG6.js";import{a as wt}from"./chunk-IKK5DQ3Z.js";import{a as xt}from"./chunk-LEEL6MDA.js";import{a as yt,b as St}from"./chunk-HUXCPIDO.js";import{a as j}from"./chunk-XPF5YBGU.js";import{a as vt}from"./chunk-XUEIITMC.js";import{a as bt}from"./chunk-2DD7CZB4.js";import{a as Nt}from"./chunk-YGAHR42T.js";import{a as le,b as Ne,c as de,d as Mt}from"./chunk-NTF5XIGH.js";import{b as Rt}from"./chunk-Z3HRRJWO.js";import{a as Vt}from"./chunk-3PQNISIL.js";import{a as Ie}from"./chunk-SH2F2DCQ.js";import{a as De}from"./chunk-V32HQ2F2.js";import{a as Ut}from"./chunk-Q736XS6E.js";import{a as kt,b as Tt}from"./chunk-TVCLJWZS.js";import{a as ee}from"./chunk-WM5A6BAU.js";import{a as Dt,d as It,e as q}from"./chunk-JNANYFF2.js";import{a as $}from"./chunk-YMC4QOLO.js";import{b as Ue,d as Ee}from"./chunk-6NTXC6VK.js";import{a as ae}from"./chunk-6HVGPPAG.js";import{a as Et}from"./chunk-Y2PHG5VS.js";import{a as Te}from"./chunk-SYLZLLGS.js";import{a as Ct}from"./chunk-IVXFG5AJ.js";import{d as re}from"./chunk-2SO4BVIT.js";import{a as R}from"./chunk-2BNLISUN.js";import{a as J,b as X,e as Y,o as Z,p as k}from"./chunk-T5HLFYHP.js";import{a as ne,c as N}from"./chunk-KCJ5HNXP.js";import{a as L}from"./chunk-3SC2PPSK.js";import{a as M}from"./chunk-B67EMZ2H.js";import{b as oe}from"./chunk-MID2IYAR.js";import{a as I}from"./chunk-7A4HO4AV.js";import{$a as ie,Aa as a,B as at,Ba as r,Ca as T,F as st,Ga as he,Ha as be,I as b,Ja as v,K as p,L as m,La as u,Na as d,Oa as dt,Pa as ct,Pb as _t,Q as xe,R as x,Ra as _e,Rb as gt,Sa as ye,Sb as ft,Ua as Qe,Va as pt,Wa as B,Xa as l,Ya as C,Za as y,_ as s,_a as K,ab as mt,bb as A,cb as P,db as F,g as et,ga as E,ib as ut,jb as Je,k as tt,ka as Ce,m as nt,nb as Se,pb as W,qb as h,rb as z,s as it,sa as ve,sb as V,ta as g,tb as D,ua as f,ub as ge,v as ot,va as lt,w as rt,wa as te,wb as we,xa as S,ya as w,za as _}from"./chunk-FYA6QUPZ.js";import{c as Ze}from"./chunk-WFIHWVQO.js";var Pe=class i{api=b(R);groupsApi=b(le);users=x(null);groups=x([]);error=x("");groupsOf=h(()=>{let t=new Map;for(let e of this.groups())for(let n of e.members){let o=t.get(n.userId)??[];o.push(e),t.set(n.userId,o)}return t});upsert(t){this.users.update(e=>[...(e??[]).filter(n=>n.userId!==t.userId),t])}load(){this.error.set(""),this.api.listUsers().subscribe({next:t=>this.users.set(t),error:()=>{this.users.set([]),this.error.set("Could not load users. Try reloading the page.")}}),this.groupsApi.list().subscribe({next:t=>this.groups.set(t),error:()=>this.groups.set([])})}static \u0275fac=function(e){return new(e||i)};static \u0275prov=st({token:i,factory:i.\u0275fac,providedIn:"root"})};var Xt=["*"],pe=class i{maxHeight=D("max-h-56");classes=h(()=>`block overflow-y-auto rounded-lg border border-border-strong ${this.maxHeight()}`);static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-checklist"]],hostVars:2,hostBindings:function(e,n){e&2&&B(n.classes())},inputs:{maxHeight:[1,"maxHeight"]},ngContentSelectors:Xt,decls:1,vars:0,template:function(e,n){e&1&&(dt(),ct(0))},encapsulation:2})};var Lt=(i,t)=>t.userId;function Yt(i,t){if(i&1&&(a(0,"span",8),l(1),r()),i&2){let e=d().$implicit;s(),C(e.message)}}function Zt(i,t){if(i&1&&(a(0,"div",3)(1,"span"),l(2),r(),a(3,"span",6)(4,"span",7),l(5),r(),g(6,Yt,2,1,"span",8),r()()),i&2){let e=t.$implicit,n=d(2);s(),B(e.status==="DELETED"?"text-success":"text-danger"),s(),y(" ",e.status==="DELETED"?"\u2713":"\u2715"," "),s(3),C(n.emailOf(e.userId)),s(),f(e.message?6:-1)}}function en(i,t){if(i&1){let e=v();a(0,"p",1),l(1),r(),a(2,"div",2),S(3,Zt,7,5,"div",3,Lt),r(),a(5,"div",4)(6,"app-button",5),u("click",function(){p(e);let o=d();return m(o.closed.emit())}),l(7,"Done"),r()()}if(i&2){let e=t,n=d();s(),ie(" ",n.deletedCount()," of ",e.length," user",e.length===1?"":"s"," deleted. "),s(2),w(e)}}function tn(i,t){if(i&1){let e=v();a(0,"label",12)(1,"input",18),u("change",function(){let o=p(e).$implicit,c=d(2);return m(c.toggle(o.userId))}),r(),a(2,"span",19),l(3),r()()}if(i&2){let e=t.$implicit,n=d(2);s(),_("checked",n.picked().has(e.userId)),s(2),C(e.email||e.userId)}}function nn(i,t){if(i&1&&(a(0,"p",13),l(1),r()),i&2){let e=d(2);s(),y('No users match "',e.query(),'".')}}function on(i,t){if(i&1&&(a(0,"p",14),l(1),r()),i&2){let e=d(2);s(),C(e.error())}}function rn(i,t){if(i&1){let e=v();a(0,"app-banner",9),l(1," Deleting removes each checked user's account, role grants, open requests, and group memberships \u2014 immediately. This can't be undone. "),r(),a(2,"input",10),u("ngModelChange",function(o){p(e);let c=d();return m(c.query.set(o))}),r(),a(3,"app-checklist",11),S(4,tn,4,2,"label",12,Lt,!1,nn,2,1,"p",13),r(),g(7,on,2,1,"p",14),a(8,"div",15)(9,"app-button",16),u("click",function(){p(e);let o=d();return m(o.closed.emit())}),l(10,"Cancel"),r(),a(11,"app-button",17),u("click",function(){p(e);let o=d();return m(o.confirm())}),l(12),r()()}if(i&2){let e=d();s(2),_("ngModel",e.query()),s(2),w(e.filtered()),s(3),f(e.error()?7:-1),s(4),_("loading",e.busy())("disabled",e.picked().size===0),s(),K(" Delete ",e.picked().size||""," user",e.picked().size===1?"":"s"," ")}}var Fe=class i{api=b(R);toast=b(N);users=D.required();preselect=D([]);deleted=V();closed=V();query=x("");picked=x(new Set);busy=x(!1);error=x("");results=x(null);filtered=h(()=>{let t=this.query().trim().toLowerCase();return t?this.users().filter(e=>e.email.toLowerCase().includes(t)):this.users()});deletedCount=h(()=>(this.results()??[]).filter(t=>t.status==="DELETED").length);ngOnInit(){this.picked.set(new Set(this.preselect()))}emailOf(t){return this.users().find(e=>e.userId===t)?.email??t}toggle(t){this.picked.update(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})}confirm(){this.picked().size!==0&&(this.error.set(""),this.busy.set(!0),this.api.deleteUsers([...this.picked()]).subscribe({next:t=>{this.busy.set(!1),this.results.set(t);let e=t.filter(n=>n.status==="DELETED").length;e?(this.toast.success(`Deleted ${e} user${e===1?"":"s"}`),this.deleted.emit()):this.toast.error("No users were deleted \u2014 see the details.")},error:t=>{this.busy.set(!1),this.error.set(k(t,"Could not delete the users."))}}))}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-bulk-delete-dialog"]],inputs:{users:[1,"users"],preselect:[1,"preselect"]},outputs:{deleted:"deleted",closed:"closed"},decls:3,vars:2,consts:[[3,"closed","title"],[1,"mb-2","text-sm","text-muted-foreground"],[1,"max-h-72","overflow-y-auto","rounded-lg","border","border-border-strong"],[1,"flex","items-start","gap-2.5","border-b","border-border","px-3","py-2","text-sm","last:border-b-0"],[1,"mt-5","flex","justify-end"],[3,"click"],[1,"min-w-0","flex-1"],[1,"block","truncate","text-surface-foreground"],[1,"block","text-xs","text-danger"],["tone","danger"],["placeholder","Filter by email",1,"ui-input","mb-2","mt-3",3,"ngModelChange","ngModel"],["maxHeight","max-h-56"],[1,"ui-check-row","text-sm"],[1,"px-3","py-3","text-sm","text-muted-foreground"],[1,"mt-2","text-sm","text-danger"],[1,"mt-5","flex","justify-end","gap-2"],["variant","outline",3,"click"],["variant","danger",3,"click","loading","disabled"],["type","checkbox",1,"ui-checkbox",3,"change","checked"],[1,"min-w-0","flex-1","truncate","text-surface-foreground"]],template:function(e,n){if(e&1&&(a(0,"app-dialog",0),u("closed",function(){return n.closed.emit()}),g(1,en,8,3)(2,rn,13,7),r()),e&2){let o;_("title",n.results()?"Users deleted":"Delete users"),s(),f((o=n.results())?1:2,o)}},dependencies:[Z,J,X,Y,L,I,M,pe],encapsulation:2})};var jt=(i,t)=>t.userId;function an(i,t){if(i&1&&(a(0,"span",7),l(1),r()),i&2){let e=d().$implicit;s(),C(e.message)}}function sn(i,t){if(i&1&&(a(0,"div",2)(1,"span"),l(2),r(),a(3,"span",5)(4,"span",6),l(5),r(),g(6,an,2,1,"span",7),r()()),i&2){let e=t.$implicit,n=d(2);s(),B(e.ok?"text-success":"text-danger"),s(),y(" ",e.ok?"\u2713":"\u2715"," "),s(3),C(n.emailOf(e.userId)),s(),f(e.message?6:-1)}}function ln(i,t){if(i&1){let e=v();a(0,"p",0),l(1),r(),a(2,"div",1),S(3,sn,7,5,"div",2,jt),r(),a(5,"div",3)(6,"app-button",4),u("click",function(){p(e);let o=d();return m(o.closed.emit())}),l(7,"Done"),r()()}if(i&2){let e=t,n=d();s(),ie(" ",n.sentCount()," of ",e.length," invitation email",e.length===1?"":"s"," sent. "),s(2),w(e)}}function dn(i,t){if(i&1){let e=v();a(0,"label",11)(1,"input",17),u("change",function(){let o=p(e).$implicit,c=d(2);return m(c.toggle(o.userId))}),r(),a(2,"span",18),l(3),r()()}if(i&2){let e=t.$implicit,n=d(2);s(),_("checked",n.picked().has(e.userId)),s(2),C(e.email||e.userId)}}function cn(i,t){if(i&1&&(a(0,"p",12),l(1),r()),i&2){let e=d(2);s(),y('No users match "',e.query(),'".')}}function pn(i,t){if(i&1&&(a(0,"p",13),l(1),r()),i&2){let e=d(2);s(),C(e.error())}}function mn(i,t){if(i&1){let e=v();a(0,"p",8),l(1," Only selected users still on their invite's temporary password are listed. Each checked user gets a fresh set-password email. "),r(),a(2,"input",9),u("ngModelChange",function(o){p(e);let c=d();return m(c.query.set(o))}),r(),a(3,"app-checklist",10),S(4,dn,4,2,"label",11,jt,!1,cn,2,1,"p",12),r(),g(7,pn,2,1,"p",13),a(8,"div",14)(9,"app-button",15),u("click",function(){p(e);let o=d();return m(o.closed.emit())}),l(10,"Cancel"),r(),a(11,"app-button",16),u("click",function(){p(e);let o=d();return m(o.send())}),l(12),r()()}if(i&2){let e=d();s(2),_("ngModel",e.query()),s(2),w(e.filtered()),s(3),f(e.error()?7:-1),s(4),_("loading",e.busy())("disabled",e.picked().size===0),s(),K(" Send ",e.picked().size||""," invite",e.picked().size===1?"":"s"," ")}}var Be=class i{api=b(R);toast=b(N);users=D.required();preselect=D([]);sentAny=V();closed=V();query=x("");picked=x(new Set);busy=x(!1);error=x("");results=x(null);filtered=h(()=>{let t=this.query().trim().toLowerCase();return t?this.users().filter(e=>e.email.toLowerCase().includes(t)):this.users()});sentCount=h(()=>(this.results()??[]).filter(t=>t.ok).length);ngOnInit(){this.picked.set(new Set(this.preselect()))}emailOf(t){return this.users().find(e=>e.userId===t)?.email??t}toggle(t){this.picked.update(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})}send(){if(this.picked().size===0)return;this.error.set(""),this.busy.set(!0);let t=[...this.picked()].map(e=>this.api.resendInvite(e).pipe(tt(()=>({userId:e,ok:!0})),it(n=>et({userId:e,ok:!1,message:k(n,"Could not send the invite email")}))));nt(t).subscribe(e=>{this.busy.set(!1),this.results.set(e);let n=e.filter(o=>o.ok).length;n?(this.toast.success(`Re-sent ${n} invitation${n===1?"":"s"}`),this.sentAny.emit()):this.toast.error("No invitations were sent \u2014 see the details.")})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-resend-invites"]],inputs:{users:[1,"users"],preselect:[1,"preselect"]},outputs:{sentAny:"sentAny",closed:"closed"},decls:2,vars:1,consts:[[1,"mb-2","text-xs","text-muted-foreground"],[1,"max-h-72","overflow-y-auto","rounded-lg","border","border-border-strong"],[1,"flex","items-start","gap-2.5","border-b","border-border","px-3","py-2","text-sm","last:border-b-0"],[1,"mt-5","flex","justify-end"],[3,"click"],[1,"min-w-0","flex-1"],[1,"block","truncate","text-surface-foreground"],[1,"block","text-xs","text-danger"],[1,"mb-3","text-xs","text-muted-foreground"],["placeholder","Filter by email",1,"ui-input","mb-2",3,"ngModelChange","ngModel"],["maxHeight","max-h-56"],[1,"ui-check-row","text-sm"],[1,"px-3","py-3","text-xs","text-muted-foreground"],[1,"mt-2","text-xs","text-danger"],[1,"mt-5","flex","justify-end","gap-2"],["variant","outline",3,"click"],[3,"click","loading","disabled"],["type","checkbox",1,"ui-checkbox",3,"change","checked"],[1,"min-w-0","flex-1","truncate","text-surface-foreground"]],template:function(e,n){if(e&1&&g(0,ln,8,3)(1,mn,13,7),e&2){let o;f((o=n.results())?0:1,o)}},dependencies:[Z,J,X,Y,I,pe],encapsulation:2})};var un=(i,t)=>t.email;function _n(i,t){if(i&1&&(a(0,"div",1)(1,"span",6),l(2,"App"),r(),a(3,"span",7),l(4),r(),T(5,"app-copy-button",8),r()),i&2){let e=d(2);s(4),C(e.appUrl),s(),_("text",e.appUrl)}}function gn(i,t){if(i&1&&(a(0,"span",11),l(1),r()),i&2){let e=d().$implicit;s(),C(e.message)}}function fn(i,t){if(i&1&&T(0,"app-copy-button",12),i&2){let e=d(3);_("text",e.absolute(t))}}function xn(i,t){if(i&1&&(a(0,"div",3)(1,"span"),l(2),r(),a(3,"span",9)(4,"span",10),l(5),r(),g(6,gn,2,1,"span",11),r(),g(7,fn,1,1,"app-copy-button",12),r()),i&2){let e,n=t.$implicit;s(),B(n.status==="CREATED"?"text-success":"text-danger"),s(),y(" ",n.status==="CREATED"?"\u2713":"\u2715"," "),s(3),C(n.email),s(),f(n.message?6:-1),s(),f((e=n.signupLink)?7:-1,e)}}function Cn(i,t){if(i&1){let e=v();a(0,"p",0),l(1),r(),g(2,_n,6,2,"div",1),a(3,"div",2),S(4,xn,8,6,"div",3,un),r(),a(6,"div",4)(7,"app-button",5),u("click",function(){p(e);let o=d();return m(o.closed.emit())}),l(8,"Done"),r()()}if(i&2){let e=d();s(),mt(" ",e.createdCount()," of ",e.results().length," user",e.results().length===1?"":"s"," created",e.sendEmail()?" and invited by email":" \u2014 no emails sent; copy each sign-up link below",". Everyone sets their own password on first sign-in. "),s(),f(e.sendEmail()?-1:2),s(2),w(e.results())}}function vn(i,t){if(i&1&&(a(0,"p",19),l(1),r()),i&2){let e=d(2);s(),y(" ",e.parsed().length," addresses \u2014 every one gets the same admin setting below. ")}}function hn(i,t){if(i&1&&l(0),i&2){let e=d(2);y(" Cognito emails ",e.parsed().length>1?"each of them":"them"," a set-your-password link, valid 7 days, from a generic address (about 50 a day). No sign-up link is shown here. To hand the invitation over yourself, switch this off. ")}}function bn(i,t){i&1&&l(0," The sign-up link works for 7 days and lets whoever holds it set the password \u2014 send it privately. ")}function yn(i,t){if(i&1&&l(0),i&2){let e=d(2);y(" ",e.parsed().length>1?"Send "+e.parsed().length+" invites":"Send invite"," ")}}function Sn(i,t){if(i&1&&l(0),i&2){let e=d(2);y(" ",e.parsed().length>1?"Create "+e.parsed().length+" users":"Create user"," ")}}function wn(i,t){if(i&1){let e=v();a(0,"div",13)(1,"app-field",14)(2,"textarea",15),u("ngModelChange",function(o){p(e);let c=d();return m(c.input.set(o))}),r()(),a(3,"label",16),T(4,"app-icon",17),l(5," Upload a .txt or .csv list "),a(6,"input",18),u("change",function(o){p(e);let c=d();return m(c.onListFile(o))}),r()(),g(7,vn,2,1,"p",19),a(8,"div",20),u("click",function(){p(e);let o=d();return m(o.admin.set(!o.admin()))}),a(9,"span")(10,"span",21),l(11,"Admin"),r(),a(12,"span",22),l(13),r()(),a(14,"app-toggle",23),F("checkedChange",function(o){p(e);let c=d();return P(c.admin,o)||(c.admin=o),m(o)}),r()(),a(15,"div",20),u("click",function(){p(e);let o=d();return m(o.sendEmail.set(!o.sendEmail()))}),a(16,"span")(17,"span",21),l(18,"Send invitation email"),r(),a(19,"span",22),l(20," Off: nobody is emailed \u2014 you get a sign-up link to pass on yourself. "),r()(),a(21,"app-toggle",24),F("checkedChange",function(o){p(e);let c=d();return P(c.sendEmail,o)||(c.sendEmail=o),m(o)}),r()(),a(22,"app-banner",25)(23,"span",26),g(24,hn,1,1)(25,bn,1,0),r()()(),a(26,"div",27)(27,"app-button",28),u("click",function(){p(e);let o=d();return m(o.closed.emit())}),l(28,"Cancel"),r(),a(29,"app-button",29),u("click",function(){p(e);let o=d();return m(o.submit())}),g(30,yn,1,1)(31,Sn,1,1),r()()}if(i&2){let e=d();s(),_("error",e.error()),s(),_("ngModel",e.input()),s(5),f(e.parsed().length>1?7:-1),s(6),y(" Adds ",e.parsed().length>1?"all of them":"them"," to the admins group. "),s(),A("checked",e.admin),s(7),A("checked",e.sendEmail),s(3),f(e.sendEmail()?24:25),s(5),_("loading",e.busy()),s(),f(e.sendEmail()?30:31)}}var kn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,qt=50,$e=class i{api=b(R);toast=b(N);created=V();createdOne=V();closed=V();appUrl=location.origin;input=x("");admin=x(!1);sendEmail=x(!0);busy=x(!1);error=x("");results=x(null);parsed=h(()=>{let t=new Set,e=[];for(let n of this.input().split(/[\n,;]+/)){let o=n.trim();!o||t.has(o.toLowerCase())||(t.add(o.toLowerCase()),e.push(o))}return e});createdCount=h(()=>(this.results()??[]).filter(t=>t.status==="CREATED").length);absolute(t){return t.startsWith("/")?`${location.origin}${t}`:t}onListFile(t){let e=t.target,n=e.files?.[0];n&&n.text().then(o=>{let c=o.split(/[\s,;"]+/).filter(U=>U.includes("@"));if(!c.length){this.error.set(`No email addresses found in ${n.name}.`);return}this.error.set(""),this.input.update(U=>U.trim()?`${U.trimEnd()}
${c.join(`
`)}`:c.join(`
`)),e.value=""})}submit(){let t=this.parsed();if(t.length===0){this.error.set("Enter at least one email address.");return}let e=t.filter(n=>!kn.test(n));if(e.length){this.error.set(e.length===1?`"${e[0]}" is not a valid email address.`:`${e.length} entries are not valid email addresses (first: "${e[0]}").`);return}if(t.length>qt){this.error.set(`At most ${qt} invites at once.`);return}if(this.error.set(""),this.busy.set(!0),t.length===1){this.api.createUser(t[0],this.admin(),this.sendEmail()).subscribe({next:({user:n,signupLink:o})=>{this.busy.set(!1),this.toast.success(this.sendEmail()?`Invitation sent to ${n.email}`:`Created ${n.email}`),this.createdOne.emit({user:n,emailed:this.sendEmail(),signupLink:o??null})},error:n=>{this.busy.set(!1),this.error.set(k(n,"Could not create the user."))}});return}this.api.createUsers(t,this.admin(),this.sendEmail()).subscribe({next:n=>{this.busy.set(!1),this.results.set(n);let o=n.filter(U=>U.status==="CREATED").length,c=n.length-o;o?(this.toast.success(`${this.sendEmail()?"Sent":"Created"} ${o} ${this.sendEmail()?"invitation":"user"}${o===1?"":"s"}${c?`, ${c} failed`:""}`),this.created.emit()):this.toast.error("No users were created \u2014 see the details.")},error:n=>{this.busy.set(!1),this.error.set(k(n,"Could not send the invitations."))}})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-user-create-form"]],outputs:{created:"created",createdOne:"createdOne",closed:"closed"},decls:2,vars:1,consts:[[1,"mb-2","text-xs","text-muted-foreground"],[1,"mb-2","flex","items-center","gap-2","rounded-lg","border","border-border-strong","bg-muted/40","p-3","text-xs"],[1,"max-h-72","overflow-y-auto","rounded-lg","border","border-border-strong"],[1,"flex","items-start","gap-2.5","border-b","border-border","px-3","py-2","text-sm","last:border-b-0"],[1,"mt-5","flex","justify-end"],[3,"click"],[1,"w-20","shrink-0","ui-microlabel","text-text-secondary"],[1,"min-w-0","flex-1","truncate","font-mono","text-surface-foreground"],["label","Copy app URL",3,"text"],[1,"min-w-0","flex-1"],[1,"block","truncate","text-surface-foreground"],[1,"block","text-xs","text-danger"],["variant","icon","label","Copy sign-up link",3,"text"],[1,"space-y-5"],["label","Emails","hint","One per line \u2014 commas work too, or upload a list. Each address gets its own invite.",3,"error"],["rows","5","placeholder",`person@company.com
teammate@company.com`,1,"ui-input",3,"ngModelChange","ngModel"],[1,"-mt-3","inline-flex","cursor-pointer","items-center","gap-1.5","text-xs","font-medium","text-brand-text"],["name","download",1,"h-3.5","w-3.5","rotate-180"],["type","file","accept",".txt,.csv,text/plain,text/csv",1,"hidden",3,"change"],[1,"-mt-2","text-xs","text-muted-foreground"],[1,"flex","w-full","cursor-pointer","items-center","justify-between","rounded-lg","border","border-border","p-3","text-left",3,"click"],[1,"block","text-sm","font-medium","text-surface-foreground"],[1,"block","text-xs","text-muted-foreground"],["ariaLabel","Admin",3,"checkedChange","checked"],["ariaLabel","Send invitation email",3,"checkedChange","checked"],["tone","info"],[1,"text-xs"],[1,"mt-5","flex","justify-end","gap-2"],["variant","outline",3,"click"],[3,"click","loading"]],template:function(e,n){e&1&&g(0,Cn,9,5)(1,wn,32,9),e&2&&f(n.results()!==null?0:1)},dependencies:[Z,J,X,Y,I,Ct,M,Et,oe,Q],encapsulation:2})};function Tn(i,t){if(i&1&&(a(0,"p",3),l(1),r()),i&2){let e=d();s(),C(e.error())}}var Oe=class i{api=b(R);toast=b(N);user=D.required();deleted=V();closed=V();busy=x(!1);error=x("");confirm(){this.busy.set(!0),this.error.set(""),this.api.deleteUser(this.user().userId).subscribe({next:()=>{this.busy.set(!1),this.toast.success(`Deleted ${this.user().email||"user"}`),this.deleted.emit()},error:t=>{this.busy.set(!1),this.error.set(k(t,"Could not delete the user."))}})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-user-delete-dialog"]],inputs:{user:[1,"user"]},outputs:{deleted:"deleted",closed:"closed"},decls:16,vars:3,consts:[["title","Delete user",3,"closed"],["tone","danger"],[1,"flex","items-start","gap-2.5"],[1,"mt-3","text-sm","text-danger"],[1,"mt-5","flex","justify-end","gap-2"],["variant","outline",3,"click"],["variant","danger",3,"click","loading"]],template:function(e,n){e&1&&(a(0,"app-dialog",0),u("closed",function(){return n.closed.emit()}),a(1,"app-banner",1)(2,"span",2)(3,"span"),l(4,"\u{1F5D1}\uFE0F"),r(),a(5,"span"),l(6," Permanently delete "),a(7,"strong"),l(8),r(),l(9," from Cognito and remove all of their role grants. This can't be undone. "),r()()(),g(10,Tn,2,1,"p",3),a(11,"div",4)(12,"app-button",5),u("click",function(){return n.closed.emit()}),l(13,"Cancel"),r(),a(14,"app-button",6),u("click",function(){return n.confirm()}),l(15," Delete user "),r()()()),e&2&&(s(8),C(n.user().email||n.user().userId),s(2),f(n.error()?10:-1),s(4),_("loading",n.busy()))},dependencies:[L,I,M],encapsulation:2})};var Ge=class i{link=D.required();appUrl=location.origin;href=h(()=>this.link().startsWith("/")?`${this.appUrl}${this.link()}`:this.link());static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-signup-link-box"]],inputs:{link:[1,"link"]},decls:15,vars:5,consts:[[1,"rounded-lg","border","border-border-strong","bg-muted/40","p-3","text-xs"],[1,"flex","items-center","gap-2"],[1,"w-20","shrink-0","ui-microlabel","text-text-secondary"],[1,"min-w-0","flex-1","truncate","font-mono","text-surface-foreground",3,"title"],["label","Copy link",3,"text"],[1,"mt-2","flex","items-center","gap-2"],[1,"min-w-0","flex-1","truncate","font-mono","text-surface-foreground"],["label","Copy app URL",3,"text"],[1,"mt-2.5","text-muted-foreground"]],template:function(e,n){e&1&&(a(0,"div",0)(1,"div",1)(2,"span",2),l(3,"Sign-up link"),r(),a(4,"span",3),l(5),r(),T(6,"app-copy-button",4),r(),a(7,"div",5)(8,"span",2),l(9,"App"),r(),a(10,"span",6),l(11),r(),T(12,"app-copy-button",7),r(),a(13,"p",8),l(14," Anyone with the link can set this person's password \u2014 send it privately. It works for 7 days; a resent email or a new link replaces it. "),r()()),e&2&&(s(4),_("title",n.href()),s(),C(n.href()),s(),_("text",n.href()),s(5),C(n.appUrl),s(),_("text",n.appUrl))},dependencies:[Q],encapsulation:2})};var Un=(i,t)=>t.id;function En(i,t){i&1&&(a(0,"p",0),l(1),r()),i&2&&(s(),C(t))}function Dn(i,t){i&1&&(a(0,"div",1),T(1,"app-skeleton",5)(2,"app-skeleton",5)(3,"app-skeleton",5),r())}function In(i,t){if(i&1&&(a(0,"p",2),l(1),r()),i&2){let e=d();s(),y("Nothing recorded in the last ",e.days," days.")}}function Nn(i,t){if(i&1&&(a(0,"span",15),l(1),r()),i&2){let e=d(2).$implicit;s(),C(e.detail)}}function Vn(i,t){if(i&1&&(a(0,"app-chip",12)(1,"span",14),l(2),r(),g(3,Nn,2,1,"span",15),r()),i&2){let e=d().$implicit;_("title",e.title),s(2),C(e.text),s(),f(e.detail?3:-1)}}function Rn(i,t){if(i&1&&(a(0,"span",13),l(1),r()),i&2){let e=d().$implicit;s(),C(e.text)}}function Mn(i,t){if(i&1&&(a(0,"span"),l(1),r()),i&2){let e=d().$implicit;s(),C(e.text)}}function An(i,t){if(i&1&&g(0,Vn,4,3,"app-chip",12)(1,Rn,2,1,"span",13)(2,Mn,2,1,"span"),i&2){let e,n=t.$implicit;f((e=n.kind)==="chip"?0:e==="name"?1:2)}}function Pn(i,t){if(i&1&&(a(0,"span",10),l(1),r()),i&2){let e=d().$implicit;s(),C(e.sub)}}function Fn(i,t){if(i&1&&(a(0,"li",6)(1,"span",7),l(2),r(),a(3,"span",8)(4,"span",9),S(5,An,3,1,null,null,lt),r(),g(7,Pn,2,1,"span",10),r(),a(8,"app-badge",11),l(9),r()()),i&2){let e=t.$implicit;s(),_("title",e.exact),s(),C(e.when),s(3),w(e.what),s(2),f(e.sub?7:-1),s(),_("tone",e.badge.tone),ve("title",e.reason||null),s(),C(e.badge.label)}}function Bn(i,t){if(i&1&&(a(0,"ul",3),S(1,Fn,10,6,"li",6,Un),r()),i&2){let e=d();s(),w(e.rows())}}function $n(i,t){if(i&1){let e=v();a(0,"div",4)(1,"app-button",16),u("click",function(){p(e);let o=d();return m(o.loadOlder())}),l(2,"Load older"),r()()}if(i&2){let e=d();s(),_("loading",e.loadingOlder())}}var Ye=90,Wt=25,Le=class i{api=b(Re);names=b(j);toast=b(N);userId=D.required();days=Ye;events=x(null);nextBefore=x(null);error=x(null);loadingOlder=x(!1);seq=0;reload=z(()=>{let t=this.userId();W(()=>this.load(t))});groupNames=h(()=>Gt(this.events()??[]));ctx=h(()=>{let t=this.groupNames();return this.names.label(""),{accountLabel:e=>this.names.label(e),groupName:e=>t.get(e)}});rows=h(()=>{let t=this.events();if(!t)return null;let e=this.ctx();return t.map(n=>({id:n.eventId,when:yt(n.at),exact:n.at,what:Pt(n,e,{subjectShown:!0,byActor:!n.derived}),sub:Bt(n,e,!!n.derived).join(" \xB7 "),badge:Ft(n),reason:n.reason}))});load(t){let e=++this.seq;this.events.set(null),this.nextBefore.set(null),this.error.set(null),this.api.listEvents({user:[t],days:Ye,limit:Wt}).subscribe({next:n=>{e===this.seq&&(this.events.set(n.events),this.nextBefore.set(n.nextBefore??null))},error:n=>{e===this.seq&&this.error.set(k(n,"Could not load this person's history."))}})}loadOlder(){let t=this.nextBefore();if(!t||this.loadingOlder())return;let e=this.seq;this.loadingOlder.set(!0);let n=Ot(this.events()??[],t);this.api.listEvents({user:[this.userId()],days:Ye,limit:Wt,before:t,skip:n}).subscribe({next:o=>{this.loadingOlder.set(!1),e===this.seq&&(this.events.update(c=>$t([...c??[],...o.events])),this.nextBefore.set(o.nextBefore??null))},error:o=>{this.loadingOlder.set(!1),e===this.seq&&this.toast.error(k(o,"Could not load older history."))}})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-user-history"]],inputs:{userId:[1,"userId"]},decls:5,vars:2,consts:[[1,"text-xs","text-danger"],[1,"space-y-2"],[1,"text-xs","text-muted-foreground"],[1,"divide-y","divide-border"],[1,"mt-3"],["sizeClass","h-8 w-full"],[1,"grid","grid-cols-[6.5rem_minmax(0,1fr)_max-content]","items-start","gap-3","py-2","text-xs"],[1,"font-mono","text-[11px]","text-muted-foreground",3,"title"],[1,"min-w-0"],[1,"flex","flex-wrap","items-center","gap-x-1","gap-y-0.5","text-surface-foreground"],[1,"mt-0.5","block","text-muted-foreground"],[3,"tone"],[3,"title"],[1,"font-medium"],[1,"min-w-0","truncate"],[1,"ml-1","min-w-0","shrink-[60]","truncate"],["size","sm","variant","outline",3,"click","loading"]],template:function(e,n){if(e&1&&(g(0,En,2,1,"p",0)(1,Dn,4,0,"div",1)(2,In,2,1,"p",2)(3,Bn,3,0,"ul",3),g(4,$n,3,1,"div",4)),e&2){let o;f((o=n.error())?0:n.rows()===null?1:n.rows().length===0?2:3,o),s(4),f(n.nextBefore()?4:-1)}},dependencies:[$,I,q,ee],encapsulation:2})};var On=i=>({user:i}),Gn=i=>({kind:"user",userId:i}),Ln=(i,t)=>t.key;function jn(i,t){if(i&1&&(a(0,"a",2),l(1," Open in Activity "),T(2,"app-icon",7),r()),i&2){let e=d();_("queryParams",Je(1,On,e.user().userId))}}function qn(i,t){if(i&1&&T(0,"app-user-history",3),i&2){let e=d();_("userId",e.user().userId)}}function Wn(i,t){i&1&&l(0," Invitation emailed. They set their password on first sign-in. Grant access below, or close the panel \u2014 nothing else is needed. ")}function zn(i,t){i&1&&l(0," Nobody has been emailed. The sign-up link below is the only invitation: copy it and send it privately. ")}function Hn(i,t){if(i&1&&(a(0,"div",8)(1,"app-banner",23),g(2,Wn,1,0)(3,zn,1,0),r()()),i&2){let e=t;s(),_("tone",e.emailed?"success":"warning"),s(),f(e.emailed?2:3)}}function Kn(i,t){i&1&&(a(0,"app-badge",13),l(1,"admin"),r())}function Qn(i,t){if(i&1){let e=v();a(0,"app-button",24),u("click",function(){p(e);let o=d(2);return m(o.resetMfa())}),l(1," Reset MFA "),r()}if(i&2){let e=d(2);_("loading",e.mfaBusy())}}function Jn(i,t){if(i&1){let e=v();a(0,"app-button",14),u("click",function(){p(e);let o=d(3);return m(o.mintLink())}),l(1,"Copy sign-up link"),r()}if(i&2){let e=d(3);_("loading",e.linkBusy())}}function Xn(i,t){i&1&&(a(0,"p",28),l(1,"This link replaced the previous one \u2014 the emailed link no longer works."),r())}function Yn(i,t){if(i&1&&(T(0,"app-signup-link-box",27),g(1,Xn,2,0,"p",28)),i&2){let e=d(3);_("link",t),s(),f(e.minted()?1:-1)}}function Zn(i,t){if(i&1){let e=v();a(0,"div",12)(1,"app-badge",25),l(2,"invited"),r(),g(3,Jn,2,1,"app-button",26),a(4,"app-button",24),u("click",function(){p(e);let o=d(2);return m(o.resend())}),l(5,"Send invite email"),r()(),g(6,Yn,2,2)}if(i&2){let e,n=d(2);s(3),f(n.signupLink()?-1:3),s(),pt("ml-auto",!!n.signupLink()),_("loading",n.resendBusy()),s(2),f((e=n.signupLink())?6:-1,e)}}function ei(i,t){if(i&1&&(a(0,"p",16),l(1),a(2,"span",29),l(3),r()()),i&2){let e=t.$implicit;s(),y("",e.label,": "),s(2),C(e.value)}}function ti(i,t){if(i&1&&l(0),i&2){let e=d(2);y(" Last seen ",e.ago(t)," ")}}function ni(i,t){i&1&&l(0," No activity recorded yet ")}function ii(i,t){if(i&1){let e=v();a(0,"app-plugin-access-panel",30),u("changed",function(){p(e);let o=d(2);return m(o.loadPluginAccess(o.user().userId))}),r()}if(i&2){let e=d(2);_("principal",Je(5,Gn,e.user().userId))("holder",e.user().email)("assignments",e.pluginAccess().assignments)("capabilities",e.pluginAccess().capabilities)("groupNames",e.groupNameById())}}function oi(i,t){if(i&1){let e=v();g(0,Hn,4,2,"div",8),a(1,"fieldset",9)(2,"legend",10),l(3,"Account"),r(),a(4,"div",11)(5,"div",12),g(6,Kn,2,0,"app-badge",13),a(7,"app-button",14),u("click",function(){p(e);let o=d();return m(o.toggleAdmin())}),l(8),r(),g(9,Qn,2,1,"app-button",15),r(),g(10,Zn,7,5),S(11,ei,4,2,"p",16,Ln),a(13,"p",16),g(14,ti,1,1)(15,ni,1,0),r()()(),a(16,"fieldset",9)(17,"legend",10),l(18),r(),a(19,"div",17)(20,"app-button",18),u("click",function(){p(e);let o=d();return m(o.grantingGroups.set(!0))}),l(21,"\uFF0B Add to group"),r()(),a(22,"app-access-list",19),u("action",function(o){p(e);let c=d();return m(c.leaveGroup(o))}),r()(),a(23,"fieldset",9)(24,"legend",10),l(25),r(),a(26,"div",17)(27,"app-button",18),u("click",function(){p(e);let o=d();return m(o.grantingRoles.set(!0))}),l(28,"\uFF0B Grant role"),r()(),a(29,"app-access-list",20),u("action",function(o){p(e);let c=d();return m(c.revokeRole(o))}),r()(),g(30,ii,1,7,"app-plugin-access-panel",21),a(31,"fieldset",9)(32,"legend",10),l(33),r(),a(34,"div",17)(35,"app-button",18),u("click",function(){p(e);let o=d();return m(o.grantingResources.set(!0))}),l(36,"\uFF0B Grant resource"),r()(),a(37,"app-access-list",22),u("action",function(o){p(e);let c=d();return m(c.revokeResource(o))}),r()()}if(i&2){let e,n,o,c=d();f((e=c.justCreated())?0:-1,e),s(6),f(c.user().admin?6:-1),s(),_("loading",c.adminBusy()),s(),y(" ",c.user().admin?"Remove admin":"Make admin"," "),s(),f(c.mfaEnabled?9:-1),s(),f(c.user().pendingInvite?10:-1),s(),w(c.claimRows()),s(3),f((n=c.user().lastSeenAt)?14:15,n),s(4),y("Groups \xB7 ",c.memberOf().length),s(4),_("rows",c.groupRows()),s(3),y("Roles \xB7 ",c.shown().roles.length),s(4),_("rows",c.roleRows()),s(),f(c.pluginsOn?30:-1),s(3),y("Network resources \xB7 ",((o=c.shown().resources)==null?null:o.length)||0),s(4),_("rows",c.resourceRows())}}function ri(i,t){if(i&1){let e=v();a(0,"app-grant-dialog",31),u("granted",function(o){p(e);let c=d();return m(c.joinGroups(o.ids))})("closed",function(){p(e);let o=d();return m(o.grantingGroups.set(!1))}),r()}if(i&2){let e=d();_("intro",e.user().email+" gets each group's whole bundle (roles + resources), long-term, while a member.")("options",e.groupOptions())("busy",e.busy())}}function ai(i,t){if(i&1){let e=v();a(0,"app-grant-dialog",32),u("granted",function(o){p(e);let c=d();return m(c.grantRoles(o.ids,o.durationHours))})("closed",function(){p(e);let o=d();return m(o.grantingRoles.set(!1))}),r()}if(i&2){let e=d();_("intro",e.user().email+" \u2014 takes effect at their next vend.")("accountSource",e.accountsPage)("optionsFor",e.rolesOf)("busy",e.busy())}}function si(i,t){if(i&1){let e=v();a(0,"app-grant-dialog",33),u("granted",function(o){p(e);let c=d();return m(c.grantResources(o.ids,o.durationHours))})("closed",function(){p(e);let o=d();return m(o.grantingResources.set(!1))}),r()}if(i&2){let e=d();_("intro",e.user().email+" \u2014 reaches the network within about 5 minutes.")("options",e.resourceOptions())("busy",e.busy())}}var je=class i{api=b(R);pluginsApi=b(vt);pluginsStore=b(ht);resourcesApi=b(Te);groupsApi=b(le);toast=b(N);names=b(j);mfaEnabled=!!b(ne).config.mfa;roleColors=b(Me);user=D.required();justCreated=D(null);tabs=["Access","History"];tab=x("Access");federation=b(Ve);claimRows=h(()=>this.federation.claimRows(this.user().claims));changed=V();busy=x(!1);adminBusy=x(!1);resendBusy=x(!1);linkBusy=x(!1);signupLink=x(null);minted=x(!1);mfaBusy=x(!1);roleGrants=x([]);resourceGrants=x([]);resources=x([]);groups=x([]);grantingGroups=x(!1);grantingRoles=x(!1);grantingResources=x(!1);memberOf=h(()=>this.groups().filter(t=>t.members.some(e=>e.userId===this.user().userId)));groupNameById=h(()=>Object.fromEntries(this.groups().map(t=>[t.groupId,t.name])));groupRows=h(()=>this.memberOf().map(t=>({id:t.groupId,title:t.name,subtitle:`${t.roles.length} role${t.roles.length===1?"":"s"}, ${t.resources?.length||0} resource${(t.resources?.length||0)===1?"":"s"}`,pillClass:"bg-muted text-muted-foreground",badges:[],action:{label:"Remove",disabled:this.busy()}})));whyBadges(t,e,n){let o=e.map(c=>({text:`via ${c}`,tone:"gray",title:`Granted through the group ${c}`}));return t&&o.unshift(n?{text:`direct \xB7 expires ${n}`,tone:"amber",title:"Direct grant, temporary"}:{text:"direct \xB7 long-term",tone:"gray",title:"Direct grant, long-term"}),o}full=x(null);fullRequest=0;destroyRef=b(xe);shown=h(()=>{let t=this.full();return t&&t.userId===this.user().userId?t:this.user()});roleRows=h(()=>this.shown().roles.map(t=>({id:`${t.accountNumber}#${t.roleName}`,title:t.roleName,subtitle:this.names.label(t.accountNumber),pillClass:"role-chip",chipColor:this.roleColors.colorOf(t.accountNumber,t.roleName)||ce(t.accountNumber),badges:this.whyBadges(t.direct,t.groups,this.roleExpiry(t.accountNumber,t.roleName)),action:t.direct?{label:"Revoke",disabled:this.busy()}:void 0})));resourceRows=h(()=>(this.shown().resources??[]).map(t=>({id:t.resourceId,title:t.name,subtitle:t.accountNumber?this.names.label(t.accountNumber):void 0,pillClass:t.accountNumber?"role-chip":"bg-muted text-surface-foreground ring-1 ring-border",chipColor:t.accountNumber?ce(t.accountNumber):null,badges:this.whyBadges(t.direct,t.groups,this.resourceExpiry(t.resourceId)),action:t.direct?{label:"Revoke",disabled:this.busy()}:void 0})));groupOptions=h(()=>this.groups().filter(t=>!t.members.some(e=>e.userId===this.user().userId)).map(t=>({id:t.groupId,label:t.name,sublabel:`${t.members.length} member${t.members.length===1?"":"s"}`})));accountsPage=t=>this.api.listAccountsPage(t);rolesOf=t=>{let e=new Set(this.shown().roles.filter(n=>n.direct).map(n=>`${n.accountNumber}#${n.roleName}`));return t.roles.filter(n=>!e.has(`${t.accountNumber}#${n.roleName}`)).map(n=>({id:`${t.accountNumber}#${n.roleName}`,label:n.displayName||n.roleName,sublabel:n.displayName?n.roleName:void 0}))};resourceOptions=h(()=>{let t=new Set((this.shown().resources??[]).filter(e=>e.direct).map(e=>e.resourceId));return this.resources().filter(e=>!t.has(e.resourceId)).map(e=>({id:e.resourceId,label:e.name,sublabel:e.cidr,group:this.names.label(e.accountNumber)}))});constructor(){z(()=>{let t=this.user().userId,e=this.justCreated(),n=this.user();W(()=>{if(this.loadGrants(t),this.signupLink.set(e?.signupLink??null),this.minted.set(!1),this.full.set(null),(n.roleCount??0)>n.roles.length||(n.resourceCount??0)>(n.resources?.length??0)){let c=++this.fullRequest;this.api.getUser(t).pipe(ke(this.destroyRef)).subscribe({next:U=>c===this.fullRequest&&this.full.set(U),error:()=>{}})}})})}ngOnInit(){this.roleColors.ensure(),this.resourcesApi.listAll().subscribe({next:t=>this.resources.set(t),error:()=>this.resources.set([])}),this.loadGroups()}loadGroups(){this.groupsApi.list().subscribe({next:t=>this.groups.set(t),error:()=>this.groups.set([])})}pluginAccess=x({assignments:[],capabilities:[]});pluginsOn=!!b(ne).config.plugins?.enabled;loadPluginAccess(t){this.pluginsOn&&this.pluginsApi.userAccess(t).subscribe({next:e=>this.pluginAccess.set(e),error:()=>this.pluginAccess.set({assignments:[],capabilities:[]})})}loadGrants(t){this.loadPluginAccess(t),this.api.listUserGrants(t).subscribe({next:e=>this.roleGrants.set(e),error:()=>this.roleGrants.set([])}),this.api.listUserResourceGrants(t).subscribe({next:e=>this.resourceGrants.set(e),error:()=>this.resourceGrants.set([])})}roleExpiry(t,e){let n=this.roleGrants().find(o=>o.accountNumber===t&&o.roleName===e);return n?.expiresAt?re(n.expiresAt):null}resourceExpiry(t){let e=this.resourceGrants().find(n=>n.resourceId===t);return e?.expiresAt?re(e.expiresAt):null}done(t){this.busy.set(!1),this.toast.success(t),this.loadGrants(this.user().userId),this.loadGroups(),this.changed.emit()}membershipChanged(t){this.done(t),this.pluginsStore.refresh()}fail(t,e){this.busy.set(!1),this.toast.error(k(t,e))}ago=wt;saveEmail(t){t&&this.api.updateUser(this.user().userId,{email:t}).subscribe({next:()=>{this.toast.success("Saved"),this.changed.emit()},error:e=>this.toast.error(k(e,"Could not change the email."))})}toggleAdmin(){let t=!this.user().admin;this.adminBusy.set(!0),this.api.updateUser(this.user().userId,{admin:t}).subscribe({next:()=>{this.adminBusy.set(!1),this.toast.success(t?"Now an admin":"Admin removed"),this.changed.emit()},error:e=>{this.adminBusy.set(!1),this.toast.error(k(e,"Could not change admin status."))}})}mintLink(){this.linkBusy.set(!0),this.api.mintSignupLink(this.user().userId).subscribe({next:t=>{this.linkBusy.set(!1),this.signupLink.set(t),this.minted.set(!0)},error:t=>{this.linkBusy.set(!1),this.toast.error(k(t,"Could not create a sign-up link."))}})}resend(){this.resendBusy.set(!0),this.api.resendInvite(this.user().userId).subscribe({next:()=>{this.resendBusy.set(!1),this.signupLink.set(null),this.minted.set(!1),this.toast.success(`Invitation email sent to ${this.user().email}`)},error:t=>{this.resendBusy.set(!1),this.toast.error(k(t,"Could not send the invitation email."))}})}resetMfa(){this.mfaBusy.set(!0),this.api.resetMfa(this.user().userId).subscribe({next:()=>{this.mfaBusy.set(!1),this.toast.success(`MFA reset \u2014 ${this.user().email} signs in with just their password again`)},error:t=>{this.mfaBusy.set(!1),this.toast.error(k(t,"Could not reset MFA."))}})}joinGroups(t){if(!t.length)return;this.grantingGroups.set(!1);let e=n=>{if(n>=t.length)return this.membershipChanged(`Added to ${t.length} group${t.length===1?"":"s"}`);this.busy.set(!0),this.groupsApi.addMembers(t[n],[this.user().userId]).subscribe({next:()=>e(n+1),error:o=>this.fail(o,"Could not add to the group.")})};e(0)}leaveGroup(t){let e=this.groups().find(n=>n.groupId===t);this.busy.set(!0),this.groupsApi.removeMembers(t,[this.user().userId]).subscribe({next:()=>this.membershipChanged(`Removed from ${e?.name??"the group"}`),error:n=>this.fail(n,"Could not remove from the group.")})}grantRoles(t,e){if(!t.length)return;let n=t.map(o=>{let c=o.indexOf("#");return{accountNumber:o.slice(0,c),roleName:o.slice(c+1)}});this.grantingRoles.set(!1),this.busy.set(!0),this.api.assignRoles([this.user().userId],n,e).subscribe({next:o=>{let c=o.filter(U=>U.status==="FAILED").length;c?this.fail(null,`${c} grant${c===1?"":"s"} failed.`):this.done(`Granted ${n.length} role${n.length===1?"":"s"}`),c&&this.changed.emit()},error:o=>this.fail(o,"Could not grant the roles.")})}revokeRole(t){let e=t.indexOf("#"),n=t.slice(0,e),o=t.slice(e+1);this.busy.set(!0),this.api.revokeGrant(n,o,this.user().userId).subscribe({next:()=>this.done(`Revoked ${o}`),error:c=>this.fail(c,"Could not revoke the role.")})}grantResources(t,e){if(!t.length)return;this.grantingResources.set(!1);let n=o=>{if(o>=t.length)return this.done(`Granted ${t.length} resource${t.length===1?"":"s"}`);this.busy.set(!0),this.resourcesApi.grant(t[o],this.user().userId,e).subscribe({next:()=>n(o+1),error:c=>this.fail(c,"Could not grant the resource.")})};n(0)}revokeResource(t){let e=this.shown().resources?.find(n=>n.resourceId===t)?.name??"resource";this.busy.set(!0),this.resourcesApi.revoke(t,this.user().userId).subscribe({next:()=>this.done(`Revoked ${e}`),error:n=>this.fail(n,"Could not revoke the resource.")})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-user-detail"]],inputs:{user:[1,"user"],justCreated:[1,"justCreated"]},outputs:{changed:"changed"},decls:8,vars:8,consts:[["size","lg","align","start","ariaLabel","email",3,"save","value"],[1,"mt-4","block",3,"selectedChange","tabs","selected"],["routerLink","/admin/activity","title","Leaves this page: the Activity page with every filter, showing this person",1,"inline-flex","items-center","gap-1","text-xs","font-medium","text-brand-text","hover:underline",3,"queryParams"],[1,"mt-4","block",3,"userId"],["title","Add to groups","placeholder","Filter groups","emptyText","Already in every group.","verb","Add to",3,"intro","options","busy"],["title","Grant roles","placeholder","Filter the account's roles","emptyText","Every catalogued role is already held directly.","withDuration","",3,"intro","accountSource","optionsFor","busy"],["title","Grant network resources","placeholder","Filter by resource or account","emptyText","Every resource is already held directly.","withDuration","",3,"intro","options","busy"],["name","external-link",1,"h-3.5","w-3.5"],[1,"mt-4"],[1,"mt-5","rounded-lg","border","border-border","px-5","pb-5","pt-2.5"],[1,"-ml-1.5","px-1.5","text-xs","font-medium","text-muted-foreground"],[1,"space-y-2.5","text-xs"],[1,"flex","flex-wrap","items-center","gap-2"],["tone","brand"],["variant","outline","size","sm",1,"ml-auto",3,"click","loading"],["variant","outline","size","sm",3,"loading"],[1,"text-muted-foreground"],[1,"-mt-1","mb-2","flex","justify-end"],["variant","secondary","size","sm",3,"click"],["empty","Not in any group.",3,"action","rows"],["empty","No roles.",3,"action","rows"],[3,"principal","holder","assignments","capabilities","groupNames"],["empty","No network resources.",3,"action","rows"],[3,"tone"],["variant","outline","size","sm",3,"click","loading"],["tone","amber","icon","clock"],["variant","outline","size","sm",1,"ml-auto",3,"loading"],[3,"link"],[1,"text-warning"],[1,"text-surface-foreground"],[3,"changed","principal","holder","assignments","capabilities","groupNames"],["title","Add to groups","placeholder","Filter groups","emptyText","Already in every group.","verb","Add to",3,"granted","closed","intro","options","busy"],["title","Grant roles","placeholder","Filter the account's roles","emptyText","Every catalogued role is already held directly.","withDuration","",3,"granted","closed","intro","accountSource","optionsFor","busy"],["title","Grant network resources","placeholder","Filter by resource or account","emptyText","Every resource is already held directly.","withDuration","",3,"granted","closed","intro","options","busy"]],template:function(e,n){e&1&&(a(0,"app-inline-edit",0),u("save",function(c){return n.saveEmail(c)}),r(),a(1,"app-tabs",1),F("selectedChange",function(c){return P(n.tab,c)||(n.tab=c),c}),g(2,jn,3,3,"a",2),r(),g(3,qn,1,1,"app-user-history",3)(4,oi,38,14),g(5,ri,1,3,"app-grant-dialog",4),g(6,ai,1,4,"app-grant-dialog",5),g(7,si,1,3,"app-grant-dialog",6)),e&2&&(_("value",n.user().email),s(),_("tabs",n.tabs),A("selected",n.tab),s(),f(n.tab()==="History"?2:-1),s(),f(n.tab()==="History"?3:4),s(2),f(n.grantingGroups()?5:-1),s(),f(n.grantingRoles()?6:-1),s(),f(n.grantingResources()?7:-1))},dependencies:[ft,Ne,$,I,de,oe,Mt,At,Ge,De,Le,M],encapsulation:2})};var zt=[{value:"email-asc",label:"Email A to Z"},{value:"email-desc",label:"Email Z to A"},{value:"seen-desc",label:"Last seen, most recent first"},{value:"seen-asc",label:"Last seen, longest ago first"}];function qe(i,t){return(i.email||i.userId).localeCompare(t.email||t.userId,void 0,{sensitivity:"base"})||i.userId.localeCompare(t.userId)}function We(i){let t=i.lastSeenAt?Date.parse(i.lastSeenAt):NaN;return Number.isNaN(t)?-1/0:t}function Ht(i,t){let e=[...i];switch(t){case"email-asc":return e.sort(qe);case"email-desc":return e.sort((n,o)=>qe(o,n));case"seen-desc":return e.sort((n,o)=>We(o)-We(n)||qe(n,o));case"seen-asc":return e.sort((n,o)=>We(n)-We(o)||qe(n,o))}}function li(i,t){if(i&1&&(a(0,"app-badge",0),l(1),r()),i&2){let e=t.$implicit,n=d();_("tone",e==="admin.write.all"||e==="admin.read.all"?"brand":"gray"),s(),C(n.text(e))}}var me=class i{scopes=D.required();text(t){return t==="admin.write.all"?"admin":t==="admin.read.all"?"admin \xB7 read":H(t)}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-scope-badges"]],hostAttrs:[1,"contents"],inputs:{scopes:[1,"scopes"]},decls:2,vars:0,consts:[[3,"tone"]],template:function(e,n){e&1&&S(0,li,2,2,"app-badge",0,te),e&2&&w(n.scopes())},dependencies:[$],encapsulation:2})};var Kt=(i,t)=>t.scope,di=(i,t)=>t.accountNumber+"#"+t.roleName;function ci(i,t){i&1&&(a(0,"app-badge",3),l(1,"previous secret active"),r())}function pi(i,t){if(i&1){let e=v();a(0,"fieldset",10)(1,"legend",12),l(2,"Previous client"),r(),a(3,"div",22)(4,"code",23),l(5),r(),a(6,"app-badge",24),l(7,"still works"),r()(),a(8,"p",25),l(9," Switch the automation to the new client ID + secret, wait for \u201CLast used\u201D to show the new client authenticating, then remove this one. "),r(),a(10,"div",26)(11,"app-button",27),u("click",function(){p(e);let o=d();return m(o.confirmingRemovePrev.set(!0))}),l(12," Remove previous secret "),r()()()}if(i&2){let e=d();s(5),C(t.clientId),s(6),_("disabled",e.busy())}}function mi(i,t){if(i&1){let e=v();a(0,"label",29)(1,"input",33),u("change",function(){let o=p(e).$implicit,c=d(2);return m(c.toggleDraftScope(o.scope))}),r(),a(2,"span",34)(3,"span",35),l(4),r(),a(5,"span",36),l(6),r()()()}if(i&2){let e=t.$implicit,n=d(2);s(),_("checked",n.draftScopes().has(e.scope)),s(3),C(e.label),s(2),C(e.description)}}function ui(i,t){if(i&1){let e=v();a(0,"div",28),S(1,mi,7,3,"label",29,Kt),r(),a(3,"p",25),l(4,"Holds from its next API call \u2014 a token it already has does not keep what it had."),r(),a(5,"div",30)(6,"app-button",31),u("click",function(){p(e);let o=d();return m(o.editingScopes.set(!1))}),l(7,"Cancel"),r(),a(8,"app-button",32),u("click",function(){p(e);let o=d();return m(o.saveScopes())}),l(9,"Save scopes"),r()()}if(i&2){let e=d();s(),w(e.SCOPES),s(5),_("disabled",e.busy()),s(2),_("loading",e.busy())("disabled",e.draftScopes().size===0||!e.scopesChanged())}}function _i(i,t){if(i&1&&(a(0,"div",38)(1,"span",39),l(2),r(),a(3,"span",40),l(4),r()()),i&2){let e=t.$implicit;s(2),C(e.label),s(2),C(e.description)}}function gi(i,t){if(i&1){let e=v();a(0,"div",13)(1,"app-button",14),u("click",function(){p(e);let o=d();return m(o.openScopes())}),l(2,"Change scopes"),r()(),a(3,"div",37),S(4,_i,5,2,"div",38,Kt),r()}if(i&2){let e=d();s(4),w(e.heldScopes())}}function fi(i,t){i&1&&(a(0,"p",15),l(1," No roles \u2014 it can get tokens, but every credential request is denied until one is granted. "),r())}function xi(i,t){if(i&1){let e=v();a(0,"app-search-input",45),F("valueChange",function(o){p(e);let c=d(2);return P(c.rolesFold.query,o)||(c.rolesFold.query=o),m(o)}),r()}if(i&2){let e=d(2);A("value",e.rolesFold.query)}}function Ci(i,t){if(i&1&&(a(0,"app-badge",50),l(1),r()),i&2){let e=d().$implicit,n=d(2);s(),y("expires ",n.until(e.expiresAt))}}function vi(i,t){i&1&&(a(0,"app-badge",51),l(1,"long-term"),r())}function hi(i,t){if(i&1){let e=v();a(0,"div",42)(1,"app-chip",46)(2,"span",47),l(3),r()(),a(4,"span",48),l(5),r(),a(6,"span",49),g(7,Ci,2,1,"app-badge",50)(8,vi,2,0,"app-badge",51),a(9,"app-button",27),u("click",function(){let o=p(e).$implicit,c=d(2);return m(c.revokeRole(o.accountNumber,o.roleName))}),l(10,"Revoke"),r()()()}if(i&2){let e=t.$implicit,n=d(2);s(3),C(e.roleName),s(2),y("\xB7 ",n.names.label(e.accountNumber)),s(2),f(e.expiresAt?7:8),s(2),_("disabled",n.busy())}}function bi(i,t){if(i&1&&(a(0,"p",43),l(1),r()),i&2){let e=d(2);s(),y('Nothing matches "',e.rolesFold.query(),'".')}}function yi(i,t){if(i&1){let e=v();a(0,"button",53),u("click",function(){p(e);let o=d(3);return m(o.rolesFold.showMore())}),l(1),r()}if(i&2){let e=d(3);s(),y(" Show ",e.rolesFold.more()," more ")}}function Si(i,t){if(i&1){let e=v();a(0,"button",53),u("click",function(){p(e);let o=d(3);return m(o.rolesFold.showLess())}),l(1,"Show less"),r()}}function wi(i,t){if(i&1&&(a(0,"p",44),g(1,yi,2,1,"button",52),g(2,Si,2,0,"button",52),a(3,"span"),l(4),r()()),i&2){let e=d(2);s(),f(e.rolesFold.more()?1:-1),s(),f(e.rolesFold.expanded()?2:-1),s(2),ie("",e.rolesFold.visible().length," of ",e.rolesFold.matching().length,"",e.rolesFold.searchable()?" \u2014 or search":"")}}function ki(i,t){if(i&1&&(g(0,xi,1,1,"app-search-input",41),a(1,"div",37),S(2,hi,11,4,"div",42,di,!1,bi,2,1,"p",43),r(),g(5,wi,5,5,"p",44)),i&2){let e=d();f(e.rolesFold.searchable()?0:-1),s(2),w(e.rolesFold.visible()),s(3),f(e.rolesFold.more()||e.rolesFold.expanded()?5:-1)}}function Ti(i,t){if(i&1){let e=v();a(0,"app-grant-dialog",54),u("granted",function(o){p(e);let c=d();return m(c.grantResources(o.ids,o.durationHours))})("closed",function(){p(e);let o=d();return m(o.grantingResources.set(!1))}),r()}if(i&2){let e=d();_("intro",e.serviceUser().name+" \u2014 reaches the network within about 5 minutes.")("options",e.resourceOptions())("busy",e.busy())}}function Ui(i,t){if(i&1){let e=v();a(0,"app-grant-dialog",55),u("granted",function(o){p(e);let c=d();return m(c.grantRoles(o.ids,o.durationHours))})("closed",function(){p(e);let o=d();return m(o.grantingRole.set(!1))}),r()}if(i&2){let e=d();_("intro",e.serviceUser().name+" \u2014 takes effect on its next API call.")("accountSource",e.accountsPage)("optionsFor",e.rolesOf)("busy",e.busy())}}function Ei(i,t){if(i&1){let e=v();a(0,"app-dialog",56),u("closed",function(){p(e);let o=d();return m(o.confirmingRemovePrev.set(!1))}),a(1,"p",57),l(2," The old client ID and secret stop working immediately. Make sure the automation already authenticates with the new credentials \u2014 \u201CLast used\u201D above should reflect a call made with them. "),r(),a(3,"div",58)(4,"app-button",59),u("click",function(){p(e);let o=d();return m(o.confirmingRemovePrev.set(!1))}),l(5,"Cancel"),r(),a(6,"app-button",60),u("click",function(){p(e);let o=d();return m(o.removePrevious())}),l(7,"Remove previous secret"),r()()()}if(i&2){let e=d();s(6),_("loading",e.busy())}}var ze=class i{api=b(R);resourcesApi=b(Te);toast=b(N);names=b(j);serviceUser=D.required();changed=V();SCOPES=Ae;editingScopes=x(!1);draftScopes=x(new Set);heldScopes=h(()=>this.SCOPES.filter(t=>this.serviceUser().scopes.includes(t.scope)));scopesChanged=h(()=>{let t=this.serviceUser().scopes,e=this.draftScopes();return t.length!==e.size||t.some(n=>!e.has(n))});resourceGrants=x([]);resources=x([]);grantingResources=x(!1);resourceRows=h(()=>this.resourceGrants().map(t=>({id:t.resourceId,title:t.resourceName,subtitle:this.names.label(this.resources().find(e=>e.resourceId===t.resourceId)?.accountNumber??""),badges:[t.expiresAt?{text:`expires ${re(t.expiresAt)}`,tone:"amber",title:"Temporary grant"}:{text:"long-term",tone:"gray",title:"Standing access"}],action:{label:"Revoke",disabled:this.busy()}})));resourceOptions=h(()=>{let t=new Set(this.resourceGrants().map(e=>e.resourceId));return this.resources().filter(e=>!t.has(e.resourceId)).map(e=>({id:e.resourceId,label:e.name,sublabel:e.cidr,group:this.names.label(e.accountNumber)}))});constructor(){z(()=>{let t=this.serviceUser().clientId;W(()=>this.loadResources(t))})}until(t){return re(t)}lastUsed(){return se(this.serviceUser().lastUsedAt)}createdDay=h(()=>this.serviceUser().createdAt.slice(0,10));busy=x(!1);rolesFold=Rt(h(()=>this.serviceUser().roles),t=>`${t.roleName} ${this.names.label(t.accountNumber)} ${t.accountNumber}`);grantingRole=x(!1);confirmingRemovePrev=x(!1);accountsPage=t=>this.api.listAccountsPage(t);rolesOf=t=>{let e=new Set(this.serviceUser().roles.map(n=>`${n.accountNumber}#${n.roleName}`));return t.roles.filter(n=>!e.has(`${t.accountNumber}#${n.roleName}`)).map(n=>({id:`${t.accountNumber}#${n.roleName}`,label:n.displayName||n.roleName,sublabel:n.displayName?n.roleName:void 0}))};ngOnInit(){this.resourcesApi.listAll().subscribe({next:t=>this.resources.set(t),error:()=>this.resources.set([])})}loadResources(t){this.api.listUserResourceGrants(t).subscribe({next:e=>this.resourceGrants.set(e),error:()=>this.resourceGrants.set([])})}done(t){this.busy.set(!1),this.toast.success(t),this.changed.emit()}openScopes(){this.draftScopes.set(new Set(this.serviceUser().scopes)),this.editingScopes.set(!0)}toggleDraftScope(t){let e=new Set(this.draftScopes());e.has(t)?e.delete(t):e.add(t),this.draftScopes.set(e)}saveScopes(){this.busy.set(!0),this.api.updateServiceUserScopes(this.serviceUser().clientId,[...this.draftScopes()]).subscribe({next:()=>{this.editingScopes.set(!1),this.done("Scopes updated \u2014 they hold from its next call")},error:t=>this.fail(t,"Could not update the scopes.")})}grantResources(t,e){if(!t.length)return;this.grantingResources.set(!1);let n=o=>{if(o>=t.length)return this.done(`Granted ${t.length} resource${t.length===1?"":"s"}`);this.busy.set(!0),this.resourcesApi.grant(t[o],this.serviceUser().clientId,e).subscribe({next:()=>n(o+1),error:c=>this.fail(c,"Could not grant the resource.")})};n(0)}revokeResource(t){let e=this.resourceGrants().find(n=>n.resourceId===t)?.resourceName??"resource";this.busy.set(!0),this.resourcesApi.revoke(t,this.serviceUser().clientId).subscribe({next:()=>this.done(`Revoked ${e}`),error:n=>this.fail(n,"Could not revoke the resource.")})}fail(t,e){this.busy.set(!1),this.toast.error(k(t,e))}openGrantRole(){this.grantingRole.set(!0)}grantRoles(t,e){if(!t.length)return;let n=t.map(o=>{let c=o.indexOf("#");return{accountNumber:o.slice(0,c),roleName:o.slice(c+1)}});this.grantingRole.set(!1),this.busy.set(!0),this.api.assignRoles([this.serviceUser().clientId],n,e).subscribe({next:o=>{let c=o.filter(U=>U.status==="FAILED").length;c?this.fail(null,`${c} grant${c===1?"":"s"} failed.`):this.done(`Granted ${n.length} role${n.length===1?"":"s"}`),c&&this.changed.emit()},error:o=>this.fail(o,"Could not grant the roles.")})}revokeRole(t,e){this.busy.set(!0),this.api.revokeGrant(t,e,this.serviceUser().clientId).subscribe({next:()=>this.done(`Revoked ${e} \u2014 denied from its next call`),error:n=>this.fail(n,"Could not revoke the role.")})}removePrevious(){this.busy.set(!0),this.api.removePreviousSecret(this.serviceUser().clientId).subscribe({next:()=>{this.confirmingRemovePrev.set(!1),this.done("Previous secret removed \u2014 rotation finished")},error:t=>this.fail(t,"Could not remove the previous secret.")})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-service-user-detail"]],inputs:{serviceUser:[1,"serviceUser"]},outputs:{changed:"changed"},decls:44,vars:16,consts:[[1,"flex","flex-wrap","items-center","gap-2"],["tone","gray"],[3,"scopes"],["tone","amber"],[1,"mt-4","grid","gap-x-4","gap-y-2","text-sm",2,"grid-template-columns","auto 1fr"],[1,"text-xs","font-medium","text-muted-foreground"],[1,"flex","min-w-0","items-center","gap-1.5"],[1,"min-w-0","truncate","font-mono","text-xs"],["variant","icon","label","Copy client ID",3,"text"],[1,"text-xs","text-surface-foreground"],[1,"mt-5","rounded-lg","border","border-border","px-5","pb-3","pt-2.5"],["data-testid","scopes",1,"mt-5","rounded-lg","border","border-border","px-5","pb-3","pt-2.5"],[1,"-ml-1.5","px-1.5","text-xs","font-medium","text-muted-foreground"],[1,"-mt-1","mb-1","flex","justify-end"],["variant","ghost","size","sm",3,"click"],[1,"pb-1","text-xs","text-placeholder"],["data-testid","resources",1,"mt-5","rounded-lg","border","border-border","px-5","pb-5","pt-2.5"],[1,"-mt-1","mb-2","flex","justify-end"],["empty","No network resources \u2014 with the Network devices scope it can join the private network, but reaches nothing until a resource is granted.",3,"action","rows"],["title","Grant network resources","placeholder","Filter by resource or account","emptyText","Every resource is already granted.","withDuration","",3,"intro","options","busy"],["title","Grant roles","placeholder","Filter the account's roles","emptyText","Every catalogued role is already granted.","withDuration","",3,"intro","accountSource","optionsFor","busy"],["title","Remove the previous secret?"],[1,"flex","min-w-0","flex-wrap","items-center","gap-1.5"],[1,"min-w-0","truncate","font-mono","text-xs","text-muted-foreground"],["tone","amber","title","The old secret still authenticates until removed"],[1,"mt-2","text-xs","text-muted-foreground"],[1,"mt-2","flex","justify-end"],["size","sm","variant","danger",3,"click","disabled"],[1,"-mx-1","rounded-lg","border","border-border"],[1,"ui-check-row","text-sm"],[1,"mt-2","flex","justify-end","gap-2"],["size","sm","variant","outline",3,"click","disabled"],["size","sm",3,"click","loading","disabled"],["type","checkbox",1,"ui-checkbox",3,"change","checked"],[1,"min-w-0","flex-1"],[1,"block","font-medium","text-surface-foreground"],[1,"block","text-xs","text-muted-foreground"],[1,"divide-y","divide-border"],[1,"py-1.5","text-sm"],[1,"font-medium","text-surface-foreground"],[1,"ml-1.5","text-xs","text-muted-foreground"],["compact","","placeholder","Search roles by name or account",1,"mb-2","block",3,"value"],[1,"flex","items-center","gap-2","py-1.5","text-sm"],[1,"py-2","text-xs","text-muted-foreground"],[1,"mt-1.5","flex","items-center","gap-2","text-[11px]","text-text-secondary"],["compact","","placeholder","Search roles by name or account",1,"mb-2","block",3,"valueChange","value"],[1,"min-w-0"],[1,"min-w-0","truncate"],[1,"min-w-0","truncate","text-xs","text-muted-foreground"],[1,"ml-auto","flex","shrink-0","flex-wrap","items-center","justify-end","gap-1"],["tone","amber","title","Temporary grant"],["tone","gray","title","Standing access"],["type","button",1,"text-xs","text-muted-foreground","underline","hover:text-surface-foreground"],["type","button",1,"text-xs","text-muted-foreground","underline","hover:text-surface-foreground",3,"click"],["title","Grant network resources","placeholder","Filter by resource or account","emptyText","Every resource is already granted.","withDuration","",3,"granted","closed","intro","options","busy"],["title","Grant roles","placeholder","Filter the account's roles","emptyText","Every catalogued role is already granted.","withDuration","",3,"granted","closed","intro","accountSource","optionsFor","busy"],["title","Remove the previous secret?",3,"closed"],[1,"text-sm","text-muted-foreground"],[1,"mt-4","flex","justify-end","gap-2"],["variant","outline",3,"click"],["variant","danger",3,"click","loading"]],template:function(e,n){if(e&1&&(a(0,"div",0)(1,"app-badge",1),l(2,"service user"),r(),T(3,"app-scope-badges",2),g(4,ci,2,0,"app-badge",3),r(),a(5,"dl",4)(6,"dt",5),l(7,"Client ID"),r(),a(8,"dd",6)(9,"code",7),l(10),r(),T(11,"app-copy-button",8),r(),a(12,"dt",5),l(13,"Created"),r(),a(14,"dd",9),l(15),r(),a(16,"dt",5),l(17,"Last used"),r(),a(18,"dd",9),l(19),r()(),g(20,pi,13,2,"fieldset",10),a(21,"fieldset",11)(22,"legend",12),l(23),r(),g(24,ui,10,3)(25,gi,6,0),r(),a(26,"fieldset",10)(27,"legend",12),l(28),r(),a(29,"div",13)(30,"app-button",14),u("click",function(){return n.openGrantRole()}),l(31,"\uFF0B Grant role"),r()(),g(32,fi,2,0,"p",15)(33,ki,6,3),r(),a(34,"fieldset",16)(35,"legend",12),l(36),r(),a(37,"div",17)(38,"app-button",14),u("click",function(){return n.grantingResources.set(!0)}),l(39,"\uFF0B Grant resource"),r()(),a(40,"app-access-list",18),u("action",function(c){return n.revokeResource(c)}),r()(),g(41,Ti,1,3,"app-grant-dialog",19),g(42,Ui,1,4,"app-grant-dialog",20),g(43,Ei,8,1,"app-dialog",21)),e&2){let o;s(3),_("scopes",n.serviceUser().scopes),s(),f(n.serviceUser().previous?4:-1),s(6),C(n.serviceUser().clientId),s(),_("text",n.serviceUser().clientId),s(4),C(n.createdDay()),s(4),C(n.lastUsed()),s(),f((o=n.serviceUser().previous)?20:-1,o),s(3),y("Scopes \xB7 ",n.serviceUser().scopes.length),s(),f(n.editingScopes()?24:25),s(4),y("Roles \xB7 ",n.serviceUser().roles.length),s(4),f(n.serviceUser().roles.length===0?32:33),s(4),y("Network resources \xB7 ",n.resourceGrants().length),s(4),_("rows",n.resourceRows()),s(),f(n.grantingResources()?41:-1),s(),f(n.grantingRole()?42:-1),s(),f(n.confirmingRemovePrev()?43:-1)}},dependencies:[Ne,$,I,q,Q,L,de,me,Ie],encapsulation:2})};function Di(i,t){i&1&&(a(0,"p",8),l(1," Both values changed \u2014 update the client ID "),a(2,"span",17),l(3,"and"),r(),l(4," the secret in the automation. The previous secret keeps working until you remove it from this service user's panel. "),r())}function Ii(i,t){i&1&&(l(0," The token can perform "),a(1,"span",17),l(2,"admin actions"),r(),l(3," in this app, so keep the secret in a secret store, never in code or logs. "))}function Ni(i,t){i&1&&(l(0," The token can "),a(1,"span",17),l(2,"read every administration page"),r(),l(3," but change nothing; keep the secret in a secret store, never in code or logs. "))}function Vi(i,t){if(i&1&&l(0),i&2){let e=d();y(" The token reaches only its scopes (",e.scopeNames(),"); keep the secret in a secret store, never in code or logs. ")}}var He=class i{configService=b(ne);created=D.required();rotated=D(!1);closed=V();writeAdmin=h(()=>this.created().serviceUser.scopes.includes("admin.write.all"));readAdmin=h(()=>this.created().serviceUser.scopes.includes("admin.read.all"));scopeNames=h(()=>this.created().serviceUser.scopes.map(H).join(", "));curl=h(()=>[`curl -s -X POST ${this.configService.config.hostedUiDomain.replace(/\/$/,"")}/oauth2/token \\`,` -u '${this.created().serviceUser.clientId}:CLIENT_SECRET' \\`," -d 'grant_type=client_credentials&scope=api/invoke'"].join(`
`));static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-service-user-secret"]],inputs:{created:[1,"created"],rotated:[1,"rotated"]},outputs:{closed:"closed"},decls:34,vars:8,consts:[["tone","warning"],[1,"mt-4","grid","gap-y-1","text-sm"],[1,"text-xs","font-medium","text-muted-foreground"],[1,"mb-3","flex","items-center","justify-between","gap-2","rounded-md","bg-muted","px-3","py-2"],[1,"min-w-0","truncate","font-mono","text-xs"],["variant","icon","label","Copy client ID",3,"text"],[1,"flex","items-center","justify-between","gap-2","rounded-md","bg-muted","px-3","py-2"],["variant","icon","label","Copy client secret",3,"text"],[1,"mt-3","text-xs","text-muted-foreground"],[1,"mt-5"],[1,"mb-1","flex","items-center","justify-between"],["variant","icon","label","Copy command",3,"text"],[1,"overflow-x-auto","rounded-md","bg-muted","px-3","py-2","font-mono","text-[11px]","leading-relaxed","text-muted-foreground"],[1,"mt-2","text-xs","text-muted-foreground"],[1,"font-mono"],[1,"mt-5","flex","justify-end"],["size","lg",3,"click"],[1,"font-medium"]],template:function(e,n){e&1&&(a(0,"app-banner",0),l(1," Copy the secret now \u2014 it can't be shown again. If it's lost, rotate it from this service user's panel. "),r(),a(2,"dl",1)(3,"dt",2),l(4,"Client ID"),r(),a(5,"dd",3)(6,"code",4),l(7),r(),T(8,"app-copy-button",5),r(),a(9,"dt",2),l(10,"Client secret"),r(),a(11,"dd",6)(12,"code",4),l(13),r(),T(14,"app-copy-button",7),r()(),g(15,Di,5,0,"p",8),a(16,"div",9)(17,"div",10)(18,"span",2),l(19,"Get a token"),r(),T(20,"app-copy-button",11),r(),a(21,"pre",12),l(22),r(),a(23,"p",13),l(24," Tokens last 1 hour \u2014 the automation just requests a new one each run and sends it as "),a(25,"code",14),l(26,"Authorization: Bearer \u2026"),r(),l(27," on API calls. "),g(28,Ii,4,0)(29,Ni,4,0)(30,Vi,1,1),r()(),a(31,"div",15)(32,"app-button",16),u("click",function(){return n.closed.emit()}),l(33,"Done"),r()()),e&2&&(s(7),C(n.created().serviceUser.clientId),s(),_("text",n.created().serviceUser.clientId),s(5),C(n.created().clientSecret),s(),_("text",n.created().clientSecret),s(),f(n.rotated()?15:-1),s(5),_("text",n.curl()),s(2),C(n.curl()),s(6),f(n.writeAdmin()?28:n.readAdmin()?29:30))},dependencies:[M,I,Q],encapsulation:2})};var Ri=["panelTpl"],Mi=(i,t)=>t.clientId,Ai=(i,t)=>t.accountNumber+"#"+t.roleName,Pi=(i,t)=>t.scope;function Fi(i,t){if(i&1&&(a(0,"app-banner",1),l(1),r()),i&2){let e=d();s(),C(e.error())}}function Bi(i,t){i&1&&(a(0,"div",2),T(1,"app-skeleton",7)(2,"app-skeleton",7),r())}function $i(i,t){i&1&&(a(0,"app-empty-state",3)(1,"span",8),l(2,"Add service user"),r(),l(3," creates a client ID + secret an automation (CI job, script, a VM agent, another system) uses to call the API. Its scopes say what it may call \u2014 get AWS credentials, join the private network, share ports, or administer the portal. Roles and resources are granted per item, just like a person. "),r())}function Oi(i,t){if(i&1&&(a(0,"app-empty-state",4),l(1),r()),i&2){let e=d();s(),y(' Nothing matches "',e.query(),'". Try a different name, client ID, scope, or role. ')}}function Gi(i,t){i&1&&(a(0,"app-badge",19),l(1,"previous secret active"),r())}function Li(i,t){i&1&&(a(0,"app-badge",21),l(1,"No roles"),r())}function ji(i,t){if(i&1&&(a(0,"app-chip",24)(1,"span",26),l(2),r(),a(3,"span",27),l(4),r()()),i&2){let e=t.$implicit,n=d(4);s(2),C(e.roleName),s(2),y("\xB7 ",n.names.label(e.accountNumber))}}function qi(i,t){if(i&1&&(a(0,"app-badge",25),l(1),r()),i&2){let e=d(2).$implicit;s(),y("+",e.roles.length-2," more")}}function Wi(i,t){if(i&1&&(a(0,"div",22),S(1,ji,5,2,"app-chip",24,Ai),g(3,qi,2,1,"app-badge",25),r()),i&2){let e=d().$implicit;s(),w(e.roles.slice(0,2)),s(2),f(e.roles.length>2?3:-1)}}function zi(i,t){if(i&1){let e=v();a(0,"div",14),u("click",function(){let o=p(e).$implicit,c=d(2);return m(c.openDetail(o))}),a(1,"div",15)(2,"span",16),l(3),r(),a(4,"span",17),T(5,"app-scope-badges",18),g(6,Gi,2,0,"app-badge",19),r()(),a(7,"div",15)(8,"code",20),l(9),r()(),a(10,"div",15),g(11,Li,2,0,"app-badge",21)(12,Wi,4,1,"div",22),r(),a(13,"div",23),l(14),r(),a(15,"div",23),l(16),r()()}if(i&2){let e=t.$implicit,n=d(2);B(n.panelClientId()===e.clientId?"bg-brand/5":""),s(3),C(e.name),s(2),_("scopes",e.scopes),s(),f(e.previous?6:-1),s(3),C(n.shortId(e.clientId)),s(2),f(e.roles.length===0?11:12),s(3),C(n.ago(e.lastUsedAt)),s(2),C(e.createdAt.slice(0,10))}}function Hi(i,t){if(i&1&&(a(0,"div",5)(1,"div",9)(2,"div",10),l(3,"Name"),r(),a(4,"div",10),l(5,"Client ID"),r(),a(6,"div",10),l(7,"Roles"),r(),a(8,"div",10),l(9,"Last used"),r(),a(10,"div",10),l(11,"Created"),r()(),a(12,"div",11)(13,"div",12),S(14,zi,17,9,"div",13,Mi),r()()()),i&2){let e=d();s(14),w(e.filtered())}}function Ki(i,t){if(i&1){let e=v();a(0,"label",35)(1,"input",39),u("change",function(){let o=p(e).$implicit,c=d(3);return m(c.toggleNewScope(o.scope))}),r(),a(2,"span",40)(3,"span",41),l(4),r(),a(5,"span",42),l(6),r()()()}if(i&2){let e=t.$implicit,n=d(3);s(),_("checked",n.newScopes().has(e.scope)),s(3),C(e.label),s(2),C(e.description)}}function Qi(i,t){if(i&1){let e=v();a(0,"label",30),l(1,"Name"),r(),a(2,"input",31),u("ngModelChange",function(o){p(e);let c=d(2);return m(c.newName.set(o))}),r(),a(3,"p",32),l(4," Lowercase letters, digits, and hyphens \u2014 shown in this list and the activity log. Name it after what the automation does. "),r(),a(5,"p",33),l(6,"Scopes"),r(),a(7,"div",34),S(8,Ki,7,3,"label",35,Pi),r(),a(10,"p",36),l(11," Creating it generates a client ID and secret (shown once, on the next screen). Store the secret like a credential with exactly these scopes \u2014 with "),a(12,"span",8),l(13,"Admin (read + write)"),r(),l(14," it is a full admin credential. Roles and network resources start empty; grant them from its panel afterwards. Scopes can be changed there too. "),r(),a(15,"div",37)(16,"app-button",38),u("click",function(){p(e);let o=d(2);return m(o.create())}),l(17,"Create"),r()()}if(i&2){let e=d(2);s(2),_("ngModel",e.newName()),s(6),w(e.SCOPES),s(8),_("loading",e.creating())("disabled",!e.newName().trim()||e.newScopes().size===0)}}function Ji(i,t){if(i&1){let e=v();a(0,"app-service-user-secret",44),u("closed",function(){p(e);let o=d(3);return m(o.afterSecretDone())}),r()}if(i&2){let e=d(3);_("created",t)("rotated",e.lastSecretWasRotation())}}function Xi(i,t){if(i&1&&g(0,Ji,1,2,"app-service-user-secret",43),i&2){let e,n=d(2);f((e=n.lastSecret())?0:-1,e)}}function Yi(i,t){if(i&1){let e=v();a(0,"app-service-user-detail",46),u("changed",function(){p(e);let o=d(3);return m(o.load())}),r()}i&2&&_("serviceUser",t)}function Zi(i,t){if(i&1&&g(0,Yi,1,1,"app-service-user-detail",45),i&2){let e,n=d(2);f((e=n.panelServiceUser())?0:-1,e)}}function eo(i,t){if(i&1){let e=v();a(0,"app-button",47),u("click",function(){let o=p(e),c=d(3);return m(c.confirmingRotate.set(o))}),l(1," Rotate secret "),r(),a(2,"app-button",48),u("click",function(){let o=p(e),c=d(3);return m(c.confirmingDelete.set(o))}),l(3,"Delete service user"),r()}if(i&2){let e=t;_("disabled",!!e.previous)("title",e.previous?"Finish the current rotation first \u2014 remove the previous secret":"")}}function to(i,t){if(i&1&&g(0,eo,4,2),i&2){let e,n=d(2);f((e=n.panelServiceUser())?0:-1,e)}}function no(i,t){if(i&1){let e=v();a(0,"app-panel",28),u("closed",function(){p(e);let o=d();return m(o.closePanel())}),g(1,Qi,18,3)(2,Xi,1,1)(3,Zi,1,1),he(4,29),g(5,to,1,1),be(),r()}if(i&2){let e,n=d();_("title",n.panelTitle())("contentKey",n.panelKind()+":"+n.panelClientId()),s(),f((e=n.panelKind())==="create"?1:e==="secret"?2:e==="detail"?3:-1),s(4),f(n.panelKind()==="detail"?5:-1)}}function io(i,t){if(i&1){let e=v();a(0,"app-dialog",49),u("closed",function(){p(e);let o=d();return m(o.confirmingRotate.set(null))}),a(1,"p",50),l(2," This issues a "),a(3,"span",51),l(4,"new client ID and secret"),r(),l(5," and copies its scopes, roles and resources to it. You'll see the new secret once, on the next screen. "),r(),a(6,"p",52),l(7," The "),a(8,"span",51),l(9,"previous secret keeps working"),r(),l(10," until you remove it \u2014 switch the automation over first, then remove it from the panel. "),r(),a(11,"div",53)(12,"app-button",54),u("click",function(){p(e);let o=d();return m(o.confirmingRotate.set(null))}),l(13,"Cancel"),r(),a(14,"app-button",55),u("click",function(){let o=p(e),c=d();return m(c.rotate(o))}),l(15,"Rotate"),r()()()}if(i&2){let e=d();_("title","Rotate secret for "+t.name+"?"),s(14),_("loading",e.rotating())}}function oo(i,t){if(i&1){let e=v();a(0,"app-dialog",49),u("closed",function(){p(e);let o=d();return m(o.confirmingDelete.set(null))}),a(1,"p",50),l(2," Its credentials stop working and all its role and resource grants are removed. Any automation still using them will start failing. This can't be undone. "),r(),a(3,"div",53)(4,"app-button",54),u("click",function(){p(e);let o=d();return m(o.confirmingDelete.set(null))}),l(5,"Cancel"),r(),a(6,"app-button",56),u("click",function(){let o=p(e),c=d();return m(c.doDelete(o))}),l(7,"Delete service user"),r()()()}if(i&2){let e=d();_("title","Delete "+t.name+"?"),s(6),_("loading",e.deleting())}}var ue=class i{api=b(R);toast=b(N);names=b(j);query=we("");serviceUsers=x(null);error=x(null);panelKind=x(null);panelClientId=x(null);panelTpl=ge("panelTpl");newName=x("");newScopes=x(new Set);SCOPES=Ae;creating=x(!1);rotating=x(!1);deleting=x(!1);lastSecret=x(null);lastSecretWasRotation=x(!1);confirmingRotate=x(null);confirmingDelete=x(null);filtered=h(()=>{let t=this.query().trim().toLowerCase(),e=this.serviceUsers()??[];return t?e.filter(n=>n.name.toLowerCase().includes(t)||n.clientId.toLowerCase().includes(t)||n.scopes.some(o=>H(o).toLowerCase().includes(t)||o.includes(t))||n.roles.some(o=>o.roleName.toLowerCase().includes(t)||this.names.label(o.accountNumber).toLowerCase().includes(t))):e});panelServiceUser=h(()=>(this.serviceUsers()??[]).find(t=>t.clientId===this.panelClientId())??null);panelTitle=h(()=>{switch(this.panelKind()){case"create":return"New service user";case"secret":return this.lastSecret()?.serviceUser.name??"Credentials";default:return this.panelServiceUser()?.name??"Service user"}});constructor(){Ue(()=>this.panelKind(),()=>this.panelTpl(),()=>this.closePanel())}ngOnInit(){this.load()}load(){this.api.listServiceUsers().subscribe({next:t=>this.serviceUsers.set(t),error:t=>this.error.set(k(t,"Could not load service users."))})}ago(t){return se(t)}shortId(t){return t.length<=12?t:`${t.slice(0,5)}\u2026${t.slice(-4)}`}openCreate(){this.newName.set(""),this.newScopes.set(new Set),this.panelClientId.set(null),this.panelKind.set("create")}toggleNewScope(t){let e=new Set(this.newScopes());e.has(t)?e.delete(t):e.add(t),this.newScopes.set(e)}openDetail(t){this.panelClientId.set(t.clientId),this.panelKind.set("detail")}closePanel(){this.panelKind.set(null),this.panelClientId.set(null),this.lastSecret.set(null)}create(){this.creating.set(!0),this.api.createServiceUser(this.newName().trim(),[...this.newScopes()]).subscribe({next:t=>{this.creating.set(!1),this.lastSecret.set(t),this.lastSecretWasRotation.set(!1),this.panelClientId.set(t.serviceUser.clientId),this.panelKind.set("secret"),this.load()},error:t=>{this.creating.set(!1),this.toast.error(k(t,"Could not create the service user."))}})}rotate(t){this.rotating.set(!0),this.api.rotateServiceUser(t.clientId).subscribe({next:e=>{this.rotating.set(!1),this.confirmingRotate.set(null),this.lastSecret.set(e),this.lastSecretWasRotation.set(!0),this.panelClientId.set(e.serviceUser.clientId),this.panelKind.set("secret"),this.load()},error:e=>{this.rotating.set(!1),this.toast.error(k(e,"Could not rotate the secret."))}})}afterSecretDone(){let t=this.panelClientId();this.lastSecret.set(null),t?this.panelKind.set("detail"):this.closePanel()}doDelete(t){this.deleting.set(!0),this.api.deleteServiceUser(t.clientId).subscribe({next:()=>{this.deleting.set(!1),this.confirmingDelete.set(null),this.toast.success(`Deleted ${t.name}`),this.closePanel(),this.load()},error:e=>{this.deleting.set(!1),this.toast.error(k(e,"Could not delete the service user."))}})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-service-users-tab"]],viewQuery:function(e,n){e&1&&_e(n.panelTpl,Ri,5),e&2&&ye()},hostAttrs:[1,"flex","min-h-0","flex-1","flex-col"],inputs:{query:[1,"query"]},outputs:{query:"queryChange"},decls:9,vars:3,consts:[["panelTpl",""],["tone","danger"],[1,"space-y-2"],["title","No service users yet"],["title","No matches"],[1,"flex","min-h-0","flex-1","flex-col","overflow-x-auto"],[3,"title"],["sizeClass","h-12 w-full"],[1,"font-medium"],[1,"grid","min-w-[720px]","shrink-0","grid-cols-[26%_20%_30%_13%_minmax(0,1fr)]"],[1,"px-4","py-2.5","text-left","ui-microlabel","text-text-secondary"],[1,"flex","min-h-0","min-w-[720px]","flex-col","overflow-hidden","rounded-lg","border","border-border","bg-card-bg"],[1,"min-h-0","overflow-y-auto"],["data-testid","row",1,"grid","cursor-pointer","grid-cols-[26%_20%_30%_13%_minmax(0,1fr)]","items-start","border-t","border-border","text-sm","transition-colors","first:border-t-0","hover:bg-state-hover",3,"class"],["data-testid","row",1,"grid","cursor-pointer","grid-cols-[26%_20%_30%_13%_minmax(0,1fr)]","items-start","border-t","border-border","text-sm","transition-colors","first:border-t-0","hover:bg-state-hover",3,"click"],[1,"px-4","py-3"],[1,"block","break-words","font-medium","tracking-[0.015em]","text-surface-foreground"],[1,"mt-1","flex","flex-wrap","gap-1.5"],[3,"scopes"],["tone","amber"],[1,"font-mono","text-xs","text-muted-foreground"],["tone","dashed"],[1,"flex","flex-wrap","gap-1.5"],[1,"px-4","py-3","text-xs","tabular-nums","text-muted-foreground"],[1,"min-w-0"],["tone","gray"],[1,"min-w-0","truncate"],[1,"ml-1","min-w-0","truncate","text-muted-foreground"],["size","lg",3,"closed","title","contentKey"],["ngProjectAs","[panel-footer]",5,["","panel-footer",""]],["for","su-name",1,"text-xs","font-medium","text-muted-foreground"],["id","su-name","placeholder","github-actions-deploy","autocomplete","off",1,"ui-input","mt-1",3,"ngModelChange","ngModel"],[1,"mt-1.5","text-xs","text-muted-foreground"],[1,"mb-1.5","mt-4","text-sm","font-medium","text-surface-foreground"],["data-testid","scope-options",1,"rounded-lg","border","border-border"],[1,"ui-check-row","text-sm"],[1,"mt-4","text-xs","text-muted-foreground"],[1,"mt-5","flex","justify-end"],["size","lg",3,"click","loading","disabled"],["type","checkbox",1,"ui-checkbox",3,"change","checked"],[1,"min-w-0","flex-1"],[1,"block","font-medium","text-surface-foreground"],[1,"block","text-xs","text-muted-foreground"],[3,"created","rotated"],[3,"closed","created","rotated"],[3,"serviceUser"],[3,"changed","serviceUser"],["size","lg","variant","outline",3,"click","disabled","title"],["size","lg","variant","danger",3,"click"],[3,"closed","title"],[1,"text-sm","text-muted-foreground"],[1,"font-medium","text-surface-foreground"],[1,"mt-2","text-sm","text-muted-foreground"],[1,"mt-4","flex","justify-end","gap-2"],["variant","outline",3,"click"],[3,"click","loading"],["variant","danger",3,"click","loading"]],template:function(e,n){if(e&1&&(g(0,Fi,2,1,"app-banner",1)(1,Bi,3,0,"div",2)(2,$i,4,0,"app-empty-state",3)(3,Oi,2,1,"app-empty-state",4)(4,Hi,16,0,"div",5),Ce(5,no,6,4,"ng-template",null,0,Se),g(7,io,16,2,"app-dialog",6),g(8,oo,8,2,"app-dialog",6)),e&2){let o,c;f(n.error()?0:n.serviceUsers()===null?1:n.serviceUsers().length===0?2:n.filtered().length===0?3:4),s(7),f((o=n.confirmingRotate())?7:-1,o),s(),f((c=n.confirmingDelete())?8:-1,c)}},dependencies:[Z,J,X,Y,$,M,I,q,L,ae,Ee,ee,ze,He,me],encapsulation:2})};var ro=(i,t)=>t.tokenId;function ao(i,t){if(i&1&&(a(0,"app-banner",0),l(1),r()),i&2){let e=d();s(),C(e.error())}}function so(i,t){i&1&&(a(0,"div",1),T(1,"app-skeleton",6)(2,"app-skeleton",6),r())}function lo(i,t){i&1&&(a(0,"app-empty-state",2),l(1," Nobody has created a personal access token yet. "),r())}function co(i,t){if(i&1&&(a(0,"app-empty-state",3),l(1),r()),i&2){let e=d();s(),y(' Nothing matches "',e.query(),'". Try a different email or token name. ')}}function po(i,t){if(i&1&&(a(0,"span",15),l(1),r()),i&2){let e=d().$implicit;s(),K(" limited to ",e.roles.length," role",e.roles.length===1?"":"s"," ")}}function mo(i,t){if(i&1&&(a(0,"app-chip"),l(1),r()),i&2){let e=t.$implicit,n=d(3);s(),C(n.scopeLabel(e))}}function uo(i,t){i&1&&(a(0,"app-badge",19),l(1,"expired"),r())}function _o(i,t){if(i&1){let e=v();a(0,"div",11)(1,"div",12)(2,"span",13),l(3),r()(),a(4,"div",12)(5,"span",14),l(6),r(),g(7,po,2,2,"span",15),r(),a(8,"div",16)(9,"div",17),S(10,mo,2,1,"app-chip",null,te),r()(),a(12,"div",18),l(13),g(14,uo,2,0,"app-badge",19),r(),a(15,"div",20),l(16),r(),a(17,"div",21)(18,"app-button",22),u("click",function(){let o=p(e).$implicit,c=d(2);return m(c.confirmingRevoke.set(o))}),l(19,"Revoke"),r()()()}if(i&2){let e=t.$implicit,n=d(2);s(3),C(e.ownerEmail||e.ownerId),s(3),C(e.name),s(),f(e.roles!=null&&e.roles.length?7:-1),s(3),w(e.scopes),s(3),y(" ",n.date(e.expiresAt)," "),s(),f(n.expired(e)?14:-1),s(2),C(n.ago(e.lastUsedAt))}}function go(i,t){if(i&1&&(a(0,"div",4)(1,"div",7)(2,"div",8),l(3,"Owner"),r(),a(4,"div",8),l(5,"Token"),r(),a(6,"div",8),l(7,"Scopes"),r(),a(8,"div",8),l(9,"Expires"),r(),a(10,"div",8),l(11,"Last used"),r(),T(12,"div"),r(),a(13,"div",9)(14,"div",10),S(15,_o,20,6,"div",11,ro),r()()()),i&2){let e=d();s(15),w(e.filtered())}}function fo(i,t){if(i&1){let e=v();a(0,"app-dialog",23),u("closed",function(){p(e);let o=d();return m(o.confirmingRevoke.set(null))}),a(1,"p",24),l(2," This token of "),a(3,"span",25),l(4),r(),l(5," stops working at once. Anything still using it will start failing. This can't be undone. "),r(),a(6,"div",26)(7,"app-button",27),u("click",function(){p(e);let o=d();return m(o.confirmingRevoke.set(null))}),l(8,"Cancel"),r(),a(9,"app-button",28),u("click",function(){let o=p(e),c=d();return m(c.revoke(o))}),l(10,"Revoke token"),r()()()}if(i&2){let e=t,n=d();_("title","Revoke "+e.name+"?"),s(4),C(e.ownerEmail||e.ownerId),s(5),_("loading",n.revoking())}}var Ke=class i{api=b(bt);toast=b(N);query=we("");tokens=x(null);error=x("");confirmingRevoke=x(null);revoking=x(!1);scopeLabel=H;filtered=h(()=>{let t=this.query().trim().toLowerCase(),e=this.tokens()??[];return t?e.filter(n=>n.name.toLowerCase().includes(t)||(n.ownerEmail??"").toLowerCase().includes(t)||n.scopes.some(o=>H(o).toLowerCase().includes(t))):e});ngOnInit(){this.load()}load(){this.api.adminList().subscribe({next:t=>{this.error.set(""),this.tokens.set(t)},error:t=>this.error.set(k(t,"Could not load access tokens."))})}revoke(t){this.revoking.set(!0),this.api.adminRevoke(t.tokenId).subscribe({next:()=>{this.revoking.set(!1),this.confirmingRevoke.set(null),this.toast.success(`Revoked ${t.name}`),this.tokens.update(e=>(e??[]).filter(n=>n.tokenId!==t.tokenId))},error:e=>{this.revoking.set(!1),this.toast.error(k(e,"Could not revoke the token."))}})}expired(t){return Date.parse(t.expiresAt)<=Date.now()}date(t){return St(t)}ago(t){return se(t)}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-admin-tokens-tab"]],hostAttrs:[1,"flex","min-h-0","flex-1","flex-col"],inputs:{query:[1,"query"]},outputs:{query:"queryChange"},decls:6,vars:2,consts:[["tone","danger"],[1,"space-y-2"],["title","No access tokens"],["title","No matches"],[1,"flex","min-h-0","flex-1","flex-col","overflow-x-auto"],[3,"title"],["sizeClass","h-12 w-full"],[1,"grid","min-w-[800px]","shrink-0","grid-cols-[24%_20%_22%_12%_11%_minmax(0,1fr)]"],[1,"px-4","py-2.5","ui-microlabel","text-text-secondary"],[1,"flex","min-h-0","min-w-[800px]","flex-col","overflow-hidden","rounded-lg","border","border-border","bg-card-bg"],[1,"min-h-0","overflow-y-auto"],["data-testid","row",1,"grid","grid-cols-[24%_20%_22%_12%_11%_minmax(0,1fr)]","items-start","border-t","border-border","text-sm","first:border-t-0"],[1,"min-w-0","px-4","py-3"],[1,"block","break-words","font-medium","tracking-[0.015em]","text-surface-foreground"],[1,"block","break-words","text-surface-foreground"],[1,"mt-0.5","block","text-xs","text-muted-foreground"],[1,"px-4","py-3"],[1,"flex","flex-wrap","gap-1.5"],[1,"whitespace-nowrap","px-4","py-3","text-xs","tabular-nums","text-muted-foreground"],["tone","red",1,"mt-1","block","w-fit"],[1,"px-4","py-3","text-xs","tabular-nums","text-muted-foreground"],[1,"flex","justify-end","px-4","py-2.5"],["variant","outline","size","sm",3,"click"],[3,"closed","title"],[1,"text-sm","text-muted-foreground"],[1,"font-medium","text-surface-foreground"],[1,"mt-4","flex","justify-end","gap-2"],["variant","outline",3,"click"],["variant","danger",3,"click","loading"]],template:function(e,n){if(e&1&&(g(0,ao,2,1,"app-banner",0)(1,so,3,0,"div",1)(2,lo,2,0,"app-empty-state",2)(3,co,2,1,"app-empty-state",3)(4,go,17,0,"div",4),g(5,fo,11,3,"app-dialog",5)),e&2){let o;f(n.error()?0:n.tokens()===null?1:n.tokens().length===0?2:n.filtered().length===0?3:4),s(5),f((o=n.confirmingRevoke())?5:-1,o)}},dependencies:[$,M,I,q,L,ae,ee],encapsulation:2})};var xo=["panelTpl"],Co=()=>[],vo=(i,t)=>t.value,ho=(i,t)=>t.userId,bo=(i,t)=>t.key,yo=(i,t)=>t.groupId,So=(i,t)=>t.accountNumber+"#"+t.roleName,wo=(i,t)=>t.resourceId;function ko(i,t){if(i&1){let e=v();a(0,"app-button",14),u("click",function(){p(e);let o=d();return m(o.accessReport())}),T(1,"app-icon",15),l(2," Access report "),r(),a(3,"app-button",16),u("click",function(){p(e);let o=d();return m(o.openCreate())}),T(4,"app-icon",17),l(5," Create user "),r()}if(i&2){let e=d();_("loading",e.reportBusy()),s(4),_("strokeWidth",2)}}function To(i,t){if(i&1){let e=v();a(0,"app-button",16),u("click",function(){let o;p(e);let c=d();return m((o=c.serviceTab())==null?null:o.openCreate())}),T(1,"app-icon",17),l(2," Add service user "),r()}i&2&&(s(),_("strokeWidth",2))}function Uo(i,t){if(i&1){let e=v();a(0,"div",18)(1,"app-search-input",19),F("valueChange",function(o){p(e);let c=d();return P(c.serviceQuery,o)||(c.serviceQuery=o),m(o)}),r()(),a(2,"app-service-users-tab",20),F("queryChange",function(o){p(e);let c=d();return P(c.serviceQuery,o)||(c.serviceQuery=o),m(o)}),r()}if(i&2){let e=d();s(),A("value",e.serviceQuery),s(),A("query",e.serviceQuery)}}function Eo(i,t){if(i&1){let e=v();a(0,"div",18)(1,"app-search-input",21),F("valueChange",function(o){p(e);let c=d();return P(c.tokensQuery,o)||(c.tokensQuery=o),m(o)}),r()(),a(2,"app-admin-tokens-tab",20),F("queryChange",function(o){p(e);let c=d();return P(c.tokensQuery,o)||(c.tokensQuery=o),m(o)}),r()}if(i&2){let e=d();s(),A("value",e.tokensQuery),s(),A("query",e.tokensQuery)}}function Do(i,t){if(i&1&&(a(0,"app-banner",6),l(1),r()),i&2){let e=d();s(),C(e.store.error())}}function Io(i,t){i&1&&(a(0,"div",7),T(1,"app-skeleton",22)(2,"app-skeleton",22)(3,"app-skeleton",22),r())}function No(i,t){i&1&&(a(0,"app-empty-state",8),l(1," Invite someone with "),a(2,"span",23),l(3,"Create user"),r(),l(4," \u2014 they'll get an email to set their password. "),r())}function Vo(i,t){if(i&1&&(a(0,"option",29),l(1),r()),i&2){let e=t.$implicit,n=d(2);_("value",e.value)("selected",e.value===n.sort()),s(),C(e.label)}}function Ro(i,t){if(i&1&&l(0),i&2){let e=d(3);y(' Nothing matches "',e.query(),'". Try a different email, role, account, or resource, or clear the filters. ')}}function Mo(i,t){i&1&&l(0," No users match the current filters. ")}function Ao(i,t){if(i&1&&(a(0,"app-empty-state",31),g(1,Ro,1,1)(2,Mo,1,0),r()),i&2){let e=d(2);s(),f(e.query()?1:2)}}function Po(i,t){if(i&1&&(a(0,"span",46),l(1),r()),i&2){let e=t.$implicit;s(),K("",e.label," \xB7 ",e.value)}}function Fo(i,t){i&1&&(a(0,"app-badge",50),l(1,"admin"),r())}function Bo(i,t){i&1&&(a(0,"app-badge",51),l(1,"invited"),r())}function $o(i,t){if(i&1&&(a(0,"span",47),g(1,Fo,2,0,"app-badge",50),g(2,Bo,2,0,"app-badge",51),r()),i&2){let e=d().$implicit;s(),f(e.admin?1:-1),s(),f(e.pendingInvite?2:-1)}}function Oo(i,t){i&1&&(a(0,"app-badge",48),l(1,"No groups"),r())}function Go(i,t){if(i&1&&(a(0,"app-chip")(1,"span",52),l(2),r()()),i&2){let e=t.$implicit;s(2),C(e.name)}}function Lo(i,t){if(i&1&&(a(0,"div",49),S(1,Go,3,1,"app-chip",null,yo),r()),i&2){let e=d().$implicit,n=d(3);s(),w(n.store.groupsOf().get(e.userId))}}function jo(i,t){i&1&&(a(0,"app-badge",48),l(1,"No roles"),r())}function qo(i,t){i&1&&(a(0,"span",57),l(1," direct "),r())}function Wo(i,t){if(i&1&&(a(0,"span",58),l(1),r()),i&2){let e=t.$implicit;s(),y(" ",e," ")}}function zo(i,t){if(i&1&&(a(0,"span",55)(1,"span",52),l(2),r(),a(3,"span",56),l(4),r(),g(5,qo,2,0,"span",57),S(6,Wo,2,1,"span",58,te),r()),i&2){let e=t.$implicit,n=d(5);B(n.acctChip(e.accountNumber)),Qe("--role-c",n.roleChipColor(e)),_("title",n.roleTitle(e)),s(2),C(e.roleName),s(2),y("\xB7 ",n.names.label(e.accountNumber)),s(),f(e.direct&&e.groups.length?5:-1),s(),w(e.groups)}}function Ho(i,t){if(i&1&&(a(0,"span",54),l(1),r()),i&2){let e=d(2).$implicit,n=d(3);_("title",n.hiddenRolesTitle(e)),s(),y(" +",(e.roleCount??e.roles.length)-2," more ")}}function Ko(i,t){if(i&1&&(a(0,"div",49),S(1,zo,8,8,"span",53,So),g(3,Ho,2,2,"span",54),r()),i&2){let e=d().$implicit;s(),w(e.roles.slice(0,2)),s(2),f((e.roleCount??e.roles.length)>2?3:-1)}}function Qo(i,t){i&1&&(a(0,"app-badge",48),l(1,"No network resources"),r())}function Jo(i,t){if(i&1&&(a(0,"span",56),l(1),r()),i&2){let e=d().$implicit,n=d(5);s(),y("\xB7 ",n.names.label(e.accountNumber))}}function Xo(i,t){i&1&&(a(0,"span",57),l(1," direct "),r())}function Yo(i,t){if(i&1&&(a(0,"span",58),l(1),r()),i&2){let e=t.$implicit;s(),y(" ",e," ")}}function Zo(i,t){if(i&1&&(a(0,"span",55)(1,"span",52),l(2),r(),g(3,Jo,2,1,"span",56),g(4,Xo,2,0,"span",57),S(5,Yo,2,1,"span",58,te),r()),i&2){let e=t.$implicit,n=d(5);B(n.acctChip(e.accountNumber)),Qe("--role-c",n.acctChipColor(e.accountNumber)),_("title",n.resourceTitle(e)),s(2),C(e.name),s(),f(e.accountNumber?3:-1),s(),f(e.direct&&e.groups.length?4:-1),s(),w(e.groups)}}function er(i,t){if(i&1&&(a(0,"span",54),l(1),r()),i&2){let e=d(2).$implicit,n=d(3);_("title",n.hiddenResourcesTitle(e)),s(),y(" +",(e.resourceCount??e.resources.length)-2," more ")}}function tr(i,t){if(i&1&&(a(0,"div",49),S(1,Zo,7,8,"span",53,wo),g(3,er,2,2,"span",54),r()),i&2){let e=d().$implicit;s(),w(e.resources.slice(0,2)),s(2),f((e.resourceCount??e.resources.length)>2?3:-1)}}function nr(i,t){if(i&1){let e=v();a(0,"div",42),u("click",function(){let o=p(e).$implicit,c=d(3);return m(c.openDetail(o))}),a(1,"div",43)(2,"input",44),u("click",function(o){return p(e),m(o.stopPropagation())})("change",function(){let o=p(e).$implicit,c=d(3);return m(c.toggleSelect(o.userId))}),r()(),a(3,"div",43)(4,"span",45),l(5),r(),S(6,Po,2,2,"span",46,bo),g(8,$o,3,2,"span",47),r(),a(9,"div",43),g(10,Oo,2,0,"app-badge",48)(11,Lo,3,0,"div",49),r(),a(12,"div",43),g(13,jo,2,0,"app-badge",48)(14,Ko,4,1,"div",49),r(),a(15,"div",43),g(16,Qo,2,0,"app-badge",48)(17,tr,4,1,"div",49),r()()}if(i&2){let e,n=t.$implicit,o=d(3);B(o.selected().has(n.userId)||o.panelUserId()===n.userId?"bg-brand/5":""),s(2),_("checked",o.selected().has(n.userId)),ve("aria-label","Select "+(n.email||n.userId)),s(3),y(" ",n.email||"(no email)"," "),s(),w(o.claimRows(n)),s(2),f(n.admin||n.pendingInvite?8:-1),s(2),f((e=o.store.groupsOf().get(n.userId))!=null&&e.length?11:10),s(3),f(n.roles.length===0?13:14),s(3),f(n.resources!=null&&n.resources.length?17:16)}}function ir(i,t){if(i&1){let e=v();a(0,"app-load-more",59),u("reached",function(){p(e);let o=d(3);return m(o.window.loadMore())}),r()}}function or(i,t){if(i&1&&l(0),i&2){let e=d(3);y(" (filtered from ",e.store.users().length,") ")}}function rr(i,t){if(i&1){let e=v();a(0,"div",32)(1,"div",33)(2,"div",34)(3,"input",35),u("change",function(){p(e);let o=d(2);return m(o.toggleSelectAll())}),r()(),a(4,"div",36),l(5,"User"),r(),a(6,"div",36),l(7,"Groups"),r(),a(8,"div",36),l(9,"Roles"),r(),a(10,"div",36),l(11,"Network"),r()(),a(12,"div",37)(13,"div",38),S(14,nr,18,9,"div",39,ho),g(16,ir,1,0,"app-load-more",40),r()()(),a(17,"app-result-count",41),g(18,or,1,1),r()}if(i&2){let e=d(2);s(3),_("checked",e.allSelected()),s(11),w(e.window.items()),s(2),f(e.window.hasMore()?16:-1),s(),_("shown",e.window.shown())("total",e.filtered().length),s(),f(e.filtered().length!==e.store.users().length?18:-1)}}function ar(i,t){if(i&1){let e=v();a(0,"div",24)(1,"app-filter-popup",25),F("filtersChange",function(o){p(e);let c=d();return P(c.filters,o)||(c.filters=o),m(o)}),r(),a(2,"div",26)(3,"span",27),l(4,"Sort:"),r(),a(5,"select",28),u("change",function(o){p(e);let c=d();return m(c.sort.set(o.target.value))}),S(6,Vo,2,3,"option",29,vo),r()(),a(8,"app-search-input",30),F("valueChange",function(o){p(e);let c=d();return P(c.query,o)||(c.query=o),m(o)}),r()(),g(9,Ao,3,1,"app-empty-state",31)(10,rr,19,5)}if(i&2){let e=d();s(),_("sections",e.filterSections()),A("filters",e.filters),s(5),w(e.SORTS),s(2),A("value",e.query),s(),f(e.filtered().length===0?9:10)}}function sr(i,t){if(i&1){let e=v();a(0,"div",9)(1,"span",60),l(2),r(),a(3,"button",61),u("click",function(){p(e);let o=d();return m(o.selected.set(o.emptySet))}),l(4," Clear "),r(),T(5,"span",62),a(6,"app-button",63),u("click",function(){p(e);let o=d();return m(o.openResend())}),l(7," Send invite emails "),r(),a(8,"app-button",64),u("click",function(){p(e);let o=d();return m(o.openAddToGroup())}),l(9," Add to group "),r(),a(10,"app-button",65),u("click",function(){p(e);let o=d();return m(o.openDelete())}),l(11," Delete "),r()()}if(i&2){let e=d();s(2),y(" ",e.selected().size," selected "),s(4),_("disabled",e.resendCandidates().length===0)("title",e.resendCandidates().length?"":"Only users still waiting on their invite")}}function lr(i,t){if(i&1){let e=v();a(0,"app-user-create-form",68),u("created",function(){p(e);let o=d(2);return m(o.store.load())})("createdOne",function(o){p(e);let c=d(2);return m(c.openCreated(o))})("closed",function(){p(e);let o=d(2);return m(o.closePanel())}),r()}}function dr(i,t){if(i&1){let e=v();a(0,"app-user-detail",70),u("changed",function(){p(e);let o=d(3);return m(o.store.load())}),r()}if(i&2){let e=d(3);_("user",t)("justCreated",e.justCreated())}}function cr(i,t){if(i&1&&g(0,dr,1,2,"app-user-detail",69),i&2){let e,n=d(2);f((e=n.panelUser())?0:-1,e)}}function pr(i,t){if(i&1){let e=v();a(0,"app-resend-invites",71),u("sentAny",function(){p(e);let o=d(2);return m(o.store.load())})("closed",function(){p(e);let o=d(2);return m(o.closePanel())}),r()}if(i&2){let e=d(2);_("users",e.resendCandidates())("preselect",e.resendCandidateIds())}}function mr(i,t){if(i&1){let e=v();a(0,"app-button",72),u("click",function(){let o=p(e),c=d(3);return m(c.revokingAll.set(o))}),l(1,"Revoke everything"),r(),a(2,"app-button",73),u("click",function(){let o=p(e),c=d(3);return m(c.deleting.set(o))}),l(3,"Delete user"),r()}}function ur(i,t){if(i&1&&g(0,mr,4,0),i&2){let e,n=d(2);f((e=n.panelUser())?0:-1,e)}}function _r(i,t){if(i&1){let e=v();a(0,"app-panel",66),u("closed",function(){p(e);let o=d();return m(o.closePanel())}),g(1,lr,1,0,"app-user-create-form")(2,cr,1,1)(3,pr,1,2,"app-resend-invites",10),he(4,67),g(5,ur,1,1),be(),r()}if(i&2){let e,n=d();_("title",n.panelTitle())("contentKey",n.panelKind()+":"+n.panelUserId()),s(),f((e=n.panelKind())==="create"?1:e==="detail"?2:e==="resend"?3:-1),s(4),f(n.panelKind()==="detail"?5:-1)}}function gr(i,t){if(i&1){let e=v();a(0,"app-bulk-delete-dialog",74),u("deleted",function(){p(e);let o=d();return m(o.afterBulk())})("closed",function(){p(e);let o=d();return m(o.bulkDeleteOpen.set(!1))}),r()}if(i&2){let e=d();_("users",e.store.users()??ut(2,Co))("preselect",e.selectedIds())}}function fr(i,t){if(i&1){let e=v();a(0,"app-grant-dialog",75),u("granted",function(o){p(e);let c=d();return m(c.addToGroups(o.ids))})("closed",function(){p(e);let o=d();return m(o.addToGroupOpen.set(!1))}),r()}if(i&2){let e=d();_("intro",e.addToGroupIntro())("options",e.groupOptions())("busy",e.groupBusy())}}function xr(i,t){if(i&1){let e=v();a(0,"app-dialog",76),u("closed",function(){p(e);let o=d();return m(o.revokingAll.set(null))}),a(1,"p",77),l(2," Remove "),a(3,"b"),l(4,"every"),r(),l(5),r(),a(6,"div",78)(7,"app-button",79),u("click",function(){p(e);let o=d();return m(o.revokingAll.set(null))}),l(8,"Cancel"),r(),a(9,"app-button",80),u("click",function(){let o=p(e),c=d();return m(c.revokeAll(o))}),l(10,"Revoke everything"),r()()()}if(i&2){let e=d();s(5),y(" role and network-resource grant of ",t.email," and take them out of all groups? The user account stays (they can be granted access again); this cannot be undone in one step. "),s(4),_("loading",e.revokeBusy())}}function Cr(i,t){if(i&1){let e=v();a(0,"app-user-delete-dialog",81),u("deleted",function(){p(e);let o=d();return m(o.afterDeleted())})("closed",function(){p(e);let o=d();return m(o.deleting.set(null))}),r()}i&2&&_("user",t)}var vr=[],Qt=class i{federation=b(Ve);claimRows(t){if(!t.claims)return vr;let e=this.claimRowCache.get(t);return e||(e=this.federation.claimRows(t.claims),this.claimRowCache.set(t,e)),e}claimRowCache=new WeakMap;store=b(Pe);api=b(R);groupsApi=b(le);names=b(j);roleColors=b(Me);toast=b(N);query=x("");bulkDeleteOpen=x(!1);addToGroupOpen=x(!1);groups=this.store.groups;groupBusy=x(!1);addToGroupIntro=h(()=>`${this.selected().size} user${this.selected().size===1?"":"s"} selected \u2014 each gets every picked group's whole bundle (roles + resources), long-term.`);groupOptions=h(()=>this.groups().map(t=>({id:t.groupId,label:t.name,sublabel:`${t.members.length} member${t.members.length===1?"":"s"}`})));openAddToGroup(){this.addToGroupOpen.set(!0)}addToGroups(t){if(!t.length)return;let e=this.selectedIds(),n=o=>{if(o>=t.length){this.groupBusy.set(!1),this.addToGroupOpen.set(!1),this.toast.success(`Added ${e.length} user${e.length===1?"":"s"} to ${t.length} group${t.length===1?"":"s"}`),this.selected.set(new Set),this.store.load();return}this.groupBusy.set(!0),this.groupsApi.addMembers(t[o],e).subscribe({next:()=>n(o+1),error:c=>{this.groupBusy.set(!1),this.toast.error(k(c,"Could not add to the group."))}})};n(0)}SERVICE_TAB="Service users";TOKENS_TAB="Access tokens";tokensOn=!!xt(b(ne));TABS=["People",this.SERVICE_TAB,...this.tokensOn?[this.TOKENS_TAB]:[]];tab=x("People");serviceQuery=x("");tokensQuery=x("");serviceTab=ge(ue);selected=x(new Set);emptySet=new Set;panelKind=x(null);panelUserId=x(null);justCreated=x(null);panelTpl=ge("panelTpl");selectedUsers=h(()=>(this.store.users()??[]).filter(t=>this.selected().has(t.userId)));selectedIds=h(()=>Array.from(this.selected()));singleSelected=h(()=>this.selectedUsers().length===1?this.selectedUsers()[0]:null);panelUser=h(()=>(this.store.users()??[]).find(t=>t.userId===this.panelUserId())??null);panelTitle=h(()=>{switch(this.panelKind()){case"create":return"Invite users";case"detail":return"User info";case"resend":return"Send invite emails";default:return"User info"}});openCreate(){this.panelUserId.set(null),this.panelKind.set("create")}openDetail(t){this.justCreated.set(null),this.panelUserId.set(t.userId),this.panelKind.set("detail")}openCreated(n){var o=n,{user:t}=o,e=Ze(o,["user"]);this.store.upsert(t),this.justCreated.set(e),this.panelUserId.set(t.userId),this.panelKind.set("detail")}closePanel(){this.panelKind.set(null),this.panelUserId.set(null),this.justCreated.set(null)}openDelete(){let t=this.singleSelected();t?this.deleting.set(t):this.bulkDeleteOpen.set(!0)}resendCandidates=h(()=>this.selectedUsers().filter(t=>t.pendingInvite));resendCandidateIds=h(()=>this.resendCandidates().map(t=>t.userId));openResend(){if(this.resendCandidates().length===0){this.toast.error("None of the selected users are waiting on an invite.");return}this.panelUserId.set(null),this.panelKind.set("resend")}allSelected=h(()=>{let t=this.filtered();return t.length>0&&t.every(e=>this.selected().has(e.userId))});toggleSelect(t){this.selected.update(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})}toggleSelectAll(){let t=this.filtered();this.selected.update(e=>{let n=new Set(e);if(t.every(o=>n.has(o.userId)))for(let o of t)n.delete(o.userId);else for(let o of t)n.add(o.userId);return n})}afterBulk(){this.selected.set(new Set),this.closePanel(),this.store.load()}deleting=x(null);revokingAll=x(null);revokeBusy=x(!1);revokeAll(t){this.revokeBusy.set(!0),this.api.revokeAllAccess(t.userId).subscribe({next:({removed:e})=>{this.revokeBusy.set(!1),this.revokingAll.set(null),this.toast.success(`Revoked everything for ${t.email} (${e} entr${e===1?"y":"ies"})`),this.store.load()},error:e=>{this.revokeBusy.set(!1),this.toast.error(k(e,"Could not revoke everything."))}})}auditApi=b(Re);reportBusy=x(!1);destroyRef=b(xe);accessReport(){this.reportBusy.set(!0);let t=e=>{this.reportBusy.set(!1),this.toast.error(k(e,"Could not build the access report."))};this.auditApi.startAccessReport().subscribe({next:e=>{this.auditApi.accessReportJob(e.jobId).pipe(rt({delay:2e3}),at(n=>n.status==="running",!0),ot(),ke(this.destroyRef)).subscribe({next:n=>{this.reportBusy.set(!1),n.status==="done"&&n.url?(this.toast.success(`Access report ready \u2014 ${n.rows??0} rows`),window.open(n.url,"_blank","noopener")):this.toast.error(n.error||"Could not build the access report.")},error:t})},error:t})}filters=x([]);filterSections=h(()=>{let t=["role","resource","team","user","status"],e={role:"Role",resource:"Resource",team:"Team",user:"User",status:"Status"},n=new Map(t.map(o=>[o,new Map]));for(let o of this.store.users()??[])for(let c of t){let U=n.get(c);for(let fe of new Set(this.facetValues(o,c)))U.set(fe,(U.get(fe)??0)+1)}return t.map(o=>({key:o,label:e[o],options:[...n.get(o).entries()].sort((c,U)=>c[0].localeCompare(U[0])).map(([c,U])=>({value:c,count:U}))}))});selectedByKey=h(()=>{let t=new Map;for(let e of this.filters()){let n=t.get(e.key);n||t.set(e.key,n=new Set),n.add(e.value)}return t});serverHits=x(null);serverSearchSeq=0;filtered=h(()=>{let t=this.store.users()??[],e=this.query().trim().toLowerCase(),n=this.selectedByKey();if(!e&&n.size===0)return t;let o=e?this.serverHits():null;return t.filter(c=>{if(o?!o.has(c.userId):!this.matchesSearch(c,e))return!1;for(let[U,fe]of n)if(!this.facetValues(c,U).some(Jt=>fe.has(Jt)))return!1;return!0})});serverSearch(t){let e=++this.serverSearchSeq;if(!t){this.serverHits.set(null);return}this.api.listUsersPage({q:t,limit:200}).subscribe({next:n=>{e===this.serverSearchSeq&&this.serverHits.set(new Set(n.items.map(o=>o.userId)))},error:()=>{}})}facetValues(t,e){switch(e){case"role":return t.roleNames??t.roles.map(n=>n.roleName);case"resource":return(t.resources??[]).map(n=>n.name);case"team":return t.groupNames??[...t.roles.flatMap(n=>n.groups),...(t.resources??[]).flatMap(n=>n.groups)];case"user":return[t.email];case"status":{let n=[];return t.admin&&n.push("Admin"),t.pendingInvite&&n.push("Pending invite"),t.roles.length===0&&n.push("No roles"),n}default:return[]}}matchesSearch(t,e){return e?t.email.toLowerCase().includes(e)||this.claimRows(t).some(n=>n.value.toLowerCase().includes(e))||t.roles.some(n=>n.roleName.toLowerCase().includes(e)||n.accountNumber.toLowerCase().includes(e)||this.names.label(n.accountNumber).toLowerCase().includes(e)||n.groups.some(o=>o.toLowerCase().includes(e)))||(t.resources??[]).some(n=>n.name.toLowerCase().includes(e)||n.groups.some(o=>o.toLowerCase().includes(e))):!0}SORTS=zt;sort=x("email-asc");sorted=h(()=>Ht(this.filtered(),this.sort()));window=Vt(this.sorted,30);acctChip(t){return t?"role-chip":"bg-muted text-surface-foreground ring-1 ring-border"}acctChipColor(t){return t?ce(t):null}roleChipColor(t){return this.roleColors.colorOf(t.accountNumber,t.roleName)||ce(t.accountNumber)}roleSource(t){let e=t.groups.length?`the ${t.groups.join(", ")} team${t.groups.length===1?"":"s"}`:"";return t.direct&&e?`Held directly, and via ${e}`:e?`Granted via ${e}`:"Granted directly"}roleTitle(t){return`${t.roleName} \xB7 ${this.names.label(t.accountNumber)} \u2014 ${this.roleSource(t)}`}resourceTitle(t){let e=t.accountNumber?` \xB7 ${this.names.label(t.accountNumber)}`:"";return`${t.name}${e} \u2014 ${this.resourceSource(t)}`}hiddenRolesTitle(t){return t.roles.slice(2).map(e=>`${e.roleName} \xB7 ${this.names.label(e.accountNumber)}`).join(`
`)}hiddenResourcesTitle(t){return(t.resources??[]).slice(2).map(e=>`${e.name}${e.accountNumber?` \xB7 ${this.names.label(e.accountNumber)}`:""}`).join(`
`)}resourceSource(t){let e=t.groups.length?`the ${t.groups.join(", ")} team${t.groups.length===1?"":"s"}`:"";return t.direct&&e?`Held directly, and via ${e}`:e?`Granted via ${e}`:"Granted directly"}afterDeleted(){let t=this.deleting()?.userId??null;this.deleting.set(null),t&&t===this.panelUserId()&&this.closePanel(),this.selected.set(new Set),this.store.load()}constructor(){this.store.load(),this.names.ensure(),this.roleColors.ensure(),Ue(this.panelKind,this.panelTpl,()=>this.closePanel());let t;z(()=>{let c=this.query().trim();t&&clearTimeout(t),W(()=>{if(!c){this.serverSearch("");return}t=setTimeout(()=>this.serverSearch(c),250)})});let e=b(_t),n=b(gt),o={"service-users":this.SERVICE_TAB};this.tokensOn&&(o["access-tokens"]=this.TOKENS_TAB),e.queryParamMap.subscribe(c=>{this.tab.set(o[c.get("tab")??""]??"People")}),z(()=>{let c=Object.keys(o).find(U=>o[U]===this.tab())??null;W(()=>{this.closePanel(),(e.snapshot.queryParamMap.get("tab")??null)!==c&&n.navigate([],{relativeTo:e,queryParams:{tab:c},replaceUrl:!0})})})}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=E({type:i,selectors:[["app-users-page"]],viewQuery:function(e,n){e&1&&(_e(n.serviceTab,ue,5),_e(n.panelTpl,xo,5)),e&2&&ye(2)},hostAttrs:[1,"flex","min-h-0","flex-1","flex-col"],decls:19,vars:14,consts:[["panelTpl",""],[3,"tabbed","fill"],["pageHeader","","title","Users",3,"subtitle","subtitleInfo","showHeaderSearch"],["headerActions","",1,"flex","items-center","gap-3"],["size","lg"],[1,"mt-4","block",3,"selectedChange","tabs","selected"],["tone","danger"],[1,"space-y-2"],["title","No users yet"],["floatingBar","",1,"floating-bar","pointer-events-auto","flex","items-center","gap-2.5","rounded-xl","border-[1.5px]","border-brand/60","px-3","py-2"],[3,"users","preselect"],["title","Add to groups","placeholder","Filter groups","verb","Add to",3,"intro","options","busy"],["title","Revoke everything"],[3,"user"],["size","lg","variant","outline",3,"click","loading"],["name","download",1,"h-4","w-4"],["size","lg",3,"click"],["name","plus",1,"h-4","w-4",3,"strokeWidth"],[1,"mb-3","flex","shrink-0","justify-end"],["compact","","placeholder","Search by name or role",1,"w-[260px]",3,"valueChange","value"],[3,"queryChange","query"],["compact","","placeholder","Search by email or token",1,"w-[260px]",3,"valueChange","value"],["sizeClass","h-12 w-full"],[1,"font-medium"],[1,"mb-3","flex","shrink-0","items-start","gap-2"],[1,"min-w-0",3,"filtersChange","sections","filters"],[1,"relative","ml-auto","shrink-0"],["aria-hidden","true",1,"pointer-events-none","absolute","left-2.5","top-1/2","z-10","-translate-y-1/2","text-sm","text-text-secondary"],["aria-label","Sort users",1,"ui-input","h-7","w-auto","!py-0","pl-11","pr-7","text-sm",3,"change"],[3,"value","selected"],["compact","","placeholder","Search by email or role",1,"w-[260px]","shrink-0",3,"valueChange","value"],["title","No matches"],[1,"flex","min-h-0","flex-1","flex-col","overflow-x-auto"],[1,"grid","min-w-[760px]","shrink-0","grid-cols-[40px_22%_18%_30%_minmax(0,1fr)]"],[1,"flex","items-center","px-4","py-2.5"],["type","checkbox","aria-label","Select all listed users",1,"ui-checkbox",3,"change","checked"],[1,"px-4","py-2.5","text-left","ui-microlabel","text-text-secondary"],[1,"flex","min-h-0","min-w-[760px]","flex-1","flex-col","overflow-hidden","rounded-lg","border","border-border","bg-card-bg"],[1,"min-h-0","flex-1","overflow-y-auto"],["data-testid","row",1,"group","grid","cursor-pointer","grid-cols-[40px_22%_18%_30%_minmax(0,1fr)]","items-start","border-t","border-border","text-sm","transition-colors","first:border-t-0","hover:bg-state-hover",3,"class"],["appInfiniteScroll",""],["noun","user",3,"shown","total"],["data-testid","row",1,"group","grid","cursor-pointer","grid-cols-[40px_22%_18%_30%_minmax(0,1fr)]","items-start","border-t","border-border","text-sm","transition-colors","first:border-t-0","hover:bg-state-hover",3,"click"],[1,"px-4","py-3"],["type","checkbox",1,"ui-checkbox",3,"click","change","checked"],[1,"block","break-words","font-medium","tracking-[0.015em]","text-surface-foreground"],[1,"block","text-xs","text-muted-foreground"],[1,"mt-1","flex","flex-wrap","gap-1.5"],["tone","dashed"],[1,"flex","flex-wrap","gap-1.5"],["tone","brand"],["tone","amber","icon","clock"],[1,"min-w-0","truncate"],[1,"inline-flex","max-w-full","items-center","overflow-hidden","whitespace-nowrap","rounded-full","px-2","py-0.5","text-xs","font-medium",3,"class","--role-c","title"],[1,"inline-flex","items-center","whitespace-nowrap","rounded-full","border","border-border","px-2","py-0.5","text-xs","font-medium","text-muted-foreground",3,"title"],[1,"inline-flex","max-w-full","items-center","overflow-hidden","whitespace-nowrap","rounded-full","px-2","py-0.5","text-xs","font-medium",3,"title"],[1,"ml-1","min-w-0","shrink-[60]","truncate","text-muted-foreground"],[1,"ml-1.5","chip-tag","min-w-0","shrink-[400]"],[1,"ml-1","chip-tag","min-w-0","shrink-[400]"],["appInfiniteScroll","",3,"reached"],[1,"text-sm","font-medium","text-brand-muted-foreground"],[1,"text-xs","text-muted-foreground","hover:text-surface-foreground","hover:underline",3,"click"],[1,"mx-0.5","h-4","w-px","bg-border"],["size","sm","variant","outline",3,"click","disabled","title"],["size","sm","variant","outline",3,"click"],["size","sm","variant","danger",3,"click"],["size","lg",3,"closed","title","contentKey"],["ngProjectAs","[panel-footer]",5,["","panel-footer",""]],[3,"created","createdOne","closed"],[3,"user","justCreated"],[3,"changed","user","justCreated"],[3,"sentAny","closed","users","preselect"],["size","lg","variant","outline",1,"mr-auto",3,"click"],["size","lg","variant","danger",3,"click"],[3,"deleted","closed","users","preselect"],["title","Add to groups","placeholder","Filter groups","verb","Add to",3,"granted","closed","intro","options","busy"],["title","Revoke everything",3,"closed"],[1,"text-sm","text-surface-foreground"],[1,"mt-4","flex","justify-end","gap-2"],["variant","outline",3,"click"],["variant","danger",3,"click","loading"],[3,"deleted","closed","user"]],template:function(e,n){if(e&1){let o=v();a(0,"app-page",1)(1,"app-page-header",2)(2,"div",3),g(3,ko,6,2)(4,To,3,1,"app-button",4),r(),a(5,"app-tabs",5),F("selectedChange",function(U){return p(o),P(n.tab,U)||(n.tab=U),m(U)}),r()(),g(6,Uo,3,2)(7,Eo,3,2)(8,Do,2,1,"app-banner",6)(9,Io,4,0,"div",7)(10,No,5,0,"app-empty-state",8)(11,ar,11,4),g(12,sr,12,3,"div",9),r(),Ce(13,_r,6,4,"ng-template",null,0,Se),g(15,gr,1,3,"app-bulk-delete-dialog",10),g(16,fr,1,3,"app-grant-dialog",11),g(17,xr,11,2,"app-dialog",12),g(18,Cr,1,1,"app-user-delete-dialog",13)}if(e&2){let o,c;_("tabbed",!0)("fill",!0),s(),_("subtitle",n.tab()==="People"?"Everyone in the directory and the roles they can assume.":n.tab()===n.TOKENS_TAB?"Personal access tokens people created for their scripts and tools.":"Machine identities for automation.")("subtitleInfo",n.tab()==="People"?"Search freely, or add filters for role, resource, account, or team.":n.tab()===n.TOKENS_TAB?"A token acts as its owner within its scopes. Revoking it stops it at once.":"Each gets a client ID + secret and calls the API directly, no login.")("showHeaderSearch",!1),s(2),f(n.tab()==="People"?3:n.tab()===n.SERVICE_TAB?4:-1),s(2),_("tabs",n.TABS),A("selected",n.tab),s(),f(n.tab()===n.SERVICE_TAB?6:n.tab()===n.TOKENS_TAB?7:n.store.error()?8:n.store.users()===null?9:n.store.users().length===0?10:11),s(6),f(n.tab()==="People"&&n.store.users()!==null&&!n.store.error()&&n.selected().size>0?12:-1),s(3),f(n.bulkDeleteOpen()?15:-1),s(),f(n.addToGroupOpen()?16:-1),s(),f((o=n.revokingAll())?17:-1,o),s(),f((c=n.deleting())?18:-1,c)}},dependencies:[$,I,ee,Fe,Be,$e,je,q,de,L,Oe,Tt,Dt,It,M,ae,Ie,Ut,kt,oe,Nt,Ee,De,ue,Ke],encapsulation:2})};export{Pe as a,Qt as b};