1import{d as N,j as e,u as K,e as U}from"./query-Cd4R38ht.js";import{j as Y,r as Q,L as z}from"./vendor-KI3_YM0_.js";import{y as J,B as f,v as Z,z as ee,D as R,e as _}from"./index-cYoSSA0q.js";import{S as B}from"./Spinner-utowHqLH.js";import{C as u,t as r,m as re}from"./Card-DK1KIq3z.js";import{ap as w,_ as oe,d as I,S as G,$ as se,m as L,as as le,aB as te,aC as ae,J as ie,ao as ne,U as ce,aD as M,Y as de,an as V,aE as ue,aF as pe,E as ge}from"./ui-RSzmhUhL.js";import{B as x}from"./Body1-C0PtTAx_.js";import{B as S}from"./Button-aYtLslhR.js";import{T as xe}from"./Title3-7-Y3JXTn.js";import{C as n}from"./Caption1-C4GSJSr-.js";import{B as b}from"./Badge-BeA4BIbs.js";import{C as F}from"./CardHeader-DPL_6ChI.js";import{S as y}from"./Subtitle2-CQmr-MWi.js";import{R as W,A as he,C as X,X as E,Y as O,T as $,d as me,B as ye,a as je}from"./charts-kmEeFAH3.js";import{T as fe,a as j}from"./Tab-BFLxVnxG.js";import"./Label-Dn7YFqg0.js";import"./keys-BH0sHvId.js";import"./useTimeout-K898qoR5.js";import"./useBrowserTimer-Cq2U1JyX.js";import"./useARIAButtonProps-Wb8a9tVz.js";import"./useEventCallback-Las2pN9z.js";import"./useArrowNavigationGroup-2JpoGzMH.js";import"./useContextSelector-DUIngNnz.js";import"./useAnimationFrame-BfOWg4aY.js";const be={critical:"danger",high:"severe",medium:"warning",low:"success"},ve={sanctioned:"success",unsanctioned:"danger",under_review:"warning",deprecated:"subtle"},Ne={critical:"danger",high:"severe",medium:"warning",low:"success"},m=re({page:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalL},header:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",columnGap:r.spacingHorizontalM},headerLeft:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalM},iconWrap:{width:"40px",height:"40px",borderRadius:r.borderRadiusMedium,backgroundColor:r.colorBrandBackground2,display:"flex",alignItems:"center",justifyContent:"center",color:r.colorBrandForeground1},metaRow:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalS,marginTop:r.spacingVerticalXXS},headerRight:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalS},statGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:r.spacingHorizontalM,"@media (min-width: 1024px)":{gridTemplateColumns:"repeat(4, 1fr)"}},statCard:{padding:r.spacingHorizontalL,display:"flex",flexDirection:"column",rowGap:r.spacingVerticalXS},statHeaderRow:{display:"flex",alignItems:"center",justifyContent:"space-between"},statValue:{fontSize:r.fontSizeHero700,fontWeight:r.fontWeightSemibold,color:r.colorNeutralForeground1,lineHeight:r.lineHeightHero700},card:{padding:r.spacingHorizontalL,display:"flex",flexDirection:"column",rowGap:r.spacingVerticalM},cardSection:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalS},twoColLayout:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:r.spacingHorizontalL,"@media (min-width: 1024px)":{gridTemplateColumns:"repeat(4, 1fr)"}},threeColLayout:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:r.spacingHorizontalM},emptyState:{paddingTop:r.spacingVerticalXXXL,paddingBottom:r.spacingVerticalXXXL,textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",rowGap:r.spacingVerticalS},loadingWrap:{display:"flex",alignItems:"center",justifyContent:"center",height:"256px"},eventRow:{display:"flex",alignItems:"flex-start",columnGap:r.spacingHorizontalM,padding:r.spacingHorizontalM},eventDot:{width:"8px",height:"8px",borderRadius:r.borderRadiusCircular,backgroundColor:r.colorBrandBackground,flexShrink:0,marginTop:"8px"},monoChip:{fontFamily:r.fontFamilyMonospace,fontSize:r.fontSizeBase200,backgroundColor:r.colorNeutralBackground3,color:r.colorNeutralForeground2,paddingTop:"2px",paddingBottom:"2px",paddingLeft:r.spacingHorizontalXS,paddingRight:r.spacingHorizontalXS,borderRadius:r.borderRadiusSmall},alertCard:{display:"flex",alignItems:"flex-start",columnGap:r.spacingHorizontalM,padding:r.spacingHorizontalL},sevBar:{width:"4px",alignSelf:"stretch",borderRadius:r.borderRadiusMedium,flexShrink:0},banner:{padding:r.spacingHorizontalL,borderRadius:r.borderRadiusLarge,display:"flex",alignItems:"center",columnGap:r.spacingHorizontalM}
1,bannerSuccess:{backgroundColor:r.colorPaletteGreenBackground1,borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:r.colorPaletteGreenBorder1,borderRightWidth:"1px",borderRightStyle:"solid",borderRightColor:r.colorPaletteGreenBorder1,borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:r.colorPaletteGreenBorder1,borderLeftWidth:"1px",borderLeftStyle:"solid",borderLeftColor:r.colorPaletteGreenBorder1},bannerDanger:{backgroundColor:r.colorPaletteRedBackground1,borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:r.colorPaletteRedBorder1,borderRightWidth:"1px",borderRightStyle:"solid",borderRightColor:r.colorPaletteRedBorder1,borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:r.colorPaletteRedBorder1,borderLeftWidth:"1px",borderLeftStyle:"solid",borderLeftColor:r.colorPaletteRedBorder1},progressTrack:{width:"100%",height:"8px",backgroundColor:r.colorNeutralBackground3,borderRadius:r.borderRadiusMedium,overflow:"hidden"},kvList:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalS},kvRow:{display:"flex",alignItems:"center",justifyContent:"space-between"}}),ke=({tier:s,score:o})=>{const t=s||"low",i=o??0;return e.jsxs(b,{appearance:"tint",color:be[t]||"subtle",icon:e.jsx(G,{size:10}),children:[t.toUpperCase()," · ",i.toFixed(0)]})};function k({label:s,value:o,sub:t,icon:i,color:l=r.colorBrandForeground1}){const c=m();return e.jsxs(u,{className:c.statCard,children:[e.jsxs("div",{className:c.statHeaderRow,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2,textTransform:"uppercase",letterSpacing:"0.05em"},children:s}),e.jsx(i,{size:16,style:{color:l}})]}),e.jsx("div",{className:c.statValue,children:o}),t&&e.jsx(n,{style:{color:r.colorNeutralForeground3},children:t})]})}function lr(){var v,T,A,D,H,P;const s=m(),{id:o}=Y(),[t,i]=Q.useState("timeline"),{data:l,isLoading:c}=N({queryKey:["asset",o],queryFn:()=>_.get(o),enabled:!!o}),{data:p}=N({queryKey:["asset-events",o],queryFn:()=>_.getEvents(o,{limit:50}),enabled:!!o}),{data:g}=N({queryKey:["asset-alerts",o],queryFn:()=>_.getAlerts(o),enabled:!!o}),a=((v=l==null?void 0:l.data)==null?void 0:v.asset)||(l==null?void 0:l.data),h=((T=p==null?void 0:p.data)==null?void 0:T.data)||[],d=((A=g==null?void 0:g.data)==null?void 0:A.data)||[];if(c)return e.jsx("div",{className:s.loadingWrap,children:e.jsx(B,{size:"large"})});if(!a)return e.jsxs(u,{className:s.emptyState,children:[e.jsx(w,{size:40,color:r.colorNeutralForeground3}),e.jsx(x,{style:{color:r.colorNeutralForeground2},children:"Asset not found"}),e.jsx(z,{to:"/assets",style:{textDecoration:"none"},children:e.jsx(S,{appearance:"subtle",children:"â Back to Assets"})})]});const C=ze(h);return e.jsxs("div",{className:s.page,children:[e.jsxs("div",{className:s.header,children:[e.jsxs("div",{className:s.headerLeft,children:[e.jsx("div",{className:s.iconWrap,children:e.jsx(w,{size:20})}),e.jsxs("div",{children:[e.jsx(xe,{children:a.name}),e.jsxs("div",{className:s.metaRow,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:a.provider}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:"·"}),e.jsx(n,{style:{color:r.colorNeutralForeground2},children:(D=a.asset_type)==null?void 0:D.replace(/_/g," ")}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:"·"}),e.jsx(n,{style:{color:r.colorNeutralForeground2},children:a.department})]})]})]}),e.jsxs("div",{className:s.headerRight,children:[e.jsx(ke,{tier:a.risk_tier,score:a.risk_score}),e.jsx(b,{appearance:"tint",color:ve[a.deployment_type]||"subtle",children:(H=a.deployment_type)==null?void 0:H.replace(/_/g," ").toUpperCase()})]})]}),e.jsxs("div",{className:s.statGrid,children:[e.jsx(k,{label:"Open Alerts",value:d.length,icon:oe,color:d.length>0?r.colorPaletteRedForeground1:r.colorPaletteGreenForeground1}),e.jsx(k,{label:"Events (7d)",value:h.length,sub:"API calls observed",icon:I}),e.jsx(k,{label:"Risk Score",value:((P=a.risk_score)==null?void 0:P.toFixed(1))||"â",sub:a.risk_tier,icon:G,color:a.risk_tier==="critical"?r.colorPaletteRedForeground1:a.risk_tier==="high"?r.colorPaletteDarkOrangeForeground1:r.colorBrandForeground1}),e.jsx(k,{label:"Last Seen",value:f(a.last_seen_at),sub:J(a.last_seen_at),icon:se})]}),e.jsx(L.div,{initial:{opacity:0,y:12}
1,animate:{opacity:1,y:0},children:e.jsxs(u,{className:s.card,children:[e.jsx(F,{header:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(y,{children:"Event Volume (48h)"}),e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:[h.length," total events"]})]})}),e.jsx(W,{width:"100%",height:160,children:e.jsxs(he,{data:C,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"assetGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:r.colorBrandStroke1,stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:r.colorBrandStroke1,stopOpacity:0})]})}),e.jsx(X,{strokeDasharray:"3 3",stroke:r.colorNeutralStroke2,vertical:!1}),e.jsx(E,{dataKey:"hour",tick:{fill:r.colorNeutralForeground3,fontSize:11},tickLine:!1,stroke:r.colorNeutralStroke2}),e.jsx(O,{tick:{fill:r.colorNeutralForeground3,fontSize:11},tickLine:!1,axisLine:!1,stroke:r.colorNeutralStroke2}),e.jsx($,{contentStyle:{backgroundColor:r.colorNeutralBackground1,border:`1px solid ${r.colorNeutralStroke2}`,borderRadius:r.borderRadiusMedium,color:r.colorNeutralForeground1},labelStyle:{color:r.colorNeutralForeground2}}),e.jsx(me,{type:"monotone",dataKey:"events",stroke:r.colorBrandStroke1,strokeWidth:2,fill:"url(#assetGrad)",dot:!1})]})})]})}),e.jsxs(fe,{selectedValue:t,onTabSelect:(Le,q)=>i(q.value),children:[e.jsx(j,{value:"timeline",children:"Timeline"}),e.jsx(j,{value:"alerts",children:"Alerts"}),e.jsx(j,{value:"baseline",children:"Behavioral Baseline"}),e.jsx(j,{value:"compliance",children:"Compliance"}),e.jsx(j,{value:"access",children:"Access Grants"}),e.jsx(j,{value:"decommission",children:"Decommission"})]}),t==="timeline"&&e.jsx(Se,{events:h}),t==="alerts"&&e.jsx(Fe,{alerts:d}),t==="baseline"&&e.jsx(Ce,{events:h}),t==="compliance"&&e.jsx(_e,{asset:a}),t==="access"&&e.jsx(Re,{assetId:o}),t==="decommission"&&e.jsx(we,{assetId:o})]})}function Se({events:s}){const o=m();return s.length===0?e.jsxs(u,{className:o.emptyState,children:[e.jsx(I,{size:32,color:r.colorNeutralForeground3}),e.jsx(x,{style:{color:r.colorNeutralForeground2},children:"No events recorded for this asset"})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalS},children:s.map((t,i)=>e.jsx(L.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:i*.02},children:e.jsxs(u,{className:o.eventRow,children:[e.jsx("span",{className:o.eventDot}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalXS,flexWrap:"wrap"},children:[e.jsx(x,{style:{fontWeight:r.fontWeightSemibold},children:t.action||"API call"}),e.jsx("span",{className:o.monoChip,children:t.ai_model||t.ai_provider}),t.risk_score>70&&e.jsx(b,{appearance:"tint",color:"severe",size:"small",children:"High Risk"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalM,marginTop:r.spacingVerticalXS,flexWrap:"wrap"},children:[e.jsx(n,{style:{color:r.colorNeutralForeground3},children:t.source_user||"Unknown user"}),t.source_ip&&e.jsx(n,{style:{color:r.colorNeutralForeground3},children:t.source_ip}),t.tokens_used!=null&&e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:[Z(t.tokens_used)," tokens"]}),t.cost_usd&&e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:["$",t.cost_usd.toFixed(4)]}),e.jsx(n,{style:{color:r.colorNeutralForeground3,marginLeft:"auto"},children:f(t.occurred_at)})]})]})]})},t.id))})}function Fe({alerts:s}){const o=m();if(s.length===0)return e.jsxs(u,{className:o.emptyState,children:[e.jsx(G,{size:32,color:r.colorPaletteGreenForeground1}),e.jsx(x,{style:{color:r.colorPaletteGreenForeground1},children:"No open alerts for this asset"})]});const t={critical:r.colorPaletteRedForeground1,high:r.colorPaletteDarkOrangeForeground1,medium:r.colorPaletteYellowForeground1,low:r.colorPaletteGreenForeground1};return e.jsx("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalS},children:s.map(i=>e.jsxs(u,{className:o.alertCard,children:[e.jsx("div",{className:o.sevBar,style:{backgroundColor:t[i.severity]||r.colorNeutralStroke1}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",columnGap:r.spacingHorizontalS},children:[e.jsxs("div",{children:[e.jsx(x,{style:{fontWeight:r.fontWeightSemibold,color:r.colorNeutralForeground1},children:i.title}),e.jsx(n,{style:{color:r.colorNeutralForeground2,marginTop:r.spacingVerticalXXS,display:"block"},children:i.description})]}),e.jsx(z,{to:`/alerts/${i.id}`,style:{textDecoration:"none"},children:e.jsx(S,{appearance:"subtle",size:"small",icon:e.jsx(le,{size:14})})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalS,marginTop:r.spacingVerticalXS,flexWrap:"wrap"},children:[e.jsx(b,{appearance:"tint",color:Ne[i.severity]||"subtle",size:"small",children:i.severity}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:"·"}),e.jsx(n,{style:{color:r.colorNeutralForeground3,fontFamily:r.fontFamilyMonospace},children:i.rule_id_str}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:"·"}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:f(i.created_at)})]})]})]},i.id))})}function Ce({events:s}){const o=m(),t=s.filter(a=>a.tokens_used).map(a=>a.tokens_used),i=s.filter(a=>a.cost_usd).map(a=>a.cost_usd),l=a=>a.length?a.reduce((h,d)=>h+d,0)/a.length:0,c=a=>a.length?Math.max(...a):0,p=[{label:"Avg Tokens/Request",value:l(t).toFixed(0),max:c(t).toFixed(0),unit:"tokens"},{label:"Avg Cost/Request",value:`$${l(i).toFixed(4)}`,max:`$${c(i).toFixed(4)}`,unit:""},{label:"Total Events",value:s.length,max:"",unit:"events"}],g=Be(s);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalL},children:[e.jsx("div",{className:o.threeColLayout,children:p.map(a=>e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:a.label}),e.jsx("div",{className:o.statValue,children:a.value}),a.max&&e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:["Max: ",a.max," ",a.unit]})]},a.label))}),e.jsxs(u,{className:o.card,children:[e.jsx(F,{header:e.jsx(y,{children:"Token Distribution"})}),g.length>0?e.jsx(W,{width:"100%",height:180,children:e.jsxs(ye,{data:g,children:[e.jsx(X,{strokeDasharray:"3 3",stroke:r.colorNeutralStroke2,vertical:!1}),e.jsx(E,{dataKey:"bucket",tick:{fill:r.colorNeutralForeground3,fontSize:10},tickLine:!1,stroke:r.colorNeutralStroke2}
1),e.jsx(O,{tick:{fill:r.colorNeutralForeground3,fontSize:10},tickLine:!1,axisLine:!1,stroke:r.colorNeutralStroke2}),e.jsx($,{contentStyle:{backgroundColor:r.colorNeutralBackground1,border:`1px solid ${r.colorNeutralStroke2}`,borderRadius:r.borderRadiusMedium,color:r.colorNeutralForeground1}}),e.jsx(je,{dataKey:"count",fill:r.colorBrandStroke1,radius:[3,3,0,0]})]})}):e.jsx(n,{style:{color:r.colorNeutralForeground3,textAlign:"center",paddingTop:r.spacingVerticalL,paddingBottom:r.spacingVerticalL},children:"No token data available yet"})]})]})}function _e({asset:s}){var p,g;const o=m(),t=[{label:"Risk Classification",pass:s.risk_tier!==null,notes:s.risk_tier?`Tier: ${s.risk_tier}`:"Not classified"},{label:"Asset Owner Defined",pass:!!s.owner_id,notes:s.owner_id?"Owner assigned":"No owner assigned"},{label:"Department Tagged",pass:!!s.department,notes:s.department||"No department"},{label:"Sanctioned Deployment",pass:s.deployment_type==="sanctioned",notes:(p=s.deployment_type)==null?void 0:p.replace(/_/g," ")},{label:"Last Activity < 7 Days",pass:Ge(s.last_seen_at,7),notes:f(s.last_seen_at)}],i=t.filter(a=>a.pass).length,l=Math.round(i/t.length*100),c=l>=80?r.colorPaletteGreenForeground1:l>=50?r.colorPaletteYellowForeground1:r.colorPaletteRedForeground1;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalM},children:[e.jsxs(u,{className:o.card,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(y,{children:"Compliance Readiness Score"}),e.jsxs("span",{style:{fontSize:r.fontSizeHero700,fontWeight:r.fontWeightSemibold,color:c},children:[l,"%"]})]}),e.jsx("div",{className:o.progressTrack,children:e.jsx("div",{style:{height:"100%",borderRadius:r.borderRadiusMedium,transition:"width 0.3s",width:`${l}%`,backgroundColor:c}})}),e.jsx("div",{className:o.kvList,children:t.map(a=>e.jsxs("div",{className:o.kvRow,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalXS},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:r.borderRadiusCircular,backgroundColor:a.pass?r.colorPaletteGreenForeground1:r.colorPaletteRedForeground1}}),e.jsx(x,{children:a.label})]}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:a.notes})]},a.label))})]}),e.jsxs(u,{className:o.card,children:[e.jsx(F,{header:e.jsx(y,{children:"EU AI Act Relevance"})}),e.jsxs("div",{className:o.cardSection,children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",columnGap:r.spacingHorizontalXS},children:[e.jsx(te,{size:14,color:r.colorBrandForeground1,style:{marginTop:2,flexShrink:0}}),e.jsxs("div",{children:[e.jsx(x,{children:"Asset Type:"}),e.jsx(n,{style:{color:r.colorNeutralForeground2,marginLeft:r.spacingHorizontalXS},children:(g=s.asset_type)==null?void 0:g.replace(/_/g," ")})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",columnGap:r.spacingHorizontalXS},children:[e.jsx(ae,{size:14,color:r.colorBrandForeground1,style:{marginTop:2,flexShrink:0}}),e.jsxs("div",{children:[e.jsx(x,{children:"Provider:"}),e.jsx(n,{style:{color:r.colorNeutralForeground2,marginLeft:r.spacingHorizontalXS},children:s.provider})]})]}),e.jsx(n,{style:{color:r.colorNeutralForeground3,marginTop:r.spacingVerticalS},children:"Run a full EU AI Act assessment from the Compliance page to evaluate this asset against all applicable controls."}),e.jsx(z,{to:"/compliance",style:{textDecoration:"none"},children:e.jsx(S,{appearance:"subtle",size:"small",icon:e.jsx(ie,{size:12}),iconPosition:"after",children:"Go to Compliance"})})]})]})]})}function Re({assetId:s}){var h;const o=m(),t=K(),{data:i,isLoading:l}=N({queryKey:["access-grants",s],queryFn:()=>R.getAssetAccessGrants(s),enabled:!!s}),c=U({mutationFn:d=>R.revokeAccessGrant(s,d),onSuccess:()=>{t.invalidateQueries({queryKey:["access-grants",s]}),ee.success("Access grant revoked")}}),p=((h=i==null?void 0:i.data)==null?void 0:h.grants)||[];if(l)return e.jsx("div",{className:o.loadingWrap,children:e.jsx(B,{size:"medium"})});if(p.length===0)return e.jsxs(u,{className:o.emptyState,children:[e.jsx(ne,{size:32,color:r.colorNeutralForeground3}),e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"No access grants found for this asset"})]});const g={high:"severe",medium:"warning",low:"success"},a={user:e.jsx(ge,{size:14,color:r.colorBrandForeground1}),group:e.jsx(pe,{size:14,color:r.colorPaletteYellowForeground1}),service_account:e.jsx(w,{size:14,color:r.colorPaletteGreenForeground1})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalM},children:[e.jsxs("div",{className:o.threeColLayout,children:[e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Total Grants"}),e.jsx("div",{className:o.statValue,children:p.length})]}),e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"High Risk"}),e.jsx("div",{className:o.statValue,style:{color:r.colorPaletteRedForeground1},children:p.filter(d=>d.risk_level==="high").length})]}),e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Service Accounts"}),e.jsx("div",{className:o.statValue,children:p.filter(d=>d.principal_type==="service_account").length})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalS},children:p.map((d,C)=>e.jsx(L.div,{initial:{opacity:0,y:8}
1,animate:{opacity:1,y:0},transition:{delay:C*.04},children:e.jsx(u,{className:o.card,style:{rowGap:r.spacingVerticalS},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",columnGap:r.spacingHorizontalM},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",columnGap:r.spacingHorizontalM,flex:1},children:[e.jsx("div",{style:{width:32,height:32,backgroundColor:r.colorNeutralBackground3,borderRadius:r.borderRadiusMedium,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:a[d.principal_type]||e.jsx(ce,{size:14,color:r.colorNeutralForeground3})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalXS,flexWrap:"wrap"},children:[e.jsx(x,{style:{fontWeight:r.fontWeightSemibold},children:d.principal}),e.jsx(b,{appearance:"outline",size:"small",color:"subtle",children:d.principal_type.replace(/_/g," ")}),e.jsx(b,{appearance:"tint",size:"small",color:g[d.risk_level]||"subtle",children:d.risk_level})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:r.spacingHorizontalXS,marginTop:r.spacingVerticalXS},children:d.scopes.map(v=>e.jsx("span",{style:{fontFamily:r.fontFamilyMonospace,fontSize:r.fontSizeBase200,color:r.colorNeutralForeground2,backgroundColor:r.colorNeutralBackground3,paddingTop:"2px",paddingBottom:"2px",paddingLeft:r.spacingHorizontalXS,paddingRight:r.spacingHorizontalXS,borderRadius:r.borderRadiusSmall},children:v},v))}),e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalS,marginTop:r.spacingVerticalXS,flexWrap:"wrap"},children:[e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:["Granted by ",d.granted_by]}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:"·"}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:f(d.granted_at)}),e.jsx(n,{style:{color:r.colorNeutralForeground3},children:"·"}),e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:["Last used ",f(d.last_used_at)]})]})]})]}),e.jsx(S,{appearance:"secondary",size:"small",icon:e.jsx(M,{size:12}),onClick:()=>c.mutate(d.id),disabled:c.isPending,children:"Revoke"})]})})},d.id))})]})}function we({assetId:s}){const o=m(),{data:t,isLoading:i}=N({queryKey:["decommission",s],queryFn:()=>R.getDecommissionReport(s),enabled:!!s}),l=(t==null?void 0:t.data)||null;if(i)return e.jsx("div",{className:o.loadingWrap,children:e.jsx(B,{size:"medium"})});if(!l)return e.jsxs(u,{className:o.emptyState,children:[e.jsx(de,{size:32,color:r.colorNeutralForeground3}),e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Unable to generate decommission report"})]});const c=l.total_changes>0?Math.round(l.retracted_changes/l.total_changes*100):0,p=l.decommission_ready?r.colorPaletteGreenForeground1:r.colorPaletteRedForeground1;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",rowGap:r.spacingVerticalL},children:[e.jsxs("div",{className:`${o.banner} ${l.decommission_ready?o.bannerSuccess:o.bannerDanger}`,children:[l.decommission_ready?e.jsx(V,{size:24,color:r.colorPaletteGreenForeground1}):e.jsx(ue,{size:24,color:r.colorPaletteRedForeground1}),e.jsxs("div",{children:[e.jsx(y,{style:{color:p},children:l.decommission_ready?"Ready for Decommission":"Not Ready for Decommission"}),e.jsx(x,{style:{color:r.colorNeutralForeground2,marginTop:r.spacingVerticalXXS},children:l.recommendation})]})]}),e.jsxs("div",{className:o.twoColLayout,children:[e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Total Changes"}),e.jsx("div",{className:o.statValue,children:l.total_changes})]}),e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Reversible"}),e.jsx("div",{className:o.statValue,style:{color:r.colorBrandForeground1},children:l.reversible_changes}),e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:[l.total_changes>0?Math.round(l.reversible_changes/l.total_changes*100):0,"% of total"]})]}),e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Critical Changes"}),e.jsx("div",{className:o.statValue,style:{color:r.colorPaletteRedForeground1},children:l.critical_changes})]}),e.jsxs(u,{className:o.statCard,children:[e.jsx(n,{style:{color:r.colorNeutralForeground2},children:"Active Access Grants"}),e.jsx("div",{className:o.statValue,style:{color:r.colorPaletteDarkOrangeForeground1},children:l.active_access_grants})]})]}),e.jsxs(u,{className:o.card,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(y,{children:"Retraction Progress"}),e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:[l.retracted_changes," of ",l.total_changes," retracted"]})]}),e.jsx("div",{className:o.progressTrack,children:e.jsx("div",{style:{height:"100%",borderRadius:r.borderRadiusMedium,transition:"width 0.3s",width:`${c}%`,backgroundColor:r.colorBrandStroke1}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:[c,"% complete"]}),e.jsxs(n,{style:{color:r.colorNeutralForeground3},children:[l.total_changes-l.retracted_changes," remaining"]})]})]}),e.jsxs(u,{className:o.card,children:[e.jsx(F,{header:e.jsx(y,{children:"Decommission Checklist"})}),e.jsx("div",{className:o.kvList,children:[{label:"All critical changes addressed",pass:l.critical_changes===0},{label:"Access grants revoked",pass:l.active_access_grants===0},{label:"Reversible changes retracted",pass:l.retracted_changes>=l.reversible_changes},{label:"Data residency verified",pass:l.decommission_ready},{label:"Audit log archived",pass:!0}].map(g=>e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:r.spacingHorizontalS},children:[g.pass?e.jsx(V,{size:16,color:r.colorPaletteGreenForeground1,style:{flexShrink:0}}):e.jsx(M,{size:16,color:r.colorPaletteRedForeground1,style:{flexShrink:0}}),e.jsx(x,{style:{color:g.pass?r.colorNeutralForeground1:r.colorNeutralForeground2},children:g.label})]},g.label))})]})]})}function ze(s){const o={},t=Date.now();for(let i=47;i>=0;i--){const c=`${new Date(t-i*36e5).getHours()}:00`;o[c]=0}
1return s.forEach(i=>{const c=`${new Date(i.occurred_at).getHours()}:00`;c in o&&o[c]++}),Object.entries(o).map(([i,l])=>({hour:i,events:l}))}function Be(s){const t={};return s.forEach(i=>{if(!i.tokens_used)return;const l=Math.floor(i.tokens_used/1e3)*1e3,c=`${l}-${l+1e3}`;t[c]=(t[c]||0)+1}),Object.entries(t).sort(([i],[l])=>parseInt(i)-parseInt(l)).map(([i,l])=>({bucket:i,count:l}))}function Ge(s,o){return s?Date.now()-new Date(s).getTime()<o*864e5:!1}export{lr 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.