PageSourceSearch

https://zop.dev/zopnight/app/assets/TeamDetailPage-MSl3XmkW.js

js zop.dev collected 2026-09-25 14:35:00 UTC 32,343 bytes, 1 lines download raw bytes

1import{r,j as e,L as Xe,i as Ts,u as Ps}from"./react-vendor-CSsSSEML.js";import{D as te,B as i,r as z,k as Te,S as re,E as D,j as se,o as Is,bS as Es,c8 as Us,f as Ce,c as Ds,F as we,K as Gs,M as H,aU as Bs,P as Re}from"./index-BVsjb7mB.js";import{P as Ls}from"./PageHeader-KYv9RwiA.js";import{P as Se}from"./Pagination-BnDSIG0w.js";import{E as Ae}from"./ErrorState-CE1mnLGb.js";import{D as $s}from"./DetailSkeleton-BOcVjxYM.js";import{a as zs,b as Ve}from"./useTeams-DCi7LYev.js";import{b as Os,a as Fs,c as Ys,d as _s,e as Hs}from"./useTeamMutations-nfxYKQlG.js";import{u as Ws}from"./useGroups-BAd--nxI.js";import{b as qs}from"./useGroupMutations-BvDsMXvi.js";import{c as Je,d as Vs,e as Js,u as Ks}from"./useTeamResources-BiRT-L3k.js";import{R as Zs}from"./ResourcePickerPanel-BmPweAFI.js";import{e as Me,v as Qs,T as Xs,M as et}from"./MemberAccessInfo-BGZM-inB.js";import{i as st}from"./formDirty-KbNXPJ_S.js";import{R as tt}from"./RoleSelect-CSOPqBr4.js";import{u as rt}from"./useUsers-CuI5bcSX.js";import{u as nt}from"./useTeamHref-BejmE-Lv.js";import{c as es}from"./useBudgets-Cvm99vBV.js";import{c as at}from"./useShowback-C_Eqq8eW.js";import{C as it}from"./chartPalette-BsoHyBiY.js";import"./tanstack-vendor-D2LStv3_.js";import"./sentry-vendor-DQkRq1-W.js";import"./CostInfoBanner-CP3PQYna.js";import"./TagsBadge-BD-3toVV.js";import"./SearchableSelect-BM_5_tjW.js";import"./GroupedAccountDropdown-DnL0M513.js";import"./GroupedTypeDropdown-iViufUrm.js";import"./FilterChips-CaksgMJ0.js";import"./useResources-Dn15QQUL.js";import"./useResourceFilterState-e6VKY49x.js";import"./useDebouncedValue-x0dK07ix.js";import"./importedName-D6DVdCGk.js";import"./useRoleMutations-afvY3QHG.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"33b2f1a2eb67da61a8a79f4c3c0fca45c630c2e5"};var x=new t.Error().stack;x&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[x]="3b496ef0-ec00-4776-8fb0-62ba13007058",t._sentryDebugIdIdentifier="sentry-dbid-3b496ef0-ec00-4776-8fb0-62ba13007058")}catch{}})();function ot({member:t,teamId:x,allTeamGroups:n,teamResources:c,onClose:m,canUpdate:v,roles:R,updateMemberRole:d}){const p=t?.roleName||t?.roleId||"—",f=nt(),A=!!t,[P,j]=r.useState(!1),[y,w]=r.useState(""),{data:h,isLoading:I}=rt({email:t?.email,enabled:A&&!!t?.email}),o=r.useMemo(()=>(Array.isArray(h)?h:h?.items??[])[0],[h]),b=o&&t?.email&&o.email?.toLowerCase()===t.email.toLowerCase()?o:void 0,T=I||!!o&&!b,N=!!h&&!!b,l=r.useMemo(()=>{const g=Array.isArray(b?.teams)?b.teams:[];return x==null?g:g.filter(ne=>String(ne.teamId)!==String(x))},[b,x]);function u(){w(t?.roleId||""),j(!0)}function G(){d.mutate({email:t.email,roleId:y},{onSuccess:()=>{j(!1),w("")}})}function O(){j(!1),w(""),m()}return e.jsx(te,{open:!!t,onClose:O,title:t?.email??"",children:t?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-lg bg-surface-secondary border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-text-muted",children:"Team role:"}),P?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{value:y,onChange:w,roles:R,required:!0}),e.jsx(i,{size:"xs",className:"h-7 min-w-[68px]",onClick:G,disabled:!y||y===t.roleId||d.isPending,children:d.isPending?"Updating...":"Update"}),e.jsx(i,{variant:"secondary",size:"xs",className:"h-7 min-w-[68px]",onClick:()=>j(!1),children:"Cancel"})]}):e.jsx(z,{children:p})]}),!P&&v&&e.jsx("button",{className:"text-sm font-medium text-primary-600 hover:text-primary-700 transition-colors",onClick:u,children:"Edit Role"})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-3",children:["Team memberships",T?"":` (${l.length})`]}),T?e.jsx("p",{className:"text-xs text-text-muted py-2",children:"Loading..."}):l.length===0?e.jsx("p",{className:"text-xs text-text-muted py-2",children:N?"Not a member of any team.":"Team memberships unavailable for this user."}):e.jsx("div",{className:"space-y-2",children:l.map(g=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-surface-secondary border border-border",children:[e.jsx(Xe,{to:f(g.teamId),onClick:O,className:"text-sm font-medium text-primary-600 hover:text-primary-700 hover:underline truncate",children:g.teamName}),e.jsx(z,{children:g.roleName||g.roleId||"—"})]},g.teamId))})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-3",children:["Access via Team (",c.length+n.length," items)"]}),c.length===0&&n.length===0?e.jsx("p",{className:"text-xs text-text-muted py-2",children:"No team resources or groups assigned."}):e.jsxs("div",{className:"space-y-2",children:[n.map(g=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 rounded-lg bg-surface-secondary border border-border",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-text-primary",children:g.name}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:"Resource Group"})]}),e.jsx(z,{variant:"success",children:p})]},g.id)),c.map(g=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 rounded-lg bg-surface-secondary border border-border",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-mono text-text-primary truncate block max-w-[220px]",children:g.resourceUid}),e.jsx("span",{className:"text-xs text-text-muted",children:"Individual Resource"})]}),e.jsx(z,{variant:"success",children:p})]},g.id??g.resourceUid))]})]})]}):null})}const Ke={green:{label:"On Track",dot:"bg-success-500",text:"text-success-600",icon:null},yellow:{label:"At Risk",dot:"bg-warning-500",text:"text-warning-600",icon:"warning"},red:{label:"Over Budget",dot:"bg-danger-500",text:"text-danger-600",icon:"warning"}};function Ze(t){return Ke[t]??Ke.green}const ke=e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.16
17 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 6a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 6zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})});function lt(t,x,n){if(t.resourceGroupId)return x?.find(m=>m.id===t.resourceGroupId)?.name??t.resourceGroupId;if(t.resourceUid){const c=n?.find(v=>v.resourceUid===t.resourceUid||v.uid===t.resourceUid);if(c?.name||c?.resourceName)return c.name||c.resourceName;const m=t.resourceUid;if(m.includes("/")){const v=m.split("/").pop();if(m.includes(":")){const R=m.split(":"),d=R[R.length-1],[p,f]=d.split("/");if(p&&f)return`${p.charAt(0).toUpperCase()+p.slice(1)} ${f}`}return v}return m.length>24?m.slice(0,24)+"...":m}return"Unknown"}function dt({teamId:t,groups:x,teamResources:n}){const{fmtCurrency:c,fmtCurrencyCompact:m}=Te(),{data:v,isLoading:R}=es(t);if(R)return e.jsx(re,{});const d=v?.summary??v??{},p=d.budgets??v?.budgets??[];if(!p.length)return e.jsx(D,{message:"No budgets set for this team's resources. Set budgets on resource groups or individual resources."});const f=d.totalBudgetUsd??0,A=d.totalSpendUsd??0,P=d.remainingUsd??f-A,j=d.memberCount??0,y=j>0?f/j:0,w=f>0?Math.min(Math.round(A/f*100),100):0,h=Ze(d.status),I=p.some(o=>o.status==="yellow"||o.status==="red");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h.icon&&e.jsx("span",{className:h.text,children:ke}),e.jsx("span",{className:`w-2 h-2 rounded-full ${h.dot}`}),e.jsx("span",{className:`text-sm font-medium ${h.text}`,children:h.label})]}),e.jsxs("span",{className:"text-xs text-text-muted",children:[w,"% utilized"]})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-tertiary overflow-hidden mb-5",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-normal ${h.dot}`,style:{width:`${w}%`}})}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"Total Budget"}),e.jsx(se,{content:c(f),children:e.jsx("p",{className:"text-lg font-semibold text-text-primary",children:m(f)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"Spent"}),e.jsx(se,{content:c(A),children:e.jsx("p",{className:"text-lg font-semibold text-text-primary",children:m(A)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"Remaining"}),e.jsx(se,{content:c(P),children:e.jsx("p",{className:"text-lg font-semibold text-text-primary",children:m(P)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"Per Member"}),j>0?e.jsxs(e.Fragment,{children:[e.jsx(se,{content:c(d.perMemberBudgetUsd??y),children:e.jsx("p",{className:"text-lg font-semibold text-text-primary",children:m(d.perMemberBudgetUsd??y)})}),e.jsxs("p",{className:"text-xs text-text-muted",children:[j," member",j!==1?"s":""]})]}):e.jsx("p",{className:"text-sm text-text-muted",children:"No members"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:"Budget Breakdown"}),I&&e.jsx("span",{className:"text-warning-500",children:ke})]}),e.jsx("div",{className:"space-y-2",children:p.map(o=>{const b=Ze(o.status),T=o.monthlyBudgetUsd>0?Math.min(Math.round((o.currentSpendUsd??0)/o.monthlyBudgetUsd*100),100):0,N=!!o.resourceGroupId,l=lt(o,x,n);return e.jsxs("div",{className:"bg-surface border border-border rounded-lg px-4 py-3 flex items-center gap-4",children:[e.jsx("div",{className:"shrink-0 w-5",children:b.icon?e.jsx("span",{className:b.text,children:ke}):e.jsx("span",{className:"w-5"})}),e.jsx("div",{className:"shrink-0 w-20",children:e.jsxs("span",{className:`inline-flex items-center gap-1 text-xs font-medium ${N?"text-primary-600":"text-text-muted"}`,children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:N?e.jsx("path",{fillRule:"evenodd",d:"M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10zm0 5.25a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75a.75.75 0 01-.75-.75z",clipRule:"evenodd"}):e.jsx("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 003 3.5v13A1.5 1.5 0 004.5 18h11a1.5 1.5 0 001.5-1.5V7.621a1.5 1.5 0 00-.44-1.06l-4.12-4.122A1.5 1.5 0 0011.378 2H4.5z",clipRule:"evenodd"})}),N?"Group":"Resource"]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:l}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 ml-3",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[c(o.currentSpendUsd??0)," / ",c(o.monthlyBudgetUsd)]}),e.jsxs("span",{className:`flex items-center gap-1 text-xs font-medium ${b.text}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.dot}`}),b.label]})]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface-tertiary overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-normal ${b.dot}`,style:{width:`${T}%`}})})]})]},o.id)})})]})]})}const ct={aws:"#f59e0b",gcp:"#3b82f6",azure:"#8a3ffc"},Qe=it;function mt({name:t,cost:x,totalCost:n,color:c}){const{fmtCurrency:m}=Te(),v=n>0?Math.round(x/n*100):0,R=n>0?x/n*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-text-primary truncate",children:t||"Other"}),e.jsxs("span",{className:"text-sm text-text-secondary whitespace-nowrap ml-2",children:[m(x)," (",v,"%)"]})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${R}%`,backgroundColor:c}})})]})}function ut(){const t=new Date;return`${t.getFullYear()}
1-${String(t.getMonth()+1).padStart(2,"0")}`}function xt({teamId:t,period:x}){const{fmtCurrency:n}=Te(),c=x||ut(),{data:m,isLoading:v}=at(t,{period:c}),{data:R}=es(t);if(v)return e.jsx(re,{});const d=m??{},p=d.allocatedCostUsd??0,f=d.percentOfTotal??0,A=d.resourceCount??0,j=(R?.summary??R??{}).totalBudgetUsd??0;if(p===0&&A===0)return e.jsx(D,{message:"No cost attribution data for this team in the current period."});const y=Object.entries(d.byProvider??{}).sort((l,u)=>u[1]-l[1]),w=Object.entries(d.byResourceType??{}).sort((l,u)=>u[1]-l[1]),h=y.reduce((l,[,u])=>l+u,0),I=w.reduce((l,[,u])=>l+u,0),o=j>0?Math.min(Math.round(p/j*100),100):0,b=o>=100?"red":o>=80?"yellow":"green",N={green:{label:"On Track",dot:"bg-success-500",text:"text-success-600"},yellow:{label:"At Risk",dot:"bg-warning-500",text:"text-warning-600"},red:{label:"Over Budget",dot:"bg-danger-500",text:"text-danger-600"}}[b];return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"Team Cost"}),e.jsx("p",{className:"text-lg font-semibold text-text-primary",children:n(p)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"% of Org"}),e.jsxs("p",{className:"text-lg font-semibold text-text-primary",children:[f.toFixed(1),"%"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted mb-0.5",children:"Resources"}),e.jsx("p",{className:"text-lg font-semibold text-text-primary",children:A})]})]}),j>0&&e.jsxs("div",{className:"pt-4 border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${N.dot}`}),e.jsx("span",{className:`text-xs font-medium ${N.text}`,children:N.label})]}),e.jsxs("span",{className:"text-xs text-text-muted",children:[n(p)," of ",n(j)," budget (",o,"%)"]})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${N.dot}`,style:{width:`${o}%`}})})]})]}),(y.length>0||w.length>0)&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[y.length>0&&e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary mb-3",children:"Cost by Provider"}),e.jsx("div",{className:"space-y-3",children:y.map(([l,u])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Is,{provider:l,className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"text-sm text-text-primary",children:l})]}),e.jsxs("span",{className:"text-sm text-text-secondary",children:[n(u)," (",h>0?Math.round(u/h*100):0,"%)"]})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${h>0?u/h*100:0}%`,backgroundColor:ct[l]??"#6b7280"}})})]},l))})]}),w.length>0&&e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary mb-3",children:"Cost by Resource Type"}),e.jsx("div",{className:"space-y-3",children:w.map(([l,u],G)=>e.jsx(mt,{name:l,cost:u,totalCost:I,color:Qe[G%Qe.length]},l))})]})]})]})}const U=10;function ht(t){if(!t)return null;if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return null}}function Vt(){const{id:t}=Ts(),x=Ps(),{data:n,isLoading:c,isError:m,error:v,refetch:R}=zs(t),[d,p]=r.useState(1),[f,A]=r.useState(1),[P,j]=r.useState(1),{data:y,isLoading:w,isError:h,error:I,refetch:o}=Ve(t,{page:d,size:U}),b=y?.items??[],T=y?.total??0,{data:N=[]}=Es(),{data:l=[]}=Us(),{data:u=[]}=Ws(),G=r.useMemo(()=>{const s=new Map(N.map(k=>[k.id,k])),a=[],S=new Set;for(const k of l){if(k.assigneeType!=="team"||k.assigneeId!==t)continue;const M=s.get(k.roleId),Ms=Array.isArray(M?.policies)?M.policies:[],ks=M?.metadata?.importedFrom;if(M&&Ms.length===0&&ks)continue;const ee=k.roleName||M?.name||k.roleId;!ee||S.has(ee)||(S.add(ee),a.push(ee))}return a},[l,N,t]),{data:O,isLoading:g,isError:ne,error:ss,refetch:ts}=Je(t,{page:P,size:U}),rs=O?.items??[],ae=O?.total??0,{data:Pe}=Je(t),W=r.useMemo(()=>Pe?.items??[],[Pe]),ie=Vs(t),oe=Js(t),B=qs(),le=Os(),de=Fs(),ce=Ys(t),ns=_s(t),me=Hs(t),C=Ce(Re.TEAM_UPDATE),Ie=Ce(Re.TEAM_DELETE),as=Ce(Re.TEAM_VIEW),Ee=Ks(),ue=C&&Ee,Ue=C?Ee?void 0:"Resource-group roles manage the group, not its individual resources — needs resource:update.":"You don't have permission. Contact your admin.",is=Ds(s=>s.user?.email),[De,Ge]=r.useState(null),os=De?b.find(s=>
1s.email===De)??null:null,[ls,F]=r.useState(!1),[q,Be]=r.useState(""),[xe,Le]=r.useState(""),[$e,he]=r.useState(!1),[pe,V]=r.useState([Me()]),[J,K]=r.useState(null),[ge,Z]=r.useState(null),{data:ze}=Ve(t),ds=r.useMemo(()=>{const s=new Set;for(const a of ze?.items??[])a?.email&&s.add(a.email.toLowerCase());return s},[ze]),[cs,fe]=r.useState(!1),[ms,L]=r.useState(!1),[je,Y]=r.useState(""),[$,Q]=r.useState(null),[us,be]=r.useState(!1),[E,ve]=r.useState([]),[ye,X]=r.useState(null),_=r.useMemo(()=>u.filter(s=>s.teamId===t),[u,t]),Ne=_.length,xs=r.useMemo(()=>{const s=(f-1)*U;return _.slice(s,s+U)},[_,f]),Oe=u.filter(s=>!s.teamId),hs=[{value:"",label:"Select a resource group"},...Oe.map(s=>({value:s.id,label:s.name}))],Fe=r.useMemo(()=>new Set((W??[]).map(s=>s.resourceUid)),[W]),Ye=r.useMemo(()=>{const s=new Set;for(const a of u)for(const S of a.members??[])S.resourceUid&&s.add(S.resourceUid);return s},[u]);function ps(s){s.preventDefault();const a=u.find(S=>S.id===je);a&&B.mutate({id:a.id,name:a.name,description:a.description??"",teamId:t},{onSuccess:()=>{L(!1),Y("")}})}function gs(){$&&B.mutate({id:$.id,name:$.name,description:$.description??"",teamId:""},{onSuccess:()=>Q(null)})}function fs(){Be(n?.name??""),Le(n?.description??""),F(!0)}const _e=st({name:n?.name??"",description:n?.description??""},{name:q,description:xe});function js(s){if(s?.preventDefault(),_e){F(!1);return}le.mutate({id:t,name:q,description:xe},{onSuccess:()=>F(!1)})}function bs(){de.mutate(t,{onSuccess:()=>x("/settings/teams")})}async function vs(s){s?.preventDefault();const a=pe.filter(M=>M.email.trim()&&M.roleId);if(!a.length)return;const S=[];let k=0;Z({done:0,total:a.length});for(const M of a){try{await ce.mutateAsync({email:M.email.trim(),roleId:M.roleId})}catch{S.push(M)}k+=1,Z({done:k,total:a.length})}if(Z(null),S.length){V(S);return}he(!1),V([Me()])}function He(){he(!1),V([Me()]),Z(null)}const{hasIncomplete:We,completeCount:ys}=Qs(pe),Ns=ys>0&&!We;function Cs(){J&&me.mutate(J,{onSuccess:()=>K(null)})}async function ws(s){if(s?.preventDefault(),!!E.length){for(const a of E)await ie.mutateAsync(a).catch(()=>{});be(!1),ve([])}}function qe(){be(!1),ve([])}const Rs=r.useCallback(s=>Ye.has(s.uid)?{label:"In resource group",tooltip:"This resource belongs to a resource group. Assign the group to the team instead.",disabled:!0,icon:"folder"}:Fe.has(s.uid)?{label:"Assigned",tooltip:"Already assigned to this team.",disabled:!0}:null,[Ye,Fe]),Ss=r.useCallback(s=>E.includes(s.uid),[E]),As=r.useCallback(s=>{ve(a=>a.includes(s.uid)?a.filter(S=>S!==s.uid):[...a,s.uid])},[]);return c?e.jsx($s,{}):as?m?e.jsx(Ae,{title:"Failed to load team details",error:v,onRetry:R,resource:"team details"}):n?e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("button",{onClick:()=>x("/settings/teams"),className:"text-xs text-text-muted hover:text-text-primary transition-colors mb-2 flex items-center gap-1",children:"← Back to Teams"})}),e.jsx(Ls,{title:n.name,action:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{variant:"action",onClick:fs,disabled:!C,title:C?void 0:"You don't have permission. Contact your admin.",children:"Edit"}),e.jsx(i,{variant:"delete",onClick:()=>fe(!0),disabled:!Ie,title:Ie?void 0:"You don't have permission. Contact your admin.",children:"Delete"})]})}),n.description&&e.jsx("p",{className:"text-sm text-text-muted -mt-4 mb-6",children:n.description}),e.jsxs("div",{className:"mt-6",children:[!!!ht(n?.metadata)?.importedFrom?.groupResolutionDenied||T>0?null:e.jsx("div",{className:"mb-3 p-3 rounded-lg bg-warning-400/10 border border-warning-400/20",children:e.jsxs("p",{className:"text-[13px] text-warning-600 leading-snug",children:[e.jsx("span",{className:"font-medium",children:"We couldn't bring in the members for this team."})," ","A Workspace admin needs to assign the"," ",e.jsx("code",{className:"font-mono px-1 py-0.5 rounded bg-warning-400/15 text-text-primary",children:"Groups Reader"})," ","admin role to the service account in the Google Admin console (admin.google.com), then re-run Import IAM. You can also add members manually below."]})}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Members (",T,")"]}),e.jsx(i,{size:"sm",onClick:()=>he(!0),disabled:!C,title:C?void 0:"You don't have permission. Contact your admin.",children:"+ Add Member"})]}),w?e.jsx(re,{}):h?e.jsx(Ae,{message:I?.message||"Failed to load members",onRetry:o}):T===0?e.jsx(D,{title:"No members yet",description:"Add members to this team to manage access."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border border-border rounded-xl bg-surface divide-y divide-border",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 px-4 py-2 text-xs font-medium text-text-muted uppercase tracking-wider bg-surface-secondary rounded-t-xl",children:[e.jsx("span",{children:"Email"}),e.jsx("span",{children:"Role"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),b.map(s=>e.jsxs("div",{className:"grid grid-cols-3 gap-4 px-4 py-3 items-center cursor-pointer hover:bg-surface-secondary/50 transition-colors",onClick:()=>Ge(s.email),children:[e.jsx("span",{className:"text-sm text-text-primary truncate",children:s.email}),e.jsx("span",{className:"flex items-center gap-2 flex-wrap",children:s.roleName||s.roleId?e.jsx(z,{children:s.roleName||s.roleId}):G.length>0?e.jsx(e.Fragment,{children:G.map(a=>e.jsx(z,{children:a},a))}):e.jsx("span",{className:"text-xs text-text-muted",children:"—"})}),e.jsxs("div",{className:"text-right flex items-center justify-end gap-2",children:[s.email!==is&&e.jsx(i,{variant:"delete",size:"xs",onClick:C?a=>{a.stopPropagation(),K(s.email)}:void 0,disabled:!C,title:C?void 0:"You don't have permission. Contact your admin.",children:"Remove"}),e.jsx("svg",{className:"w-3.5 h-3.5 text-text-muted shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]},s.email))]}),e.jsx(Se,{page:d,total:T,pageSize:U,onPageChange:p,label:"members"})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Resource Groups (",Ne,")"]}),e.jsx(i,{size:"sm",onClick:()=>L(!0),disabled:!C,title:C?void 0:"You don't have permission. Contact your admin.",children:"+ Assign Group"})]}
1),Ne===0?e.jsx(D,{title:"No resource groups assigned",description:"Assign resource groups to this team to control what resources they manage."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border border-border rounded-xl bg-surface divide-y divide-border",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 px-4 py-2 text-xs font-medium text-text-muted uppercase tracking-wider bg-surface-secondary rounded-t-xl",children:[e.jsx("span",{children:"Group Name"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),xs.map(s=>e.jsxs("div",{className:"grid grid-cols-2 gap-4 px-4 py-3 items-center",children:[e.jsx("span",{className:"text-sm text-text-primary",children:s.name}),e.jsx("div",{className:"text-right",children:e.jsx(i,{variant:"delete",size:"xs",onClick:C?()=>Q(s):void 0,disabled:!C,title:C?void 0:"You don't have permission. Contact your admin.",children:"Unassign"})})]},s.id))]}),e.jsx(Se,{page:f,total:Ne,pageSize:U,onPageChange:A,label:"groups"})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Individual Resources (",ae,")"]}),e.jsx(i,{size:"sm",onClick:()=>be(!0),disabled:!ue,title:Ue,children:"+ Assign Resource"})]}),g?e.jsx(re,{}):ne?e.jsx(Ae,{message:ss?.message||"Failed to load team resources",onRetry:ts}):ae===0?e.jsx(D,{title:"No individual resources assigned",description:"Assign specific resources directly to this team. Access level is determined by each member's team role."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border border-border rounded-xl bg-surface divide-y divide-border",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 px-4 py-2 text-xs font-medium text-text-muted uppercase tracking-wider bg-surface-secondary rounded-t-xl",children:[e.jsx("span",{children:"Resource UID"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),rs.map(s=>e.jsxs("div",{className:"grid grid-cols-2 gap-4 px-4 py-3 items-center",children:[e.jsx("span",{className:"text-sm text-text-primary font-mono truncate",children:s.resourceUid}),e.jsx("div",{className:"text-right",children:e.jsx(i,{variant:"delete",size:"xs",onClick:ue?()=>X(s):void 0,disabled:!ue,title:Ue,children:"Remove"})})]},s.id))]}),e.jsx(Se,{page:P,total:ae,pageSize:U,onPageChange:j,label:"resources"})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Budget"}),e.jsx(dt,{teamId:n?.id,groups:_,teamResources:W})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Cost Attribution"}),e.jsx(xt,{teamId:n?.id})]}),e.jsx(te,{open:ls,onClose:()=>F(!1),title:"Edit Team",footer:e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:js,disabled:!q.trim()||le.isPending||_e,children:le.isPending?"Saving...":"Save"}),e.jsx(i,{variant:"secondary",onClick:()=>F(!1),children:"Cancel"})]}),children:e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(we,{label:"Name",required:!0,children:e.jsx(Gs,{placeholder:"Team name",value:q,onChange:s=>Be(s.target.value),required:!0})}),e.jsx(we,{label:"Description",children:e.jsx("textarea",{placeholder:"Description (optional)",value:xe,onChange:s=>Le(s.target.value),rows:3,className:"w-full px-3 py-2 bg-surface-tertiary border border-border-strong rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-primary-600/30 focus:border-primary-600/40 transition-all duration-fast resize-none"})})]})}),e.jsx(te,{open:$e,onClose:He,title:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:["Add Members",e.jsx(et,{})]}),footer:e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:vs,disabled:!Ns||ce.isPending,children:ge?`Adding ${ge.done} of ${ge.total}...`:ce.isPending?"Adding...":"Add Members"}),e.jsx(i,{variant:"secondary",onClick:He,children:"Cancel"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:"Members already on this team are hidden from the picker."}),e.jsx(Xs,{members:pe,onChange:V,roles:N,excludeEmails:ds,enabled:$e}),We&&e.jsx("p",{className:"text-xs text-danger-500",children:"Enter a valid email and pick a role for each member you add (or clear the row)."})]})}),e.jsx(te,{open:us,onClose:qe,title:"Assign Resource",half:!0,footer:e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:ws,disabled:!E.length||ie.isPending,children:ie.isPending?"Assigning...":`Assign${E.length>1?` (${E.length})`:""}`}),e.jsx(i,{variant:"secondary",onClick:qe,children:"Cancel"})]}),children:e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("p",{className:"shrink-0 text-xs text-text-muted mb-4",children:"Each member's team role determines their access level to assigned resources."}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Zs,{isSelected:Ss,onToggleSelect:As,getRowBadge:Rs,emptyText:"No resources found."})})]})}),e.jsxs(H,{open:cs,onClose:()=>fe(!1),title:"Delete Team",children:[e.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Are you sure you want to delete ",e.jsx("strong",{children:n.name}),"? This will remove all members and unassign resource groups."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"secondary",onClick:()=>fe(!1),children:"Cancel"}),e.jsx(i,{variant:"delete",onClick:bs,disabled:de.isPending,children:de.isPending?"Deleting...":"Delete"})]})]}),e.jsxs(H,{open:!!J,onClose:()=>K(null),title:"Remove Member",children:[e.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Remove ",e.jsx("strong",{children:J})," from this team?"]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"secondary",onClick:()=>K(null),children:"Cancel"}),e.jsx(i,{variant:"delete",onClick:Cs,disabled:me.isPending,children:me.isPending?"Removing...":"Remove"})]})]}),e.jsx(H,{open:ms,onClose:()=>{L(!1),Y("")},title:"Assign Resource Group",children:Oe.length===0?e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"All resource groups are already assigned to a team. Create a new resource group to assign it here."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"secondary",onClick:()=>{L(!1),Y("")},children:"Close"}),e.jsx(Xe,{to:"/resource-groups",children:e.jsx(i,{onClick:()=>L(!1),children:"Go to Resource Groups"})})]})]}
1):e.jsxs("form",{onSubmit:ps,className:"flex flex-col gap-4",children:[e.jsx(we,{label:"Resource Group",required:!0,children:e.jsx(Bs,{value:je,onChange:s=>Y(s.target.value),options:hs,required:!0})}),e.jsx("p",{className:"text-xs text-text-muted",children:"Only unassigned groups are shown. A group can belong to one team at a time."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"secondary",type:"button",onClick:()=>{L(!1),Y("")},children:"Cancel"}),e.jsx(i,{type:"submit",disabled:!je||B.isPending,children:B.isPending?"Assigning...":"Assign"})]})]})}),e.jsxs(H,{open:!!$,onClose:()=>Q(null),title:"Unassign Resource Group",children:[e.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Remove ",e.jsx("strong",{children:$?.name})," from this team? The group will become unassigned."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"secondary",onClick:()=>Q(null),children:"Cancel"}),e.jsx(i,{variant:"delete",onClick:gs,disabled:B.isPending,children:B.isPending?"Removing...":"Unassign"})]})]}),e.jsxs(H,{open:!!ye,onClose:()=>X(null),title:"Remove Resource",children:[e.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Remove ",e.jsx("strong",{className:"font-mono text-xs",children:ye?.resourceUid})," from this team?"]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"secondary",onClick:()=>X(null),children:"Cancel"}),e.jsx(i,{variant:"delete",onClick:()=>oe.mutate(ye?.resourceUid,{onSuccess:()=>X(null)}),disabled:oe.isPending,children:oe.isPending?"Removing...":"Remove"})]})]}),e.jsx(ot,{member:os,teamId:t,allTeamGroups:_,teamResources:W,onClose:()=>Ge(null),canUpdate:C,roles:N,updateMemberRole:ns})]}):e.jsx(D,{title:"Team not found"}):e.jsx(D,{title:"Access denied",description:"You don't have permission to view this."})}export{Vt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.