@unerr-ai/unerr 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js
CHANGED
|
@@ -7166,7 +7166,8 @@ function startDaemonApi(pm) {
|
|
|
7166
7166
|
return c.json({ error: `Cannot read server.json for ${label}` }, 500);
|
|
7167
7167
|
}
|
|
7168
7168
|
const remaining = c.req.path.replace(`/api/repo/${label}`, "");
|
|
7169
|
-
const
|
|
7169
|
+
const qs = new URL(c.req.url).search;
|
|
7170
|
+
const targetPath = `/api${remaining || "/"}${qs}`;
|
|
7170
7171
|
try {
|
|
7171
7172
|
const proxyResponse = await proxyToRepoHttp(
|
|
7172
7173
|
repoPort,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{n as r,t as i}from"./vis-network-NIJHUFI3.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var a=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};async function o(e,t){let n=await fetch(e,{...t,headers:{Accept:`application/json`,...t?.headers}}),r=await n.text(),i;try{i=r?JSON.parse(r):null}catch{i=r}if(!n.ok)throw new a(typeof i==`object`&&i&&`error`in i?String(i.error):n.statusText,n.status);return i}function s(e,t){return e?e+t.replace(/^\/api/,``):t}var c=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},l=new class extends c{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},u={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},d=new class{#e=u;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function f(e){setTimeout(e,0)}var p=typeof window>`u`||`Deno`in globalThis;function m(){}function h(e,t){return typeof e==`function`?e(t):e}function g(e){return typeof e==`number`&&e>=0&&e!==1/0}function _(e,t){return Math.max(e+(t||0)-Date.now(),0)}function v(e,t){return typeof e==`function`?e(t):e}function y(e,t){return typeof e==`function`?e(t):e}function b(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==S(o,t.options))return!1}else if(!w(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function x(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(C(t.options.mutationKey)!==C(a))return!1}else if(!w(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function S(e,t){return(t?.queryKeyHashFn||C)(e)}function C(e){return JSON.stringify(e,(e,t)=>ne(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function w(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>w(e[n],t[n])):!1}var T=Object.prototype.hasOwnProperty;function ee(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=E(e)&&E(t);if(!r&&!(ne(e)&&ne(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:T.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ee(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function te(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function E(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ne(e){if(!D(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!D(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function D(e){return Object.prototype.toString.call(e)===`[object Object]`}function re(e){return new Promise(t=>{d.setTimeout(t,e)})}function ie(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ee(e,t)}function O(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function k(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ae=Symbol();function oe(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ae?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function se(e,t){return typeof e==`function`?e(...t):!!e}function ce(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var A=(()=>{let e=()=>p;return{isServer(){return e()},setIsServer(t){e=t}}})();function j(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var le=f;function ue(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=le,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var M=ue(),de=new class extends c{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function fe(e){return Math.min(1e3*2**e,3e4)}function pe(e){return(e??`online`)===`online`?de.isOnline():!0}var me=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function he(e){let t=!1,n=0,r,i=j(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new me(t);p(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},u=()=>l.isFocused()&&(e.networkMode===`always`||de.isOnline())&&e.canRun(),d=()=>pe(e.networkMode)&&e.canRun(),f=e=>{a()||(r?.(),i.resolve(e))},p=e=>{a()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(a()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),h=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(a())return;let i=e.retry??(A.isServer()?0:3),o=e.retryDelay??fe,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),re(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:d,start:()=>(d()?h():m().then(h),i)}}var ge=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),g(this.gcTime)&&(this.#e=d.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(A.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(d.clearTimeout(this.#e),this.#e=void 0)}};function _e(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ce(e,()=>t.signal,()=>n=!0)},u=oe(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?k:O;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?ye:ve,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:ve(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function ve(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ye(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var be=class extends ge{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Ce(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ce(this.options);e.data!==void 0&&(this.setState(Se(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ie(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(m).catch(m):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>y(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ae||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>v(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!_(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=oe(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?_e(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=he({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof me&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof me){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...xe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Se(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),M.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function xe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Se(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ce(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var we=class extends c{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=j(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ee(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return De(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return De(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof y(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!te(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Oe(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||y(this.options.enabled,this.#t)!==y(t.enabled,this.#t)||v(this.options.staleTime,this.#t)!==v(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||y(this.options.enabled,this.#t)!==y(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Ae(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(m)),t}#g(){this.#b();let e=v(this.options.staleTime,this.#t);if(A.isServer()||this.#r.isStale||!g(e))return;let t=_(this.#r.dataUpdatedAt,e)+1;this.#d=d.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(A.isServer()||y(this.options.enabled,this.#t)===!1||!g(this.#p)||this.#p===0)&&(this.#f=d.setInterval(()=>{(this.options.refetchIntervalInBackground||l.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(d.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(d.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ee(e,t),o=i&&Oe(e,n,t,r);(a||o)&&(l={...l,...xe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ie(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ie(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,b=_&&g,x=d!==void 0,S={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&x,isStale:ke(e,t),refetch:this.refetch,promise:this.#o,isEnabled:y(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{i(this.#o=S.promise=j())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!te(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){M.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Te(e,t){return y(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&y(t.retryOnMount,e)===!1)}function Ee(e,t){return Te(e,t)||e.state.data!==void 0&&De(e,t,t.refetchOnMount)}function De(e,t,n){if(y(t.enabled,e)!==!1&&v(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&ke(e,t)}return!1}function Oe(e,t,n,r){return(e!==t||y(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&ke(e,n)}function ke(e,t){return y(t.enabled,e)!==!1&&e.isStaleByTime(v(t.staleTime,e))}function Ae(e,t){return!te(e.getCurrentResult(),t)}var je=class extends ge{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Me(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=he({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),M.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Me(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ne=class extends c{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new je({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Pe(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Pe(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Pe(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Pe(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){M.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>x(t,e))}findAll(e={}){return this.getAll().filter(t=>x(e,t))}notify(e){M.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return M.batch(()=>Promise.all(e.map(e=>e.continue().catch(m))))}};function Pe(e){return e.options.scope?.id}var Fe=class extends c{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),te(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&C(t.mutationKey)!==C(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Me();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){M.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ie=class extends c{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??S(r,t),a=this.get(i);return a||(a=new be({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){M.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>b(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>b(e,t)):t}notify(e){M.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){M.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){M.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Le=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ie,this.#t=e.mutationCache||new Ne,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=l.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=de.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(v(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=h(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return M.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;M.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return M.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=M.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(m).catch(m)}invalidateQueries(e,t={}){return M.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=M.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(m)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(m)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(v(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(m).catch(m)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(m).catch(m)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return de.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(C(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{w(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(C(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{w(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=S(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ae&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Re=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function ee(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function te(e,t){return ee(e.type,t,e.props)}function E(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ne(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var D=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?ne(``+e.key):t.toString(36)}function ie(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function O(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,O(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(D,`$&/`)+`/`),O(o,r,i,``,function(e){return e})):o!=null&&(E(o)&&(o=te(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(D,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+re(a,u),c+=O(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+re(a,u++),c+=O(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return O(ie(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function k(e,t,n){if(e==null)return e;var r=[],i=0;return O(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var oe=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},se={map:k,forEach:function(e,t,n){k(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return k(e,function(){t++}),t},toArray:function(e){return k(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=se,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return ee(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return ee(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=E,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,oe)}catch(e){oe(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.5`})),ze=n(((e,t)=>{t.exports=Re()})),Be=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ve=n(((e,t)=>{t.exports=Be()})),N=t(ze(),1),P=Ve(),He=N.createContext(void 0),Ue=e=>{let t=N.useContext(He);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},We=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(He.Provider,{value:e,children:t})),Ge=N.createContext(!1),Ke=()=>N.useContext(Ge);Ge.Provider;function qe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Je=N.createContext(qe()),Ye=()=>N.useContext(Je),Xe=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?se(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ze=e=>{N.useEffect(()=>{e.clearReset()},[e])},Qe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||se(n,[e.error,r])),$e=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},et=(e,t)=>e.isLoading&&e.isFetching&&!t,tt=(e,t)=>e?.suspense&&t.isPending,nt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function rt(e,t,n){let r=Ke(),i=Ye(),a=Ue(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,$e(o),Xe(o,i,s),Ze(i);let c=!a.getQueryCache().get(o.queryHash),[l]=N.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(e=>{let t=d?l.subscribe(M.batchCalls(e)):m;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),N.useEffect(()=>{l.setOptions(o)},[o,l]),tt(o,u))throw nt(o,l,i);if(Qe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!A.isServer()&&et(u,r)&&(c?nt(o,l,i):s?.promise)?.catch(m).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function F(e,t){return rt(e,we,t)}function it(e,t){let n=Ue(t),[r]=N.useState(()=>new Fe(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(M.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((e,t)=>{r.mutate(e,t).catch(m)},[r]);if(i.error&&se(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function at(){let[e,t]=(0,N.useState)(!1),n=Ue(),{data:r}=F({queryKey:[`version`,`check`],queryFn:()=>o(`/api/daemon/version`),refetchInterval:6e4,staleTime:3e4}),i=it({mutationFn:async e=>{await fetch(`/api/daemon/version/dismiss`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:e})})},onSuccess:()=>{t(!0),n.invalidateQueries({queryKey:[`version`]})}});return!r?.available||r.dismissed||e?null:(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 16px`,background:`linear-gradient(90deg, #1e293b 0%, #0f172a 100%)`,borderBottom:`1px solid #334155`,fontSize:13},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,P.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:`50%`,background:`#22D3EE`,animation:`pulse 2s infinite`}}),(0,P.jsxs)(`span`,{style:{color:`#e2e8f0`},children:[`Update available:`,` `,(0,P.jsx)(`span`,{style:{fontWeight:600},children:r.current}),` → `,(0,P.jsx)(`span`,{style:{fontWeight:600,color:`#22D3EE`},children:r.latest})]}),(0,P.jsxs)(`span`,{style:{color:`#64748b`},children:[`(`,r.behindMinor,` minor version`,r.behindMinor===1?``:`s`,` `,`behind)`]})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[(0,P.jsx)(`a`,{href:`https://github.com/unerr-ai/unerr/releases/tag/v${r.latest}`,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#8B5CF6`,textDecoration:`none`,fontSize:12},children:`Changelog`}),(0,P.jsx)(`code`,{style:{background:`#1e293b`,padding:`2px 8px`,borderRadius:4,color:`#34D399`,fontSize:11},children:`unerr daemon update`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i.mutate(r.latest),style:{background:`none`,border:`none`,color:`#64748b`,cursor:`pointer`,padding:`2px 6px`,borderRadius:4,fontSize:16,lineHeight:1},title:`Dismiss this version`,children:`×`})]})]})}var ot={overview:`Dashboard`,visual:`Codebase Map`,graph:`Code Intelligence`,facts:`Project Memory`,"token-trace":`Token Trace`,reasoning:`Reasoning Quality`,activity:`Activity`,settings:`Settings`,"all-repos":`All Repositories`,daemon:`Daemon Supervisor`};function st(e){return ot[e]}function ct(){let e=(window.location.hash.replace(/^#/,``).split(`?`)[0]?.trim()||`/`).split(`/`).filter(Boolean),t=e[0]?.toLowerCase();if(t===`all-repos`)return{routeId:`all-repos`,repoLabel:null};if(t===`daemon`)return{routeId:`daemon`,repoLabel:null};if(t===`repo`&&e.length>=2){let t=e[1],n=e[2]?.toLowerCase();return{routeId:lt(n),repoLabel:t}}return{routeId:lt(t),repoLabel:null}}function lt(e){switch(e){case`visual`:return`visual`;case`graph`:return`graph`;case`facts`:return`facts`;case`token-trace`:return`token-trace`;case`reasoning`:return`reasoning`;case`activity`:case`session-timeline`:case`timeline`:return`activity`;case`settings`:return`settings`;default:return`overview`}}function ut(){let[e,t]=(0,N.useState)(()=>typeof window>`u`?`overview`:ct().routeId);return(0,N.useEffect)(()=>{t(ct().routeId);let e=()=>t(ct().routeId);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function dt(){let[e,t]=(0,N.useState)(()=>typeof window>`u`?{routeId:`overview`,repoLabel:null}:ct());return(0,N.useEffect)(()=>{t(ct());let e=()=>t(ct());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function ft(e,t){if(e===`all-repos`||e===`daemon`){window.location.hash=`#/${e}`;return}if(t){window.location.hash=e===`overview`?`#/repo/${t}`:`#/repo/${t}/${e}`;return}window.location.hash=e===`overview`?`#/`:`#/${e}`}var pt=[{id:`overview`,label:`Dashboard`},{id:`token-trace`,label:`Token Trace`},{id:`reasoning`,label:`Reasoning Quality`},{id:`visual`,label:`Codebase Map`},{id:`graph`,label:`Code Intelligence`},{id:`facts`,label:`Project Memory`},{id:`activity`,label:`Activity`},{id:`settings`,label:`Settings`}],mt=[{id:`all-repos`,label:`All Repositories`},{id:`daemon`,label:`Daemon`}];function ht(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean),n=t[t.length-1]??e;return{name:n,dir:t.length>=2?`${t[t.length-2]}/${t[t.length-1]}`:n}}function gt({title:e,subtitle:t,statusDot:n,repoPath:r,activeRoute:i,repoLabel:a,isDaemonMode:o,repos:s,children:c}){let l=r?ht(r):null,u=i===`all-repos`||i===`daemon`;return(0,P.jsxs)(`div`,{className:`flex min-h-screen flex-col md:flex-row`,children:[(0,P.jsxs)(`aside`,{className:`flex w-full shrink-0 flex-col border-b border-border-subtle bg-sidebar px-5 py-6 md:w-56 md:border-r md:border-b-0 md:sticky md:top-0 md:h-screen md:overflow-y-auto`,children:[(0,P.jsx)(`div`,{className:`mb-8 flex items-center justify-center`,children:(0,P.jsx)(`img`,{src:`/icon-wordmark.png`,alt:`unerr`,className:`h-7`,draggable:!1})}),o&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`mb-2 px-3 text-[10px] font-semibold uppercase tracking-widest t-tertiary`,children:`Global`}),(0,P.jsx)(`nav`,{className:`flex flex-col gap-0.5 mb-4`,"aria-label":`Global`,children:mt.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(e.id),className:`block w-full rounded-md px-3 py-2 text-left text-sm transition-colors ${i===e.id?`el-raised font-medium text-foreground-emphasis`:`text-muted-foreground hover:text-foreground hover:el-raised`}`,children:e.label},e.id))}),s&&s.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`mb-2 px-3 text-[10px] font-semibold uppercase tracking-widest t-tertiary`,children:`Repositories`}),(0,P.jsx)(`div`,{className:`flex flex-col gap-0.5 mb-4`,children:s.map(e=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>ft(`overview`,e.label),className:`flex items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors ${a===e.label&&!u?`el-raised font-medium text-foreground-emphasis`:`text-muted-foreground hover:text-foreground hover:el-raised`}`,children:[(0,P.jsx)(`span`,{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${e.status===`running`?`bg-success shadow-[0_0_4px_rgba(52,211,153,0.6)]`:e.status===`error`?`bg-error`:`bg-muted-foreground/40`}`}),(0,P.jsx)(`span`,{className:`truncate`,children:e.label})]},e.label))})]}),a&&!u&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`divider-shimmer mb-3`}),(0,P.jsx)(`nav`,{className:`flex flex-col gap-0.5`,"aria-label":`Repo`,children:pt.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(e.id,a),className:`block w-full rounded-md px-3 py-2 text-left text-sm transition-colors ${i===e.id?`el-raised font-medium text-foreground-emphasis`:`text-muted-foreground hover:text-foreground hover:el-raised`}`,children:e.label},e.id))})]})]}),!o&&(0,P.jsx)(`nav`,{className:`flex flex-col gap-0.5`,"aria-label":`Primary`,children:pt.map(e=>(0,P.jsx)(`a`,{href:e.id===`overview`?`#/`:`#/${e.id}`,className:`block rounded-md px-3 py-2 text-sm transition-colors ${i===e.id?`el-raised font-medium text-foreground-emphasis`:`text-muted-foreground hover:text-foreground hover:el-raised`}`,children:e.label},e.id))}),t?(0,P.jsxs)(`div`,{className:`mt-auto pt-8`,children:[(0,P.jsx)(`div`,{className:`divider-shimmer mb-4`}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs leading-relaxed`,children:t})]}):null]}),(0,P.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-auto bg-background`,children:[(0,P.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border-subtle bg-background/90 px-6 py-4 backdrop-blur-sm`,children:[(0,P.jsx)(`h1`,{children:e}),l&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,title:r,children:[(0,P.jsx)(`span`,{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${n===`live`?`bg-success shadow-[0_0_6px_rgba(52,211,153,0.6)]`:`bg-warning animate-pulse`}`,title:n===`live`?`Connected`:`Reconnecting...`}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-foreground-emphasis`,children:l.name}),(0,P.jsx)(`span`,{className:`t-tertiary text-xs font-mono hidden sm:inline`,children:l.dir})]})]}),(0,P.jsx)(`div`,{className:`flex-1 p-6`,children:c})]})]})}var _t=new Le({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:5e3}}}),vt=(0,N.createContext)({label:null,path:null,status:null,apiBase:``,isDaemonMode:!1});function yt(){return(0,N.useContext)(vt)}function I(){let{apiBase:e,label:t}=yt();return{url:(0,N.useCallback)(t=>s(e,t),[e]),queryKey:(0,N.useCallback)(e=>t?[`repo`,t,...e]:[...e],[t])}}var bt=[`live-feed`],xt=[`session-snapshot`];function St(e){try{return JSON.parse(e)}catch{return e}}function Ct(e,t){let n=!1,r=null,i=1e3,a=null,o=(t,n)=>{let r={t:Date.now(),type:t,data:n};e.setQueryData(bt,(e=[])=>[...e,r].slice(-100))},s=()=>{e.invalidateQueries({queryKey:[`intelligence`]})},c=()=>{e.invalidateQueries({queryKey:[`session`]})},l=e=>t=>{o(e,St(t.data)),e===`drift`&&s(),e===`intent`&&c(),(e===`violation`||e===`circuit_breaker`)&&c()},u=t=>{let n=St(t.data);e.setQueryData(xt,n),e.invalidateQueries({queryKey:[`session`]})},d=()=>{},f=()=>{a!==null&&(clearTimeout(a),a=null)},p=()=>{f(),!n&&(a=setTimeout(()=>{i=Math.min(i*2,3e4),m()},i))};function m(){if(!n){r?.close();try{r=new EventSource(`/api/stream`)}catch{t(!1),p();return}r.onopen=()=>{i=1e3,t(!0)},r.onerror=()=>{t(!1),r?.close(),r=null,p()};for(let e of[`tool_call`,`drift`,`violation`,`circuit_breaker`,`intent`])r.addEventListener(e,l(e));r.addEventListener(`session_stats`,u),r.addEventListener(`ping`,d)}}return m(),()=>{n=!0,f(),r?.close(),r=null,t(!1)}}var wt={running:`bg-success shadow-[0_0_6px_rgba(52,211,153,0.6)]`,stopped:`bg-muted-foreground/40`,starting:`bg-warning animate-pulse`,error:`bg-error`};function Tt(e){return e===null?`—`:e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}function Et(){let{data:e}=F({queryKey:[`daemon`,`repos`],queryFn:()=>o(`/api/repos`),refetchInterval:5e3}),{data:t}=F({queryKey:[`daemon`,`aggregate`],queryFn:()=>o(`/api/repos/aggregate`),refetchInterval:1e4}),n=e?.repos??[],r=t?.summary;return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[r&&(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,P.jsx)(Dt,{label:`Repositories`,value:r.totalRepos,sub:`${r.runningRepos} running`}),(0,P.jsx)(Dt,{label:`Total Entities`,value:r.totalEntities.toLocaleString(),sub:`${r.totalEdges.toLocaleString()} edges`}),(0,P.jsx)(Dt,{label:`Memory`,value:`${r.totalMemoryMb} MB`,sub:`across ${r.runningRepos} processes`}),(0,P.jsx)(Dt,{label:`Connections`,value:r.totalConnections,sub:r.totalNeedsInput>0?`${r.totalNeedsInput} need input`:`all healthy`})]}),t?.tokenFlow&&t.tokenFlow.total>0&&(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3`,children:[(0,P.jsx)(Dt,{label:`Tokens Saved`,value:t.tokenFlow.saved.toLocaleString(),sub:`across all repos`,accent:!0}),(0,P.jsx)(Dt,{label:`Tool Calls`,value:t.tokenFlow.total.toLocaleString(),sub:`resolved locally`}),(0,P.jsx)(Dt,{label:`Violations`,value:t.tokenFlow.violations,sub:`caught`})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:[n.map(e=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>ft(`overview`,e.label),className:`el-raised flex flex-col gap-3 rounded-lg p-4 text-left transition-all hover:ring-2 hover:ring-brand/30`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`inline-flex h-2.5 w-2.5 shrink-0 rounded-full ${wt[e.status]??wt.stopped}`,title:e.status}),(0,P.jsx)(`span`,{className:`text-sm font-semibold text-foreground-emphasis truncate`,children:e.label})]}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs font-mono truncate`,children:e.path}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-xs t-tertiary`,children:[e.status===`running`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{children:[e.memory??0,` MB`]}),(0,P.jsxs)(`span`,{children:[e.entityCount?.toLocaleString()??0,` entities`]}),(0,P.jsxs)(`span`,{children:[`idle `,Tt(e.idle)]}),(0,P.jsxs)(`span`,{children:[e.connections,` conn`]})]}),e.status===`stopped`&&(0,P.jsx)(`span`,{className:`italic`,children:`Stopped`}),e.status===`starting`&&(0,P.jsx)(`span`,{className:`animate-pulse`,children:`Starting…`}),e.status===`error`&&(0,P.jsx)(`span`,{className:`text-error`,children:`Error`})]}),e.needsInput.length>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-warning`,children:[(0,P.jsx)(`span`,{children:`⚠`}),(0,P.jsxs)(`span`,{children:[e.needsInput.length,` need`,e.needsInput.length===1?`s`:``,` input`]})]})]},e.path)),n.length===0&&(0,P.jsxs)(`div`,{className:`col-span-full text-center py-12 t-tertiary`,children:[(0,P.jsx)(`p`,{className:`text-lg font-medium`,children:`No repos registered`}),(0,P.jsxs)(`p`,{className:`mt-2 text-sm`,children:[`Run`,` `,(0,P.jsx)(`code`,{className:`font-mono text-foreground`,children:`unerr daemon add .`}),` `,`from a project directory.`]})]})]})]})}function Dt({label:e,value:t,sub:n,accent:r}){return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-4`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:`mt-1 text-2xl font-bold ${r?`text-brand`:`text-foreground-emphasis`}`,children:t}),n&&(0,P.jsx)(`p`,{className:`t-tertiary mt-1 text-xs`,children:n})]})}var Ot={started:`#34D399`,skipped:`#FBBF24`,failed:`#F87171`,aborted:`#F87171`},kt={started:`✓`,skipped:`○`,failed:`✗`,aborted:`⚠`};function At(){let{data:e,isLoading:t}=F({queryKey:[`daemon`,`warm-start`],queryFn:()=>o(`/api/daemon/warm-start`),refetchInterval:3e4});if(t)return(0,P.jsx)(`div`,{style:{padding:16,color:`#94a3b8`},children:`Loading warm-start info…`});if(!e||!e.events||e.events.length===0)return(0,P.jsxs)(`div`,{style:{padding:20,background:`#0f172a`,borderRadius:12,border:`1px solid #1e293b`},children:[(0,P.jsx)(`h3`,{style:{margin:`0 0 8px`,color:`#e2e8f0`,fontSize:14},children:`Warm-Start`}),(0,P.jsx)(`p`,{style:{color:`#64748b`,margin:0,fontSize:13},children:`No warm-start events yet. Repos will be pre-warmed after daemon boot.`}),e?.config&&(0,P.jsxs)(`div`,{style:{marginTop:12,fontSize:12,color:`#475569`},children:[`Budget: `,e.config.warmStartBudget,` · Idle cutoff:`,` `,e.config.warmStartIdleDays,`d · Delay:`,` `,e.config.warmStartDelayMs,`ms`]})]});let n=e.events.filter(e=>e.status===`started`),r=e.events.filter(e=>e.status===`skipped`);e.events.filter(e=>e.status===`failed`||e.status===`aborted`);let i=e.events.filter(e=>e.status===`started`).reduce((e,t)=>e+t.ms,0);return(0,P.jsxs)(`div`,{style:{padding:20,background:`#0f172a`,borderRadius:12,border:`1px solid #1e293b`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:16},children:[(0,P.jsxs)(`h3`,{style:{margin:0,color:`#e2e8f0`,fontSize:14},children:[`Warm-Start`,` `,e.lastRun&&(0,P.jsxs)(`span`,{style:{color:`#64748b`,fontWeight:400},children:[`· `,e.lastRun]})]}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:`#64748b`},children:[n.length,` warmed · `,r.length,` skipped · `,i,`ms total`]})]}),(0,P.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.events.map((e,t)=>(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 10px`,background:`#1e293b`,borderRadius:6,fontSize:13},children:[(0,P.jsx)(`span`,{style:{color:Ot[e.status]||`#64748b`},children:kt[e.status]||`·`}),(0,P.jsx)(`span`,{style:{color:`#e2e8f0`,flex:1},children:e.label}),e.ms>0&&(0,P.jsxs)(`span`,{style:{color:`#64748b`,fontSize:11},children:[e.ms,`ms`]}),e.reason&&(0,P.jsx)(`span`,{style:{color:`#94a3b8`,fontSize:11},children:e.reason})]},`${e.repo}-${t}`))}),e.config&&(0,P.jsxs)(`div`,{style:{marginTop:12,paddingTop:12,borderTop:`1px solid #1e293b`,fontSize:12,color:`#475569`},children:[`Budget: `,e.config.warmStartBudget,` · Idle cutoff:`,` `,e.config.warmStartIdleDays,`d · Delay:`,` `,e.config.warmStartDelayMs,`ms`]})]})}function jt(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}h ${n}m`:n>0?`${n}m ${r}s`:`${r}s`}function Mt(){let{data:e}=F({queryKey:[`daemon`,`info`],queryFn:()=>o(`/api/daemon`),refetchInterval:1e4}),{data:t}=F({queryKey:[`daemon`,`repos`],queryFn:()=>o(`/api/repos`),refetchInterval:5e3}),n=t?.repos??[];return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[e&&(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-6`,children:[(0,P.jsx)(`h2`,{className:`text-lg font-semibold text-foreground-emphasis mb-4`,children:`Supervisor`}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4 text-sm`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase`,children:`PID`}),(0,P.jsx)(`p`,{className:`font-mono text-foreground-emphasis`,children:e.pid})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase`,children:`Uptime`}),(0,P.jsx)(`p`,{className:`font-mono text-foreground-emphasis`,children:jt(e.uptime)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase`,children:`Version`}),(0,P.jsx)(`p`,{className:`font-mono text-foreground-emphasis`,children:e.version})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase`,children:`Dashboard Port`}),(0,P.jsx)(`p`,{className:`font-mono text-foreground-emphasis`,children:e.port})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-6`,children:[(0,P.jsx)(`h2`,{className:`text-lg font-semibold text-foreground-emphasis mb-4`,children:`Managed Processes`}),n.length===0?(0,P.jsxs)(`p`,{className:`t-tertiary text-sm`,children:[`No repos registered. Run`,` `,(0,P.jsx)(`code`,{className:`font-mono`,children:`unerr daemon add .`}),` from a project.`]}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle text-left t-tertiary text-xs uppercase tracking-wider`,children:[(0,P.jsx)(`th`,{className:`pb-2 pr-4`,children:`Repo`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4`,children:`Status`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4`,children:`PID`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4`,children:`Memory`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4`,children:`Connections`}),(0,P.jsx)(`th`,{className:`pb-2`,children:`Last Activity`})]})}),(0,P.jsx)(`tbody`,{children:n.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle/50 last:border-0`,children:[(0,P.jsxs)(`td`,{className:`py-3 pr-4`,children:[(0,P.jsx)(`div`,{className:`font-medium text-foreground-emphasis`,children:e.label}),(0,P.jsx)(`div`,{className:`font-mono text-xs t-tertiary truncate max-w-xs`,children:e.path})]}),(0,P.jsx)(`td`,{className:`py-3 pr-4`,children:(0,P.jsx)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`running`?`bg-success/10 text-success`:e.status===`error`?`bg-error/10 text-error`:`bg-muted-foreground/10 text-muted-foreground`}`,children:e.status})}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono`,children:e.pid??`—`}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono`,children:e.memory?`${e.memory} MB`:`—`}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono`,children:e.connections}),(0,P.jsx)(`td`,{className:`py-3 text-xs t-tertiary`,children:e.lastActivity?new Date(e.lastActivity).toLocaleTimeString():`—`})]},e.path))})]})})]}),(0,P.jsx)(At,{})]})}function Nt({className:e=``}){return(0,P.jsx)(`div`,{className:`animate-pulse rounded-md bg-surface-overlay ${e}`,"aria-hidden":`true`})}var Pt=[`c0`,`c1`,`c2`,`c3`];function Ft({n:e=4}){return(0,P.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:Pt.slice(0,Math.min(e,Pt.length)).map(e=>(0,P.jsxs)(`div`,{className:`glass-card rounded-xl p-4`,children:[(0,P.jsx)(Nt,{className:`h-3 w-20`}),(0,P.jsx)(Nt,{className:`mt-3 h-8 w-14`})]},e))})}var It=[`h0`,`h1`,`h2`,`h3`,`h4`,`h5`],Lt=[`t0`,`t1`,`t2`,`t3`,`t4`,`t5`,`t6`,`t7`];function Rt({cols:e=5,rows:t=6}){let n=It.slice(0,Math.min(e,It.length)),r=Lt.slice(0,Math.min(t,Lt.length));return(0,P.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,P.jsx)(`div`,{className:`mb-3 flex gap-2 border-b border-border-subtle pb-2`,children:n.map(e=>(0,P.jsx)(Nt,{className:`h-3 flex-1`},e))}),r.map(e=>(0,P.jsx)(`div`,{className:`mb-2 flex gap-2`,children:n.map(t=>(0,P.jsx)(Nt,{className:`h-4 flex-1`},`${e}-${t}`))},e))]})}function zt(e){return e==null?`—`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Bt(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Vt(e){try{let t=JSON.stringify(e);return t.length>320?`${t.slice(0,317)}…`:t}catch{return String(e)}}var Ht={graph_query:`Graph Query`,shell_compression:`Shell Compression`,format_encoding:`Format Encoding`,file_read:`File Read`,session_dedup:`Session Dedup`,smart_truncation:`Smart Truncation`,behavior_automation:`Behavior Automation`};function Ut({label:e,value:t,sub:n,color:r=`text-live`,large:i}){return(0,P.jsxs)(`div`,{className:`flex flex-col`,children:[(0,P.jsx)(`span`,{className:`section-label`,children:e}),(0,P.jsx)(`span`,{className:`mt-1 font-mono font-semibold tabular-nums ${r} ${i?`text-3xl`:`text-2xl`}`,children:t}),n?(0,P.jsx)(`span`,{className:`mt-0.5 t-tertiary text-xs`,children:n}):null]})}function Wt({label:e,tokens:t,maxTokens:n}){let r=n>0?t/n*100:0;return(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`span`,{className:`w-32 shrink-0 truncate text-xs t-secondary`,children:e}),(0,P.jsx)(`div`,{className:`relative h-2 flex-1 rounded-full bg-surface-overlay`,children:(0,P.jsx)(`div`,{className:`absolute inset-y-0 left-0 rounded-full bg-violet-500/80`,style:{width:`${Math.max(r,1)}%`}})}),(0,P.jsx)(`span`,{className:`w-14 shrink-0 text-right font-mono text-xs text-foreground`,children:zt(t)})]})}function Gt({sseConnected:e,liveFeed:t,sessionSnapshot:n}){let{url:r,queryKey:i}=I(),a=F({queryKey:i([`token-flow`,`global`]),queryFn:()=>o(r(`/api/token-flow/global`))}),s=F({queryKey:i([`token-flow`,`sessions-recent`]),queryFn:()=>o(r(`/api/token-flow/sessions?limit=5&offset=0`))}),c=F({queryKey:i([`intelligence`,`graph-stats`]),queryFn:()=>o(r(`/api/intelligence/graph-stats`))}),l=F({queryKey:i([`system`,`status`]),queryFn:()=>o(r(`/api/system/status`))}),u=F({queryKey:i([`facts`,`health`]),queryFn:()=>o(r(`/api/facts/health`)),staleTime:3e4}),d=a.data?.data,f=c.data?.data,p=l.data?.data,m=s.data?.data??[],h=u.data?.data,g=d&&d.total_tokens_saved>0?(d.total_context_avoided/d.total_tokens_saved).toFixed(1):null,_=d?Object.entries(d.by_mechanism).filter(([,e])=>e.tokens_saved>0).sort((e,t)=>t[1].tokens_saved-e[1].tokens_saved):[],v=_.length>0?_[0][1].tokens_saved:1,y=a.isLoading&&d===void 0,b=n?.tool_calls??p?.session.tool_calls;return(0,P.jsxs)(`div`,{className:`mx-auto flex max-w-6xl flex-col gap-6`,children:[y?(0,P.jsx)(Ft,{n:4}):(0,P.jsxs)(`section`,{className:`glass-panel rounded-xl p-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Token Optimization`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(`token-trace`),className:`text-xs text-violet-400 hover:text-violet-300 transition-colors`,children:`View details →`})]}),d?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mt-5 grid grid-cols-2 gap-6 sm:grid-cols-4`,children:[(0,P.jsx)(Ut,{label:`Tokens Saved`,value:zt(d.total_tokens_saved),sub:`of ${zt(d.total_tokens_without)} original`,large:!0}),(0,P.jsx)(Ut,{label:`Context Avoided`,value:zt(d.total_context_avoided),sub:`compounding savings`,color:`text-cyan-400`,large:!0}),(0,P.jsx)(Ut,{label:`Efficiency`,value:`${d.efficiency_pct.toFixed(1)}%`,sub:`${zt(d.total_tokens_with)} delivered`,color:`text-success`}),(0,P.jsx)(Ut,{label:`Compound Multiplier`,value:g?`${g}×`:`—`,sub:`context avoided ÷ saved`,color:`text-amber-400`})]}),_.length>0?(0,P.jsxs)(`div`,{className:`mt-6 space-y-2`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs font-medium uppercase tracking-wider`,children:`Savings by mechanism`}),(0,P.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:_.map(([e,t])=>(0,P.jsx)(Wt,{label:Ht[e]??e,tokens:t.tokens_saved,maxTokens:v},e))})]}):null]}):(0,P.jsx)(`p`,{className:`mt-4 t-tertiary text-sm`,children:`No token flow data yet. Use MCP tools to start tracking.`})]}),(0,P.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-5`,children:[(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl p-5 lg:col-span-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Recent Sessions`}),(0,P.jsxs)(`span`,{className:`font-mono text-xs t-tertiary`,children:[s.data?._meta.total??`—`,` total`]})]}),s.isLoading?(0,P.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,P.jsx)(Nt,{className:`h-10 w-full`}),(0,P.jsx)(Nt,{className:`h-10 w-full`}),(0,P.jsx)(Nt,{className:`h-10 w-full`})]}):m.length===0?(0,P.jsx)(`p`,{className:`mt-4 t-tertiary text-sm`,children:`No sessions recorded yet.`}):(0,P.jsx)(`div`,{className:`mt-3 divide-y divide-border-subtle`,children:m.map(e=>(0,P.jsxs)(`div`,{className:`flex items-center gap-4 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.agent_name||`Unknown Agent`}),(0,P.jsx)(`span`,{className:`shrink-0 rounded bg-violet-500/10 px-1.5 py-0.5 font-mono text-[10px] text-violet-400 ring-1 ring-violet-500/20`,children:e.session_id.length>8?`${e.session_id.slice(0,8)}…`:e.session_id}),(0,P.jsx)(`span`,{className:`shrink-0 t-tertiary text-xs`,children:Bt(e.last_ts)})]}),(0,P.jsxs)(`div`,{className:`mt-0.5 flex gap-3 text-xs t-secondary`,children:[(0,P.jsxs)(`span`,{children:[e.total_turns,` turns`]}),(0,P.jsxs)(`span`,{children:[e.event_count,` events`]}),(0,P.jsx)(`span`,{children:e.mechanisms.slice(0,3).map(e=>Ht[e]??e).join(`, `)})]})]}),(0,P.jsx)(`span`,{className:`shrink-0 font-mono text-sm text-live tabular-nums`,children:zt(e.total_saved)})]},e.session_id))})]}),(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl p-5 lg:col-span-2`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Code Graph`}),c.isLoading?(0,P.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,P.jsx)(Nt,{className:`h-4 w-full`}),(0,P.jsx)(Nt,{className:`h-4 w-3/4`}),(0,P.jsx)(Nt,{className:`h-4 w-1/2`})]}):(0,P.jsxs)(`dl`,{className:`mt-4 space-y-3 text-sm`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Indexed files`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-foreground`,children:f?.fileCount??p?.graph.entities??`—`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Entities`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-foreground`,children:f?.entityCount??p?.graph.entities??`—`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Edges`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-foreground`,children:f?.edgeCount??p?.graph.edges??`—`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Rules`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-foreground`,children:f?.ruleCount??p?.graph.rules??`—`})]}),f?.driftCount?(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`text-warning`,children:`Drift entries`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-warning`,children:f.driftCount})]}):null]})]})]}),(0,P.jsxs)(`section`,{className:`glass-panel rounded-xl p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Project Intelligence`}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(`facts`),className:`text-xs text-violet-400 hover:text-violet-300 transition-colors`,children:`View Memory →`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(`activity`),className:`text-xs text-cyan-400 hover:text-cyan-300 transition-colors`,children:`View Activity →`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(`graph`),className:`text-xs text-emerald-400 hover:text-emerald-300 transition-colors`,children:`Code Intelligence →`})]})]}),u.isLoading?(0,P.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,P.jsx)(Nt,{className:`h-14 w-full`}),(0,P.jsx)(Nt,{className:`h-14 w-full`}),(0,P.jsx)(Nt,{className:`h-14 w-full`}),(0,P.jsx)(Nt,{className:`h-14 w-full`})]}):h?(0,P.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary text-xs`,children:`Total Facts`}),(0,P.jsx)(`div`,{className:`mt-1 text-lg font-mono text-foreground`,children:h.total_facts})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary text-xs`,children:`Conventions`}),(0,P.jsx)(`div`,{className:`mt-1 text-lg font-mono text-emerald-400`,children:h.by_type?.convention??0})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary text-xs`,children:`Session History`}),(0,P.jsx)(`div`,{className:`mt-1 text-lg font-mono text-cyan-400`,children:h.by_type?.episodic??0})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary text-xs`,children:`Semantic`}),(0,P.jsx)(`div`,{className:`mt-1 text-lg font-mono text-amber-400`,children:h.by_type?.semantic??0})]})]}):(0,P.jsx)(`p`,{className:`mt-4 t-tertiary text-sm`,children:`No intelligence data yet. Facts are auto-detected from coding sessions.`})]}),(0,P.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-5`,children:[(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl p-5 lg:col-span-2`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`System`}),l.isLoading?(0,P.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,P.jsx)(Nt,{className:`h-4 w-full`}),(0,P.jsx)(Nt,{className:`h-4 w-3/4`})]}):l.error?(0,P.jsx)(`p`,{className:`mt-3 text-error text-sm`,children:`Could not load system status`}):(0,P.jsxs)(`dl`,{className:`mt-4 space-y-3 text-sm`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Status`}),(0,P.jsxs)(`dd`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`inline-flex h-1.5 w-1.5 rounded-full ${e?`bg-success`:`bg-warning animate-pulse`}`}),(0,P.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e?`Connected`:`Reconnecting`})]})]}),(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Tool calls`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-foreground`,children:b??`—`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`IDE`}),(0,P.jsx)(`dd`,{className:`truncate font-mono text-xs text-foreground max-w-[10rem]`,children:p?.ide??`—`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Working dir`}),(0,P.jsx)(`dd`,{className:`truncate font-mono text-xs text-foreground max-w-[10rem]`,title:p?.cwd,children:p?.cwd??`—`})]}),p?.uptime_s==null?null:(0,P.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,P.jsx)(`dt`,{className:`t-secondary`,children:`Uptime`}),(0,P.jsx)(`dd`,{className:`font-mono text-xs text-foreground`,children:p.uptime_s>=3600?`${(p.uptime_s/3600).toFixed(1)}h`:`${Math.floor(p.uptime_s/60)}m`})]})]})]}),(0,P.jsxs)(`div`,{className:`glass-panel overflow-hidden rounded-xl lg:col-span-3`,children:[(0,P.jsxs)(`div`,{className:`border-b border-border-subtle px-5 py-3`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Live Feed`}),(0,P.jsx)(`p`,{className:`mt-0.5 t-tertiary text-xs`,children:`tool_call · drift · violation · session_stats`})]}),(0,P.jsx)(`div`,{className:`custom-scrollbar max-h-[20rem] overflow-auto font-mono text-xs leading-relaxed`,children:(t?.length??0)===0?(0,P.jsx)(`div`,{className:`px-5 py-6 t-tertiary`,children:`Waiting for events…`}):(0,P.jsx)(`ul`,{className:`divide-y divide-border-subtle`,children:t?.map((e,t)=>(0,P.jsxs)(`li`,{className:`px-5 py-2`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:new Date(e.t).toLocaleTimeString()}),` `,(0,P.jsx)(`span`,{className:`text-violet-500 font-medium`,children:e.type}),(0,P.jsx)(`pre`,{className:`mt-0.5 whitespace-pre-wrap break-words t-secondary`,children:Vt(e.data)})]},`${e.t}-${t}`))})})]})]}),(a.error||c.error)&&(0,P.jsx)(`p`,{className:`text-error text-sm`,children:`Some requests failed. Ensure the unerr proxy is running.`})]})}var Kt={semantic:{label:`Coding Patterns`,icon:`◆`,color:`violet`,description:`Conventions your codebase consistently follows`,emptyMsg:`No patterns detected yet. Run a full index to discover conventions.`},procedural:{label:`Hot Files`,icon:`⚡`,color:`cyan`,description:`Files you keep coming back to across sessions`,emptyMsg:`Not enough session data yet. Keep coding — patterns emerge after 3+ sessions.`},negative:{label:`Lessons Learned`,icon:`✗`,color:`red`,description:`Things that went wrong — remembered so you don't repeat them`,emptyMsg:`No anti-patterns detected. That's a good thing.`},episodic:{label:`Change History`,icon:`◎`,color:`amber`,description:`Changes that survived or were reverted within 24 hours`,emptyMsg:`No change survival data yet.`},convention:{label:`Explicit Rules`,icon:`▸`,color:`emerald`,description:`Rules you've explicitly told unerr to remember`,emptyMsg:`No explicit rules recorded. Use record_fact to teach unerr.`}};function qt(e){let t=e.content;if(t=t.replace(/^Naming convention:\s*/,``),t=t.replace(/^Structure pattern:\s*/,``),t=t.replace(/^Import convention:\s*/,``),t=t.replace(/^Convention:\s*/,``),t=t.replace(/\s*\(\d+%\s*confidence(?:,\s*\d+\s*entities?)?\)/,``),e.fact_type===`procedural`&&t.includes(`is accessed in`)){let e=t.match(/is accessed in (\d+)% of sessions/);if(e)return`Accessed in ${e[1]}% of your coding sessions`}if(e.fact_type===`procedural`&&t.includes(`revert rate`)){let e=t.match(/has a (\d+)% revert rate/);if(e)return`${e[1]}% of changes here get reverted — handle with care`}return t}function Jt(e){let t=Date.now()-e,n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Yt(e){let t=e.split(`/`);return t.length>1?t[t.length-1]:e}function Xt(e){let t=e.split(`/`);return t.length>1?`${t.slice(0,-1).join(`/`)}/`:``}function Zt(e){return e>=.7?`bg-emerald-400`:e>=.4?`bg-amber-400`:`bg-red-400`}function Qt(e){return e>=.7?`Strong`:e>=.4?`Moderate`:`Fading`}function $t(){let e=Ue(),{url:t,queryKey:n}=I(),[r,i]=(0,N.useState)(!1),[a,s]=(0,N.useState)(null),c=F({queryKey:n([`facts`,`health`]),queryFn:()=>o(t(`/api/facts/health`)),refetchInterval:3e4}),l=F({queryKey:n([`facts`,`list`,`all`]),queryFn:()=>o(t(`/api/facts?${new URLSearchParams({scope:`*`,min_confidence:`0`,limit:`100`})}`)),refetchInterval:15e3}),u=it({mutationFn:e=>o(t(`/api/facts/${e}/reinforce`),{method:`POST`}),onSuccess:()=>{e.invalidateQueries({queryKey:n([`facts`])})}}),d=it({mutationFn:e=>o(t(`/api/facts/${e}`),{method:`DELETE`}),onSuccess:()=>{e.invalidateQueries({queryKey:n([`facts`])})}}),f=c.data,p=l.data?.facts??[],m=p.reduce((e,t)=>{let n=t.fact_type,r=e[n];return r||(r=[],e[n]=r),r.push(t),e},{}),h=m.semantic??[],g=m.procedural??[],_=m.negative??[],v=m.episodic??[],y=m.convention??[],b=c.isLoading||l.isLoading;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,P.jsx)(`section`,{className:`glass-panel rounded-xl p-6`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-6`,children:[(0,P.jsx)(en,{score:f?.avg_confidence??0,total:f?.total??0}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Project Memory`}),(0,P.jsx)(`p`,{className:`mt-1 text-sm t-secondary leading-relaxed`,children:`unerr learns about your project as you code — detecting patterns, tracking which files you revisit, and remembering what went wrong. This knowledge gets injected into every tool response to help your AI agent make better decisions.`}),b?(0,P.jsx)(`div`,{className:`mt-4`,children:(0,P.jsx)(Ft,{n:4})}):f?(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 grid-cols-2 lg:grid-cols-4`,children:[(0,P.jsx)(tn,{label:`Total memories`,value:f.total,color:`text-foreground`}),(0,P.jsx)(tn,{label:`Patterns`,value:f.by_type.semantic??0,color:`text-violet-400`}),(0,P.jsx)(tn,{label:`Hot files`,value:f.by_type.procedural??0,color:`text-cyan-400`}),(0,P.jsx)(tn,{label:`Lessons`,value:(f.by_type.negative??0)+(f.by_type.episodic??0),color:`text-red-400`})]}):null]})]})}),(0,P.jsx)(nn,{meta:Kt.convention,facts:y,renderCard:e=>(0,P.jsx)(rn,{fact:e,onSelect:()=>s(e),onReinforce:()=>u.mutate(e.fact_id),onDismiss:()=>d.mutate(e.fact_id),isPending:u.isPending||d.isPending},e.fact_id),isLoading:b}),(0,P.jsx)(nn,{meta:Kt.negative,facts:[..._,...v],renderCard:e=>(0,P.jsx)(on,{fact:e,onSelect:()=>s(e),onReinforce:()=>u.mutate(e.fact_id),onDismiss:()=>d.mutate(e.fact_id),isPending:u.isPending||d.isPending},e.fact_id),isLoading:b}),(0,P.jsx)(nn,{meta:Kt.convention,facts:y,renderCard:e=>(0,P.jsx)(rn,{fact:e,onSelect:()=>s(e),onReinforce:()=>u.mutate(e.fact_id),onDismiss:()=>d.mutate(e.fact_id),isPending:u.isPending||d.isPending},e.fact_id),isLoading:b}),(0,P.jsx)(nn,{meta:Kt.semantic,facts:h,renderCard:e=>(0,P.jsx)(rn,{fact:e,onSelect:()=>s(e),onReinforce:()=>u.mutate(e.fact_id),onDismiss:()=>d.mutate(e.fact_id),isPending:u.isPending||d.isPending},e.fact_id),isLoading:b}),(0,P.jsx)(nn,{meta:Kt.procedural,facts:g,renderCard:e=>(0,P.jsx)(an,{fact:e,onSelect:()=>s(e),onReinforce:()=>u.mutate(e.fact_id),onDismiss:()=>d.mutate(e.fact_id),isPending:u.isPending||d.isPending},e.fact_id),isLoading:b}),p.length>0&&(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-xs t-tertiary hover:text-foreground transition-colors`,onClick:()=>i(!r),children:[(0,P.jsx)(`span`,{className:`transition-transform`,style:{transform:r?`rotate(90deg)`:`rotate(0deg)`},children:`▸`}),r?`Hide`:`Show`,` all `,p.length,` raw facts`]}),r&&(0,P.jsx)(`div`,{className:`mt-3 glass-panel rounded-xl p-4 overflow-x-auto custom-scrollbar`,children:(0,P.jsxs)(`table`,{className:`w-full min-w-[700px] text-left text-xs`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary uppercase`,children:[(0,P.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Type`}),(0,P.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Subject`}),(0,P.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Content`}),(0,P.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Confidence`}),(0,P.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Age`})]})}),(0,P.jsx)(`tbody`,{children:p.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle`,children:[(0,P.jsx)(`td`,{className:`py-2 pr-3`,children:(0,P.jsx)(hn,{type:e.fact_type})}),(0,P.jsx)(`td`,{className:`py-2 pr-3 font-mono max-w-[160px] truncate`,title:e.subject,children:e.subject}),(0,P.jsx)(`td`,{className:`py-2 pr-3 max-w-[300px] truncate t-secondary`,title:e.content,children:e.content}),(0,P.jsxs)(`td`,{className:`py-2 pr-3 font-mono tabular-nums`,children:[(e.effective_confidence*100).toFixed(0),`%`]}),(0,P.jsx)(`td`,{className:`py-2 pr-3 t-tertiary tabular-nums`,children:Jt(e.created_at)})]},e.fact_id))})]})})]}),a&&(0,P.jsx)(un,{fact:a,allFacts:p,onClose:()=>s(null),onReinforce:()=>{u.mutate(a.fact_id),s(null)},onDismiss:()=>{d.mutate(a.fact_id),s(null)},isPending:u.isPending||d.isPending})]})}function en({score:e,total:t}){let n=2*Math.PI*36,r=n*Math.min(1,e),i=t===0?`—`:`${Math.round(e*100)}%`;return(0,P.jsxs)(`div`,{className:`relative flex-shrink-0`,style:{width:88,height:88},children:[(0,P.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 88 88`,className:`w-full h-full`,children:[(0,P.jsx)(`circle`,{cx:`44`,cy:`44`,r:36,fill:`none`,stroke:`currentColor`,strokeWidth:`5`,className:`text-surface-overlay opacity-40`}),(0,P.jsx)(`circle`,{cx:`44`,cy:`44`,r:36,fill:`none`,strokeWidth:`5`,strokeLinecap:`round`,strokeDasharray:`${r} ${n-r}`,strokeDashoffset:n*.25,className:`text-violet-400 transition-all duration-700`})]}),(0,P.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center`,children:[(0,P.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:i}),(0,P.jsx)(`span`,{className:`text-[9px] t-tertiary uppercase tracking-wider`,children:`recall`})]})]})}function tn({label:e,value:t,color:n}){return(0,P.jsxs)(`div`,{className:`glass-card rounded-lg px-3 py-2.5`,children:[(0,P.jsx)(`p`,{className:`text-[10px] t-tertiary uppercase tracking-wide font-medium`,children:e}),(0,P.jsx)(`p`,{className:`text-xl font-semibold tabular-nums ${n}`,children:t})]})}function nn({meta:e,facts:t,renderCard:n,isLoading:r}){return r?(0,P.jsxs)(`section`,{children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:e.label}),(0,P.jsx)(`div`,{className:`mt-3`,children:(0,P.jsx)(Ft,{n:3})})]}):(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,P.jsxs)(`h2`,{className:`section-label`,style:{color:`var(--color-${e.color}-400, currentColor)`},children:[(0,P.jsx)(`span`,{className:`mr-1.5 opacity-60`,children:e.icon}),e.label]}),t.length>0&&(0,P.jsx)(`span`,{className:`text-[10px] t-tertiary tabular-nums`,children:t.length})]}),(0,P.jsx)(`p`,{className:`mt-1 text-xs t-tertiary`,children:e.description}),t.length===0?(0,P.jsx)(`p`,{className:`mt-4 text-sm t-tertiary italic`,children:e.emptyMsg}):(0,P.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:t.map(n)})]})}function rn({fact:e,onSelect:t,onReinforce:n,onDismiss:r,isPending:i}){let a=qt(e),o=e.effective_confidence;return(0,P.jsxs)(`div`,{className:`glass-card rounded-xl p-4 flex flex-col gap-3 cursor-pointer hover:ring-1 hover:ring-violet-500/30 transition-all`,onClick:t,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-foreground leading-snug truncate`,children:e.subject}),(0,P.jsx)(cn,{onReinforce:n,onDismiss:r,isPending:i})]}),(0,P.jsx)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:a}),(0,P.jsx)(sn,{confidence:o}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] t-tertiary`,children:[(0,P.jsx)(`span`,{children:Jt(e.created_at)}),e.reinforcement_count>0&&(0,P.jsxs)(`span`,{children:[`reinforced `,e.reinforcement_count,`x`]})]})]})}function an({fact:e,onSelect:t,onReinforce:n,onDismiss:r,isPending:i}){let a=qt(e),o=e.content.match(/(\d+)% of sessions/),s=o?Number.parseInt(o[1],10):0;return(0,P.jsxs)(`div`,{className:`glass-card rounded-xl p-4 flex flex-col gap-3 cursor-pointer hover:ring-1 hover:ring-cyan-500/30 transition-all`,onClick:t,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-foreground truncate`,title:e.subject,children:Yt(e.subject)}),(0,P.jsx)(`p`,{className:`text-[10px] font-mono t-tertiary truncate`,title:e.subject,children:Xt(e.subject)})]}),(0,P.jsx)(cn,{onReinforce:n,onDismiss:r,isPending:i})]}),(0,P.jsx)(`p`,{className:`text-xs t-secondary`,children:a}),s>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex-1 h-1.5 rounded-full bg-surface-overlay overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full rounded-full bg-cyan-400 transition-all duration-500`,style:{width:`${s}%`}})}),(0,P.jsxs)(`span`,{className:`text-[10px] font-mono text-cyan-400 tabular-nums`,children:[s,`%`]})]}),(0,P.jsx)(`div`,{className:`text-[10px] t-tertiary`,children:Jt(e.created_at)})]})}function on({fact:e,onSelect:t,onReinforce:n,onDismiss:r,isPending:i}){let a=qt(e);return(0,P.jsxs)(`div`,{className:`glass-card rounded-xl p-4 flex flex-col gap-3 border border-red-500/10 cursor-pointer hover:ring-1 hover:ring-red-500/30 transition-all`,onClick:t,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,P.jsx)(`span`,{className:`flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-bold bg-red-500/15 text-red-400 flex-shrink-0`,children:e.content.includes(`reverted`)?`↩`:`!`}),(0,P.jsx)(`h3`,{className:`text-sm font-medium text-foreground truncate`,title:e.subject,children:Yt(e.subject)})]}),(0,P.jsx)(cn,{onReinforce:n,onDismiss:r,isPending:i})]}),(0,P.jsx)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:a}),(0,P.jsx)(sn,{confidence:e.effective_confidence})]})}function sn({confidence:e}){let t=Math.round(e*100);return(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex-1 h-1 rounded-full bg-surface-overlay overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${Zt(e)}`,style:{width:`${t}%`}})}),(0,P.jsx)(`span`,{className:`text-[10px] tabular-nums ${t>=70?`text-emerald-400`:t>=40?`text-amber-400`:`text-red-400`}`,children:Qt(e)})]})}function cn({onReinforce:e,onDismiss:t,isPending:n}){return(0,P.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0`,children:[(0,P.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-xs text-emerald-400/60 hover:text-emerald-400 hover:bg-emerald-500/10 transition-colors disabled:opacity-30`,onClick:e,disabled:n,title:`This is still true — strengthen this memory`,children:(0,P.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,P.jsx)(`path`,{d:`M8 12V4M5 7l3-3 3 3`})})}),(0,P.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-xs text-red-400/60 hover:text-red-400 hover:bg-red-500/10 transition-colors disabled:opacity-30`,onClick:t,disabled:n,title:`This is wrong — forget this memory`,children:(0,P.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,P.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})})]})}var ln={convention_detector:{label:`Convention Detector`,description:`Automatically detected by analyzing your codebase patterns after indexing`},session_analysis:{label:`Session Analysis`,description:`Discovered by analyzing patterns across your coding sessions`},causal_bridge:{label:`24h Survival Check`,description:`Tracked whether your changes survived or were reverted within 24 hours`},negative_knowledge:{label:`Revert Detection`,description:`Captured when a change was made and then undone — the approach was wrong`},agent_explicit:{label:`Manually Recorded`,description:`You or your AI agent explicitly told unerr to remember this`}};function un({fact:e,allFacts:t,onClose:n,onReinforce:r,onDismiss:i,isPending:a}){(0,N.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let o=Kt[e.fact_type],s=o?.label??e.fact_type,c=o?.icon??`?`,l=o?.color??`violet`,u=Math.round(e.base_confidence*100),d=Math.round(e.effective_confidence*100),f=u-d;return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,onClick:n,children:[(0,P.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`}),(0,P.jsxs)(`div`,{className:`relative glass-panel rounded-2xl w-full max-w-lg max-h-[85vh] overflow-y-auto custom-scrollbar shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,P.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between gap-3 px-6 py-4 border-b border-border-subtle bg-surface/95 backdrop-blur-sm rounded-t-2xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg text-sm font-bold`,style:{background:`var(--color-${l}-500, #8B5CF6)1a`,color:`var(--color-${l}-400, #8B5CF6)`},children:c}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide t-tertiary font-medium`,children:s}),(0,P.jsx)(`h3`,{className:`text-sm font-semibold text-foreground truncate`,title:e.subject,children:e.subject})]})]}),(0,P.jsx)(`button`,{type:`button`,className:`flex-shrink-0 rounded-lg p-1.5 t-tertiary hover:text-foreground hover:bg-surface-overlay transition-colors`,onClick:n,children:(0,P.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,P.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})})]}),(0,P.jsxs)(`div`,{className:`px-6 py-5 flex flex-col gap-5`,children:[(0,P.jsx)(dn,{title:`What this means`,children:(0,P.jsx)(fn,{fact:e})}),(0,P.jsx)(dn,{title:`Summary`,children:(0,P.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed`,children:qt(e)})}),(0,P.jsx)(dn,{title:`Memory strength`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsx)(sn,{confidence:e.effective_confidence}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs mt-1`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`Base confidence`}),(0,P.jsxs)(`span`,{className:`font-mono tabular-nums text-foreground text-right`,children:[u,`%`]}),(0,P.jsx)(`span`,{className:`t-tertiary`,children:`Current (after decay)`}),(0,P.jsxs)(`span`,{className:`font-mono tabular-nums text-foreground text-right`,children:[d,`%`]}),f>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`Decay`}),(0,P.jsxs)(`span`,{className:`text-amber-400 tabular-nums text-right`,children:[`-`,f,`%`]})]}),e.reinforcement_count>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`Reinforcements`}),(0,P.jsxs)(`span`,{className:`text-emerald-400 tabular-nums text-right`,children:[e.reinforcement_count,`x`,` `,(0,P.jsx)(`span`,{className:`text-[10px] t-tertiary`,children:`(slows decay)`})]})]})]})]})}),(0,P.jsx)(pn,{fact:e,allFacts:t}),(0,P.jsx)(dn,{title:`How it's used`,children:(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`When your AI agent reads or modifies files near`,` `,(0,P.jsx)(`span`,{className:`font-mono text-foreground`,children:e.scope}),`, this memory is automatically injected into the context — the agent sees it before writing code.`]})}),(0,P.jsx)(dn,{title:`Source`,children:(()=>{let t=ln[e.source]??{label:e.source,description:`Automatically generated`};return(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-violet-400/60 mt-1.5 flex-shrink-0`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:t.label}),(0,P.jsx)(`p`,{className:`text-[10px] t-tertiary mt-0.5`,children:t.description})]})]})})()}),(0,P.jsx)(dn,{title:`Timeline`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`First detected`}),(0,P.jsx)(`span`,{className:`t-secondary text-right`,children:new Date(e.created_at).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}),e.last_reinforced_at>e.created_at&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`Last reinforced`}),(0,P.jsx)(`span`,{className:`t-secondary text-right`,children:new Date(e.last_reinforced_at).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]})]})}),(0,P.jsx)(dn,{title:`Original data`,children:(0,P.jsx)(`p`,{className:`font-mono text-[11px] t-tertiary leading-relaxed bg-surface-overlay rounded-lg px-3 py-2`,children:e.content})})]}),(0,P.jsxs)(`div`,{className:`sticky bottom-0 flex items-center justify-between gap-3 px-6 py-4 border-t border-border-subtle bg-surface/95 backdrop-blur-sm rounded-b-2xl`,children:[(0,P.jsxs)(`span`,{className:`text-[10px] t-tertiary`,children:[`ID: `,e.fact_id.slice(0,8)]}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-emerald-400 bg-emerald-500/10 hover:bg-emerald-500/20 transition-colors disabled:opacity-30`,onClick:r,disabled:a,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,P.jsx)(`path`,{d:`M8 12V4M5 7l3-3 3 3`})}),`Still true`]}),(0,P.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-red-400 bg-red-500/10 hover:bg-red-500/20 transition-colors disabled:opacity-30`,onClick:i,disabled:a,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`w-3.5 h-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,P.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})}),`Forget this`]})]})]})]})]})}function dn({title:e,children:t}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide t-tertiary`,children:e}),t]})}function fn({fact:e}){if(e.fact_type===`semantic`)return(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`unerr detected that your codebase consistently follows this pattern. When your AI agent modifies code in`,` `,(0,P.jsx)(`span`,{className:`font-mono text-violet-400`,children:e.scope}),`, this convention is automatically surfaced so it doesn't accidentally break the pattern.`]});if(e.fact_type===`procedural`)return(0,P.jsx)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:`You keep coming back to this file across coding sessions. unerr prioritizes it in context so your AI agent understands this is central to your workflow.`});if(e.fact_type===`negative`||e.fact_type===`episodic`){let t=e.content.includes(`reverted`),n=e.source===`causal_bridge`,r=e.source===`session_analysis`,i=e.source===`negative_knowledge`;return t&&n?(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`A change was made to`,` `,(0,P.jsx)(`span`,{className:`font-mono text-red-400`,children:e.subject}),` but it was reverted within 24 hours — the approach didn't work out. unerr remembers this so your AI agent avoids the same mistake.`]}):!t&&n?(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`A change to`,` `,(0,P.jsx)(`span`,{className:`font-mono text-amber-400`,children:e.subject}),` `,`survived past the 24-hour window and shipped. This is tracked as a successful change.`]}):i?(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`The file`,` `,(0,P.jsx)(`span`,{className:`font-mono text-red-400`,children:e.subject}),` was modified and then reverted — the approach was incorrect. unerr captured this as a lesson so the same mistake isn't repeated.`]}):r?(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`Changes to`,` `,(0,P.jsx)(`span`,{className:`font-mono text-red-400`,children:e.subject}),` `,`frequently get reverted across multiple sessions. This file may have tricky edge cases or dependencies that make changes fragile.`]}):(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`Something went wrong with`,` `,(0,P.jsx)(`span`,{className:`font-mono text-red-400`,children:e.subject}),`. This lesson is surfaced when your AI agent works in this area.`]})}return e.fact_type===`convention`?(0,P.jsxs)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:[`This is a rule you or your AI agent explicitly recorded. It's injected whenever the agent works in`,` `,(0,P.jsx)(`span`,{className:`font-mono text-emerald-400`,children:e.scope}),`.`]}):(0,P.jsx)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:e.content})}function pn({fact:e,allFacts:t}){if(e.fact_type===`semantic`){let t=e.content.match(/(\d+)\s*entit/),n=t?t[1]:null;return n?(0,P.jsx)(dn,{title:`How widespread`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-lg font-semibold text-violet-400 tabular-nums`,children:n}),(0,P.jsx)(`span`,{className:`text-xs t-secondary`,children:`entities in your codebase follow this convention`})]})}):null}if(e.fact_type===`procedural`){let n=e.content.match(/(\d+)% of sessions/),r=n?Number.parseInt(n[1],10):0,i=e.content.match(/(\d+)% revert rate/),a=i?Number.parseInt(i[1],10):0,o=Xt(e.subject),s=t.filter(t=>t.fact_id!==e.fact_id&&t.fact_type===`procedural`&&Xt(t.subject)===o).slice(0,4),c=t.filter(t=>(t.fact_type===`negative`||t.fact_type===`episodic`)&&t.subject===e.subject);return(0,P.jsxs)(P.Fragment,{children:[(r>0||a>0)&&(0,P.jsx)(dn,{title:`Session frequency`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[r>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-36 h-2.5 rounded-full bg-surface-overlay overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full rounded-full bg-cyan-400`,style:{width:`${r}%`}})}),(0,P.jsxs)(`span`,{className:`text-xs text-cyan-400 font-semibold tabular-nums`,children:[r,`%`]}),(0,P.jsx)(`span`,{className:`text-[10px] t-tertiary`,children:`of sessions`})]}),a>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-36 h-2.5 rounded-full bg-surface-overlay overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full rounded-full bg-red-400`,style:{width:`${a}%`}})}),(0,P.jsxs)(`span`,{className:`text-xs text-red-400 font-semibold tabular-nums`,children:[a,`%`]}),(0,P.jsx)(`span`,{className:`text-[10px] t-tertiary`,children:`revert rate`})]})]})}),s.length>0&&(0,P.jsx)(dn,{title:`Often changed together`,children:(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-overlay px-2 py-0.5 text-[10px] font-mono t-secondary`,children:Yt(e.subject)},e.fact_id))})}),c.length>0&&(0,P.jsx)(dn,{title:`Known issues with this file`,children:(0,P.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:c.map(e=>(0,P.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-red-400 flex-shrink-0 mt-0.5`,children:`!`}),(0,P.jsx)(`span`,{className:`t-secondary`,children:qt(e)})]},e.fact_id))})})]})}return e.fact_type===`negative`||e.fact_type===`episodic`?(0,P.jsx)(dn,{title:`Affected code`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-red-400`,children:e.subject}),e.scope!==e.subject&&(0,P.jsxs)(`span`,{className:`text-[10px] t-tertiary`,children:[`in `,e.scope]})]})}):null}var mn={procedural:`bg-cyan-500/15 text-cyan-400`,semantic:`bg-violet-500/15 text-violet-400`,negative:`bg-red-500/15 text-red-400`,convention:`bg-emerald-500/15 text-emerald-400`,episodic:`bg-amber-500/15 text-amber-400`};function hn({type:e}){return(0,P.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-[10px] font-medium uppercase ${mn[e]??`bg-surface-overlay text-muted-foreground`}`,children:e})}function gn(e){switch(e){case`low`:return`bg-emerald-500/20 border-emerald-500/40 text-emerald-300`;case`medium`:return`bg-amber-500/20 border-amber-500/40 text-amber-300`;case`high`:return`bg-orange-500/20 border-orange-500/40 text-orange-300`;case`critical`:return`bg-red-500/20 border-red-500/40 text-red-300`;default:return`bg-zinc-700/30 border-zinc-600 text-zinc-400`}}function _n(e){switch(e){case`low`:return`bg-emerald-500/30 text-emerald-300`;case`medium`:return`bg-amber-500/30 text-amber-300`;case`high`:return`bg-orange-500/30 text-orange-300`;case`critical`:return`bg-red-500/30 text-red-300`;default:return`bg-zinc-600/30 text-zinc-400`}}function vn({label:e,value:t,max:n,unit:r,hint:i}){let a=Math.min(t/n*100,100);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,P.jsx)(`span`,{className:`w-28 text-zinc-300 shrink-0 font-medium`,children:e}),(0,P.jsx)(`div`,{className:`flex-1 h-1.5 bg-zinc-700 rounded-full overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full bg-violet-500 rounded-full transition-all`,style:{width:`${a}%`}})}),(0,P.jsxs)(`span`,{className:`w-12 text-right text-zinc-400 tabular-nums`,children:[typeof t==`number`&&t%1!=0?t.toFixed(2):t,r??``]})]}),i&&(0,P.jsx)(`div`,{className:`mt-0.5 ml-[7.5rem] text-[10px] text-zinc-500 leading-snug`,children:i})]})}function yn({node:e,onDrillDown:t,onSelect:n,isSelected:r}){let i=e.children&&e.children.length>0;return(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},className:`border rounded-lg p-3 text-left transition-all hover:scale-[1.01] cursor-pointer ${r?`ring-2 ring-violet-500 `:``}${gn(e.risk_level)}`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,P.jsx)(`span`,{className:`font-medium text-sm truncate`,children:e.name}),(0,P.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full font-medium ${_n(e.risk_level)}`,children:e.risk_level})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-zinc-400`,children:[(0,P.jsxs)(`span`,{children:[`Score: `,Math.round(e.health_score*100),`%`]}),(0,P.jsxs)(`span`,{children:[e.entity_count,` entities`]}),i&&(0,P.jsxs)(`span`,{children:[e.children?.length,` dirs`]})]}),i&&t&&(0,P.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:`text-[11px] text-violet-300 hover:text-violet-200 transition-colors px-1.5 py-0.5 rounded hover:bg-violet-500/10`,"aria-label":`Open ${e.name}`,children:`Open \\u25B8`})]})]})}function bn({node:e,activity:t}){let n=e.metrics;return(0,P.jsxs)(`div`,{className:`border border-zinc-700 rounded-lg p-4 bg-zinc-800/50`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h3`,{className:`font-semibold text-sm text-zinc-200 truncate`,children:e.path}),(0,P.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full font-medium ${_n(e.risk_level)}`,children:[Math.round(e.health_score*100),`% health`]})]}),t&&t.edit_count>=3&&(0,P.jsxs)(`div`,{className:`mb-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-200`,children:[(0,P.jsxs)(`div`,{className:`font-medium`,children:[`🩹 Active churn — `,t.edit_count,` edits in the last`,` `,t.window_days,` days`]}),(0,P.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-amber-200/80`,children:[t.session_count,` session`,t.session_count===1?``:`s`,` touched this file. Hot files are more likely to break unrelated callers.`]})]}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsx)(vn,{label:`Called by`,value:n.fan_in,max:40,hint:n.fan_in>=20?`${n.fan_in} places depend on this — high-blast file`:n.fan_in>=5?`${n.fan_in} dependents`:`Few dependents`}),(0,P.jsx)(vn,{label:`Calls`,value:n.fan_out,max:40,hint:n.fan_out>=20?`Imports ${n.fan_out} things — consider splitting`:`Uses ${n.fan_out} other entities`}),(0,P.jsx)(vn,{label:`Edited recently`,value:n.change_frequency,max:10,hint:n.change_frequency>=5?`${n.change_frequency} recent edits — hot file`:`${n.change_frequency} recent edits`}),(0,P.jsx)(vn,{label:`Co-changes with`,value:n.coupling_count,max:10,hint:n.coupling_count>=5?`Edited alongside ${n.coupling_count} other files — likely coupled`:`${n.coupling_count} co-change partners`}),(0,P.jsx)(vn,{label:`Stability`,value:Math.round(n.durability*100),max:100,unit:`%`,hint:n.durability>=.7?`Rarely changes — stable surface`:n.durability>=.4?`Moderate churn`:`Changes often`})]}),(0,P.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-zinc-700 text-xs text-zinc-500`,children:[e.entity_count,` entities in this`,` `,e.children?`directory`:`file`]})]})}function xn({initialFilter:e}={}){let[t,n]=(0,N.useState)([]),[r,i]=(0,N.useState)(null),[a,s]=(0,N.useState)(e??``);(0,N.useEffect)(()=>{e!==void 0&&s(e)},[e]);let{data:c,isLoading:l,error:u}=F({queryKey:[`health-map`],queryFn:()=>o(`/api/intelligence/health-map`),staleTime:3e4}),d=!!r&&!r.children,f=F({queryKey:[`health-map-file`,r?.path],queryFn:()=>o(`/api/intelligence/health-map/file?path=${encodeURIComponent(r?.path??``)}`),enabled:d,staleTime:3e4}).data?.data?.recent_activity??null;if(l)return(0,P.jsx)(`div`,{className:`flex items-center justify-center h-64 text-zinc-500`,children:`Loading health map...`});if(u||!c?.data)return(0,P.jsx)(`div`,{className:`flex items-center justify-center h-64 text-red-400`,children:`Failed to load health map`});let p=c.data;for(let e of t){let t=p.children?.find(t=>t.path===e);if(t)p=t;else break}let m=p.children??[p],h=a.trim().toLowerCase(),g=h?m.filter(e=>e.name.toLowerCase().includes(h)||e.path.toLowerCase().includes(h)):m;return(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-zinc-400`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>{n([]),i(null)},className:`hover:text-zinc-200 transition-colors`,children:`root`}),t.map((e,r)=>(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`/`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{n(t.slice(0,r+1)),i(null)},className:`hover:text-zinc-200 transition-colors`,children:e.split(`/`).pop()})]},e))]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,P.jsxs)(`span`,{className:`text-zinc-300`,children:[`Overall health:`,` `,(0,P.jsxs)(`span`,{className:`font-semibold text-violet-400`,children:[Math.round(p.health_score*100),`%`]})]}),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[p.entity_count,` entities`]}),(0,P.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${_n(p.risk_level)}`,children:[p.risk_level,` risk`]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`search`,value:a,onChange:e=>s(e.target.value),placeholder:`Filter files in this level…`,className:`text-xs rounded-md border border-zinc-700 bg-zinc-800/60 px-2.5 py-1.5 w-56 focus:outline-none focus:border-violet-500 placeholder:text-zinc-500`}),a&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>s(``),className:`text-xs text-zinc-500 hover:text-zinc-300`,children:`Clear`})]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,P.jsxs)(`div`,{className:`lg:col-span-2 grid grid-cols-2 sm:grid-cols-3 gap-2`,children:[g.map(e=>(0,P.jsx)(yn,{node:e,onDrillDown:e=>{n([...t,e.path]),i(null)},onSelect:i,isSelected:r?.path===e.path},e.path)),g.length===0&&(0,P.jsx)(`div`,{className:`col-span-full text-center text-zinc-500 py-8`,children:`No health data for this path`})]}),(0,P.jsx)(`div`,{children:r?(0,P.jsx)(bn,{node:r,activity:f}):(0,P.jsx)(`div`,{className:`border border-zinc-700 rounded-lg p-4 bg-zinc-800/50 text-zinc-500 text-sm`,children:`Click a file to see detailed health metrics`})})]})]})}var Sn={critical:`bg-red-500/15 text-red-400 border-red-500/20`,high:`bg-red-500/15 text-red-400 border-red-500/20`,medium:`bg-amber-500/15 text-amber-400 border-amber-500/20`,low:`bg-emerald-500/15 text-emerald-400 border-emerald-500/20`},Cn={critical:`bg-red-400`,high:`bg-red-400`,medium:`bg-amber-400`,low:`bg-emerald-400`},wn={critical:`text-red-400`,high:`text-red-400`,medium:`text-amber-400`,low:`text-emerald-400`},Tn={critical:{border:`border-red-500/30`,bg:`bg-red-500/5`,icon:`!!`,iconColor:`text-red-400 bg-red-500/20`},warning:{border:`border-amber-500/30`,bg:`bg-amber-500/5`,icon:`!`,iconColor:`text-amber-400 bg-amber-500/20`},info:{border:`border-blue-500/30`,bg:`bg-blue-500/5`,icon:`i`,iconColor:`text-blue-400 bg-blue-500/20`},positive:{border:`border-emerald-500/30`,bg:`bg-emerald-500/5`,icon:`✓`,iconColor:`text-emerald-400 bg-emerald-500/20`}},En={A:`text-emerald-400`,B:`text-emerald-400`,C:`text-amber-400`,D:`text-red-400`,F:`text-red-400`};function Dn(e){let t=e.risk_level===`high`?3:e.risk_level===`medium`?2:1,n=e.test_count===0?2:1;return e.degree*t*n}function On(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function kn(e){return`${e}%`}function An({level:e}){return(0,P.jsxs)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide ${Sn[e]??Sn.low}`,children:[(0,P.jsx)(`span`,{className:`mr-1 inline-block h-1.5 w-1.5 rounded-full ${Cn[e]??Cn.low}`}),e]})}function jn({count:e}){return e===0?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-red-400/80`,children:[(0,P.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-red-400/60`}),`untested`]}):(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-emerald-400/80`,children:[(0,P.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-emerald-400/60`}),e,` test`,e===1?``:`s`]})}function Mn({insights:e,stats:t,isLoading:n}){if(n)return(0,P.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:(0,P.jsx)(Ft,{n:4})});if(!e||!t)return(0,P.jsx)(`div`,{className:`glass-panel rounded-xl px-6 py-8 text-center`,children:(0,P.jsx)(`p`,{className:`t-secondary text-sm`,children:`Graph not loaded yet — start the proxy or wait for indexing.`})});let r=e.healthGrade,i=e.healthScore,a=e.blastRadiusCoverage;return(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_1fr]`,children:[(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl flex flex-col items-center justify-center py-6 px-4 gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,P.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 120 120`,className:`h-28 w-28`,children:[(0,P.jsx)(`circle`,{cx:`60`,cy:`60`,r:`52`,fill:`none`,stroke:`currentColor`,strokeWidth:`8`,className:`text-surface-overlay`}),(0,P.jsx)(`circle`,{cx:`60`,cy:`60`,r:`52`,fill:`none`,strokeWidth:`8`,strokeLinecap:`round`,strokeDasharray:`${i/100*327} 327`,transform:`rotate(-90 60 60)`,className:i>=80?`text-emerald-400`:i>=50?`text-amber-400`:`text-red-400`,style:{transition:`stroke-dasharray 0.6s ease`}})]}),(0,P.jsxs)(`div`,{className:`absolute flex flex-col items-center`,children:[(0,P.jsx)(`span`,{className:`text-3xl font-bold ${En[r]??`text-foreground`}`,children:r}),(0,P.jsxs)(`span`,{className:`text-xs t-tertiary font-mono`,children:[i,`/100`]})]})]}),(0,P.jsx)(`span`,{className:`text-xs t-tertiary`,children:`Codebase Health`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,P.jsx)(Nn,{label:`Tested Reach`,value:kn(a),hint:`% of your code's dependency reach that has tests guarding it.`,accent:a>=75?`emerald`:a>=50?`amber`:`red`}),(0,P.jsx)(Nn,{label:`Chokepoints`,value:String(e.bottlenecks.length),hint:`High-traffic files with no tests — break one, break many.`,accent:e.bottlenecks.length>0?`red`:`emerald`}),(0,P.jsx)(Nn,{label:`Risk Concentrated In Top 5`,value:kn(e.riskConcentration),hint:`Higher = more fragile codebase (few files carry most risk).`,accent:e.riskConcentration>60?`red`:e.riskConcentration>40?`amber`:`emerald`})]}),(0,P.jsxs)(`details`,{className:`group rounded-xl border border-border-subtle bg-sidebar/40 px-4 py-2`,children:[(0,P.jsxs)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[`Advanced metrics (`,On(t.entityCount),` entities ·`,` `,t.communityCount,` modules)`]}),(0,P.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`,children:[(0,P.jsx)(Nn,{label:`High-Risk Files`,value:String(e.riskDistribution.high),sub:`of ${e.riskDistribution.high+e.riskDistribution.medium+e.riskDistribution.low} analyzed`,hint:`Files with high blast radius and weak test coverage.`,accent:e.riskDistribution.high>0?`red`:`emerald`}),(0,P.jsx)(Nn,{label:`Untested Reach`,value:On(e.untestedBlastRadius),sub:`of ${On(e.totalBlastRadius)} total`,hint:`Dependency edges that no test currently exercises.`,accent:e.untestedBlastRadius>e.testedBlastRadius?`red`:`emerald`}),(0,P.jsx)(Nn,{label:`Modules`,value:String(t.communityCount),sub:`${On(t.fileCount)} files`,hint:`Clusters of files that change together (auto-detected).`}),e.mostCoupledPair?(0,P.jsx)(Nn,{label:`Tightest Co-Change Pair`,value:String(e.mostCoupledPair.weight),sub:`${e.mostCoupledPair.from.slice(0,16)}…`,hint:`Two files edited together this many times — likely coupled.`,accent:e.mostCoupledPair.weight>=10?`amber`:void 0}):(0,P.jsx)(Nn,{label:`Drift`,value:On(t.driftCount),sub:t.driftCount>0?`entities drifted`:`clean`,hint:`Entities modified since the graph was last indexed.`})]})]})]})]})}function Nn({label:e,value:t,sub:n,hint:r,accent:i,onClick:a}){return(0,P.jsxs)(a?`button`:`div`,{type:a?`button`:void 0,onClick:a,className:`glass-panel rounded-xl px-4 py-3 w-full ${a?`cursor-pointer hover:el-raised transition-colors text-left`:``}`,title:r,children:[(0,P.jsx)(`div`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:e}),(0,P.jsx)(`div`,{className:`mt-1 text-xl font-semibold font-mono ${i===`emerald`?`text-emerald-400`:i===`red`?`text-red-400`:i===`amber`?`text-amber-400`:`text-foreground-emphasis`}`,children:t}),n&&(0,P.jsx)(`div`,{className:`mt-0.5 t-tertiary text-[10px]`,children:n}),r&&(0,P.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground leading-snug`,children:r})]})}var Pn={"blast-radius-coverage":{label:`View hotspots`,action:`scroll`,target:`section-risk-hotspots`},bottlenecks:{label:`View bottlenecks`,action:`scroll`,target:`section-risk-hotspots`},"risk-concentration":{label:`View top 5`,action:`scroll`,target:`section-risk-hotspots`},"coupling-hotspot":{label:`View module graph`,action:`route`,target:`visual`},"no-high-risk":null};function Fn({cards:e}){if(e.length===0)return null;let t=e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})};return(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`What needs your attention`}),(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`ranked findings your IDE can't surface — start here`})]}),(0,P.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let n=Tn[e.severity]??Tn.info,r=Pn[e.id]??null;return(0,P.jsxs)(`div`,{className:`rounded-xl border ${n.border} ${n.bg} p-4 transition-colors flex flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-start gap-3 flex-1`,children:[(0,P.jsx)(`span`,{className:`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-xs font-bold ${n.iconColor}`,children:n.icon}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-foreground-emphasis leading-snug`,children:e.title}),(0,P.jsx)(`p`,{className:`mt-1.5 text-xs t-secondary leading-relaxed`,children:e.description}),e.metric!==void 0&&e.metricLabel&&(0,P.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-sm font-semibold text-foreground-emphasis`,children:e.metric}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:e.metricLabel})]})]})]}),r&&(0,P.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border-subtle/40`,children:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r.action===`scroll`?t(r.target):ft(r.target),className:`text-xs text-violet-400 hover:text-violet-300 transition-colors font-medium`,children:[r.label,` →`]})})]},e.id)})})]})}function In({hotspots:e,bottlenecks:t,isLoading:n,isError:r}){let i=e.slice(0,3),a=e.slice(3),o=new Set(t.map(e=>e.key)),s=e=>{window.location.hash=`#/visual?entity=${encodeURIComponent(e)}`};return(0,P.jsxs)(`section`,{id:`section-risk-hotspots`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Risk Hotspots`}),(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`files where a small change can cascade — fix these first`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ft(`visual`),className:`text-xs text-violet-400 hover:text-violet-300 transition-colors`,children:`View map →`})]}),n?(0,P.jsx)(Rt,{cols:4,rows:6}):r?(0,P.jsx)(`div`,{className:`glass-panel rounded-xl px-4 py-6`,children:(0,P.jsx)(`p`,{className:`text-error text-sm`,children:`Could not load risk data — graph may still be indexing.`})}):e.length===0?(0,P.jsx)(`div`,{className:`glass-panel rounded-xl px-4 py-6 text-center`,children:(0,P.jsx)(`p`,{className:`t-secondary text-sm`,children:`No entities indexed yet.`})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:i.map((e,t)=>{let n=o.has(e.key);return(0,P.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`glass-panel rounded-xl p-4 text-left w-full cursor-pointer hover:el-raised transition-all`,"aria-label":`Open ${e.name} in graph visualizer`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsxs)(`span`,{className:`text-[10px] font-medium t-tertiary uppercase tracking-wider`,children:[`#`,t+1,` highest risk`]}),(0,P.jsx)(An,{level:e.risk_level})]}),(0,P.jsx)(`div`,{className:`font-mono text-sm font-medium text-foreground-emphasis truncate`,children:e.name}),(0,P.jsx)(`div`,{className:`mt-1 text-[10px] t-tertiary truncate`,children:e.file_path}),(0,P.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 text-xs`,title:`Called by ${e.fan_in} places · calls ${e.fan_out} things`,children:[(0,P.jsxs)(`div`,{className:`font-mono`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`called by `}),(0,P.jsx)(`span`,{className:wn[e.risk_level]??`text-foreground`,children:e.fan_in})]}),(0,P.jsxs)(`div`,{className:`font-mono`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`calls `}),(0,P.jsx)(`span`,{className:`text-foreground`,children:e.fan_out})]}),(0,P.jsx)(jn,{count:e.test_count})]}),n&&(0,P.jsx)(`div`,{className:`mt-2 rounded-md bg-red-500/10 px-2 py-1 text-[10px] text-red-400 font-medium`,children:`Structural bottleneck`})]},e.key)})}),a.length>0&&(0,P.jsx)(`div`,{className:`glass-panel rounded-xl overflow-hidden`,children:(0,P.jsx)(`div`,{className:`custom-scrollbar max-h-[320px] overflow-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,P.jsx)(`thead`,{className:`sticky top-0 bg-surface-overlay/95 backdrop-blur-sm`,children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-left`,children:[(0,P.jsx)(`th`,{className:`py-2 pl-4 pr-2 font-medium`,children:`Entity`}),(0,P.jsx)(`th`,{className:`py-2 px-2 font-medium`,children:`Kind`}),(0,P.jsx)(`th`,{className:`py-2 px-2 font-medium text-right`,title:`Number of places that depend on this entity`,children:`Called By`}),(0,P.jsx)(`th`,{className:`py-2 px-2 font-medium text-right`,title:`Number of things this entity uses`,children:`Calls`}),(0,P.jsx)(`th`,{className:`py-2 px-2 font-medium`,children:`Risk`}),(0,P.jsx)(`th`,{className:`py-2 px-2 font-medium`,children:`Tests`}),(0,P.jsx)(`th`,{className:`py-2 px-2 pr-4 font-medium`,children:`Module`})]})}),(0,P.jsx)(`tbody`,{className:`divide-y divide-border-subtle`,children:a.map(e=>(0,P.jsxs)(`tr`,{onClick:()=>s(e.key),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s(e.key))},tabIndex:0,role:`button`,"aria-label":`Open ${e.name} in graph visualizer`,className:`transition-colors hover:el-raised cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-violet-500`,children:[(0,P.jsxs)(`td`,{className:`py-2 pl-4 pr-2`,children:[(0,P.jsx)(`div`,{className:`font-mono text-foreground-emphasis truncate max-w-[180px]`,children:e.name}),(0,P.jsx)(`div`,{className:`t-tertiary truncate max-w-[180px]`,children:e.file_path})]}),(0,P.jsx)(`td`,{className:`py-2 px-2`,children:(0,P.jsx)(`span`,{className:`rounded bg-surface-raised px-1.5 py-0.5 text-[10px] t-tertiary`,children:e.kind})}),(0,P.jsx)(`td`,{className:`py-2 px-2 text-right font-mono ${wn[e.risk_level]??``}`,children:e.fan_in}),(0,P.jsx)(`td`,{className:`py-2 px-2 text-right font-mono`,children:e.fan_out}),(0,P.jsx)(`td`,{className:`py-2 px-2`,children:(0,P.jsx)(An,{level:e.risk_level})}),(0,P.jsx)(`td`,{className:`py-2 px-2`,children:(0,P.jsx)(jn,{count:e.test_count})}),(0,P.jsx)(`td`,{className:`py-2 px-2 pr-4`,children:(0,P.jsx)(`span`,{className:`text-violet-400/60 truncate max-w-[100px] inline-block`,children:e.community_label||`—`})})]},e.key))})]})})})]})]})}function Ln({communities:e,onSelectModule:t}){return e.length===0?null:(0,P.jsxs)(`section`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,P.jsx)(`h2`,{className:`section-label text-violet-500`,children:`Module Health`}),(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`which parts of the codebase are well-tested vs. exposed`})]}),(0,P.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,children:e.map(e=>{let n=e.blastRadiusCoveragePct>=75?`text-emerald-400`:e.blastRadiusCoveragePct>=50?`text-amber-400`:`text-red-400`,r=e.blastRadiusCoveragePct>=75?`bg-emerald-400`:e.blastRadiusCoveragePct>=50?`bg-amber-400`:`bg-red-400`;return(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(e.label),className:`glass-panel rounded-xl p-4 text-left w-full cursor-pointer hover:el-raised transition-all`,"aria-label":`Open ${e.label} in File Health Map`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-foreground-emphasis truncate max-w-[160px]`,children:e.label}),(0,P.jsxs)(`span`,{className:`font-mono text-sm font-semibold ${n}`,children:[e.blastRadiusCoveragePct,`%`]})]}),(0,P.jsx)(`div`,{className:`h-1.5 rounded-full bg-surface-overlay overflow-hidden mb-3`,children:(0,P.jsx)(`div`,{className:`h-full rounded-full ${r} transition-all duration-500`,style:{width:`${e.blastRadiusCoveragePct}%`}})}),(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-[10px]`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary`,children:`Entities`}),(0,P.jsx)(`div`,{className:`font-mono text-foreground-emphasis`,children:e.entities})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary`,children:`Tested`}),(0,P.jsx)(`div`,{className:`font-mono text-emerald-400`,children:e.tested})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-tertiary`,children:`Untested`}),(0,P.jsx)(`div`,{className:`font-mono ${e.untested>0?`text-red-400`:`text-emerald-400`}`,children:e.untested})]})]}),(e.riskHigh>0||e.riskMedium>0)&&(0,P.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 flex-wrap`,children:[e.riskHigh>0&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-[10px] text-red-400`,children:[(0,P.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-red-400`}),e.riskHigh,` high`]}),e.riskMedium>0&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-400`,children:[(0,P.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-amber-400`}),e.riskMedium,` med`]})]})]},e.label)})})]})}function Rn(){return typeof window>`u`?`overview`:window.location.hash.replace(/^#/,``).trim().split(`/`).filter(Boolean)[1]===`file-health`?`file-health`:`overview`}function zn(e){let t=e===`file-health`?`#/graph/file-health`:`#/graph`;window.location.hash!==t&&window.history.replaceState(null,``,t)}function Bn(){let[e,t]=(0,N.useState)(()=>Rn()),[n,r]=(0,N.useState)(void 0),i=e=>{t(e),zn(e)},a=e=>{r(e),i(`file-health`)};(0,N.useEffect)(()=>{let e=()=>t(Rn());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let{url:s,queryKey:c}=I(),l=F({queryKey:c([`intelligence`,`graph-stats`]),queryFn:()=>o(s(`/api/intelligence/graph-stats`)),enabled:e===`overview`}),u=F({queryKey:c([`intelligence`,`insights`]),queryFn:()=>o(s(`/api/intelligence/insights`)),enabled:e===`overview`}),d=F({queryKey:c([`intelligence`,`risk-hotspots`]),queryFn:()=>o(s(`/api/intelligence/risk-hotspots?limit=25`)),enabled:e===`overview`}),f=F({queryKey:c([`session`,`efficiency`]),queryFn:()=>o(s(`/api/session/efficiency`)),enabled:e===`overview`,staleTime:1e4}),p=F({queryKey:c([`session`,`intents`]),queryFn:()=>o(s(`/api/session/intents`)),enabled:e===`overview`,staleTime:1e4}),m=F({queryKey:c([`intelligence`,`reading-tour`]),queryFn:()=>o(s(`/api/intelligence/reading-tour?limit=5`)),enabled:e===`overview`,staleTime:5*6e4}).data?.data,h=!!m&&m.stops.length>=3&&(f.data?.data?.totalCalls??0)===0&&(p.data?.data?.length??0)===0,g=u.data?.data,_=(d.data?.data??[]).sort((e,t)=>Dn(t)-Dn(e));return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`inline-flex rounded-lg border border-border-subtle bg-sidebar p-1`,role:`tablist`,"aria-label":`Code Intelligence view`,children:[(0,P.jsx)(Vn,{active:e===`overview`,onClick:()=>i(`overview`),children:`Overview`}),(0,P.jsx)(Vn,{active:e===`file-health`,onClick:()=>i(`file-health`),children:`File Health Map`})]}),e===`overview`?(0,P.jsxs)(`div`,{className:`space-y-8`,children:[(0,P.jsx)(Un,{efficiency:f.data?.data??null,intents:p.data?.data??null,hotspots:_}),h&&m&&(0,P.jsx)(Hn,{stops:m.stops,estimatedReadingTimeMin:m.estimatedReadingTimeMin}),g&&(0,P.jsx)(Fn,{cards:g.insights}),(0,P.jsx)(In,{hotspots:_,bottlenecks:g?.bottlenecks??[],isLoading:d.isLoading,isError:d.isError}),(0,P.jsx)(Mn,{insights:g??null,stats:l.data?.data??null,isLoading:l.isLoading||u.isLoading}),g&&(0,P.jsx)(Ln,{communities:g.communityHealth,onSelectModule:a})]}):(0,P.jsx)(xn,{initialFilter:n})]})}function Vn({active:e,onClick:t,children:n}){return(0,P.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:`px-4 py-1.5 text-sm rounded-md transition-colors ${e?`el-raised font-medium text-foreground-emphasis`:`text-muted-foreground hover:text-foreground`}`,children:n})}function Hn({stops:e,estimatedReadingTimeMin:t}){let[n,r]=(0,N.useState)(0),i=e[n],a=e=>{window.location.hash=`#/visual?entity=${encodeURIComponent(e)}`};return(0,P.jsxs)(`section`,{"aria-label":`Reading tour`,className:`rounded-xl border border-violet-500/30 bg-violet-500/5 p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,P.jsx)(`span`,{className:`text-[10px] font-medium text-violet-300 uppercase tracking-wider`,children:`New to this codebase?`})}),(0,P.jsx)(`h2`,{className:`mt-1 text-base font-semibold text-foreground-emphasis`,children:`Reading Tour — start here`}),(0,P.jsxs)(`p`,{className:`mt-1 text-xs t-secondary leading-relaxed max-w-2xl`,children:[e.length,` files form the structural backbone of this repo. Reading them in order gives you ~80% of the architecture in about`,` `,t,` minutes.`]})]}),(0,P.jsxs)(`div`,{className:`t-tertiary text-[10px] uppercase tracking-wider shrink-0`,children:[n+1,` / `,e.length]})]}),(0,P.jsx)(`div`,{className:`flex gap-1.5 mb-4 overflow-x-auto custom-scrollbar pb-1`,children:e.map((e,t)=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`shrink-0 px-3 py-1.5 rounded-md text-xs transition-colors ${t===n?`bg-violet-500/30 text-violet-100 font-medium`:`bg-surface-overlay/40 text-muted-foreground hover:text-foreground`}`,children:[(0,P.jsxs)(`span`,{className:`text-[10px] mr-1.5 opacity-60`,children:[`#`,e.rank]}),e.name]},e.key))}),i&&(0,P.jsxs)(`div`,{className:`rounded-lg bg-surface-overlay/40 border border-border-subtle p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 mb-1`,children:[(0,P.jsx)(`div`,{className:`font-mono text-sm text-foreground-emphasis truncate`,children:i.name}),(0,P.jsx)(`span`,{className:`text-[10px] t-tertiary uppercase tracking-wider shrink-0`,children:i.kind})]}),(0,P.jsx)(`div`,{className:`t-tertiary text-[11px] font-mono truncate mb-2`,children:i.file_path}),(0,P.jsx)(`p`,{className:`text-xs t-secondary leading-relaxed`,children:i.why}),(0,P.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>a(i.key),className:`text-xs text-violet-400 hover:text-violet-300 transition-colors font-medium`,children:`Open in graph →`}),n>0&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>r(e=>e-1),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:`← Prev`}),n<e.length-1&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>r(e=>e+1),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:`Next →`})]})]})]})}function Un({efficiency:e,intents:t,hotspots:n}){let r=e?.savedTokens??0,i=new Set(n.map(e=>e.key)),a=new Set;if(t)for(let e of t)for(let t of e.entitiesModified??[])i.has(t)&&a.add(t);return r>0||a.size>0?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2 rounded-lg border border-violet-500/20 bg-violet-500/5 px-4 py-2.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`t-tertiary uppercase tracking-wider text-[10px]`,children:`This session`}),a.size>0&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(`section-risk-hotspots`)?.scrollIntoView({behavior:`smooth`,block:`start`}),className:`flex items-center gap-1.5 text-foreground hover:text-violet-300 transition-colors`,children:[(0,P.jsx)(`span`,{className:`text-amber-400 font-semibold`,children:a.size}),(0,P.jsxs)(`span`,{children:[`hotspot`,a.size===1?``:`s`,` touched`]}),(0,P.jsx)(`span`,{className:`text-violet-400`,children:`→`})]}),r>0&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>ft(`reasoning`),className:`flex items-center gap-1.5 text-foreground hover:text-cyan-300 transition-colors`,children:[(0,P.jsx)(`span`,{className:`text-emerald-400 font-semibold`,children:(e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e))(r)}),(0,P.jsx)(`span`,{children:`tokens saved today`}),(0,P.jsx)(`span`,{className:`text-cyan-400`,children:`→`})]})]}):null}var Wn=[271,195,140,25,320,50,170,240,0,90,210,300,60,150,30,280];function Gn(e){return`hsl(${Wn[e%Wn.length]}, ${e%3==0?70:e%3==1?85:60}%, 62%)`}function Kn(e){return`hsl(${Wn[e%Wn.length]}, ${e%3==0?70:e%3==1?85:60}%, 42%)`}function qn(e){return`hsl(${Wn[e%Wn.length]}, 60%, 20%)`}var Jn=`hsl(160, 40%, 45%)`,Yn=`hsl(160, 40%, 30%)`,Xn={fetching:`Fetching graph data…`,building:`Building graph layout…`,done:``},Zn=`cluster:filecommunity:`,Qn=`cluster:file:`;function $n(e){return`${Zn}${e}`}function er(e){return`${Qn}${e}`}function tr(e){return Number.parseInt(e.replace(Zn,``),10)}function nr(e){return e.replace(Qn,``)}function rr(e){return e.split(`/`).pop()??e}var ir=`unerr:graph-positions`;function ar(){try{let e=localStorage.getItem(ir);return e?JSON.parse(e):null}catch{return null}}function or(e){try{localStorage.setItem(ir,JSON.stringify(e))}catch{}}var sr=100;function cr(e,t){let n=e.filter(e=>t.has(e.from)&&t.has(e.to));if(n.length<=sr)return n;let r={calls:3,tests:2,imports:1};return[...n].sort((e,t)=>(r[t.type]??0)-(r[e.type]??0)).slice(0,sr)}function lr(){let e=(0,N.useRef)(null),t=(0,N.useRef)(null),n=(0,N.useRef)(null),a=(0,N.useRef)(null),s=(0,N.useRef)(null),[c,l]=(0,N.useState)(null),[u,d]=(0,N.useState)(null),[f,p]=(0,N.useState)([]),[m,h]=(0,N.useState)(``),[g,_]=(0,N.useState)(`L0`),[v,y]=(0,N.useState)(null),[b,x]=(0,N.useState)(null),[S,C]=(0,N.useState)([{label:`All Clusters`,level:`L0`}]),[w,T]=(0,N.useState)(`fetching`),[ee,te]=(0,N.useState)(0),{url:E,queryKey:ne}=I(),{data:D,isLoading:re,isError:ie}=F({queryKey:ne([`intelligence`,`graph-visual`]),queryFn:()=>o(E(`/api/intelligence/graph-visual`))});(0,N.useEffect)(()=>{D&&w===`fetching`?T(`building`):re&&T(`fetching`)},[D,re,w]),(0,N.useEffect)(()=>{if(!D?.data||!e.current)return;n.current&&=(n.current.destroy(),null);let{nodes:t,edges:o,fileNodes:c,fileEdges:u,fileCommunities:f,positions:m}=D.data,h=D._meta.view_mode;if(t.length===0){T(`done`);return}let g=m&&Object.keys(m.files).length>0?m:ar()??{communities:{},files:{},entities:{}};m&&Object.keys(m.files).length>0&&or(m);let v=Math.max(...t.map(e=>e.fanIn+e.fanOut),1),b=t.map(e=>{let t=e.fanIn+e.fanOut,n=e.members??0,r=8+t/v*28+(n>0?Math.min(n*2,12):0),i=e.isTest===!0,a=c.find(t=>t.filePath===e.file)?.fileCommunity??0,o=i?Jn:Gn(a),s=i?Yn:Kn(a),l=t>v*.1||n>3,u=n>0?` (${n})`:``,d=e.externalOut>0?` ↗${e.externalOut}`:``,f=g.entities[e.id];return{id:e.id,label:l?`${e.label}${u}${d}`:``,title:`${e.label}\n${e.kind}${n>0?` · ${n} members`:``}\n${e.file}\nfan_in: ${e.fanIn} fan_out: ${e.fanOut}\nrisk: ${e.risk}${e.externalOut>0?`\n↗ ${e.externalOut} cross-cluster`:``}`,size:r,shape:i?`diamond`:`dot`,color:{background:o,border:s,highlight:{background:o,border:`#fafafa`},hover:{background:o,border:`#fafafa`}},font:{color:`rgba(250, 250, 250, 0.85)`,size:Math.max(10,r*.7),face:`JetBrains Mono, monospace`},borderWidth:n>0?3:2,borderWidthSelected:3,x:f?.x,y:f?.y,filePath:e.file,fileCommunity:a,_raw:e}}),S=new Map(t.map(e=>[e.id,e])),w=cr(o,new Set(t.map(e=>e.id))).map((e,t)=>{let n=S.get(e.from),r=c.find(e=>e.filePath===n?.file),i=r?Gn(r.fileCommunity):`#8B5CF6`;return{id:`e-${t}`,from:e.from,to:e.to,title:e.type,color:{color:i,opacity:.25,highlight:i,hover:i},width:e.type===`calls`?1.5:1,smooth:{type:`continuous`,roundness:.3},arrows:{to:{enabled:!0,scaleFactor:.4}},font:{color:`rgba(250, 250, 250, 0.3)`,size:8,face:`JetBrains Mono, monospace`,strokeWidth:0}}}),ee=new i(b),te=new i(w);a.current=ee,s.current=te;let E=new r(e.current,{nodes:ee,edges:te},{physics:{enabled:!1},interaction:{hover:!0,tooltipDelay:150,zoomView:!0,dragView:!0,multiselect:!1},nodes:{shape:`dot`},edges:{selectionWidth:2}});n.current=E;function ne(){for(let e of c){if(t.filter(t=>t.file===e.filePath).length===0)continue;let n=g.files[e.filePath];E.cluster({joinCondition:t=>t.filePath===e.filePath,clusterNodeProperties:{id:er(e.filePath),label:`${e.label}\n(${e.entityCount})`,title:`${e.filePath}\n${e.entityCount} entities\nfan_in: ${e.totalFanIn} fan_out: ${e.totalFanOut}\nrisk: ${e.maxRisk}`,shape:`box`,size:15+Math.min(e.entityCount*3,30),x:n?.x,y:n?.y,color:{background:qn(e.fileCommunity),border:Gn(e.fileCommunity),highlight:{background:qn(e.fileCommunity),border:`#fafafa`},hover:{background:qn(e.fileCommunity),border:`#fafafa`}},font:{color:`rgba(250, 250, 250, 0.9)`,size:11,face:`JetBrains Mono, monospace`,multi:!0},borderWidth:2,borderWidthSelected:3,fileCommunity:e.fileCommunity,_fileNode:e},clusterEdgeProperties:{color:{inherit:`both`,opacity:.35}}})}for(let e of f){let t=g.communities[e.id];E.cluster({joinCondition:t=>t.fileCommunity===e.id,clusterNodeProperties:{id:$n(e.id),label:`${e.label}\n(${e.fileCount} files)`,title:`${e.label}\n${e.fileCount} files · ${e.entityCount} entities\nCohesion: ${Math.round(e.cohesion*100)}%`,shape:`dot`,size:25+Math.min(e.fileCount*4,45),x:t?.x,y:t?.y,color:{background:qn(e.id),border:Gn(e.id),highlight:{background:qn(e.id),border:`#fafafa`},hover:{background:qn(e.id),border:`#fafafa`}},font:{color:Gn(e.id),size:14,face:`Space Grotesk, sans-serif`,bold:{color:`#fafafa`},multi:!0},borderWidth:e.cohesion>.5?3:2,borderWidthSelected:4,shapeProperties:{borderDashes:e.cohesion<.3?[5,5]:!1}},clusterEdgeProperties:{color:{inherit:`both`,opacity:.4},smooth:{type:`continuous`,roundness:.5}}})}}function re(e){let n=e===void 0?c:c.filter(t=>t.fileCommunity===e);for(let r of n){if(t.filter(e=>e.file===r.filePath).length<2)continue;let n=g.files[r.filePath];E.cluster({joinCondition:t=>e!==void 0&&t.fileCommunity!==e?!1:t.filePath===r.filePath,clusterNodeProperties:{id:er(r.filePath),label:`${r.label}\n(${r.entityCount})`,title:`${r.filePath}\n${r.entityCount} entities`,shape:`box`,size:15+Math.min(r.entityCount*3,25),x:n?.x,y:n?.y,color:{background:qn(r.fileCommunity),border:Gn(r.fileCommunity),highlight:{background:qn(r.fileCommunity),border:`#fafafa`},hover:{background:qn(r.fileCommunity),border:`#fafafa`}},font:{color:`rgba(250, 250, 250, 0.9)`,size:11,face:`JetBrains Mono, monospace`,multi:!0},borderWidth:2,borderWidthSelected:3,fileCommunity:r.fileCommunity,_fileNode:r},clusterEdgeProperties:{color:{inherit:`both`,opacity:.35}}})}}h===`hierarchical`?(ne(),_(`L0`),C([{label:`All Clusters`,level:`L0`}])):h===`file-clusters`?(re(),_(`L1`),C([{label:`All Files`,level:`L1`}])):(_(`L2`),C([{label:`Flat View`,level:`L2`}])),E.setOptions({physics:{enabled:!0,solver:`forceAtlas2Based`,forceAtlas2Based:{gravitationalConstant:-60,centralGravity:.008,springLength:120,springConstant:.06,damping:.8,avoidOverlap:.3},stabilization:!1}}),E.stabilize(80),E.on(`doubleClick`,e=>{let t=e.nodes?.[0];if(t&&E.isCluster(t)){let e=String(t).startsWith(Zn),n=String(t).startsWith(Qn);if(E.openCluster(t,{releaseFunction:(e,t)=>{let n=Object.keys(t),r=n.length,i=Math.max(80,r*12),a={};return n.forEach((t,n)=>{let o=g.files[t]??g.entities[t];if(o)a[t]={x:e.x+o.x*.5,y:e.y+o.y*.5};else{let o=2*Math.PI*n/r;a[t]={x:e.x+i*Math.cos(o),y:e.y+i*Math.sin(o)}}}),a}}),E.setOptions({physics:{enabled:!0,solver:`forceAtlas2Based`,forceAtlas2Based:{damping:.85,gravitationalConstant:-40},stabilization:{enabled:!1}}}),setTimeout(()=>{E.setOptions({physics:{enabled:!1}})},1500),e){let e=tr(t);_(`L1`),y(e),x(null),C([{label:`All Clusters`,level:`L0`},{label:f.find(t=>t.id===e)?.label||`Cluster ${e}`,level:`L1`,communityId:e}])}else if(n){let e=nr(t);_(`L2`),x(e),C(t=>[...t.slice(0,t.length>1?2:1),{label:rr(e),level:`L2`,file:e}])}setTimeout(()=>{E.fit({animation:{duration:600,easingFunction:`easeInOutQuad`}})},200)}}),E.on(`selectNode`,e=>{let n=e.nodes[0];if(E.isCluster(n)){if(String(n).startsWith(Qn)){let e=nr(n),t=c.find(t=>t.filePath===e);t&&(d(t),l(null))}return}let r=t.find(e=>e.id===n);if(r){l(r),d(null);let e=o.filter(e=>e.from===n||e.to===n),i=new Set(e.map(e=>e.from===n?e.to:e.from));p(t.filter(e=>i.has(e.id)).slice(0,20))}}),E.on(`deselectNode`,()=>{l(null),d(null),p([])});let ie=!1,k=()=>{ie||(ie=!0,E.setOptions({physics:{enabled:!1}}),T(`done`),O())};E.on(`stabilizationIterationsDone`,k);let ae=setTimeout(k,3e3);return E.on(`zoom`,()=>O()),E.on(`dragEnd`,()=>O()),T(`building`),()=>{clearTimeout(ae),E.destroy(),n.current=null,a.current=null,s.current=null}},[D,ee]);let O=(0,N.useCallback)(()=>{let r=t.current,i=n.current;if(!r||!i)return;let a=r.getContext(`2d`);if(!a)return;let o=r.width,s=r.height;a.clearRect(0,0,o,s);let c=i.getPositions(),l=Object.values(c);if(l.length===0)return;let u=1/0,d=-1/0,f=1/0,p=-1/0;for(let e of l)e.x<u&&(u=e.x),e.x>d&&(d=e.x),e.y<f&&(f=e.y),e.y>p&&(p=e.y);let m=d-u||1,h=p-f||1;a.fillStyle=`rgba(139, 92, 246, 0.5)`;for(let e of l){let t=10+(e.x-u)/m*(o-20),n=10+(e.y-f)/h*(s-20);a.beginPath(),a.arc(t,n,1.5,0,Math.PI*2),a.fill()}try{let t=i.getViewPosition(),n=i.getScale(),r=e.current;if(r&&t){let e=r.clientWidth/n,i=r.clientHeight/n,c=10+(t.x-e/2-u)/m*(o-20),l=10+(t.y-i/2-f)/h*(s-20),d=e/m*(o-20),p=i/h*(s-20);a.strokeStyle=`rgba(250, 250, 250, 0.6)`,a.lineWidth=1,a.strokeRect(c,l,d,p)}}catch{}},[]),k=(0,N.useCallback)(e=>{if(!n.current||!D?.data)return;let{fileCommunities:t,fileNodes:r,nodes:i}=D.data;e.level===`L0`?(_(`L0`),y(null),x(null),C([{label:`All Clusters`,level:`L0`}])):e.level===`L1`&&e.communityId!=null&&(_(`L1`),y(e.communityId),x(null),C([{label:`All Clusters`,level:`L0`},{label:e.label,level:`L1`,communityId:e.communityId}])),T(`building`),te(e=>e+1)},[D]);(0,N.useEffect)(()=>{function e(e){if(e.key===`Escape`&&S.length>1){let e=S[S.length-2];k(e)}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,k]);let ae=(0,N.useCallback)(e=>{if(h(e),!n.current||!D?.data||e.length<2)return;let t=e.toLowerCase(),r=D.data.nodes.find(e=>e.label.toLowerCase().includes(t)),i=D.data.fileNodes.find(e=>e.label.toLowerCase().includes(t)||e.filePath.toLowerCase().includes(t)),a=r?.id??(i?er(i.filePath):null);if(a&&n.current){let e=n.current.findNode(a);if(e&&e.length>1)for(let t=0;t<e.length-1;t++){let r=e[t];n.current.isCluster(r)&&n.current.openCluster(r)}n.current.selectNodes([a]),n.current.focus(a,{scale:1.5,animation:{duration:600,easingFunction:`easeInOutQuad`}}),r?(l(r),d(null)):i&&(d(i),l(null))}},[D]),oe=(0,N.useCallback)(()=>{if(!e.current)return;let t=e.current.querySelector(`canvas`);if(!t)return;let n=document.createElement(`canvas`);n.width=t.width,n.height=t.height;let r=n.getContext(`2d`);if(!r)return;r.drawImage(t,0,0);let i=document.createElement(`a`);i.download=`unerr-codebase-map.png`,i.href=n.toDataURL(`image/png`),i.click()},[]),se=D?.data?.nodes.length??0;D?.data?.edges.length;let ce=D?._meta,A=ce?.file_count??0,j=ce?.file_edge_count??0,le=ce?.collapsed_count??0,ue=ce?.total_entities??0,M=D?.data?.fileCommunities??[],de=ce?.view_mode??`flat`,fe=w!==`done`&&!ie;return(0,P.jsxs)(`div`,{className:`flex h-[calc(100vh-73px)] flex-col gap-0 overflow-hidden lg:flex-row`,children:[(0,P.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border-subtle bg-surface/80 px-4 py-2 backdrop-blur`,children:[(0,P.jsx)(`nav`,{className:`flex items-center gap-1 text-xs`,children:S.map((e,t)=>(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,P.jsx)(`span`,{className:`t-ghost`,children:`›`}),t<S.length-1?(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(e),className:`rounded px-1.5 py-0.5 text-violet-400 transition hover:bg-violet-500/10 hover:text-violet-300`,children:e.label}):(0,P.jsx)(`span`,{className:`px-1.5 py-0.5 text-foreground font-medium`,children:e.label})]},`${e.level}-${e.communityId??e.file??`root`}`))}),(0,P.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border-subtle`}),(0,P.jsx)(`input`,{type:`search`,value:m,onChange:e=>ae(e.target.value),placeholder:`Search files & entities...`,className:`w-48 rounded-lg border border-border bg-background px-3 py-1.5 font-mono text-sm text-foreground outline-none ring-violet-500 placeholder:t-tertiary focus:ring-2 focus:border-violet-500`}),(0,P.jsx)(`div`,{className:`flex-1`}),(0,P.jsxs)(`span`,{className:`font-mono text-xs t-tertiary`,children:[A,` files · `,se,` entities`,de!==`flat`&&(0,P.jsx)(`span`,{className:`ml-2 rounded bg-violet-500/10 px-1.5 py-0.5 text-violet-400`,children:g===`L0`?`Clusters`:g===`L1`?`Files`:`Entities`})]}),S.length>1&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(S[S.length-2]),className:`rounded-lg border border-border-subtle el-raised px-3 py-1.5 text-xs font-medium text-foreground transition hover:el-overlay hover:border-violet-500`,title:`Zoom out (Esc)`,children:`↑ Up`}),(0,P.jsx)(`button`,{type:`button`,onClick:oe,className:`rounded-lg border border-border-subtle el-raised px-3 py-1.5 text-xs font-medium text-foreground transition hover:el-overlay hover:border-violet-500`,children:`Export PNG`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>n.current?.fit({animation:!0}),className:`rounded-lg border border-border-subtle el-raised px-3 py-1.5 text-xs font-medium text-foreground transition hover:el-overlay hover:border-violet-500`,children:`Fit`})]}),(0,P.jsxs)(`div`,{className:`relative flex-1 bg-background`,children:[fe&&(0,P.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-4 rounded-xl border border-border-subtle bg-surface-default/95 px-10 py-8 shadow-2xl backdrop-blur-sm`,children:[(0,P.jsxs)(`svg`,{"aria-hidden":`true`,className:`h-12 w-12 animate-spin`,viewBox:`0 0 48 48`,fill:`none`,children:[(0,P.jsx)(`circle`,{cx:`24`,cy:`24`,r:`20`,stroke:`rgba(255,255,255,0.06)`,strokeWidth:`5`}),(0,P.jsx)(`path`,{d:`M24 4 A20 20 0 0 1 41.32 34`,stroke:`#8B5CF6`,strokeWidth:`5`,strokeLinecap:`round`}),(0,P.jsx)(`path`,{d:`M41.32 34 A20 20 0 0 1 14 40.64`,stroke:`#22D3EE`,strokeWidth:`5`,strokeLinecap:`round`}),(0,P.jsx)(`path`,{d:`M14 40.64 A20 20 0 0 1 6.06 17.1`,stroke:`#34D399`,strokeWidth:`5`,strokeLinecap:`round`})]}),(0,P.jsx)(`p`,{className:`font-mono text-sm text-foreground font-medium`,children:Xn[w]}),se>0&&(0,P.jsxs)(`p`,{className:`font-mono text-[11px] t-tertiary`,children:[A,` files · `,se,` entities`]})]})}),ie&&(0,P.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center`,children:(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl p-8 text-center`,children:[(0,P.jsx)(`p`,{className:`text-error text-sm font-medium`,children:`Graph unavailable`}),(0,P.jsxs)(`p`,{className:`mt-2 t-secondary text-xs`,children:[`Intelligence graph not loaded. Run`,` `,(0,P.jsx)(`code`,{className:`rounded el-substrate px-1.5 py-0.5 font-mono`,children:`unerr`}),` `,`in your project to index.`]})]})}),!re&&!ie&&se===0&&(0,P.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center`,children:(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl p-8 text-center`,children:[(0,P.jsx)(`p`,{className:`text-foreground text-sm font-medium`,children:`No entities found`}),(0,P.jsx)(`p`,{className:`mt-2 t-secondary text-xs`,children:`The graph will appear once the project is indexed.`})]})}),(0,P.jsx)(`div`,{ref:e,className:`absolute inset-0`,style:{opacity:w===`done`?1:w===`building`?.4:.2,transition:`opacity 0.8s ease`}}),w===`done`&&(0,P.jsx)(`div`,{className:`absolute bottom-4 left-4 rounded-lg border border-border-subtle bg-surface-default/90 p-1 backdrop-blur-sm`,children:(0,P.jsx)(`canvas`,{ref:t,width:160,height:100,className:`rounded`,style:{background:`rgba(0,0,0,0.3)`}})}),w===`done`&&g===`L0`&&de===`hierarchical`&&(0,P.jsx)(`div`,{className:`pointer-events-none absolute bottom-4 right-4 rounded-lg border border-border-subtle bg-surface-default/90 px-3 py-2 backdrop-blur-sm`,children:(0,P.jsx)(`p`,{className:`font-mono text-[10px] t-secondary`,children:`Double-click a cluster to explore its files`})})]})]}),(0,P.jsx)(`aside`,{className:`w-full shrink-0 overflow-y-auto border-t border-border-subtle glass-panel lg:w-80 lg:border-t-0 lg:border-l`,children:(0,P.jsxs)(`div`,{className:`p-4`,children:[c?(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`section-label text-violet-500`,children:`Selected entity`}),(0,P.jsxs)(`div`,{className:`mt-2 rounded-lg el-raised p-3`,children:[(0,P.jsx)(`div`,{className:`font-mono text-live text-sm font-medium`,children:c.label}),(0,P.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:c.kind}),(c.members??0)>0&&(0,P.jsxs)(`span`,{className:`rounded bg-violet-500/15 px-1.5 py-0.5 font-mono text-[10px] font-medium text-violet-400`,children:[c.members,` members`]}),c.isTest&&(0,P.jsx)(`span`,{className:`rounded bg-emerald-500/15 px-1.5 py-0.5 font-mono text-[10px] font-medium text-emerald-400`,children:`test`})]}),(0,P.jsx)(`div`,{className:`mt-1 truncate t-tertiary text-xs`,children:c.file}),(0,P.jsxs)(`div`,{className:`mt-2 flex gap-3 text-xs`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`t-secondary`,children:`in`}),` `,(0,P.jsx)(`span`,{className:`font-mono text-live`,children:c.fanIn})]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`t-secondary`,children:`out`}),` `,(0,P.jsx)(`span`,{className:`font-mono text-live`,children:c.fanOut})]}),(0,P.jsx)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-[10px] font-medium ${c.risk===`critical`?`bg-error/15 text-error`:c.risk===`high`?`bg-warning/15 text-warning`:c.risk===`medium`?`bg-violet-500/15 text-violet-500`:`bg-success/15 text-success`}`,children:c.risk})]})]})]}),(c.externalOut>0||c.externalIn>0)&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`section-label t-secondary`,children:`Cross-cluster`}),(0,P.jsxs)(`div`,{className:`mt-2 flex gap-4 text-xs`,children:[c.externalOut>0&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`text-warning`,children:`↗`}),(0,P.jsx)(`span`,{className:`font-mono text-live`,children:c.externalOut}),(0,P.jsx)(`span`,{className:`t-tertiary`,children:`outbound`})]}),c.externalIn>0&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`text-info`,children:`↙`}),(0,P.jsx)(`span`,{className:`font-mono text-live`,children:c.externalIn}),(0,P.jsx)(`span`,{className:`t-tertiary`,children:`inbound`})]})]})]}),v!=null&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`section-label t-secondary`,children:`Location`}),(0,P.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:Gn(v)}}),(0,P.jsx)(`span`,{className:`text-foreground`,children:M.find(e=>e.id===v)?.label||`Cluster ${v}`})]}),M.find(e=>e.id===v)?.cohesion!=null&&(0,P.jsxs)(`div`,{className:`mt-1 t-tertiary`,children:[`Cohesion:`,` `,Math.round((M.find(e=>e.id===v)?.cohesion??0)*100),`%`]})]})]}),f.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h3`,{className:`section-label t-secondary`,children:[`Connected (`,f.length,`)`]}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-48 space-y-1 overflow-auto custom-scrollbar`,children:f.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{n.current&&(n.current.selectNodes([e.id]),n.current.focus(e.id,{scale:1.5,animation:{duration:400,easingFunction:`easeInOutQuad`}})),l(e)},className:`w-full rounded px-2 py-1 text-left text-xs transition hover:el-raised`,children:[(0,P.jsx)(`span`,{className:`font-mono text-live`,children:e.label}),(0,P.jsxs)(`span`,{className:`t-tertiary`,children:[` `,`· `,rr(e.file)]})]})},e.id))})]})]}):u?(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`section-label text-violet-500`,children:`Selected file`}),(0,P.jsxs)(`div`,{className:`mt-2 rounded-lg el-raised p-3`,children:[(0,P.jsx)(`div`,{className:`font-mono text-live text-sm font-medium`,children:u.label}),(0,P.jsx)(`div`,{className:`mt-1 truncate t-tertiary text-xs`,children:u.filePath}),(0,P.jsxs)(`div`,{className:`mt-2 flex gap-3 text-xs flex-wrap`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`t-secondary`,children:`entities`}),` `,(0,P.jsx)(`span`,{className:`font-mono text-live`,children:u.entityCount})]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`t-secondary`,children:`fan_in`}),` `,(0,P.jsx)(`span`,{className:`font-mono text-live`,children:u.totalFanIn})]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`t-secondary`,children:`fan_out`}),` `,(0,P.jsx)(`span`,{className:`font-mono text-live`,children:u.totalFanOut})]}),(0,P.jsx)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-[10px] font-medium ${u.maxRisk===`high`?`bg-warning/15 text-warning`:u.maxRisk===`medium`?`bg-violet-500/15 text-violet-500`:`bg-success/15 text-success`}`,children:u.maxRisk})]}),(0,P.jsx)(`div`,{className:`mt-2 flex gap-2 flex-wrap`,children:Object.entries(u.kinds).map(([e,t])=>(0,P.jsxs)(`span`,{className:`rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[10px] t-secondary`,children:[e,`: `,t]},e))})]})]}),(u.externalOut>0||u.externalIn>0)&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`section-label t-secondary`,children:`Cross-cluster edges`}),(0,P.jsxs)(`div`,{className:`mt-2 flex gap-4 text-xs`,children:[u.externalOut>0&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`text-warning`,children:`↗`}),(0,P.jsx)(`span`,{className:`font-mono text-live`,children:u.externalOut}),(0,P.jsx)(`span`,{className:`t-tertiary`,children:`outbound`})]}),u.externalIn>0&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`text-info`,children:`↙`}),(0,P.jsx)(`span`,{className:`font-mono text-live`,children:u.externalIn}),(0,P.jsx)(`span`,{className:`t-tertiary`,children:`inbound`})]})]})]})]}):(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`section-label text-violet-500`,children:`Inspector`}),(0,P.jsx)(`p`,{className:`mt-3 t-secondary text-xs leading-relaxed`,children:g===`L0`?`Double-click a file cluster to explore its files. Click a node for details.`:g===`L1`?`Double-click a file to see its entities. Click a node for details.`:`Click a node to inspect its connections, risk level, and dependencies.`})]}),(0,P.jsxs)(`div`,{className:`mt-6`,children:[(0,P.jsx)(`h3`,{className:`section-label t-secondary`,children:`File Clusters`}),(0,P.jsxs)(`ul`,{className:`mt-2 max-h-40 space-y-1 overflow-auto custom-scrollbar`,children:[M.slice(0,16).map(e=>(0,P.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,P.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-full`,style:{backgroundColor:Gn(e.id)}}),(0,P.jsx)(`span`,{className:`truncate text-foreground`,children:e.label}),(0,P.jsxs)(`span`,{className:`ml-auto tabular-nums t-tertiary`,children:[e.fileCount,`f`]}),e.cohesion<.3&&(0,P.jsx)(`span`,{className:`text-warning text-[10px]`,title:`Low cohesion`,children:`!`})]},e.id)),(0,P.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,P.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rotate-45 rounded-sm`,style:{backgroundColor:Jn}}),(0,P.jsx)(`span`,{className:`text-foreground`,children:`Test files`}),(0,P.jsx)(`span`,{className:`ml-auto t-tertiary`,children:`◇`})]})]})]}),(0,P.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border-subtle el-raised p-3`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-secondary`,children:`Files`}),(0,P.jsx)(`div`,{className:`font-mono text-live text-lg tabular-nums`,children:A})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-secondary`,children:`File edges`}),(0,P.jsx)(`div`,{className:`font-mono text-live text-lg tabular-nums`,children:j})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-secondary`,children:`Clusters`}),(0,P.jsx)(`div`,{className:`font-mono text-live text-lg tabular-nums`,children:M.length})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`t-secondary`,children:`Entities`}),(0,P.jsx)(`div`,{className:`font-mono text-live text-lg tabular-nums`,children:ue})]})]}),le>0&&(0,P.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border-subtle t-tertiary text-[10px]`,children:[le,` child entities (methods, types, constructors) merged into parent nodes`]}),de!==`flat`&&(0,P.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border-subtle t-tertiary text-[10px]`,children:[`View:`,` `,de===`hierarchical`?`Hierarchical (L0→L1→L2)`:`File clusters`,` `,`· Level: `,g]})]})]})})]})}function ur(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var dr={},fr={};function pr(e,t){try{let n=(dr[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in fr?fr[n]:hr(n,n.split(`:`))}catch{if(e in fr)return fr[e];let t=e?.match(mr);return t?hr(e,t.slice(1)):NaN}}var mr=/([+-]\d\d):?(\d\d)?/;function hr(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return fr[e]=n*60+r>0?n*60+r+i:n*60-r-i}var gr=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(pr(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),br(this,NaN),vr(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-pr(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),vr(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},_r=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!_r.test(e))return;let t=e.replace(_r,`$1UTC`);gr.prototype[t]&&(e.startsWith(`get`)?gr.prototype[e]=function(){return this.internal[t]()}:(gr.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),yr(this),+this},gr.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),vr(this),+this}))});function vr(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-pr(e.timeZone,e)*60))}function yr(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),br(e)}function br(e){let t=pr(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=i- -new Date(+r).getTimezoneOffset(),o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=i-n;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=new Date(+e);c.setUTCSeconds(0);let l=i>0?c.getSeconds():(c.getSeconds()-60)%60,u=Math.round(-(pr(e.timeZone,e)*60))%60;(u||l)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+l));let d=pr(e.timeZone,e),f=d>0?Math.floor(d):Math.ceil(d),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,h=p-s;if(m&&h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+h);let t=pr(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var xr=class e extends gr{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${ur(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},Sr=365.2425,Cr=6048e5,wr=864e5,Tr=3600*24;Tr*7,Tr*Sr/12*3;var Er=Symbol.for(`constructDateFrom`);function Dr(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Er in e?e[Er](t):e instanceof Date?new e.constructor(t):new Date(t)}function L(e,t){return Dr(t||e,e)}function Or(e,t,n){let r=L(e,n?.in);return isNaN(t)?Dr(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function kr(e,t,n){let r=L(e,n?.in);if(isNaN(t))return Dr(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=Dr(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}var Ar={};function jr(){return Ar}function Mr(e,t){let n=jr(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=L(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function Nr(e,t){return Mr(e,{...t,weekStartsOn:1})}function Pr(e,t){let n=L(e,t?.in),r=n.getFullYear(),i=Dr(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=Nr(i),o=Dr(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=Nr(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function Fr(e){let t=L(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function Ir(e,...t){let n=Dr.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function Lr(e,t){let n=L(e,t?.in);return n.setHours(0,0,0,0),n}function Rr(e,t,n){let[r,i]=Ir(n?.in,e,t),a=Lr(r),o=Lr(i),s=+a-Fr(a),c=+o-Fr(o);return Math.round((s-c)/wr)}function zr(e,t){let n=Pr(e,t),r=Dr(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),Nr(r)}function Br(e,t,n){return Or(e,t*7,n)}function Vr(e,t,n){return kr(e,t*12,n)}function Hr(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=Dr.bind(null,e));let t=L(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),Dr(r,n||NaN)}function Ur(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=Dr.bind(null,e));let t=L(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),Dr(r,n||NaN)}function Wr(e,t,n){let[r,i]=Ir(n?.in,e,t);return+Lr(r)==+Lr(i)}function Gr(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Kr(e){return!(!Gr(e)&&typeof e!=`number`||isNaN(+L(e)))}function qr(e,t,n){let[r,i]=Ir(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function Jr(e,t){let n=L(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Yr(e,t){let[n,r]=Ir(e,t.start,t.end);return{start:n,end:r}}function Xr(e,t){let{start:n,end:r}=Yr(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(Dr(n,o)),o.setMonth(o.getMonth()+s);return i?c.reverse():c}function Zr(e,t){let n=L(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Qr(e,t){let n=L(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function $r(e,t){let n=L(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ei(e,t){let{start:n,end:r}=Yr(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setMonth(0,1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(Dr(n,o)),o.setFullYear(o.getFullYear()+s);return i?c.reverse():c}function ti(e,t){let n=jr(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=L(e,t?.in),a=i.getDay(),o=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function ni(e,t){return ti(e,{...t,weekStartsOn:1})}var ri={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},ii=(e,t,n)=>{let r,i=ri[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function ai(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var oi={date:ai({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:ai({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:ai({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},si={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},ci=(e,t,n,r)=>si[e];function li(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var ui={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:li({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:li({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:li({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:li({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:li({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function di(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?pi(s,e=>e.test(o)):fi(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function fi(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function pi(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function mi(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var hi={code:`en-US`,formatDistance:ii,formatLong:oi,formatRelative:ci,localize:ui,match:{ordinalNumber:mi({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:di({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:di({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:di({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:di({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:di({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function gi(e,t){let n=L(e,t?.in);return Rr(n,$r(n))+1}function _i(e,t){let n=L(e,t?.in),r=Nr(n)-+zr(n);return Math.round(r/Cr)+1}function vi(e,t){let n=L(e,t?.in),r=n.getFullYear(),i=jr(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=Dr(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Mr(o,t),c=Dr(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Mr(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function yi(e,t){let n=jr(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=vi(e,t),a=Dr(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Mr(a,t)}function bi(e,t){let n=L(e,t?.in),r=Mr(n,t)-+yi(n,t);return Math.round(r/Cr)+1}function R(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var xi={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return R(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):R(n+1,2)},d(e,t){return R(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return R(e.getHours()%12||12,t.length)},H(e,t){return R(e.getHours(),t.length)},m(e,t){return R(e.getMinutes(),t.length)},s(e,t){return R(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return R(Math.trunc(r*10**(n-3)),t.length)}},Si={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},Ci={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return xi.y(e,t)},Y:function(e,t,n,r){let i=vi(e,r),a=i>0?i:1-i;return t===`YY`?R(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):R(a,t.length)},R:function(e,t){return R(Pr(e),t.length)},u:function(e,t){return R(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return R(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return R(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return xi.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return R(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=bi(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):R(i,t.length)},I:function(e,t,n){let r=_i(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):R(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):xi.d(e,t)},D:function(e,t,n){let r=gi(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):R(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return R(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return R(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return R(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?Si.noon:r===0?Si.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?Si.evening:r>=12?Si.afternoon:r>=4?Si.morning:Si.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return xi.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):xi.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):R(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):R(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):xi.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):xi.s(e,t)},S:function(e,t){return xi.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Ti(r);case`XXXX`:case`XX`:return Ei(r);default:return Ei(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Ti(r);case`xxxx`:case`xx`:return Ei(r);default:return Ei(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+wi(r,`:`);default:return`GMT`+Ei(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+wi(r,`:`);default:return`GMT`+Ei(r,`:`)}},t:function(e,t,n){return R(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return R(+e,t.length)}};function wi(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+R(a,2)}function Ti(e,t){return e%60==0?(e>0?`-`:`+`)+R(Math.abs(e)/60,2):Ei(e,t)}function Ei(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=R(Math.trunc(r/60),2),a=R(r%60,2);return n+i+t+a}var Di=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Oi=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},ki={p:Oi,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Di(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Di(r,t)).replace(`{{time}}`,Oi(i,t))}},Ai=/^D+$/,ji=/^Y+$/,z=[`D`,`DD`,`YY`,`YYYY`];function B(e){return Ai.test(e)}function Mi(e){return ji.test(e)}function Ni(e,t,n){let r=Pi(e,t,n);if(console.warn(r),z.includes(e))throw RangeError(r)}function Pi(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var Fi=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ii=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Li=/^'([^]*?)'?$/,Ri=/''/g,zi=/[a-zA-Z]/;function Bi(e,t,n){let r=jr(),i=n?.locale??r.locale??hi,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=L(e,n?.in);if(!Kr(s))throw RangeError(`Invalid time value`);let c=t.match(Ii).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=ki[t];return n(e,i.formatLong)}return e}).join(``).match(Fi).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:Vi(e)};if(Ci[t])return{isToken:!0,value:e};if(t.match(zi))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&Mi(a)||!n?.useAdditionalDayOfYearTokens&&B(a))&&Ni(a,t,String(e));let o=Ci[a[0]];return o(s,a,i.localize,l)}).join(``)}function Vi(e){let t=e.match(Li);return t?t[1].replace(Ri,`'`):e}function Hi(e,t){let n=L(e,t?.in),r=n.getFullYear(),i=n.getMonth(),a=Dr(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function Ui(e,t){return L(e,t?.in).getMonth()}function Wi(e,t){return L(e,t?.in).getFullYear()}function Gi(e,t){return+L(e)>+L(t)}function Ki(e,t){return+L(e)<+L(t)}function qi(e,t,n){let[r,i]=Ir(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function Ji(e,t,n){let[r,i]=Ir(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function Yi(e,t,n){let r=L(e,n?.in),i=r.getFullYear(),a=r.getDate(),o=Dr(n?.in||e,0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);let s=Hi(o);return r.setMonth(t,Math.min(a,s)),r}function Xi(e,t,n){let r=L(e,n?.in);return isNaN(+r)?Dr(n?.in||e,NaN):(r.setFullYear(t),r)}var Zi=5,Qi=4;function $i(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,Zi*7-1);return t.getMonth(e)===t.getMonth(a)?Zi:Qi}function ea(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function ta(e,t){let n=ea(e,t),r=$i(e,t);return t.addDays(n,r*7-1)}var na={...hi,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>Bi(e,t,{locale:hi,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>Bi(e,n,{locale:hi,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>Bi(e,t,{locale:hi,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>Bi(e,n,{locale:hi,...t}),r(e,`cccc`)}}},ra=class e{constructor(e,t){this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?xr.tz(this.options.timeZone):new(this.options.Date??Date),this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new xr(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):Or(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):kr(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):Br(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):Vr(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):Rr(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):qr(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):Xr(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):ei(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):ta(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):ni(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):Jr(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):ti(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):Qr(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):Bi(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):_i(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):Ui(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):Wi(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):bi(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):Gi(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):Ki(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):Gr(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):Wr(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):qi(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):Ji(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):Hr(e),this.min=e=>this.overrides?.min?this.overrides.min(e):Ur(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):Yi(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):Xi(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):ea(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):Lr(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):Nr(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):Zr(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):Mr(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):$r(e),this.options={locale:na,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};ra.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var V=new ra,ia=class{constructor(e,t,n=V){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},aa=class{constructor(e,t){this.date=e,this.weeks=t}},oa=class{constructor(e,t){this.days=t,this.weekNumber=e}};function sa(e){return N.createElement(`span`,{...e})}function ca(e){let{size:t=24,orientation:n=`left`,className:r}=e;return N.createElement(`svg`,{className:r,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&N.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&N.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&N.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&N.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function la(e){let{day:t,modifiers:n,...r}=e;return N.createElement(`td`,{...r})}function ua(e){let{day:t,modifiers:n,...r}=e,i=N.useRef(null);return N.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),N.createElement(`button`,{ref:i,...r})}var H;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})(H||={});var da;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(da||={});var fa;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(fa||={});var pa;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(pa||={});var ma=(0,N.createContext)(void 0);function ha(){let e=(0,N.useContext)(ma);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function ga(e){let{options:t,className:n,...r}=e,{classNames:i,components:a}=ha(),o=[i[H.Dropdown],n].join(` `),s=t?.find(({value:e})=>e===r.value);return N.createElement(`span`,{"data-disabled":r.disabled,className:i[H.DropdownRoot]},N.createElement(a.Select,{className:o,...r},t?.map(({value:e,label:t,disabled:n})=>N.createElement(a.Option,{key:e,value:e,disabled:n},t))),N.createElement(`span`,{className:i[H.CaptionLabel],"aria-hidden":!0},s?.label,N.createElement(a.Chevron,{orientation:`down`,size:18,className:i[H.Chevron]})))}function _a(e){return N.createElement(`div`,{...e})}function va(e){return N.createElement(`div`,{...e})}function ya(e){let{calendarMonth:t,displayIndex:n,...r}=e;return N.createElement(`div`,{...r},e.children)}function ba(e){let{calendarMonth:t,displayIndex:n,...r}=e;return N.createElement(`div`,{...r})}function xa(e){return N.createElement(`table`,{...e})}function Sa(e){return N.createElement(`div`,{...e})}function Ca(e){let{components:t}=ha();return N.createElement(t.Dropdown,{...e})}function wa(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,labels:{labelPrevious:c,labelNext:l}}=ha(),u=(0,N.useCallback)(e=>{i&&n?.(e)},[i,n]),d=(0,N.useCallback)(e=>{r&&t?.(e)},[r,t]);return N.createElement(`nav`,{...a},N.createElement(o.PreviousMonthButton,{type:`button`,className:s[H.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:d},N.createElement(o.Chevron,{disabled:r?void 0:!0,className:s[H.Chevron],orientation:`left`})),N.createElement(o.NextMonthButton,{type:`button`,className:s[H.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":l(i),onClick:u},N.createElement(o.Chevron,{disabled:i?void 0:!0,orientation:`right`,className:s[H.Chevron]})))}function Ta(e){return N.createElement(`button`,{...e})}function Ea(e){return N.createElement(`option`,{...e})}function Da(e){return N.createElement(`button`,{...e})}function Oa(e){let{rootRef:t,...n}=e;return N.createElement(`div`,{...n,ref:t})}function ka(e){return N.createElement(`select`,{...e})}function Aa(e){let{week:t,...n}=e;return N.createElement(`tr`,{...n})}function ja(e){return N.createElement(`th`,{...e})}function Ma(e){return N.createElement(`thead`,{"aria-hidden":!0},N.createElement(`tr`,{...e}))}function Na(e){let{week:t,...n}=e;return N.createElement(`th`,{...n})}function Pa(e){return N.createElement(`th`,{...e})}function Fa(e){return N.createElement(`tbody`,{...e})}function Ia(e){let{components:t}=ha();return N.createElement(t.Dropdown,{...e})}var La=e({CaptionLabel:()=>sa,Chevron:()=>ca,Day:()=>la,DayButton:()=>ua,Dropdown:()=>ga,DropdownNav:()=>_a,Footer:()=>va,Month:()=>ya,MonthCaption:()=>ba,MonthGrid:()=>xa,Months:()=>Sa,MonthsDropdown:()=>Ca,Nav:()=>wa,NextMonthButton:()=>Ta,Option:()=>Ea,PreviousMonthButton:()=>Da,Root:()=>Oa,Select:()=>ka,Week:()=>Aa,WeekNumber:()=>Na,WeekNumberHeader:()=>Pa,Weekday:()=>ja,Weekdays:()=>Ma,Weeks:()=>Fa,YearsDropdown:()=>Ia});function Ra(e,t,n=!1,r=V){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function za(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function Ba(e){return!!(e&&typeof e==`object`&&`from`in e)}function Va(e){return!!(e&&typeof e==`object`&&`after`in e)}function Ha(e){return!!(e&&typeof e==`object`&&`before`in e)}function Ua(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function Wa(e,t){return Array.isArray(e)&&e.every(t.isDate)}function Ga(e,t,n=V){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(Wa(t,n))return t.some(t=>i(e,t));if(Ba(t))return Ra(t,e,!1,n);if(Ua(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(za(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return Va(t)?a(e,t.after)>0:Ha(t)?a(t.before,e)>0:typeof t==`function`?t(e):!1})}function Ka(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[da.focused]:[],[da.outside]:[],[da.disabled]:[],[da.hidden]:[],[da.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!!(n&&!f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&Ga(e,a,i)),S=!!(o&&Ga(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&Ga(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[da.focused]:!1,[da.disabled]:!1,[da.hidden]:!1,[da.outside]:!1,[da.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function qa(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[da[r]]?e.push(t[da[r]]):t[fa[r]]&&e.push(t[fa[r]]),e),[t[H.Day]])}function Ja(e){return{...La,...e}}function Ya(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function Xa(){let e={};for(let t in H)e[H[t]]=`rdp-${H[t]}`;for(let t in da)e[da[t]]=`rdp-${da[t]}`;for(let t in fa)e[fa[t]]=`rdp-${fa[t]}`;for(let t in pa)e[pa[t]]=`rdp-${pa[t]}`;return e}function Za(e,t,n){return(n??new ra(t)).formatMonthYear(e)}function Qa(e,t,n){return(n??new ra(t)).format(e,`d`)}function $a(e,t=V){return t.format(e,`LLLL`)}function eo(e,t,n){return(n??new ra(t)).format(e,`cccccc`)}function to(e,t=V){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function no(){return``}function ro(e,t=V){return t.format(e,`yyyy`)}var io=e({formatCaption:()=>Za,formatDay:()=>Qa,formatMonthDropdown:()=>$a,formatWeekNumber:()=>to,formatWeekNumberHeader:()=>no,formatWeekdayName:()=>eo,formatYearDropdown:()=>ro});function ao(e){return{...io,...e}}function oo(e,t,n,r){let i=(r??new ra(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}function so(e,t,n){return(n??new ra(t)).formatMonthYear(e)}function U(e,t,n,r){let i=(r??new ra(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function W(e){return`Choose the Month`}function co(){return``}var lo=`Go to the Next Month`;function uo(e,t){return lo}function fo(e){return`Go to the Previous Month`}function po(e,t,n){return(n??new ra(t)).format(e,`cccc`)}function mo(e,t){return`Week ${e}`}function ho(e){return`Week Number`}function go(e){return`Choose the Year`}var _o=e({labelDayButton:()=>oo,labelGrid:()=>so,labelGridcell:()=>U,labelMonthDropdown:()=>W,labelNav:()=>co,labelNext:()=>uo,labelPrevious:()=>fo,labelWeekNumber:()=>mo,labelWeekNumberHeader:()=>ho,labelWeekday:()=>po,labelYearDropdown:()=>go}),vo=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function yo(e,t){let n=t.locale?.labels??{};return{..._o,...e??{},labelDayButton:vo(oo,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:vo(W,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:vo(uo,e?.labelNext,n.labelNext),labelPrevious:vo(fo,e?.labelPrevious,n.labelPrevious),labelWeekNumber:vo(mo,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:vo(go,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:vo(so,e?.labelGrid,n.labelGrid),labelGridcell:vo(U,e?.labelGridcell,n.labelGridcell),labelNav:vo(co,e?.labelNav,n.labelNav),labelWeekNumberHeader:vo(ho,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:vo(po,e?.labelWeekday,n.labelWeekday)}}function bo(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function xo(e,t={},n={}){let r={...t?.[H.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function So(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function Co(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function wo(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new xr(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(xr.tz(e)),newDate:(t,n,r)=>new xr(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new xr(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new xr(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new xr(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new xr(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>bi(o(e),{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1}),getISOWeek:e=>_i(o(e)),differenceInCalendarDays:(e,t)=>Rr(o(e),o(t)),differenceInCalendarMonths:(e,t)=>qr(o(e),o(t))}}var To=e=>e instanceof HTMLElement?e:null,Eo=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],Do=e=>To(e.querySelector(`[data-animated-month]`)),Oo=e=>To(e.querySelector(`[data-animated-caption]`)),ko=e=>To(e.querySelector(`[data-animated-weeks]`)),Ao=e=>To(e.querySelector(`[data-animated-nav]`)),jo=e=>To(e.querySelector(`[data-animated-weekdays]`));function Mo(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,N.useRef)(null),s=(0,N.useRef)(r),c=(0,N.useRef)(!1);(0,N.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[pa.caption_after_enter]:n[pa.caption_before_enter],p=d?n[pa.weeks_after_enter]:n[pa.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(Eo(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=Do(e);t&&e.contains(t)&&e.removeChild(t);let n=Oo(e);n&&n.classList.remove(f);let r=ko(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?Eo(m):[],_=Eo(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g?.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=Ao(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=Oo(i);s&&s.classList.add(f);let l=ko(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=jo(o);m&&(m.style.opacity=`0`);let h=Oo(o);h&&(h.classList.add(d?n[pa.caption_before_exit]:n[pa.caption_after_exit]),h.addEventListener(`animationend`,u));let _=ko(o);_&&_.classList.add(d?n[pa.weeks_before_exit]:n[pa.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function No(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let ee=(c?35:42)*w;if(s&&T.length<ee){let e=ee-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function Po(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function Fo(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function Io(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function Lo(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new aa(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new ia(t,m,r);return a?a.days.push(o):e.push(new oa(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function Ro(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,today:u}=t,d=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):!n&&d&&(n=i(c(e.today??u(),-100))),r?r=s(r):!r&&d&&(r=l(e.today??u())),[n&&a(n),r&&a(r)]}function zo(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function Bo(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function Vo(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function Ho(e,t){let[n,r]=(0,N.useState)(e);return[t===void 0?n:t,r]}function Uo(e,t){let[n,r]=Ro(e,t),{startOfMonth:i,endOfMonth:a}=t,o=Io(e,n,r,t),[s,c]=Ho(o,e.month?o:void 0);(0,N.useEffect)(()=>{c(Io(e,n,r,t))},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,N.useMemo)(()=>{let i=Fo(s,r,{numberOfMonths:e.numberOfMonths},t),o=Lo(i,No(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:Vo(o),days:Po(o),previousMonth:Bo(s,n,e,t),nextMonth:zo(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var Wo;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(Wo||={});function Go(e){return!e[da.disabled]&&!e[da.hidden]&&!e[da.outside]}function Ko(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);Go(e)&&(e[da.focused]&&a<Wo.FocusedModifier?(i=o,a=Wo.FocusedModifier):r?.isEqualTo(o)&&a<Wo.LastFocused?(i=o,a=Wo.LastFocused):n(o.date)&&a<Wo.Selected?(i=o,a=Wo.Selected):e[da.today]&&a<Wo.Today&&(i=o,a=Wo.Today))}return i||=e.find(e=>Go(t(e))),i}function qo(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function Jo(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=qo(e,t,n.date,r,i,a,o),l=!!(a.disabled&&Ga(c,a.disabled,o)),u=!!(a.hidden&&Ga(c,a.hidden,o)),d=new ia(c,c,o);return!l&&!u?d:Jo(e,t,d,r,i,a,o,s+1)}function Yo(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,N.useState)(),c=Ko(t.days,n,r||(()=>!1),o),[l,u]=(0,N.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=Jo(n,r,l,t.navStart,t.navEnd,e,i);a&&(e.disableNavigation&&!t.days.some(e=>e.isEqualTo(a))||(t.goToDay(a),u(a)))}}}function Xo(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=Ho(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function Zo(e,t,n=0,r=0,i=!1,a=V){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s)if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`);if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function Qo(e,t,n=V){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function $o(e,t,n=V){return Ra(e,t.from,!1,n)||Ra(e,t.to,!1,n)||Ra(t,e.from,!1,n)||Ra(t,e.to,!1,n)}function es(e,t,n=V){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?Ra(e,t,!1,n):Wa(t,n)?t.some(t=>Ra(e,t,!1,n)):Ba(t)?t.from&&t.to?$o(e,{from:t.from,to:t.to},n):!1:Ua(t)?Qo(e,t.dayOfWeek,n):za(t)?n.isAfter(t.before,t.after)?$o(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):Ga(e.from,t,n)||Ga(e.to,t,n):Va(t)||Ha(t)?Ga(e.from,t,n)||Ga(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function ts(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=Ho(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:Zo(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&es({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&Ra(u,e,!1,t)}}function ns(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=Ho(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function rs(e,t){let n=ns(e,t),r=Xo(e,t),i=ts(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function is(e,t){return e instanceof xr&&e.timeZone===t?e:new xr(e,t)}function as(e,t,n){if(!n)return is(e,t);let r=is(e,t),i=new xr(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function os(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?as(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?as(e,t,n):e):Ba(e)?{...e,from:e.from?is(e.from,t):e.from,to:e.to?is(e.to,t):e.to}:za(e)?{before:as(e.before,t,n),after:as(e.after,t,n)}:Va(e)?{after:as(e.after,t,n)}:Ha(e)?{before:as(e.before,t,n)}:e}function ss(e,t,n){return e&&(Array.isArray(e)?e.map(e=>os(e,t,n)):os(e,t,n))}function cs(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&=is(t.today,n),t.month&&=is(t.month,n),t.defaultMonth&&=is(t.defaultMonth,n),t.startMonth&&=is(t.startMonth,n),t.endMonth&&=is(t.endMonth,n),t.mode===`single`&&t.selected?t.selected=is(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>is(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?is(t.selected.from,n):t.selected.from,to:t.selected.to?is(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=ss(t.disabled,n)),t.hidden!==void 0&&(t.hidden=ss(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=ss(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,N.useMemo)(()=>{let e={...na,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?wo(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new ra({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:Ja(t.components),formatters:ao(t.formatters),labels:yo(t.labels,a.options),locale:e,classNames:{...Xa(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:v,onNextClick:y,onPrevClick:b,showWeekNumber:x,styles:S}=t,{formatCaption:C,formatDay:w,formatMonthDropdown:T,formatWeekNumber:ee,formatWeekNumberHeader:te,formatWeekdayName:E,formatYearDropdown:ne}=i,D=Uo(t,o),{days:re,months:ie,navStart:O,navEnd:k,previousMonth:ae,nextMonth:oe,goToMonth:se}=D,ce=Ka(re,t,O,k,o),{isSelected:A,select:j,selected:le}=rs(t,o)??{},{blur:ue,focused:M,isFocusTarget:de,moveFocus:fe,setFocused:pe}=Yo(t,D,ce,A??(()=>!1),o),{labelDayButton:me,labelGridcell:he,labelGrid:ge,labelMonthDropdown:_e,labelNav:ve,labelPrevious:ye,labelNext:be,labelWeekday:xe,labelWeekNumber:Se,labelWeekNumberHeader:Ce,labelYearDropdown:we}=a,Te=(0,N.useMemo)(()=>So(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),Ee=u!==void 0||m!==void 0,De=(0,N.useCallback)(()=>{ae&&(se(ae),b?.(ae))},[ae,se,b]),Oe=(0,N.useCallback)(()=>{oe&&(se(oe),y?.(oe))},[se,oe,y]),ke=(0,N.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),pe(e),!t.disabled&&(j?.(e.date,t,n),m?.(e.date,t,n))},[j,m,pe]),Ae=(0,N.useCallback)((e,t)=>n=>{pe(e),h?.(e.date,t,n)},[h,pe]),je=(0,N.useCallback)((e,t)=>n=>{ue(),p?.(e.date,t,n)},[ue,p]),Me=(0,N.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];fe(e,t)}g?.(e.date,n,r)},[fe,g,t.dir]),Ne=(0,N.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),Pe=(0,N.useCallback)((e,t)=>n=>{v?.(e.date,t,n)},[v]),Fe=(0,N.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setMonth(o.startOfMonth(e),r);se(o.addMonths(i,-t))},[o,se]),Ie=(0,N.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setYear(o.startOfMonth(e),r);se(o.addMonths(i,-t))},[o,se]),{className:Le,style:Re}=(0,N.useMemo)(()=>({className:[c[H.Root],t.className].filter(Boolean).join(` `),style:{...S?.[H.Root],...t.style}}),[c,t.className,t.style,S]),ze=Ya(t),Be=(0,N.useRef)(null);Mo(Be,!!t.animate,{classNames:c,months:ie,focused:M,dateLib:o});let Ve={dayPickerProps:t,selected:le,select:j,isSelected:A,months:ie,nextMonth:oe,previousMonth:ae,goToMonth:se,getModifiers:ce,components:r,classNames:c,styles:S,labels:a,formatters:i};return N.createElement(ma.Provider,{value:Ve},N.createElement(r.Root,{rootRef:t.animate?Be:void 0,className:Le,style:Re,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...ze},N.createElement(r.Months,{className:c[H.Months],style:S?.[H.Months]},!t.hideNavigation&&!d&&N.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[H.Nav],style:S?.[H.Nav],"aria-label":ve(),onPreviousClick:De,onNextClick:Oe,previousMonth:ae,nextMonth:oe}),ie.map((e,n)=>{let a=t.reverseMonths?ie.length-1-n:n;return N.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[H.Month],style:S?.[H.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&N.createElement(r.PreviousMonthButton,{type:`button`,className:c[H.PreviousMonthButton],tabIndex:ae?void 0:-1,"aria-disabled":ae?void 0:!0,"aria-label":ye(ae),onClick:De,"data-animated-button":t.animate?`true`:void 0},N.createElement(r.Chevron,{disabled:ae?void 0:!0,className:c[H.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),N.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[H.MonthCaption],style:S?.[H.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?N.createElement(r.DropdownNav,{className:c[H.Dropdowns],style:S?.[H.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?N.createElement(r.MonthsDropdown,{key:`month`,className:c[H.MonthsDropdown],"aria-label":_e(),disabled:!!t.disableNavigation,onChange:Fe(e.date,a),options:bo(e.date,O,k,i,o),style:S?.[H.Dropdown],value:o.getMonth(e.date)}):N.createElement(`span`,{key:`month`},T(e.date,o)),s=l===`dropdown`||l===`dropdown-years`?N.createElement(r.YearsDropdown,{key:`year`,className:c[H.YearsDropdown],"aria-label":we(o.options),disabled:!!t.disableNavigation,onChange:Ie(e.date,a),options:Co(O,k,i,o,!!t.reverseYears),style:S?.[H.Dropdown],value:o.getYear(e.date)}):N.createElement(`span`,{key:`year`},ne(e.date,o));return o.getMonthYearOrder()===`year-first`?[s,n]:[n,s]})(),N.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},C(e.date,o.options,o))):N.createElement(r.CaptionLabel,{className:c[H.CaptionLabel],role:`status`,"aria-live":`polite`},C(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&N.createElement(r.NextMonthButton,{type:`button`,className:c[H.NextMonthButton],tabIndex:oe?void 0:-1,"aria-disabled":oe?void 0:!0,"aria-label":be(oe),onClick:Oe,"data-animated-button":t.animate?`true`:void 0},N.createElement(r.Chevron,{disabled:oe?void 0:!0,className:c[H.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&N.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[H.Nav],style:S?.[H.Nav],"aria-label":ve(),onPreviousClick:De,onNextClick:Oe,previousMonth:ae,nextMonth:oe}),N.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":ge(e.date,o.options,o)||void 0,className:c[H.MonthGrid],style:S?.[H.MonthGrid]},!t.hideWeekdays&&N.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[H.Weekdays],style:S?.[H.Weekdays]},x&&N.createElement(r.WeekNumberHeader,{"aria-label":Ce(o.options),className:c[H.WeekNumberHeader],style:S?.[H.WeekNumberHeader],scope:`col`},te()),Te.map(e=>N.createElement(r.Weekday,{"aria-label":xe(e,o.options,o),className:c[H.Weekday],key:String(e),style:S?.[H.Weekday],scope:`col`},E(e,o.options,o)))),N.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[H.Weeks],style:S?.[H.Weeks]},e.weeks.map(e=>N.createElement(r.Week,{className:c[H.Week],key:e.weekNumber,style:S?.[H.Week],week:e},x&&N.createElement(r.WeekNumber,{week:e,style:S?.[H.WeekNumber],"aria-label":Se(e.weekNumber,{locale:s}),className:c[H.WeekNumber],scope:`row`,role:`rowheader`},ee(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=ce(e);if(i[da.focused]=!i.hidden&&!!M?.isEqualTo(e),i[fa.selected]=A?.(n)||i.selected,Ba(le)){let{from:e,to:t}=le;i[fa.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[fa.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[fa.range_middle]=Ra(le,n,!0,o)}let a=xo(i,S,t.modifiersStyles),s=qa(i,c,t.modifiersClassNames),l=!Ee&&!i.hidden?he(n,i,o.options,o):void 0;return N.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&Ee?N.createElement(r.DayButton,{className:c[H.DayButton],style:S?.[H.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:de(e)?0:-1,"aria-label":me(n,i,o.options,o),onClick:ke(e,i),onBlur:je(e,i),onFocus:Ae(e,i),onKeyDown:Me(e,i),onMouseEnter:Ne(e,i),onMouseLeave:Pe(e,i)},w(n,o.options,o)):!i.hidden&&w(e.date,o.options,o))}))))))})),t.footer&&N.createElement(r.Footer,{className:c[H.Footer],style:S?.[H.Footer],role:`status`,"aria-live":`polite`},t.footer)))}var ls=[{label:`Today`,days:0},{label:`Last 7 days`,days:7},{label:`Last 30 days`,days:30},{label:`Last 90 days`,days:90},{label:`All time`,days:null}];function us(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}function ds({fromTs:e,toTs:t,onChange:n}){let[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(null),o=e||t?{from:e?new Date(e):void 0,to:t?new Date(t):void 0}:void 0;(0,N.useEffect)(()=>{if(!r)return;let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let s=e=>{if(!e){n(``,``);return}n(e.from?new Date(e.from.getFullYear(),e.from.getMonth(),e.from.getDate(),0,0,0).toISOString():``,e.to?new Date(e.to.getFullYear(),e.to.getMonth(),e.to.getDate(),23,59,59).toISOString():``)},c=e=>{if(e===null)n(``,``);else{let t=new Date;n((e===0?new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0):new Date(Date.now()-e*24*60*60*1e3)).toISOString(),t.toISOString())}i(!1)},l=o?.from||o?.to?`${o.from?us(o.from):`...`} — ${o.to?us(o.to):`...`}`:`All time`;return(0,P.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:`flex items-center gap-2 bg-surface-secondary border border-border-subtle rounded-lg px-3 py-1.5 text-xs text-foreground hover:border-violet-500/50 transition-colors`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5 t-tertiary shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})}),(0,P.jsx)(`span`,{className:`font-mono`,children:l}),(e||t)&&(0,P.jsx)(`span`,{className:`t-tertiary hover:text-foreground ml-1 cursor-pointer`,onClick:e=>{e.stopPropagation(),n(``,``)},children:`×`})]}),r&&(0,P.jsxs)(`div`,{className:`absolute top-full mt-1 right-0 z-50 border border-border-subtle rounded-xl shadow-2xl bg-[#18181b] p-4 flex gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-r border-border-subtle pr-4 min-w-[120px]`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-[10px] uppercase tracking-wider mb-2 px-2`,children:`Quick select`}),ls.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(e.days),className:`text-left text-xs px-2 py-1.5 rounded-md hover:bg-violet-500/10 hover:text-violet-300 text-foreground transition-colors whitespace-nowrap`,children:e.label},e.label))]}),(0,P.jsx)(`div`,{className:`rdp-dark`,children:(0,P.jsx)(cs,{mode:`range`,selected:o,onSelect:s,disabled:{after:new Date},numberOfMonths:1,showOutsideDays:!0,classNames:{root:`text-foreground text-xs`,months:`flex gap-4`,month_caption:`flex items-center justify-center py-1 mb-1`,caption_label:`text-xs font-medium text-foreground`,nav:`flex items-center`,button_previous:`absolute left-1 top-2.5 h-6 w-6 inline-flex items-center justify-center rounded-md hover:bg-surface-secondary t-tertiary hover:text-foreground transition-colors`,button_next:`absolute right-1 top-2.5 h-6 w-6 inline-flex items-center justify-center rounded-md hover:bg-surface-secondary t-tertiary hover:text-foreground transition-colors`,weekdays:`flex`,weekday:`w-9 text-center t-tertiary text-[10px] font-medium py-1`,week:`flex`,day:`h-9 w-9 text-center`,day_button:`h-8 w-8 rounded-md text-xs inline-flex items-center justify-center transition-colors hover:bg-surface-secondary cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed`,selected:`!bg-violet-500 !text-white font-medium rounded-md`,range_start:`!bg-violet-500 !text-white font-medium rounded-l-md rounded-r-none`,range_end:`!bg-violet-500 !text-white font-medium rounded-r-md rounded-l-none`,range_middle:`!bg-violet-500/20 !text-violet-300 rounded-none`,today:`ring-1 ring-violet-500/50 rounded-md`,outside:`opacity-40`,disabled:`opacity-30 cursor-not-allowed`}})})]})]})}function fs(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function ps(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ms({label:e,value:t,accent:n,hint:r,subtitle:i}){return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-4`,title:r,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:`mt-1 text-2xl font-bold font-mono tabular-nums ${n??`text-foreground`}`,children:t}),i&&(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] mt-1 leading-snug`,children:i})]})}function hs({items:e}){return(0,P.jsx)(`nav`,{className:`flex items-center gap-1.5 text-sm mb-5`,children:e.map((t,n)=>{let r=n===e.length-1;return(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[n>0&&(0,P.jsx)(`span`,{className:`t-tertiary`,children:`›`}),r?(0,P.jsx)(`span`,{className:`text-foreground font-medium`,children:t.label}):(0,P.jsx)(`button`,{type:`button`,className:`text-violet-400 hover:text-violet-300 transition-colors cursor-pointer`,onClick:t.onClick,children:t.label})]},t.label)})})}var gs={"claude-code":{bg:`bg-amber-500/20`,text:`text-amber-400`,label:`Claude Code`},"claude-desktop":{bg:`bg-amber-500/20`,text:`text-amber-400`,label:`Claude Desktop`},cursor:{bg:`bg-blue-500/20`,text:`text-blue-400`,label:`Cursor`},cline:{bg:`bg-emerald-500/20`,text:`text-emerald-400`,label:`Cline`},windsurf:{bg:`bg-cyan-500/20`,text:`text-cyan-400`,label:`Windsurf`},copilot:{bg:`bg-zinc-500/20`,text:`text-zinc-400`,label:`Copilot`}};function _s({name:e}){if(!e)return(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`unknown`});let t=gs[e.toLowerCase().replace(/\s+/g,`-`)]??{bg:`bg-zinc-500/20`,text:`text-zinc-400`,label:e};return(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 ${t.bg} ${t.text} text-[10px] font-medium`,children:t.label})}function vs({total:e,limit:t,offset:n,onPageChange:r}){let i=Math.ceil(e/t),a=Math.floor(n/t)+1;return i<=1?null:(0,P.jsxs)(`div`,{className:`flex items-center justify-between px-1 py-2`,children:[(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[n+1,`–`,Math.min(n+t,e),` of `,e]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:a<=1,className:`px-2.5 py-1 rounded text-xs font-medium bg-surface-secondary hover:bg-surface-tertiary disabled:opacity-30 disabled:cursor-not-allowed text-foreground transition-colors`,onClick:()=>r(Math.max(0,n-t)),children:`‹ Prev`}),(0,P.jsxs)(`span`,{className:`t-secondary text-xs px-2 font-mono`,children:[a,`/`,i]}),(0,P.jsx)(`button`,{type:`button`,disabled:a>=i,className:`px-2.5 py-1 rounded text-xs font-medium bg-surface-secondary hover:bg-surface-tertiary disabled:opacity-30 disabled:cursor-not-allowed text-foreground transition-colors`,onClick:()=>r(n+t),children:`Next ›`})]})]})}function ys({value:e,max:t,label:n}){let r=t&&t>0?Math.min(100,Math.round(e/t*100)):e;return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 ${r>=70?`bg-emerald-500/20`:r>=40?`bg-amber-500/20`:`bg-red-500/20`} ${r>=70?`text-emerald-400`:r>=40?`text-amber-400`:`text-red-400`} text-[10px] font-medium`,title:n,children:[r,`%`]})}function bs({onSelectSession:e}){let{url:t,queryKey:n}=I(),[r,i]=(0,N.useState)(``),[a,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(0),u=r||a?`${r?`&from_ts=${r}`:``}${a?`&to_ts=${a}`:``}`:``,d=F({queryKey:n([`reasoning-quality-global`,r,a]),queryFn:()=>o(t(`/api/reasoning-quality/global?_=1${u}`)),refetchInterval:5e3}),f=F({queryKey:n([`reasoning-quality-sessions`,r,a,c]),queryFn:()=>o(t(`/api/reasoning-quality/sessions?limit=20&offset=${c}${u}`)),refetchInterval:5e3}),p=F({queryKey:n([`reasoning-quality-trend`,r,a]),queryFn:()=>o(t(`/api/reasoning-quality/trend?_=1${u}`)),refetchInterval:1e4});if(d.isLoading)return(0,P.jsx)(Ft,{n:6});let m=d.data?.data,h=f.data?.data??[],g=f.data?.total??0;return!m||m.total_events===0?(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-10 text-center`,children:[(0,P.jsx)(`p`,{className:`t-secondary text-lg`,children:`No reasoning quality data yet`}),(0,P.jsx)(`p`,{className:`t-tertiary mt-2 text-sm`,children:`Quality metrics appear here as the agent uses unerr's graph-backed tools instead of grep/glob cycles.`}),(0,P.jsx)(`p`,{className:`t-tertiary mt-1 text-xs`,children:`This page shows how unerr improves your agent's thinking — not just saves tokens, but makes every remaining token count more.`})]}):(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(`div`,{className:`flex items-center justify-end gap-3 flex-wrap -mt-2`,children:(0,P.jsx)(ds,{fromTs:r,toTs:a,onChange:(e,t)=>{i(e),s(t),l(0)}})}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-4`,children:[(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-t-2 border-emerald-500/60`,title:`Share of original tokens stripped before reaching the agent`,children:[(0,P.jsx)(`p`,{className:`text-emerald-400 text-[10px] uppercase tracking-wider font-medium`,children:`Cleaner Context`}),(0,P.jsxs)(`p`,{className:`text-3xl font-bold font-mono text-emerald-400 mt-2`,children:[m.noise_removed_pct,`%`]}),(0,P.jsx)(`p`,{className:`t-secondary text-xs mt-1`,children:`Noise removed`})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-t-2 border-cyan-500/60`,title:`Lookups resolved in one graph call vs 3-5 grep/glob cycles`,children:[(0,P.jsx)(`p`,{className:`text-cyan-400 text-[10px] uppercase tracking-wider font-medium`,children:`Fewer Turns`}),(0,P.jsxs)(`p`,{className:`text-3xl font-bold font-mono text-cyan-400 mt-2`,children:[m.first_call_resolution_rate,`%`]}),(0,P.jsx)(`p`,{className:`t-secondary text-xs mt-1`,children:`First-try resolution`})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-t-2 border-amber-500/60`,title:`${m.blast_radius_warnings} warnings · ${m.convention_injections} hints${m.circuit_breaker_activations?` · ${m.circuit_breaker_activations} loop stops`:``}`,children:[(0,P.jsx)(`p`,{className:`text-amber-400 text-[10px] uppercase tracking-wider font-medium`,children:`Fewer Breakages`}),(0,P.jsx)(`p`,{className:`text-3xl font-bold font-mono text-amber-400 mt-2`,children:m.prevention_score}),(0,P.jsxs)(`p`,{className:`t-secondary text-xs mt-1`,children:[m.blast_radius_warnings,` warns · `,m.convention_injections,` hints`,m.circuit_breaker_activations>0?` · ${m.circuit_breaker_activations} stops`:``]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-t-2 border-fuchsia-500/60`,title:`Share of fact/convention/resume signals that were load-bearing`,children:[(0,P.jsx)(`p`,{className:`text-fuchsia-400 text-[10px] uppercase tracking-wider font-medium`,children:`Persistent Memory`}),(0,P.jsx)(`p`,{className:`text-3xl font-bold font-mono text-fuchsia-400 mt-2`,children:m.memory_verdicts_total>0?`${m.memory_effectiveness_pct}%`:m.memory_signals_fired>0?`${m.memory_signals_fired}↻`:`—`}),(0,P.jsx)(`p`,{className:`t-secondary text-xs mt-1`,children:m.memory_verdicts_total>0?`${m.verdicts_acted_on+m.verdicts_reinforced+m.verdicts_caught}/${m.memory_verdicts_total} load-bearing`:m.memory_signals_fired>0?`Verdicts pending`:`No memory signals yet`})]})]}),(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-violet-500/40`,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Reasoning Quality Multiplier`}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs mt-1`,title:`Composite: compression × (1 + first-call resolution rate)`,children:`Compression × precision.`})]}),(0,P.jsx)(`div`,{className:`text-right shrink-0`,children:(0,P.jsxs)(`p`,{className:`text-violet-400 font-mono font-bold text-3xl`,children:[m.reasoning_quality_multiplier,`x`]})})]})}),(()=>{let e=p.data?.data??[];if(e.length<2)return null;let t=Math.max(...e.map(e=>e.reasoning_quality_multiplier),1),n=Math.max(...e.map(e=>e.noise_removed_pct),1),r=Math.max(...e.map(e=>e.first_call_resolution_rate),1);return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,title:`One bar per session, ordered chronologically. Rising = improving.`,children:`Quality Over Time`}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`flex items-center justify-between mb-1`,children:(0,P.jsx)(`span`,{className:`text-emerald-400 text-[10px] uppercase tracking-wider font-medium`,title:`Higher = cleaner context`,children:`Noise Removed %`})}),(0,P.jsx)(`div`,{className:`flex gap-[2px]`,style:{height:`48px`},children:e.slice(-40).map((e,t)=>{let r=n>0?Math.max(4,e.noise_removed_pct/n*100):4,i=new Date(e.first_ts).toLocaleDateString([],{month:`short`,day:`numeric`});return(0,P.jsxs)(`div`,{className:`group relative flex-1 min-w-[6px] max-w-[28px] h-full flex items-end`,children:[(0,P.jsx)(`div`,{className:`w-full bg-emerald-500 opacity-70 hover:opacity-100 rounded-t transition-all cursor-pointer`,style:{height:`${r}%`}}),(0,P.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-20 pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-xs whitespace-nowrap shadow-xl`,children:[(0,P.jsx)(`div`,{className:`font-medium text-foreground`,children:i}),(0,P.jsxs)(`div`,{className:`text-emerald-400`,children:[`Noise removed: `,e.noise_removed_pct,`%`]}),(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`Session: `,e.session_id.slice(0,8)]})]})})]},e.session_id)})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,P.jsx)(`span`,{className:`text-cyan-400 text-[10px] uppercase tracking-wider font-medium`,children:`Found It First Try %`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`Higher = fewer wasted turns`})]}),(0,P.jsx)(`div`,{className:`flex gap-[2px]`,style:{height:`48px`},children:e.slice(-40).map(e=>{let t=r>0?Math.max(4,e.first_call_resolution_rate/r*100):4,n=new Date(e.first_ts).toLocaleDateString([],{month:`short`,day:`numeric`});return(0,P.jsxs)(`div`,{className:`group relative flex-1 min-w-[6px] max-w-[28px] h-full flex items-end`,children:[(0,P.jsx)(`div`,{className:`w-full bg-cyan-500 opacity-70 hover:opacity-100 rounded-t transition-all cursor-pointer`,style:{height:`${t}%`}}),(0,P.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-20 pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-xs whitespace-nowrap shadow-xl`,children:[(0,P.jsx)(`div`,{className:`font-medium text-foreground`,children:n}),(0,P.jsxs)(`div`,{className:`text-cyan-400`,children:[`First try: `,e.first_call_resolution_rate,`%`]}),(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`Turns saved: ~`,e.turns_saved]})]})})]},e.session_id)})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`flex items-center justify-between mb-1`,children:(0,P.jsx)(`span`,{className:`text-violet-400 text-[10px] uppercase tracking-wider font-medium`,title:`Higher = smarter agent`,children:`Quality Multiplier`})}),(0,P.jsx)(`div`,{className:`flex gap-[2px]`,style:{height:`48px`},children:e.slice(-40).map(e=>{let n=t>0?Math.max(4,e.reasoning_quality_multiplier/t*100):4,r=new Date(e.first_ts).toLocaleDateString([],{month:`short`,day:`numeric`});return(0,P.jsxs)(`div`,{className:`group relative flex-1 min-w-[6px] max-w-[28px] h-full flex items-end`,children:[(0,P.jsx)(`div`,{className:`w-full bg-violet-500 opacity-70 hover:opacity-100 rounded-t transition-all cursor-pointer`,style:{height:`${n}%`}}),(0,P.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-20 pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-xs whitespace-nowrap shadow-xl`,children:[(0,P.jsx)(`div`,{className:`font-medium text-foreground`,children:r}),(0,P.jsxs)(`div`,{className:`text-violet-400`,children:[`Quality: `,e.reasoning_quality_multiplier,`x`]}),(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`Attention boost: `,e.attention_multiplier,`x`]})]})})]},e.session_id)})})]})]}),e.length>0&&(0,P.jsxs)(`div`,{className:`flex justify-between mt-2 pt-2 border-t border-border-subtle/50`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:new Date(e[Math.max(0,e.length-40)].first_ts).toLocaleDateString([],{month:`short`,day:`numeric`})}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px]`,children:[Math.min(40,e.length),` sessions shown`]}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:new Date(e[e.length-1].first_ts).toLocaleDateString([],{month:`short`,day:`numeric`})})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-4 mt-3 pt-3 border-t border-border-subtle/50`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-sm bg-emerald-500`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`Noise removed`})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-sm bg-cyan-500`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`First-call resolution`})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-sm bg-violet-500`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`Quality multiplier`})]})]})]})})(),(0,P.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`text-emerald-400 text-xs font-medium uppercase tracking-wider mb-4`,children:`Context Quality Details`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Fraction of original content kept (lower = cleaner)`,children:`Signal-to-Noise`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:m.signal_to_noise_ratio})]}),(0,P.jsx)(`div`,{className:`mt-1.5 h-2 bg-surface-secondary rounded-full overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full bg-emerald-500 rounded-full transition-all`,style:{width:`${Math.max(3,(1-m.signal_to_noise_ratio)*100)}%`}})})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Entities resolved per 1K tokens delivered`,children:`Context density`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:m.context_density})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Estimated attention boost from noise removal`,children:`Attention boost`}),(0,P.jsxs)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:[m.attention_multiplier,`x`]})]}),(0,P.jsxs)(`div`,{className:`pt-2 border-t border-border-subtle/50 space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`Entities resolved`}),(0,P.jsx)(`span`,{className:`t-secondary font-mono text-xs`,children:fs(m.entities_resolved)})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,title:`Tokens delivered via graph queries`,children:`Graph tokens`}),(0,P.jsx)(`span`,{className:`t-secondary font-mono text-xs`,children:fs(m.graph_tokens_delivered)})]})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`text-cyan-400 text-xs font-medium uppercase tracking-wider mb-4`,children:`Turn Efficiency Details`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Lookups resolved in 1 graph call vs 3-5 grep cycles`,children:`First-try resolution`}),(0,P.jsxs)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:[m.first_call_resolution_rate,`%`]})]}),(0,P.jsx)(`div`,{className:`mt-1.5 h-2 bg-surface-secondary rounded-full overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full bg-cyan-500 rounded-full transition-all`,style:{width:`${Math.max(3,m.first_call_resolution_rate)}%`}})})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Estimated grep→read cycles avoided`,children:`Turns saved`}),(0,P.jsxs)(`span`,{className:`text-cyan-400 font-mono text-sm font-medium`,children:[`~`,fs(m.turns_saved)]})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Hook redirects that broke an exploration loop`,children:`Loops stopped`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:m.exploration_loops_prevented})]}),(0,P.jsxs)(`div`,{className:`pt-2 border-t border-border-subtle/50 space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`Graph calls`}),(0,P.jsx)(`span`,{className:`t-secondary font-mono text-xs`,children:fs(m.graph_calls)})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`Total tool calls`}),(0,P.jsx)(`span`,{className:`t-secondary font-mono text-xs`,children:fs(m.total_tool_calls)})]})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`text-amber-400 text-xs font-medium uppercase tracking-wider mb-4`,children:`Breakage Prevention Details`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Callers / refs / drift shown before edit`,children:`Blast-radius warns`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:m.blast_radius_warnings})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Project rules auto-injected into tool responses`,children:`Convention hints`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-sm font-medium`,children:m.convention_injections})]}),(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,title:`Circuit-breaker fires — agent stuck in fix→break→fix`,children:`Loops stopped`}),(0,P.jsx)(`span`,{className:`font-mono text-sm font-medium ${m.circuit_breaker_activations>0?`text-red-400`:`text-foreground`}`,children:m.circuit_breaker_activations})]}),(0,P.jsx)(`div`,{className:`pt-2 border-t border-border-subtle/50`,children:(0,P.jsxs)(`div`,{className:`flex justify-between items-baseline`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,title:`warnings + hints + (loops × 10)`,children:`Safety score`}),(0,P.jsxs)(`span`,{className:`text-amber-400 font-mono text-xs font-medium`,children:[m.prevention_score,` pts`]})]})})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap mb-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-fuchsia-400 text-xs font-medium uppercase tracking-wider`,children:`Persistent Memory`}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs mt-1`,title:`Each fact/convention/resume signal opens a 5-turn window and resolves into a verdict: reinforced · acted_on · caught · ignored · corrected. Load-bearing = reinforced + acted_on + caught.`,children:`Signals scored after a 5-turn observation window.`})]}),(0,P.jsxs)(`div`,{className:`text-right shrink-0`,children:[(0,P.jsxs)(`p`,{className:`text-fuchsia-400 font-mono font-bold text-3xl`,children:[m.memory_effectiveness_pct,`%`]}),(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider mt-0.5`,children:`Load-bearing`})]})]}),m.memory_verdicts_total>0&&(()=>{let e=m.memory_verdicts_total,t=t=>t/e*100;return(0,P.jsxs)(`div`,{className:`mb-4`,children:[(0,P.jsx)(`div`,{className:`flex items-center justify-between mb-1.5`,children:(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:[e,` verdict`,e===1?``:`s`]})}),(0,P.jsxs)(`div`,{className:`flex h-3 rounded-full overflow-hidden bg-surface-secondary`,children:[m.verdicts_reinforced>0&&(0,P.jsx)(`div`,{className:`bg-emerald-500`,style:{width:`${t(m.verdicts_reinforced)}%`},title:`Reinforced: ${m.verdicts_reinforced}`}),m.verdicts_acted_on>0&&(0,P.jsx)(`div`,{className:`bg-fuchsia-500`,style:{width:`${t(m.verdicts_acted_on)}%`},title:`Acted on: ${m.verdicts_acted_on}`}),m.verdicts_caught>0&&(0,P.jsx)(`div`,{className:`bg-cyan-500`,style:{width:`${t(m.verdicts_caught)}%`},title:`Caught: ${m.verdicts_caught}`}),m.verdicts_ignored>0&&(0,P.jsx)(`div`,{className:`bg-zinc-600`,style:{width:`${t(m.verdicts_ignored)}%`},title:`Ignored: ${m.verdicts_ignored}`}),m.verdicts_corrected>0&&(0,P.jsx)(`div`,{className:`bg-red-500`,style:{width:`${t(m.verdicts_corrected)}%`},title:`Corrected: ${m.verdicts_corrected}`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-3 mt-2 text-[10px] t-tertiary`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-emerald-500 mr-1`}),`reinforced `,m.verdicts_reinforced]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-fuchsia-500 mr-1`}),`acted_on `,m.verdicts_acted_on]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-cyan-500 mr-1`}),`caught `,m.verdicts_caught]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-zinc-600 mr-1`}),`ignored `,m.verdicts_ignored]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-red-500 mr-1`}),`corrected `,m.verdicts_corrected]})]})]})})(),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 pt-3 border-t border-border-subtle/50`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Facts surfaced`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium mt-0.5`,children:fs(m.facts_surfaced)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Facts recalled`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium mt-0.5`,children:fs(m.facts_recalled)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Facts recorded`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium mt-0.5`,children:fs(m.facts_recorded)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Conventions`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium mt-0.5`,children:fs(m.conventions_surfaced)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Resume hits`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium mt-0.5`,children:fs(m.resume_hits)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Anti-pattern warns`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium mt-0.5`,children:fs(m.negative_warnings)})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,title:`Click a row to drill into a session`,children:`Sessions`}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[g,` session`,g===1?``:`s`]})]}),h.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No sessions recorded.`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[800px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-2.5 font-medium`,title:`Unique session identifier`,children:`Session`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`AI agent that ran this session`,children:`Agent`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`When the last event was recorded`,children:`Last Active`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-center`,title:`% noise removed`,children:`Noise Removed`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-center`,title:`First-try lookup resolution`,children:`First Try`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-center`,title:`Warnings + hints + (loops × 10)`,children:`Safety`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-center`,title:`% of memory signals that were load-bearing`,children:`Memory`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Wasted turns avoided`,children:`Turns Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Compression × precision`,children:`Quality`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 pr-5 font-medium w-16`})]})}),(0,P.jsx)(`tbody`,{children:h.map((t,n)=>(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors cursor-pointer group`,onClick:()=>e(t.session_id),children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-foreground group-hover:text-violet-400 transition-colors`,children:t.session_id.slice(0,12)}),n===0&&c===0&&(0,P.jsx)(`span`,{className:`rounded-full bg-emerald-500/20 text-emerald-400 px-2 py-0.5 text-[10px] font-medium`,children:`latest`})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(_s,{name:t.agent_name})}),(0,P.jsx)(`td`,{className:`px-3 py-3 t-secondary text-xs`,children:ps(t.last_ts)}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-center`,children:(0,P.jsx)(ys,{value:t.noise_removed_pct,label:`Noise removed %`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-center`,children:(0,P.jsx)(ys,{value:t.first_call_resolution_rate,label:`First-call resolution rate`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-center`,children:(0,P.jsx)(`span`,{className:`text-amber-400 font-mono text-xs font-medium`,children:t.prevention_score})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-center`,children:t.memory_verdicts_total>0?(0,P.jsxs)(`span`,{className:`text-fuchsia-400 font-mono text-xs font-medium`,title:`${t.memory_verdicts_total} verdict${t.memory_verdicts_total===1?``:`s`} from ${t.memory_signals_fired} signals`,children:[t.memory_effectiveness_pct,`%`]}):t.memory_signals_fired>0?(0,P.jsxs)(`span`,{className:`t-tertiary font-mono text-xs`,title:`${t.memory_signals_fired} signal${t.memory_signals_fired===1?``:`s`} fired — verdicts pending`,children:[t.memory_signals_fired,`↻`]}):(0,P.jsx)(`span`,{className:`t-tertiary font-mono text-xs`,children:`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsxs)(`span`,{className:`text-cyan-400 font-mono text-xs`,children:[`~`,t.turns_saved]})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsxs)(`span`,{className:`text-violet-400 font-mono font-medium text-sm`,children:[t.reasoning_quality_multiplier,`x`]})}),(0,P.jsx)(`td`,{className:`pl-4 py-3 pr-5 text-right w-16`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-violet-400 opacity-0 group-hover:opacity-100 transition-opacity font-medium whitespace-nowrap`,children:[`View`,` `,(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]})})]},t.session_id))})]})}),(0,P.jsx)(`div`,{className:`px-5 py-2 border-t border-border-subtle`,children:(0,P.jsx)(vs,{total:g,limit:20,offset:c,onPageChange:l})})]})]})]})}function xs({sessionId:e}){let{url:t,queryKey:n}=I(),r=F({queryKey:n([`reasoning-quality-session`,e]),queryFn:()=>o(t(`/api/reasoning-quality/session?session_id=${e}`)),refetchInterval:5e3});if(r.isLoading)return(0,P.jsx)(Ft,{n:6});let i=r.data?.data;if(!i)return(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-8 text-center`,children:(0,P.jsxs)(`p`,{className:`t-secondary`,children:[`No quality data for session `,e.slice(0,12)]})});let a=i.trajectory??[];return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-7`,children:[(0,P.jsx)(ms,{label:`Noise Removed`,value:`${i.noise_removed_pct}%`,accent:`text-emerald-400`,hint:`Percentage of unnecessary tokens stripped from context`,subtitle:`Cleaner signal for the agent`}),(0,P.jsx)(ms,{label:`Found First Try`,value:`${i.first_call_resolution_rate}%`,accent:`text-cyan-400`,hint:`Code lookups resolved in 1 graph call`,subtitle:`vs 3-5 grep/glob cycles`}),(0,P.jsx)(ms,{label:`Safety Score`,value:i.prevention_score,accent:`text-amber-400`,hint:`Warnings, convention hints, and doom spiral stops`,subtitle:`Breakages prevented`}),(0,P.jsx)(ms,{label:`Memory`,value:i.memory_verdicts_total>0?`${i.memory_effectiveness_pct}%`:i.memory_signals_fired>0?`${i.memory_signals_fired}↻`:`—`,accent:`text-fuchsia-400`,hint:`% of fact/convention/resume signals that were load-bearing`,subtitle:i.memory_verdicts_total>0?`${i.memory_verdicts_total} verdicts resolved`:`Verdicts pending`}),(0,P.jsx)(ms,{label:`Turns Saved`,value:`~${fs(i.turns_saved)}`,accent:`text-cyan-400`,hint:`Estimated wasted turns avoided`,subtitle:`Each = a grep→read cycle skipped`}),(0,P.jsx)(ms,{label:`Attention Boost`,value:`${i.attention_multiplier}x`,accent:`text-emerald-400`,hint:`Estimated focus improvement from noise removal`,subtitle:`Based on attention research`}),(0,P.jsx)(ms,{label:`Quality Multiplier`,value:`${i.reasoning_quality_multiplier}x`,accent:`text-violet-400`,hint:`Composite: compression × precision`,subtitle:`How much smarter the agent is`})]}),a.length>0&&(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-1`,children:`Session Health Over Time`}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs mb-3`,children:`Shows how context quality evolved through the session. A flat or rising "noise removed" line means the session stayed clean. Without unerr, this typically degrades as context fills up.`}),(0,P.jsx)(`div`,{className:`flex gap-[3px]`,style:{height:`120px`},children:a.slice(-60).map(e=>(0,P.jsxs)(`div`,{className:`group relative flex-1 min-w-[6px] max-w-[28px] h-full flex items-end`,children:[(0,P.jsx)(`div`,{className:`w-full bg-emerald-500 opacity-70 hover:opacity-100 rounded-t transition-all cursor-pointer`,style:{height:`${Math.max(4,e.cumulative_noise_removed_pct)}%`}}),(0,P.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-20 pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-xs whitespace-nowrap shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`font-medium text-foreground`,children:[`Turn #`,e.turn]}),(0,P.jsxs)(`div`,{className:`text-emerald-400 mt-0.5`,children:[`Noise removed: `,e.cumulative_noise_removed_pct,`%`]}),(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`SNR: `,e.snr]}),(0,P.jsxs)(`div`,{className:`text-cyan-400`,children:[`Graph calls: `,e.graph_calls_this_turn]}),e.context_density>0&&(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`Density: `,e.context_density,`/1K tok`]})]})})]},e.turn))}),(0,P.jsxs)(`div`,{className:`flex justify-between mt-1.5`,children:[(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:[`T`,a.length>60?a.length-59:1]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:[`T`,a.length]})]}),(0,P.jsx)(`div`,{className:`flex items-center gap-4 mt-3 pt-3 border-t border-border-subtle/50`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-sm bg-emerald-500`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`Cumulative noise removed %`})]})})]}),(0,P.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`text-emerald-400 text-xs font-medium uppercase tracking-wider mb-4`,children:`Context Quality`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Signal-to-Noise Ratio`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-xs`,children:i.signal_to_noise_ratio})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Context Density`}),(0,P.jsxs)(`span`,{className:`text-foreground font-mono text-xs`,children:[i.context_density,` entities/1K tok`]})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Entities Resolved`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-xs`,children:fs(i.entities_resolved)})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Attention Boost`}),(0,P.jsxs)(`span`,{className:`text-foreground font-mono text-xs`,children:[i.attention_multiplier,`x`]})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`text-cyan-400 text-xs font-medium uppercase tracking-wider mb-4`,children:`Turn Efficiency`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Found First Try`}),(0,P.jsxs)(`span`,{className:`text-foreground font-mono text-xs`,children:[i.first_call_resolution_rate,`%`]})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Graph Calls`}),(0,P.jsxs)(`span`,{className:`text-foreground font-mono text-xs`,children:[fs(i.graph_calls),` / `,fs(i.total_tool_calls)]})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Turns Saved`}),(0,P.jsxs)(`span`,{className:`text-cyan-400 font-mono text-xs`,children:[`~`,fs(i.turns_saved)]})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Loops Prevented`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-xs`,children:i.exploration_loops_prevented})]})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`text-amber-400 text-xs font-medium uppercase tracking-wider mb-4`,children:`Breakage Prevention`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Blast Radius Warnings`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-xs`,children:i.blast_radius_warnings})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Convention Hints`}),(0,P.jsx)(`span`,{className:`text-foreground font-mono text-xs`,children:i.convention_injections})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{className:`t-secondary text-xs`,children:`Doom Spirals Stopped`}),(0,P.jsx)(`span`,{className:`font-mono text-xs ${i.circuit_breaker_activations>0?`text-red-400`:`text-foreground`}`,children:i.circuit_breaker_activations})]}),(0,P.jsxs)(`div`,{className:`flex justify-between pt-2 border-t border-border-subtle/50`,children:[(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:`Safety Score`}),(0,P.jsxs)(`span`,{className:`text-amber-400 font-mono text-xs font-medium`,children:[i.prevention_score,` pts`]})]})]})]})]}),(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-4 text-center`,children:(0,P.jsxs)(`p`,{className:`t-tertiary text-xs`,children:[`Want to see individual events and token-level details?`,` `,(0,P.jsx)(`a`,{href:`#/token-trace`,className:`text-violet-400 hover:text-violet-300 transition-colors font-medium`,children:`Open Token Trace →`})]})})]})}function Ss(){let[e,t]=(0,N.useState)({level:`global`}),n=()=>t({level:`global`}),r=e=>t({level:`session`,sessionId:e}),i=[];return e.level===`session`&&i.push({label:`All Sessions`,onClick:n},{label:`Session ${e.sessionId.slice(0,12)}`}),(0,P.jsxs)(`div`,{children:[i.length>0&&(0,P.jsx)(hs,{items:i}),e.level===`global`&&(0,P.jsx)(bs,{onSelectSession:r}),e.level===`session`&&(0,P.jsx)(xs,{sessionId:e.sessionId})]})}var Cs={page:1,perPage:15,density:`comfortable`},ws=new Set([`comfortable`,`compact`]);function Ts(){if(typeof window>`u`)return{...Cs};let e=window.location.hash.replace(/^#/,``),t=e.indexOf(`?`);if(t===-1)return{...Cs};let n=new URLSearchParams(e.slice(t+1)),r={...Cs},i=Number(n.get(`from`));Number.isFinite(i)&&i>0&&(r.from=i);let a=Number(n.get(`to`));Number.isFinite(a)&&a>0&&(r.to=a);let o=n.get(`session`);o&&o.length>0&&(r.session=o);let s=n.get(`agent`);s&&s.length>0&&(r.agent=s);let c=n.get(`type`);c&&c.length>0&&(r.type=c);let l=n.get(`q`);l&&l.length>0&&(r.q=l);let u=Number(n.get(`page`));Number.isInteger(u)&&u>0&&(r.page=u);let d=Number(n.get(`perPage`));Number.isInteger(d)&&d>0&&d<=200&&(r.perPage=d);let f=n.get(`density`);return f&&ws.has(f)&&(r.density=f),r}function Es(e){let t=new URLSearchParams;e.from!==void 0&&t.set(`from`,String(e.from)),e.to!==void 0&&t.set(`to`,String(e.to)),e.session&&t.set(`session`,e.session),e.agent&&t.set(`agent`,e.agent),e.type&&t.set(`type`,e.type),e.q&&t.set(`q`,e.q),e.page!==Cs.page&&t.set(`page`,String(e.page)),e.perPage!==Cs.perPage&&t.set(`perPage`,String(e.perPage)),e.density!==Cs.density&&t.set(`density`,e.density);let n=t.toString();return n.length>0?`?${n}`:``}var Ds=``,Os=Ts();function ks(){if(typeof window>`u`)return Os;let e=window.location.hash;return e!==Ds&&(Ds=e,Os=Ts()),Os}function As(e){return typeof window>`u`?()=>{}:(window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e))}function js(){let e=(0,N.useSyncExternalStore)(As,ks,ks),t=(0,N.useCallback)(e=>{if(typeof window>`u`)return;let t=`#${window.location.hash.replace(/^#/,``).split(`?`)[0]||`/activity`}${Es(e)}`;window.location.hash!==t&&(window.history.replaceState(null,``,t),window.dispatchEvent(new HashChangeEvent(`hashchange`)))},[]),n=(0,N.useCallback)(n=>{let r={...e,...n},i=`page`in n,a=Object.keys(n).every(e=>e===`density`);!i&&!a&&(r.page=1),t(r)},[e,t]),r=(0,N.useCallback)(()=>{t({...Cs})},[t]);return(0,N.useEffect)(()=>{Ds=``},[]),{filters:e,setFilters:n,clear:r}}function Ms(e){let t=[];return(e.from!==void 0||e.to!==void 0)&&t.push({key:`from`,label:Ps(e.from,e.to)}),e.session&&t.push({key:`session`,label:`Session ${e.session.slice(0,8)}`}),e.agent&&t.push({key:`agent`,label:`Agent: ${e.agent}`}),e.type&&t.push({key:`type`,label:Ns(e.type)}),e.q&&t.push({key:`q`,label:`“${e.q}”`}),t}function Ns(e){switch(e){case`mark_intent`:return`🎯 Goals only`;case`mark_decision`:return`💡 Decisions only`;case`mark_blocker`:return`⚠ Stuck moments only`;case`mark_resolution`:return`✅ Solutions only`;default:return e}}function Ps(e,t){return e&&t?`${Fs(e)} → ${Fs(t)}`:e?`Since ${Fs(e)}`:t?`Until ${Fs(t)}`:`All time`}function Fs(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Is(e,t=Date.now()){if(e===`all`)return{};let n=1440*6e4;if(e===`today`){let e=new Date(t);return e.setHours(0,0,0,0),{from:e.getTime(),to:t}}return e===`7d`?{from:t-7*n,to:t}:e===`30d`?{from:t-30*n,to:t}:{}}var Ls=[{value:``,label:`All notes`,emoji:`▣`,color:`text-zinc-300`},{value:`mark_intent`,label:`Goals`,emoji:`🎯`,color:`text-violet-300`},{value:`mark_decision`,label:`Decisions`,emoji:`💡`,color:`text-cyan-300`},{value:`mark_blocker`,label:`Stuck moments`,emoji:`⚠`,color:`text-rose-300`},{value:`mark_resolution`,label:`Solutions`,emoji:`✅`,color:`text-emerald-300`}];function Rs(e){return Ls.find(t=>t.value===e)??{value:e,label:e,emoji:`•`,color:`text-zinc-300`}}function zs(e){if(!Number.isFinite(e)||e<=0)return`—`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function Bs(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Vs(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Hs(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Us(e){if(!Number.isFinite(e)||e<=0)return`just now`;let t=Math.round(e/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Ws(e){if(!e)return``;let t=new Date(e).getTimezoneOffset()*6e4;return new Date(e-t).toISOString().slice(0,10)}function Gs(e,t=!1){if(!e)return;let n=Date.parse(e);if(Number.isFinite(n))return t?n+1440*6e4-1:n}function Ks(e){let t={},n=e.match(/What:\s*([^.]+?)(?:\.|$)/i);n&&(t.what=n[1].trim());let r=e.match(/Why:\s*([^.]+?)(?:\.|$)/i);r&&(t.why=r[1].trim());let i=e.match(/How:\s*([^.]+?)(?:\.|$)/i);return i&&(t.how=i[1].trim()),t}function qs(){let{url:e,queryKey:t}=I(),{filters:n,setFilters:r,clear:i}=js(),[a,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(null),{data:u,error:d}=F({queryKey:t([`timeline`,`health`]),queryFn:()=>o(e(`/api/timeline/health`)),staleTime:3e4,retry:!1}),f=!!u?.data?.ok&&!d,p=(0,N.useMemo)(()=>bc(n),[n]),{data:m,isFetching:h}=F({queryKey:t([`timeline`,`turns`,p]),queryFn:()=>o(e(`/api/timeline/turns?${p}`)),staleTime:1e4,enabled:f}),g=m?.data??[],_=m?.total??0,v=Math.max(1,Math.ceil(_/n.perPage)),y=(0,N.useMemo)(()=>{let e=new URLSearchParams;return n.session&&e.set(`session_id`,n.session),n.type&&e.set(`type`,n.type),e.set(`limit`,`500`),e.toString()},[n.session,n.type]),{data:b}=F({queryKey:t([`timeline`,`markers`,y]),queryFn:()=>o(e(`/api/timeline/markers?${y}`)),staleTime:1e4,enabled:f}),x=b?.data??[],S=(0,N.useMemo)(()=>xc(x),[x]),{data:C}=F({queryKey:t([`timeline`,`sessions`]),queryFn:()=>o(e(`/api/timeline/sessions?limit=200`)),staleTime:3e4,enabled:f}),w=C?.data??[],{data:T}=F({queryKey:t([`timeline`,`agents`]),queryFn:()=>o(e(`/api/timeline/agents`)),staleTime:6e4,enabled:f}),ee=T?.data??[],{data:te}=F({queryKey:t([`timeline`,`heatmap`]),queryFn:()=>o(e(`/api/timeline/heatmap?days=30`)),staleTime:6e4,enabled:f}),{data:E}=F({queryKey:t([`timeline`,`resume`]),queryFn:()=>o(e(`/api/timeline/resume`)),staleTime:15e3,enabled:f}),ne=E?.data??null,{data:D}=F({queryKey:t([`timeline`,`intents`]),queryFn:()=>o(e(`/api/timeline/intents?limit=10`)),staleTime:3e4,enabled:f}),re=D?.data??[],{data:ie}=F({queryKey:t([`facts`,`episodic`]),queryFn:()=>o(e(`/api/facts?type=episodic&limit=50`)),staleTime:3e4,retry:!1}),O=ie?.data??[],k=(0,N.useMemo)(()=>{let e=new Map;for(let t of O){let n=e.get(t.scope)??[];n.push(t),e.set(t.scope,n)}return e},[O]),ae=(0,N.useMemo)(()=>n.agent?w.filter(e=>e.agent_name===n.agent):w,[w,n.agent]);(0,N.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&s(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let oe=c===null?_<=3:c;if(d||!f)return(0,P.jsx)(Js,{});let se=Ms(n),ce=a?g.find(e=>e.turn_id===a)??null:null,A=a?S.get(a)??[]:[];return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[oe&&(0,P.jsx)(Ys,{onDismiss:()=>l(!1)}),(0,P.jsx)(Xs,{activityCount:_,sessionCount:w.length,taskCount:re.filter(e=>e.status===`active`).length,unresolvedCount:ne?.open_threads.length??0}),(0,P.jsx)($s,{filters:n,sessions:ae,agents:ee,chips:se,onChange:r,onClear:i,isFetching:h}),ne&&(0,P.jsx)(ic,{resume:ne}),(0,P.jsxs)(`div`,{className:`space-y-5`,children:[te&&te.data.length>0&&(0,P.jsx)(ac,{buckets:te.data,filters:n,onDayClick:e=>{r({from:e,to:e+1440*6e4-1})}}),re.length>0&&(0,P.jsx)(cc,{intents:re}),(0,P.jsx)(lc,{turns:g,markersByTurn:S,filters:n,totalTurns:_,totalPages:v,onPageChange:e=>r({page:e}),onTurnClick:e=>s(e),selectedTurnId:a,isFetching:h})]}),ce&&(0,P.jsx)(hc,{turn:ce,markers:A,episodicByFile:k,onClose:()=>s(null)})]})}function Js(){return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-amber-500/60`,children:[(0,P.jsx)(`div`,{className:`text-amber-400 text-[10px] uppercase tracking-wider font-medium`,children:`Activity subsystem isn't running`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-2 leading-relaxed`,children:[`We capture your agent's activity into`,` `,(0,P.jsx)(`code`,{className:`font-mono`,children:`.unerr/timeline.db`}),` only when the subsystem is on. Restart unerr (or unset`,` `,(0,P.jsx)(`code`,{className:`font-mono`,children:`UNERR_TIMELINE_V2=0`}),`) and reload this page.`]})]})}function Ys({onDismiss:e}){return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-violet-500/60 relative`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`absolute top-3 right-3 t-tertiary hover:text-foreground text-xs px-2 py-0.5`,"aria-label":`Dismiss explainer`,children:`✕`}),(0,P.jsx)(`h3`,{className:`text-violet-400 text-[10px] uppercase tracking-wider font-medium`,children:`What is this page?`}),(0,P.jsxs)(`ul`,{className:`t-secondary text-xs space-y-1.5 leading-relaxed mt-2 max-w-2xl`,children:[(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{className:`text-foreground`,children:`Every burst of work`}),` your agent does — between idle pauses — shows up as one`,` `,(0,P.jsx)(`em`,{children:`activity moment`}),`.`]}),(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{className:`text-foreground`,children:`Notes`}),` your agent drops along the way (🎯 a goal, 💡 a decision, ⚠ when it gets stuck, ✅ a fix) turn the raw activity into a readable story.`]}),(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{className:`text-foreground`,children:`Filters + the heatmap`}),` let you scope to a day, a coding session, a specific AI agent, or a search term. Every filter is shareable via the URL.`]})]}),(0,P.jsxs)(`p`,{className:`t-tertiary text-[10px] mt-3`,children:[`Hint: start each non-trivial task with `,(0,P.jsx)(`code`,{children:`mark_intent`}),` and you'll see crisp activity titles instead of file names.`]})]})}function Xs({activityCount:e,sessionCount:t,taskCount:n,unresolvedCount:r}){return(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,P.jsx)(Qs,{label:`Activity moments`,sublabel:`bursts of agent work`,value:e,accent:`cyan`}),(0,P.jsx)(Qs,{label:`Coding sessions`,sublabel:`each daemon run`,value:t,accent:`emerald`}),(0,P.jsx)(Qs,{label:`Tasks in progress`,sublabel:`ongoing efforts`,value:n,accent:`violet`}),(0,P.jsx)(Qs,{label:`Unresolved issues`,sublabel:r>0?`needs attention`:`all clear`,value:r,accent:r>0?`rose`:`zinc`})]})}var Zs={cyan:{border:`border-cyan-500/60`,label:`text-cyan-400`,value:`text-cyan-400`},emerald:{border:`border-emerald-500/60`,label:`text-emerald-400`,value:`text-emerald-400`},violet:{border:`border-violet-500/60`,label:`text-violet-400`,value:`text-violet-400`},rose:{border:`border-rose-500/60`,label:`text-rose-400`,value:`text-rose-400`},zinc:{border:`border-border-subtle`,label:`t-tertiary`,value:`text-foreground`}};function Qs({label:e,sublabel:t,value:n,accent:r=`zinc`}){let i=Zs[r];return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-t-2 ${i.border}`,title:t,children:[(0,P.jsx)(`p`,{className:`${i.label} text-[10px] uppercase tracking-wider font-medium`,children:e}),(0,P.jsx)(`p`,{className:`text-3xl font-bold font-mono ${i.value} mt-2`,children:n.toLocaleString()}),(0,P.jsx)(`p`,{className:`t-secondary text-xs mt-1`,children:t})]})}function $s({filters:e,sessions:t,agents:n,chips:r,onChange:i,onClear:a,isFetching:o}){let[s,c]=(0,N.useState)(e.q??``);return(0,N.useEffect)(()=>{c(e.q??``)},[e.q]),(0,N.useEffect)(()=>{let t=setTimeout(()=>{(e.q??``)!==s&&i({q:s||void 0})},350);return()=>clearTimeout(t)},[s,e.q,i]),(0,P.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-6 px-6 py-3 bg-background/85 backdrop-blur border-b border-border-subtle space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(ec,{value:(0,N.useMemo)(()=>{if(!e.from&&!e.to)return`all`;let t=Date.now(),n=Is(`7d`,t),r=Is(`30d`,t),i=Is(`today`,t);return e.from&&Math.abs(e.from-(n.from??0))<6e4&&e.to&&Math.abs(e.to-(n.to??0))<6e4?`7d`:e.from&&Math.abs(e.from-(r.from??0))<6e4&&e.to&&Math.abs(e.to-(r.to??0))<6e4?`30d`:e.from&&Math.abs(e.from-(i.from??0))<6e4&&e.to&&Math.abs(e.to-(i.to??0))<6e4?`today`:`custom`},[e.from,e.to]),onChange:e=>{if(e===`custom`)return;let t=Is(e);i({from:t.from,to:t.to})}}),(0,P.jsx)(tc,{from:e.from,to:e.to,onChange:(e,t)=>i({from:e,to:t})}),n.length>0&&(0,P.jsxs)(nc,{value:e.agent??``,onChange:e=>i({agent:e||void 0}),ariaLabel:`Filter by AI agent`,children:[(0,P.jsxs)(`option`,{value:``,children:[`All AI agents (`,n.length,`)`]}),n.map(e=>(0,P.jsxs)(`option`,{value:e.agent_name,children:[e.agent_name,` — `,e.session_count,` session`,e.session_count===1?``:`s`]},e.agent_name))]}),(0,P.jsxs)(nc,{value:e.session??``,onChange:e=>i({session:e||void 0}),ariaLabel:`Filter by coding session`,children:[(0,P.jsxs)(`option`,{value:``,children:[`All coding sessions (`,t.length,`)`]}),t.map(e=>(0,P.jsxs)(`option`,{value:e.session_id,children:[Hs(e.last_seen),` — `,e.turn_count,` activit`,e.turn_count===1?`y`:`ies`,e.agent_name&&e.agent_name!==`unknown`?` · ${e.agent_name}`:``]},e.session_id))]}),(0,P.jsx)(nc,{value:e.type??``,onChange:e=>i({type:e||void 0}),ariaLabel:`Filter by note type`,children:Ls.map(e=>(0,P.jsxs)(`option`,{value:e.value,children:[e.emoji,` `,e.label]},e.value))}),(0,P.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search your work…`,className:`flex-1 min-w-[160px] rounded-md border border-border-subtle bg-surface-secondary px-3 py-1.5 text-sm text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-violet-500`,"aria-label":`Search activity titles`}),(0,P.jsx)(rc,{value:e.density,onChange:e=>i({density:e})}),o&&(0,P.jsx)(`span`,{className:`text-[11px] t-tertiary font-mono`,children:`loading…`})]}),r.length>0&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r.map(e=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{e.key===`from`?i({from:void 0,to:void 0}):e.key===`session`?i({session:void 0}):e.key===`agent`?i({agent:void 0}):e.key===`type`?i({type:void 0}):e.key===`q`&&i({q:void 0})},className:`inline-flex items-center gap-1 rounded-full border border-violet-500/40 bg-violet-500/10 px-2 py-0.5 text-[11px] text-violet-300 hover:border-violet-400 hover:bg-violet-500/20`,children:[e.label,(0,P.jsx)(`span`,{"aria-hidden":!0,children:`✕`})]},e.key)),(0,P.jsx)(`button`,{type:`button`,onClick:a,className:`text-[11px] t-tertiary hover:text-foreground underline-offset-2 hover:underline ml-1`,children:`Clear all filters`})]})]})}function ec({value:e,onChange:t}){return(0,P.jsx)(`div`,{className:`inline-flex rounded-md border border-border-subtle overflow-hidden`,children:[{id:`today`,label:`Today`},{id:`7d`,label:`Last 7 days`},{id:`30d`,label:`Last 30 days`},{id:`all`,label:`All time`}].map((n,r)=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-2.5 py-1 text-xs transition-colors ${e===n.id?`bg-violet-500/30 text-violet-200`:`bg-surface-secondary t-secondary hover:bg-surface-secondary/70`} ${r>0?`border-l border-border-subtle`:``}`,children:n.label},n.id))})}function tc({from:e,to:t,onChange:n}){return(0,P.jsxs)(`div`,{className:`inline-flex items-center gap-1 text-xs t-secondary`,children:[(0,P.jsx)(`input`,{type:`date`,"aria-label":`From date`,value:Ws(e),onChange:e=>n(Gs(e.target.value,!1),t),className:`rounded-md border border-border-subtle bg-surface-secondary px-2 py-1 text-foreground`}),(0,P.jsx)(`span`,{children:`→`}),(0,P.jsx)(`input`,{type:`date`,"aria-label":`To date`,value:Ws(t),onChange:t=>n(e,Gs(t.target.value,!0)),className:`rounded-md border border-border-subtle bg-surface-secondary px-2 py-1 text-foreground`})]})}function nc({value:e,onChange:t,ariaLabel:n,children:r}){return(0,P.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),"aria-label":n,className:`rounded-md border border-border-subtle bg-surface-secondary px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-violet-500 max-w-[260px]`,children:r})}function rc({value:e,onChange:t}){return(0,P.jsxs)(`div`,{className:`inline-flex rounded-md border border-border-subtle overflow-hidden`,role:`group`,"aria-label":`Row density`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(`comfortable`),className:`px-2 py-1 text-[11px] transition-colors ${e===`comfortable`?`bg-violet-500/30 text-violet-200`:`bg-surface-secondary t-secondary hover:bg-surface-secondary/70`}`,title:`Spacious rows`,"aria-pressed":e===`comfortable`,children:`☰`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(`compact`),className:`px-2 py-1 text-[11px] border-l border-border-subtle transition-colors ${e===`compact`?`bg-violet-500/30 text-violet-200`:`bg-surface-secondary t-secondary hover:bg-surface-secondary/70`}`,title:`Dense rows`,"aria-pressed":e===`compact`,children:`≡`})]})}function ic({resume:e}){let t=e.intent&&e.intent.length>0?e.intent:`your last session`;return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-cyan-500/60 flex flex-wrap items-start gap-6`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`div`,{className:`text-cyan-400 text-[10px] uppercase tracking-wider font-medium`,children:`Pick up where you left off`}),(0,P.jsx)(`div`,{className:`text-foreground text-sm font-medium mt-2 truncate`,children:t}),(0,P.jsxs)(`div`,{className:`t-tertiary text-xs mt-1`,children:[`last active `,Us(e.elapsed_ms),` · session`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.session_id.slice(0,8)})]})]}),e.open_threads.length>0&&(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`text-rose-400 text-[10px] uppercase tracking-wider font-medium`,children:[`Unresolved (`,e.open_threads.length,`)`]}),(0,P.jsx)(`ul`,{className:`space-y-1 mt-2`,children:e.open_threads.slice(0,3).map(e=>(0,P.jsxs)(`li`,{className:`t-secondary text-xs`,children:[(0,P.jsx)(`span`,{className:`text-rose-400`,children:`⚠`}),` `,e.text,e.file_path&&(0,P.jsxs)(`span`,{className:`t-tertiary font-mono ml-1`,children:[`(`,e.file_path,`)`]})]},e.marker_id))})]})]})}function ac({buckets:e,filters:t,onDayClick:n}){let r=Math.max(1,...e.map(e=>e.turns)),i=e.reduce((e,t)=>e+t.turns,0);return(0,P.jsxs)(`div`,{className:`rounded-lg border border-border-subtle bg-surface-secondary/40 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`text-[11px] uppercase tracking-wider t-secondary font-mono`,children:[`Your last `,e.length,` days at a glance`]}),(0,P.jsxs)(`div`,{className:`text-[11px] t-tertiary mt-0.5`,children:[i.toLocaleString(),` activity moment`,i===1?``:`s`,` · brighter = busier · click any day to focus`]})]}),(0,P.jsxs)(`div`,{className:`text-[11px] t-tertiary font-mono`,children:[`peak `,r,`/day`]})]}),(0,P.jsx)(`div`,{className:`flex items-end gap-[3px] pb-1`,children:e.map(e=>(0,P.jsx)(oc,{bucket:e,max:r,active:sc(e.ts,t),onClick:()=>n(e.ts)},e.ts))})]})}function oc({bucket:e,max:t,active:n,onClick:r}){let i=e.turns===0?0:e.turns/t,a=e.turns===0?`bg-foreground/10 border border-border-subtle`:i>.75?`bg-violet-400`:i>.5?`bg-violet-500/85`:i>.25?`bg-violet-500/55`:`bg-violet-500/30`,o=n?`ring-2 ring-cyan-400`:``,s=`${Vs(e.ts)} — ${e.turns} activity moment${e.turns===1?``:`s`}, ${e.edits} file edit${e.edits===1?``:`s`}, ${e.tools} tool call${e.tools===1?``:`s`}`;return(0,P.jsx)(`button`,{type:`button`,onClick:r,title:s,className:`h-8 flex-1 min-w-[8px] rounded-sm hover:scale-110 transition-transform ${a} ${o}`,"aria-label":s})}function sc(e,t){return!t.from||!t.to?!1:Math.abs(t.from-e)<6e4&&t.to-t.from<1440*6e4*1.1}function cc({intents:e}){let t=e.filter(e=>e.status!==`dormant`),n=e.filter(e=>e.status===`dormant`).slice(0,3);return t.length===0&&n.length===0?null:(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`div`,{className:`text-violet-400 text-[10px] uppercase tracking-wider font-medium mb-3`,children:`Tasks you've been working on`}),(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2`,children:t.slice(0,6).map(e=>(0,P.jsxs)(`div`,{className:`rounded border border-violet-500/30 bg-violet-500/10 px-3 py-2`,children:[(0,P.jsx)(`div`,{className:`text-foreground text-sm font-medium truncate`,children:e.title||`(unnamed task)`}),(0,P.jsxs)(`div`,{className:`t-tertiary text-[11px] mt-1`,children:[e.source===`agent_marker`?`from your stated goals`:`inferred from file patterns`,` `,`· `,(e.confidence*100).toFixed(0),`% confidence · last active`,` `,Us(Date.now()-e.last_active_at)]})]},e.intent_id))}),n.length>0&&(0,P.jsxs)(`div`,{className:`mt-3 t-tertiary text-[11px]`,children:[`Older tasks (`,n.length,`):`,` `,n.map(e=>e.title||`(unnamed)`).join(` · `)]})]})}function lc({turns:e,markersByTurn:t,filters:n,totalTurns:r,totalPages:i,onPageChange:a,onTurnClick:o,selectedTurnId:s,isFetching:c}){let l=n.density===`compact`;return(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-fuchsia-500/60`,children:[(0,P.jsx)(`div`,{className:`text-fuchsia-400 text-[10px] uppercase tracking-wider font-medium`,children:`Insights — what we noticed`}),(0,P.jsxs)(`div`,{className:`t-tertiary text-xs leading-relaxed mt-2 max-w-2xl`,children:[`We'll surface stuck patterns, hot files, and learned conventions here as your agent works. Drop a few `,(0,P.jsx)(`code`,{children:`mark_intent`}),` notes to speed things up.`]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between text-xs t-tertiary`,children:[(0,P.jsx)(`span`,{children:r===0?`Nothing matches the current filters yet.`:`Showing ${e.length} of ${r.toLocaleString()} activity moment${r===1?``:`s`}`}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`page `,n.page,` / `,i]})]}),e.length===0?(0,P.jsx)(uc,{isFetching:c}):(0,P.jsx)(`div`,{className:l?`divide-y divide-border-subtle rounded-lg border border-border-subtle overflow-hidden el-raised`:`space-y-2`,children:e.map(e=>(0,P.jsx)(dc,{turn:e,markers:t.get(e.turn_id)??[],compact:l,active:s===e.turn_id,onClick:()=>o(e.turn_id)},e.turn_id))}),i>1&&(0,P.jsx)(pc,{page:n.page,totalPages:i,onChange:a})]})}function uc({isFetching:e}){return(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-6 text-sm t-secondary`,children:e?(0,P.jsx)(`span`,{children:`Loading…`}):(0,P.jsxs)(P.Fragment,{children:[`Nothing matches the current filters yet. Try`,` `,(0,P.jsx)(`span`,{className:`text-foreground`,children:`widening the date range`}),`,`,` `,(0,P.jsx)(`span`,{className:`text-foreground`,children:`clearing the search`}),`, or`,` `,(0,P.jsx)(`span`,{className:`text-foreground`,children:`picking "All time"`}),`.`]})})}function dc({turn:e,markers:t,compact:n,active:r,onClick:i}){let a=t.find(e=>e.type===`mark_intent`),o=t.filter(e=>e.type===`mark_decision`).length,s=t.filter(e=>e.type===`mark_blocker`),c=new Set(t.filter(e=>e.type===`mark_resolution`).map(e=>e.blocker_ref)),l=s.filter(e=>!c.has(e.marker_id)),u=(a?.text??``).length>0?a?.text??``:e.title&&e.title.length>0?e.title:`Activity — ${e.tool_count} tool call${e.tool_count===1?``:`s`}`;return(0,P.jsx)(`div`,{onClick:i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},role:`button`,tabIndex:0,className:`${n?`flex items-center gap-3 px-3 py-2 hover:bg-surface-secondary transition-colors cursor-pointer`:`el-raised rounded-lg border border-border-subtle hover:border-violet-500/40 transition-colors cursor-pointer`} ${r?n?`bg-violet-500/15`:`border-violet-500/60 bg-violet-500/5`:``}`,children:n?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(fc,{opened_by:e.opened_by,small:!0}),(0,P.jsx)(`span`,{className:`text-sm text-foreground truncate flex-1`,children:u}),(0,P.jsxs)(`span`,{className:`text-[11px] t-tertiary font-mono shrink-0`,children:[Vs(e.started_at),` `,Bs(e.started_at)]}),(0,P.jsxs)(`span`,{className:`text-[11px] t-tertiary shrink-0`,children:[e.tool_count,` call`,e.tool_count===1?``:`s`,` ·`,` `,e.edit_count,` edit`,e.edit_count===1?``:`s`]}),l.length>0&&(0,P.jsxs)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-rose-500/15 text-rose-400 border border-rose-500/30 shrink-0`,children:[l.length,` ⚠`]})]}):(0,P.jsxs)(`div`,{className:`px-4 py-3 flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(fc,{opened_by:e.opened_by}),(0,P.jsx)(`span`,{className:`text-sm text-foreground font-medium truncate`,children:u}),o>0&&(0,P.jsxs)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-cyan-500/15 text-cyan-400 border border-cyan-500/30 shrink-0`,children:[`💡 `,o,` decision`,o===1?``:`s`]}),l.length>0&&(0,P.jsxs)(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-rose-500/15 text-rose-400 border border-rose-500/30 shrink-0`,children:[`⚠ `,l.length,` unresolved`]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-xs t-tertiary shrink-0`,children:[(0,P.jsxs)(`span`,{children:[Vs(e.started_at),` `,Bs(e.started_at)]}),(0,P.jsx)(`span`,{children:zs(e.ended_at-e.started_at)}),(0,P.jsxs)(`span`,{children:[e.tool_count,` call`,e.tool_count===1?``:`s`,` ·`,` `,e.file_count,` file`,e.file_count===1?``:`s`,` ·`,` `,e.edit_count,` edit`,e.edit_count===1?``:`s`]})]})]})})}function fc({opened_by:e,small:t}){let n=e===`stop_hook`||e===`first_call`?`text-emerald-400 border-emerald-500/40 bg-emerald-500/10`:e===`idle_gap`?`text-amber-400 border-amber-500/40 bg-amber-500/10`:`t-secondary border-border-subtle bg-surface-secondary`,r=e===`stop_hook`?`✓ exact`:e===`first_call`?`▶ start`:e===`idle_gap`?`≈ approx`:e;return(0,P.jsx)(`span`,{title:e===`stop_hook`?`Boundary confirmed by your agent's stop signal.`:e===`first_call`?`Beginning of a coding session — exact.`:e===`idle_gap`?`Inferred from a >20s idle gap — approximate.`:e,className:`${t?`text-[9px]`:`text-[10px]`} font-mono uppercase tracking-wider px-1.5 py-0.5 rounded border ${n} shrink-0`,children:r})}function pc({page:e,totalPages:t,onChange:n}){let r=mc(e,t);return(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(Math.max(1,e-1)),disabled:e<=1,className:`rounded-md border border-border-subtle bg-surface-secondary px-3 py-1 text-xs text-foreground hover:bg-surface-secondary/70 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`← Newer`}),(0,P.jsx)(`div`,{className:`flex items-center gap-1`,children:r.map(({key:t,value:r})=>r===`…`?(0,P.jsx)(`span`,{className:`px-2 t-tertiary text-xs`,children:`…`},t):(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(r),className:`min-w-[28px] rounded-md px-2 py-1 text-xs border border-border-subtle transition-colors ${r===e?`bg-violet-500/30 text-violet-200`:`bg-surface-secondary t-secondary hover:bg-surface-secondary/70`}`,children:r},t))}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(Math.min(t,e+1)),disabled:e>=t,className:`rounded-md border border-border-subtle bg-surface-secondary px-3 py-1 text-xs text-foreground hover:bg-surface-secondary/70 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Older →`})]})}function mc(e,t){if(t<=7)return Array.from({length:t},(e,t)=>({key:`page-${t+1}`,value:t+1}));let n=[...new Set([1,t,e,e-1,e+1,e-2,e+2])].filter(e=>e>=1&&e<=t).sort((e,t)=>e-t),r=[];for(let e=0;e<n.length;e++){let t=n[e];if(e>0&&t-n[e-1]>1){let i=n[e-1];r.push({key:`ellipsis-${i}-${t}`,value:`…`})}r.push({key:`page-${t}`,value:t})}return r}function hc({turn:e,markers:t,episodicByFile:n,onClose:r}){let i=(0,N.useMemo)(()=>[...new Set(t.map(e=>e.file_path).filter(e=>typeof e==`string`&&e.length>0))],[t]),a=(0,N.useMemo)(()=>{let e=[];for(let t of i){let r=n.get(t);r&&e.push(...r)}return e.slice(0,5)},[i,n]);return(0,P.jsx)(`div`,{className:`fixed inset-0 z-30 flex justify-end bg-black/40 backdrop-blur-sm`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`dialog`,"aria-modal":`true`,tabIndex:-1,children:(0,P.jsxs)(`aside`,{className:`h-full w-full max-w-md bg-background border-l border-border-subtle shadow-2xl overflow-y-auto`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`document`,children:[(0,P.jsxs)(`div`,{className:`sticky top-0 bg-background/90 backdrop-blur border-b border-border-subtle p-4 flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`t-tertiary text-[10px] uppercase tracking-wider font-medium`,children:`Activity detail`}),(0,P.jsx)(`div`,{className:`text-sm text-foreground font-medium mt-1 truncate`,children:e.title||`(activity ${e.turn_id.slice(0,8)})`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-md border border-border-subtle bg-surface-secondary px-2 py-1 t-secondary hover:text-foreground hover:bg-surface-secondary/70 transition-colors`,"aria-label":`Close detail panel`,children:`✕`})]}),(0,P.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,P.jsx)(gc,{turn:e}),(0,P.jsx)(vc,{markers:t}),a.length>0&&(0,P.jsx)(yc,{narratives:a})]})]})})}function gc({turn:e}){return(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,P.jsx)(_c,{label:`When it started`,value:Hs(e.started_at)}),(0,P.jsx)(_c,{label:`How long it lasted`,value:zs(e.ended_at-e.started_at)}),(0,P.jsx)(_c,{label:`Tool calls`,value:String(e.tool_count)}),(0,P.jsx)(_c,{label:`Files touched`,value:String(e.file_count)}),(0,P.jsx)(_c,{label:`File edits`,value:String(e.edit_count)}),(0,P.jsx)(_c,{label:`Boundary precision`,value:e.opened_by===`stop_hook`?`Confirmed by agent`:e.opened_by===`first_call`?`Session start`:e.opened_by===`idle_gap`?`Inferred from idle gap`:e.opened_by}),(0,P.jsx)(_c,{label:`Why this ended`,value:e.closed_reason===`session_end`?`Session shutdown`:e.closed_reason===`idle_gap`?`Long idle gap`:e.closed_reason===`stop_hook`?`Agent stopped`:e.closed_reason}),(0,P.jsx)(_c,{label:`Outcome`,value:e.outcome===`unknown`?`—`:e.outcome}),(0,P.jsx)(_c,{label:`Activity ID`,value:e.turn_id.slice(0,8),mono:!0}),(0,P.jsx)(_c,{label:`Session`,value:e.session_id.slice(0,8),mono:!0})]})}function _c({label:e,value:t,mono:n}){return(0,P.jsxs)(`div`,{className:`rounded border border-border-subtle bg-surface-secondary px-2 py-1.5`,children:[(0,P.jsx)(`div`,{className:`t-tertiary text-[10px] uppercase tracking-wider font-medium`,children:e}),(0,P.jsx)(`div`,{className:`text-foreground mt-0.5 truncate ${n?`font-mono`:``}`,children:t})]})}function vc({markers:e}){return e.length===0?(0,P.jsxs)(`div`,{className:`t-tertiary text-xs leading-relaxed`,children:[`No notes recorded for this activity. Tip: drop a`,` `,(0,P.jsx)(`code`,{className:`t-secondary`,children:`mark_intent`}),` at the start of your next task and a `,(0,P.jsx)(`code`,{className:`t-secondary`,children:`mark_decision`}),` when you pick between options — they show up here as a readable trail.`]}):(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`t-secondary text-[10px] uppercase tracking-wider font-medium`,children:[`Notes from this activity (`,e.length,`)`]}),e.map(e=>{let t=Rs(e.type);return(0,P.jsxs)(`div`,{className:`rounded border border-border-subtle bg-surface-secondary px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`span`,{className:`text-[10px] font-mono uppercase ${t.color}`,children:[t.emoji,` `,t.label]}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:Bs(e.ts)})]}),(0,P.jsx)(`div`,{className:`text-xs text-foreground mt-1`,children:e.text}),e.file_path&&(0,P.jsx)(`div`,{className:`t-tertiary text-[11px] font-mono mt-1`,children:e.file_path}),e.blocker_ref&&(0,P.jsxs)(`div`,{className:`t-tertiary text-[11px] mt-1`,children:[`resolves →`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.blocker_ref.slice(0,8)})]})]},e.marker_id)})]})}function yc({narratives:e}){return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`t-secondary text-[10px] uppercase tracking-wider font-medium`,children:`Recent edits to these files`}),e.map(e=>{let t=Ks(e.content);return(0,P.jsxs)(`div`,{className:`rounded border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs`,children:[(0,P.jsx)(`div`,{className:`text-emerald-400 font-mono text-[10px] uppercase mb-1`,children:e.scope}),t.what&&(0,P.jsxs)(`div`,{className:`text-foreground`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`What — `}),t.what]}),t.why&&(0,P.jsxs)(`div`,{className:`t-secondary mt-1`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`Why — `}),t.why]}),t.how&&(0,P.jsxs)(`div`,{className:`t-secondary mt-1`,children:[(0,P.jsx)(`span`,{className:`t-tertiary`,children:`How — `}),t.how]}),!t.what&&!t.why&&!t.how&&(0,P.jsx)(`div`,{className:`t-secondary`,children:e.content})]},e.fact_id)})]})}function bc(e){let t=new URLSearchParams;return e.from!==void 0&&t.set(`from`,String(e.from)),e.to!==void 0&&t.set(`to`,String(e.to)),e.session&&t.set(`session_id`,e.session),e.q&&t.set(`q`,e.q),t.set(`limit`,String(e.perPage)),t.set(`offset`,String((e.page-1)*e.perPage)),t.toString()}function xc(e){let t=new Map;for(let n of e){let e=t.get(n.turn_id)??[];e.push(n),t.set(n.turn_id,e)}return t}function Sc(e){return e<60?`${Math.round(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.round(e%60)}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Cc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function wc(e){switch(e){case`running`:case`ready`:return`bg-emerald-500 shadow-[0_0_8px_rgba(52,211,153,0.5)]`;case`indexing`:return`bg-amber-400 animate-pulse shadow-[0_0_8px_rgba(251,191,36,0.5)]`;default:return`bg-red-500 shadow-[0_0_8px_rgba(248,113,113,0.5)]`}}function Tc(e){switch(e){case`running`:case`ready`:return`Operational`;case`indexing`:return`Indexing`;default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Ec({value:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`button`,{type:`button`,className:`ml-2 inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium t-tertiary hover:text-foreground hover:el-raised transition-all`,onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},children:t?(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3 w-3 text-emerald-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}):(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3 w-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})}function Dc({label:e,value:t,sub:n,color:r=`violet`}){return(0,P.jsxs)(`div`,{className:`glass-card rounded-lg p-4 ring-1 ${{violet:`ring-violet-500/20`,cyan:`ring-cyan-500/20`,emerald:`ring-emerald-500/20`,amber:`ring-amber-500/20`}[r]}`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[11px] uppercase tracking-wide`,children:e}),(0,P.jsx)(`p`,{className:`mt-1 text-2xl font-mono font-bold ${{violet:`text-violet-400`,cyan:`text-cyan-400`,emerald:`text-emerald-400`,amber:`text-amber-400`}[r]}`,children:t}),n&&(0,P.jsx)(`p`,{className:`mt-0.5 t-tertiary text-xs`,children:n})]})}function Oc({label:e,value:t,mono:n=!0,copyable:r=!1}){let i=t??`—`;return(0,P.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-2 border-b border-border-subtle/50 last:border-0`,children:[(0,P.jsx)(`dt`,{className:`t-secondary text-sm shrink-0`,children:e}),(0,P.jsxs)(`dd`,{className:`text-right text-xs text-foreground ${n?`font-mono`:``} flex items-center`,children:[(0,P.jsx)(`span`,{className:`break-all`,children:i}),r&&typeof i==`string`&&(0,P.jsx)(Ec,{value:i})]})]})}function kc({name:e}){return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium ring-1 ${{audit:`bg-violet-500/15 text-violet-400 ring-violet-500/30`,blame:`bg-cyan-500/15 text-cyan-400 ring-cyan-500/30`,test:`bg-emerald-500/15 text-emerald-400 ring-emerald-500/30`,lint:`bg-amber-500/15 text-amber-400 ring-amber-500/30`,commit:`bg-violet-500/15 text-violet-400 ring-violet-500/30`,"review-pr":`bg-cyan-500/15 text-cyan-400 ring-cyan-500/30`}[e.replace(/^unerr-/,``)]??`bg-violet-500/10 text-violet-400 ring-violet-500/20`}`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-2.5 w-2.5`,fill:`currentColor`,viewBox:`0 0 8 8`,children:(0,P.jsx)(`circle`,{cx:`4`,cy:`4`,r:`3`})}),e]})}function Ac({config:e}){let t=Object.entries(e);return t.length===0?(0,P.jsx)(`p`,{className:`t-tertiary text-sm italic`,children:`No configuration entries.`}):(0,P.jsx)(`div`,{className:`space-y-1`,children:t.map(([e,t])=>{let n=typeof t==`object`&&t?JSON.stringify(t,null,2):String(t??`—`),r=typeof t==`object`&&!!t;return(0,P.jsxs)(`div`,{className:`rounded-lg border border-border-subtle/50 p-3 ${r?``:`flex items-baseline justify-between gap-4`}`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),r?(0,P.jsx)(`pre`,{className:`mt-2 custom-scrollbar max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-black/20 p-2.5 font-mono text-xs leading-relaxed t-secondary`,children:n}):(0,P.jsx)(`span`,{className:`font-mono text-xs t-secondary`,children:n})]},e)})})}function jc(){let{url:e,queryKey:t}=I(),n=F({queryKey:t([`system`,`status`]),queryFn:()=>o(e(`/api/system/status`)),refetchInterval:5e3}),r=F({queryKey:t([`system`,`config`]),queryFn:()=>o(e(`/api/system/config`))}),i=n.data?.data,a=r.data?.data;return n.isLoading||r.isLoading?(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[1,2,3,4].map(e=>(0,P.jsx)(Nt,{className:`h-24 w-full rounded-lg`},e))}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-6 lg:flex-row`,children:[(0,P.jsx)(Nt,{className:`h-72 flex-1 rounded-xl`}),(0,P.jsx)(Nt,{className:`h-72 flex-1 rounded-xl`})]})]}):n.isError&&r.isError?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,P.jsxs)(`div`,{className:`glass-panel rounded-xl p-8 text-center max-w-md`,children:[(0,P.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-500/15`,children:(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-6 w-6 text-red-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z`})})}),(0,P.jsx)(`h3`,{className:`text-foreground font-medium`,children:`Connection Error`}),(0,P.jsx)(`p`,{className:`mt-2 t-secondary text-sm`,children:`Unable to reach the unerr proxy. Ensure the process is running.`})]})}):(0,P.jsxs)(`div`,{className:`space-y-8`,children:[(0,P.jsx)(`div`,{className:`glass-panel rounded-xl p-5`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,P.jsx)(`div`,{className:`relative flex h-11 w-11 items-center justify-center rounded-xl bg-violet-500/15 ring-1 ring-violet-500/30`,children:(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-5 w-5 text-violet-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.8,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5.121 17.804A13.937 13.937 0 0112 16c2.5 0 4.847.655 6.879 1.804M15 10a3 3 0 11-6 0 3 3 0 016 0zm6 2a9 9 0 11-18 0 9 9 0 0118 0z`})})}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,P.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Process Instance`}),(0,P.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-full ${i?wc(i.status):`bg-gray-500`}`}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:i?Tc(i.status):`Unknown`})]}),(0,P.jsxs)(`p`,{className:`mt-0.5 t-tertiary text-xs font-mono`,children:[`PID `,i?.pid??`—`,` · `,i?.mode??`—`,` mode · port`,` `,i?.dashboard_port??`—`]})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i?.ide&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-cyan-500/10 px-3 py-1 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3 w-3`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,P.jsx)(`path`,{d:`M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z`})}),i.ide]}),(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-violet-500/10 px-3 py-1 text-xs font-medium text-violet-400 ring-1 ring-violet-500/20`,children:[`Uptime: `,i?Sc(i.uptime_s):`—`]})]})]})}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,P.jsx)(Dc,{label:`Graph Entities`,value:i?Cc(i.graph.entities):`—`,sub:i?`${Cc(i.graph.edges)} edges`:void 0,color:`violet`}),(0,P.jsx)(Dc,{label:`Rules Active`,value:i?.graph.rules??`—`,sub:`conventions & patterns`,color:`cyan`}),(0,P.jsx)(Dc,{label:`Tool Calls`,value:i?Cc(i.session.tool_calls):`—`,sub:`this session`,color:`emerald`}),(0,P.jsx)(Dc,{label:`Tokens Saved`,value:i?Cc(i.session.tokens_saved):`—`,sub:i?.session.violations_caught?`${i.session.violations_caught} violations caught`:`via compression`,color:`amber`})]}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-6 lg:flex-row`,children:[(0,P.jsxs)(`section`,{className:`flex-1 glass-panel rounded-xl p-5`,children:[(0,P.jsxs)(`h2`,{className:`section-label text-violet-500 flex items-center gap-2`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z`})}),`Process Details`]}),n.isError?(0,P.jsx)(`p`,{className:`mt-4 text-error text-sm`,children:`Could not reach proxy.`}):(0,P.jsxs)(`dl`,{className:`mt-4`,children:[(0,P.jsx)(Oc,{label:`Status`,value:i?Tc(i.status):void 0,mono:!1}),(0,P.jsx)(Oc,{label:`Process ID`,value:i?.pid,copyable:!0}),(0,P.jsx)(Oc,{label:`Mode`,value:i?.mode}),(0,P.jsx)(Oc,{label:`Dashboard Port`,value:i?.dashboard_port}),(0,P.jsx)(Oc,{label:`IDE`,value:i?.ide||`None detected`}),(0,P.jsx)(Oc,{label:`Uptime`,value:i?Sc(i.uptime_s):void 0}),(0,P.jsx)(Oc,{label:`Working Directory`,value:i?.cwd,copyable:!0}),(0,P.jsx)(Oc,{label:`Session Started`,value:i?.session.started_at?new Date(i.session.started_at).toLocaleString():void 0})]})]}),(0,P.jsxs)(`section`,{className:`flex-1 glass-panel rounded-xl p-5`,children:[(0,P.jsxs)(`h2`,{className:`section-label text-cyan-500 flex items-center gap-2`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M13 10V3L4 14h7v7l9-11h-7z`})}),`Installed Skills`]}),(0,P.jsxs)(`p`,{className:`mt-1 t-tertiary text-xs`,children:[`Agent skills installed in this repository via`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:`unerr install`}),`.`]}),r.isError?(0,P.jsx)(`p`,{className:`mt-4 text-error text-sm`,children:`Could not load config.`}):a?.skills_installed?.length?(0,P.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:a.skills_installed.map(e=>(0,P.jsx)(kc,{name:e},e))}):(0,P.jsxs)(`div`,{className:`mt-6 flex flex-col items-center py-6 text-center`,children:[(0,P.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-amber-500/10 ring-1 ring-amber-500/20`,children:(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-5 w-5 text-amber-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})})}),(0,P.jsx)(`p`,{className:`text-sm text-foreground`,children:`No skills installed`}),(0,P.jsxs)(`p`,{className:`mt-1 t-tertiary text-xs max-w-[240px]`,children:[`Run`,` `,(0,P.jsx)(`code`,{className:`font-mono text-violet-400`,children:`unerr install <agent>`}),` `,`to install skills for your IDE.`]})]}),(0,P.jsxs)(`div`,{className:`mt-6 border-t border-border-subtle/50 pt-5`,children:[(0,P.jsxs)(`h3`,{className:`section-label text-violet-500 flex items-center gap-2`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01`})}),`Graph Intelligence`]}),(0,P.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-3`,children:[(0,P.jsxs)(`div`,{className:`rounded-lg bg-violet-500/5 p-3 text-center ring-1 ring-violet-500/10`,children:[(0,P.jsx)(`p`,{className:`text-xl font-mono font-bold text-violet-400`,children:i?Cc(i.graph.entities):`—`}),(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Entities`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-cyan-500/5 p-3 text-center ring-1 ring-cyan-500/10`,children:[(0,P.jsx)(`p`,{className:`text-xl font-mono font-bold text-cyan-400`,children:i?Cc(i.graph.edges):`—`}),(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Edges`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-emerald-500/5 p-3 text-center ring-1 ring-emerald-500/10`,children:[(0,P.jsx)(`p`,{className:`text-xl font-mono font-bold text-emerald-400`,children:i?.graph.rules??`—`}),(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Rules`})]})]})]})]})]}),(0,P.jsxs)(`section`,{className:`glass-panel rounded-xl p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`h2`,{className:`section-label text-emerald-500 flex items-center gap-2`,children:[(0,P.jsxs)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z`}),(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`})]}),`Repository Configuration`]}),(0,P.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2.5 py-0.5 text-[10px] font-mono text-emerald-400 ring-1 ring-emerald-500/20`,children:`.unerr/config.json`})]}),(0,P.jsxs)(`p`,{className:`mt-1 t-tertiary text-xs`,children:[`Per-repository configuration. Edit`,` `,(0,P.jsx)(`code`,{className:`font-mono text-emerald-400`,children:`.unerr/config.json`}),` `,`directly to modify settings.`]}),(0,P.jsx)(`div`,{className:`mt-4`,children:r.isError?(0,P.jsx)(`p`,{className:`text-error text-sm`,children:`Could not load configuration.`}):(0,P.jsx)(Ac,{config:a?.repo_config??{}})})]}),(0,P.jsxs)(`section`,{className:`glass-panel rounded-xl p-5`,children:[(0,P.jsxs)(`h2`,{className:`section-label text-amber-500 flex items-center gap-2`,children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M13 7h8m0 0v8m0-8l-8 8-4-4-6 6`})}),`Session Performance`]}),(0,P.jsx)(`p`,{className:`mt-1 t-tertiary text-xs`,children:`Live metrics for the current proxy session. Resets when the process restarts.`}),(0,P.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,P.jsxs)(`div`,{className:`rounded-lg border border-border-subtle/50 p-3`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Tool Calls`}),(0,P.jsx)(`p`,{className:`mt-1 text-xl font-mono font-bold text-foreground`,children:i?Cc(i.session.tool_calls):`—`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-border-subtle/50 p-3`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Tokens Saved`}),(0,P.jsx)(`p`,{className:`mt-1 text-xl font-mono font-bold text-foreground`,children:i?Cc(i.session.tokens_saved):`—`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-border-subtle/50 p-3`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Violations`}),(0,P.jsx)(`p`,{className:`mt-1 text-xl font-mono font-bold text-foreground`,children:i?.session.violations_caught??`—`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-border-subtle/50 p-3`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wide`,children:`Session Start`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs font-mono text-foreground leading-relaxed`,children:i?.session.started_at?new Date(i.session.started_at).toLocaleTimeString():`—`})]})]})]})]})}var Mc={graph_query:{bg:`bg-violet-500/20`,text:`text-violet-400`,bar:`bg-violet-500`,ring:`ring-violet-500/40`},shell_compression:{bg:`bg-cyan-500/20`,text:`text-cyan-400`,bar:`bg-cyan-500`,ring:`ring-cyan-500/40`},format_encoding:{bg:`bg-amber-500/20`,text:`text-amber-400`,bar:`bg-amber-500`,ring:`ring-amber-500/40`},session_dedup:{bg:`bg-emerald-500/20`,text:`text-emerald-400`,bar:`bg-emerald-500`,ring:`ring-emerald-500/40`},smart_truncation:{bg:`bg-blue-500/20`,text:`text-blue-400`,bar:`bg-blue-500`,ring:`ring-blue-500/40`},file_read:{bg:`bg-indigo-500/20`,text:`text-indigo-400`,bar:`bg-indigo-500`,ring:`ring-indigo-500/40`},behavior_automation:{bg:`bg-rose-500/20`,text:`text-rose-400`,bar:`bg-rose-500`,ring:`ring-rose-500/40`}},Nc=[`graph_query`,`shell_compression`,`format_encoding`,`session_dedup`,`smart_truncation`,`file_read`,`behavior_automation`];function G(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Pc(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Fc(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Ic(e){return Mc[e]??{bg:`bg-zinc-500/20`,text:`text-zinc-400`,bar:`bg-zinc-500`,ring:`ring-zinc-500/40`}}function Lc(e){let t=e.detail;if(!t)return e.tool??`optimization`;if(t.command){let e=String(t.command);return e.length>80?`${e.slice(0,77)}…`:e}return t.optimization?String(t.optimization):t.counterfactual&&t.counterfactual!==`generic file exploration`?String(t.counterfactual):t.format?`${e.tool??`query`} → ${t.format} format`:e.tool??`optimization`}function Rc(e){if(e.length===0)return{label:`Empty turn`,subtitle:``};let t=[...new Set(e.map(e=>e.tool).filter(Boolean))],n=[...new Set(e.map(e=>e.mechanism))],r=e.find(e=>e.detail?.command);if(r){let t=String(r.detail?.command);return{label:t.length>60?`${t.slice(0,57)}…`:t,subtitle:`shell → ${e.length} optimization${e.length>1?`s`:``}`}}let i=e.find(e=>e.detail?.optimization);if(i){let n=String(i.detail?.optimization),r=e.length>1?` +${e.length-1} more`:``;return{label:n,subtitle:t.join(`, `)+r}}if(t.length>0){let r=t.join(` → `),i=e.length,a=n[0]?.replace(/_/g,` `)??``;return{label:r,subtitle:`${i} event${i>1?`s`:``} · ${a}`}}return{label:n.map(e=>e.replace(/_/g,` `)).join(`, `),subtitle:`${e.length} event${e.length>1?`s`:``}`}}function zc({label:e,value:t,accent:n,hint:r}){return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-4`,title:r,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-xs uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:`mt-1 text-2xl font-bold font-mono tabular-nums ${n??`text-foreground`}`,children:t})]})}function Bc({mechanisms:e,totalSaved:t}){let n=Object.entries(e).sort(([,e],[,t])=>t.tokens_saved-e.tokens_saved);if(n.length===0)return(0,P.jsx)(`p`,{className:`t-secondary text-sm py-3`,children:`No mechanism data.`});let r=n[0][1].tokens_saved||1;return(0,P.jsx)(`div`,{className:`space-y-1.5`,children:n.map(([e,t])=>{let n=Ic(e),i=Math.max(3,t.tokens_saved/r*100);return(0,P.jsxs)(`div`,{className:`flex items-center gap-3 py-0.5`,children:[(0,P.jsx)(`span`,{className:`${n.text} text-xs font-medium w-36 shrink-0 truncate`,children:e.replace(/_/g,` `)}),(0,P.jsx)(`div`,{className:`flex-1 h-5 rounded bg-surface-secondary overflow-hidden`,children:(0,P.jsx)(`div`,{className:`h-full ${n.bar} opacity-80 rounded`,style:{width:`${i}%`}})}),(0,P.jsx)(`span`,{className:`text-success font-mono text-xs w-14 text-right shrink-0`,children:G(t.tokens_saved)}),(0,P.jsxs)(`span`,{className:`t-tertiary font-mono text-xs w-10 text-right shrink-0`,children:[t.pct_of_total,`%`]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs w-8 text-right shrink-0`,children:[t.event_count,`×`]})]},e)})})}function Vc({mechanism:e}){let t=Ic(e);return(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 ${t.bg} ${t.text} text-[10px] font-medium`,children:e.replace(/_/g,` `)})}function Hc({items:e}){return(0,P.jsx)(`nav`,{className:`flex items-center gap-1.5 text-sm mb-5`,children:e.map((t,n)=>{let r=n===e.length-1;return(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[n>0&&(0,P.jsx)(`span`,{className:`t-tertiary`,children:`›`}),r?(0,P.jsx)(`span`,{className:`text-foreground font-medium`,children:t.label}):(0,P.jsx)(`button`,{type:`button`,className:`text-violet-400 hover:text-violet-300 transition-colors cursor-pointer`,onClick:t.onClick,children:t.label})]},t.label)})})}var Uc={"claude-code":{bg:`bg-amber-500/20`,text:`text-amber-400`,label:`Claude Code`},"claude-desktop":{bg:`bg-amber-500/20`,text:`text-amber-400`,label:`Claude Desktop`},cursor:{bg:`bg-blue-500/20`,text:`text-blue-400`,label:`Cursor`},cline:{bg:`bg-emerald-500/20`,text:`text-emerald-400`,label:`Cline`},windsurf:{bg:`bg-cyan-500/20`,text:`text-cyan-400`,label:`Windsurf`},copilot:{bg:`bg-zinc-500/20`,text:`text-zinc-400`,label:`Copilot`}};function Wc({name:e}){if(!e)return(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:`unknown`});let t=Uc[e.toLowerCase().replace(/\s+/g,`-`)]??{bg:`bg-zinc-500/20`,text:`text-zinc-400`,label:e};return(0,P.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 ${t.bg} ${t.text} text-[10px] font-medium`,children:t.label})}function Gc({total:e,limit:t,offset:n,onPageChange:r}){let i=Math.ceil(e/t),a=Math.floor(n/t)+1;return i<=1?null:(0,P.jsxs)(`div`,{className:`flex items-center justify-between px-1 py-2`,children:[(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[n+1,`–`,Math.min(n+t,e),` of `,e]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:a<=1,className:`px-2.5 py-1 rounded text-xs font-medium bg-surface-secondary hover:bg-surface-tertiary disabled:opacity-30 disabled:cursor-not-allowed text-foreground transition-colors`,onClick:()=>r(Math.max(0,n-t)),children:`‹ Prev`}),(0,P.jsxs)(`span`,{className:`t-secondary text-xs px-2 font-mono`,children:[a,`/`,i]}),(0,P.jsx)(`button`,{type:`button`,disabled:a>=i,className:`px-2.5 py-1 rounded text-xs font-medium bg-surface-secondary hover:bg-surface-tertiary disabled:opacity-30 disabled:cursor-not-allowed text-foreground transition-colors`,onClick:()=>r(n+t),children:`Next ›`})]})]})}function Kc({onSelectSession:e}){let{url:t,queryKey:n}=I(),[r,i]=(0,N.useState)(``),[a,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(0),u=r||a?`${r?`&from_ts=${r}`:``}${a?`&to_ts=${a}`:``}`:``,d=F({queryKey:n([`token-flow-global`,r,a]),queryFn:()=>o(t(`/api/token-flow/global?_=1${u}`)),refetchInterval:5e3}),f=F({queryKey:n([`token-flow-sessions`,r,a,c]),queryFn:()=>o(t(`/api/token-flow/sessions?limit=20&offset=${c}${u}`)),refetchInterval:5e3});if(d.isLoading)return(0,P.jsx)(Ft,{n:4});let p=d.data?.data,m=f.data?.data??[],h=f.data?.total??0;return!p||p.event_count===0?(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-10 text-center`,children:[(0,P.jsx)(`p`,{className:`t-secondary text-lg`,children:`No token flow data yet`}),(0,P.jsx)(`p`,{className:`t-tertiary mt-2 text-sm`,children:`Token savings appear here as the agent makes tool calls through unerr.`}),(0,P.jsx)(`p`,{className:`t-tertiary mt-1 text-xs`,children:`Sources: graph queries, shell compression, format encoding, session dedup, smart truncation, file reads, behavior automation.`})]}):(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3 flex-wrap -mt-2`,children:[(0,P.jsx)(ds,{fromTs:r,toTs:a,onChange:(e,t)=>{i(e),s(t),l(0)}}),(0,P.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium t-secondary hover:text-foreground hover:bg-surface-secondary transition-colors`,title:`Export all token flow data as CSV`,onClick:()=>{let e=r||a?`${r?`&from_ts=${r}`:``}${a?`&to_ts=${a}`:``}`:``;fetch(t(`/api/token-flow/events?limit=500${e}`)).then(e=>e.json()).then(e=>{let t=e.data??[];if(t.length===0)return;let n=[`timestamp`,`session_id`,`turn`,`mechanism`,`tool`,`tokens_without`,`tokens_with`,`tokens_saved`,`detail`],r=t.map(e=>[e.ts,e.session_id,e.turn,e.mechanism,e.tool??``,e.tokens_without,e.tokens_with,e.tokens_saved,(e.detail??``).toString().replace(/"/g,`""`)].map(e=>`"${e}"`).join(`,`)),i=[n.join(`,`),...r].join(`
|
|
2
|
-
`),a=new Blob([i],{type:`text/csv`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`token-economics-${new Date().toISOString().slice(0,10)}.csv`,s.click(),URL.revokeObjectURL(o)})},children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`})}),`Export CSV`]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-5`,children:[(0,P.jsx)(zc,{label:`Total Tokens Saved`,value:G(p.total_tokens_saved),accent:`text-success`,hint:`Total tokens removed from responses across all sessions — direct savings before context compounding`}),(0,P.jsx)(zc,{label:`Context Avoided`,value:G(p.total_context_avoided),accent:`text-cyan-400`,hint:`Total token-turns of context pressure prevented — savings compound because each turn's reduction carries forward to all future turns`}),(0,P.jsx)(zc,{label:`Total Delivered`,value:G(p.total_tokens_with),hint:`Total tokens actually sent to the agent after optimization`}),(0,P.jsx)(zc,{label:`Efficiency`,value:`${p.efficiency_pct}%`,accent:`text-violet-400`,hint:`Percentage of original tokens that were optimized away (saved ÷ original)`}),(0,P.jsx)(zc,{label:`Sessions`,value:p.total_sessions,hint:`Number of distinct agent sessions tracked`})]}),p.avg_context_reduction>0&&(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-cyan-500/60`,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Context Pressure Prevented`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-1 max-w-xl`,children:[`Across `,p.total_sessions,` session`,p.total_sessions===1?``:`s`,` and `,p.total_turns,` turns,`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-medium`,children:G(p.total_context_avoided)}),` `,`total token-turns of context avoided — each turn ran with`,` `,G(p.avg_context_reduction),` fewer tokens on average, peaking at `,G(p.peak_context_reduction),`.`]})]}),(0,P.jsxs)(`div`,{className:`flex gap-6 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Total Context Avoided`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono font-medium text-lg`,children:G(p.total_context_avoided)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Avg / Turn`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono font-medium text-lg`,children:G(p.avg_context_reduction)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Direct Savings`}),(0,P.jsx)(`p`,{className:`text-success font-mono font-medium text-lg`,children:G(p.total_tokens_saved)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Compound Multiplier`}),(0,P.jsx)(`p`,{className:`text-violet-400 font-mono font-medium text-lg`,children:p.total_tokens_saved>0?`${(p.total_context_avoided/p.total_tokens_saved).toFixed(1)}×`:`—`})]})]})]})}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsxs)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,children:[`Savings by Mechanism`,r||a?` (Filtered)`:` (All Time)`]}),(0,P.jsx)(Bc,{mechanisms:p.by_mechanism,totalSaved:p.total_tokens_saved})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,children:`Sessions`}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[h,` session`,h===1?``:`s`]})]}),m.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No sessions recorded.`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[700px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-2.5 font-medium`,title:`Unique session identifier`,children:`Session`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`AI agent that ran this session`,children:`Agent`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`When the last event was recorded`,children:`Last Active`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Number of optimization events in this session`,children:`Events`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Types of optimization applied (e.g. graph query, shell compression)`,children:`Mechanisms`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Total tokens removed from responses (direct savings)`,children:`Tokens Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Average tokens of context pressure avoided per turn — savings compound because each turn's reduction carries to all future turns`,children:`Avg Context Reduced`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 pr-5 font-medium w-16`})]})}),(0,P.jsx)(`tbody`,{children:m.map((t,n)=>(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors cursor-pointer group`,onClick:()=>e(t.session_id),children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-foreground group-hover:text-violet-400 transition-colors`,children:t.session_id.slice(0,12)}),n===0&&c===0&&(0,P.jsx)(`span`,{className:`rounded-full bg-emerald-500/20 text-emerald-400 px-2 py-0.5 text-[10px] font-medium`,children:`latest`})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(Wc,{name:t.agent_name})}),(0,P.jsx)(`td`,{className:`px-3 py-3 t-secondary text-xs`,children:Pc(t.last_ts)}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs tabular-nums`,children:t.event_count}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.mechanisms.slice(0,4).map(e=>(0,P.jsx)(Vc,{mechanism:e},e)),t.mechanisms.length>4&&(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px]`,children:[`+`,t.mechanisms.length-4]})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-sm`,children:G(t.total_saved)})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:t.avg_context_reduction>0?(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono font-medium text-sm`,title:`Each turn ran with ~${G(t.avg_context_reduction)} fewer tokens in context on average (across ${t.total_turns} turns)`,children:G(t.avg_context_reduction)}):(0,P.jsx)(`span`,{className:`t-tertiary font-mono text-sm`,children:`—`})}),(0,P.jsx)(`td`,{className:`pl-4 py-3 pr-5 text-right w-16`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-violet-400 opacity-0 group-hover:opacity-100 transition-opacity font-medium whitespace-nowrap`,children:[`View`,` `,(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]})})]},t.session_id))})]})}),(0,P.jsx)(`div`,{className:`px-5 py-2 border-t border-border-subtle`,children:(0,P.jsx)(Gc,{total:h,limit:20,offset:c,onPageChange:l})})]})]})]})}function qc({sessionId:e,onSelectTurn:t}){let{url:n,queryKey:r}=I(),[i,a]=(0,N.useState)(0),s=F({queryKey:r([`token-flow-session`,e]),queryFn:()=>o(n(`/api/token-flow/session${e?`?session_id=${e}`:``}`)),refetchInterval:5e3}),c=F({queryKey:r([`token-flow-cumulative`,e]),queryFn:()=>o(n(`/api/token-flow/cumulative?session_id=${e}`)),refetchInterval:5e3}),l=F({queryKey:r([`token-flow-events`,e]),queryFn:()=>o(n(`/api/token-flow/events?session_id=${e}`)),refetchInterval:5e3});if(s.isLoading)return(0,P.jsx)(Ft,{n:4});let u=s.data?.data,d=c.data?.data??[],f=l.data?.data??[];if(!u)return(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-8 text-center`,children:(0,P.jsxs)(`p`,{className:`t-secondary`,children:[`No data for session `,e.slice(0,12)]})});let p=new Map;for(let e of f){let t=p.get(e.turn)??[];t.push(e),p.set(e.turn,t)}let m=[...p.entries()].sort(([e],[t])=>t-e),h=m.slice(i*20,(i+1)*20),g=h.reduce((e,[,t])=>{let n=t.reduce((e,t)=>e+t.tokens_saved,0);return Math.max(e,n)},1),_=new Map;for(let e of d)_.set(e.turn,e);return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-5`,children:[(0,P.jsx)(zc,{label:`Tokens Saved`,value:G(u.total_tokens_saved),accent:`text-success`,hint:`Tokens removed from responses in this session`}),(0,P.jsx)(zc,{label:`Delivered`,value:G(u.total_tokens_with),hint:`Tokens actually sent to the agent after optimization`}),(0,P.jsx)(zc,{label:`Without unerr`,value:G(u.total_tokens_without),hint:`Tokens that would have been sent without unerr`}),(0,P.jsx)(zc,{label:`Efficiency`,value:`${u.efficiency_pct}%`,accent:`text-violet-400`,hint:`Percentage of original tokens optimized away`}),(0,P.jsx)(zc,{label:`Turns`,value:u.total_turns,hint:`Number of conversation turns in this session`})]}),(c.data?.avg_context_reduction??0)>0&&(()=>{let e=c.data;return(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-cyan-500/60`,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Context Pressure Prevented`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-1 max-w-xl`,children:[`Across `,u.total_turns,` turns,`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-medium`,children:G(e.total_context_avoided)}),` `,`total token-turns of context avoided — each turn ran with`,` `,G(e.avg_context_reduction),` fewer tokens on average, peaking at `,G(e.peak_context_reduction),`.`]})]}),(0,P.jsxs)(`div`,{className:`flex gap-6 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Total Context Avoided`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono font-medium text-lg`,children:G(e.total_context_avoided)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Avg / Turn`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono font-medium text-lg`,children:G(e.avg_context_reduction)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Direct Savings`}),(0,P.jsx)(`p`,{className:`text-success font-mono font-medium text-lg`,children:G(u.total_tokens_saved)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Compound Multiplier`}),(0,P.jsx)(`p`,{className:`text-violet-400 font-mono font-medium text-lg`,children:u.total_tokens_saved>0?`${(e.total_context_avoided/u.total_tokens_saved).toFixed(1)}×`:`—`})]})]})]})})})(),(0,P.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-1`,children:`Cumulative Savings`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mb-3`,children:[`Each bar = cumulative tokens saved through that turn. Showing latest`,` `,Math.min(60,d.length),` of `,d.length,` turns. Hover for details.`]}),d.length===0?(0,P.jsx)(`div`,{className:`h-[140px] flex items-center justify-center`,children:(0,P.jsx)(`p`,{className:`t-tertiary text-xs`,children:`Loading chart data...`})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`flex gap-[3px]`,style:{height:`140px`},children:d.slice(-60).map(e=>{let n=d[d.length-1]?.cumulative_tokens_saved||1,r=e.cumulative_tokens_saved/n*100;return(0,P.jsxs)(`div`,{className:`group relative flex-1 min-w-[6px] max-w-[28px] h-full flex items-end`,children:[(0,P.jsx)(`div`,{className:`w-full ${Ic(Object.entries(e.mechanisms_this_turn).sort(([,e],[,t])=>t-e)[0]?.[0]??`graph_query`).bar} opacity-70 hover:opacity-100 rounded-t transition-all cursor-pointer`,style:{height:`${Math.max(4,r)}%`},onClick:()=>t(e.turn)}),(0,P.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-20 pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-xs whitespace-nowrap shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`font-medium text-foreground`,children:[`Turn #`,e.turn]}),(0,P.jsx)(`div`,{className:`t-tertiary mt-0.5`,children:e.tools.join(`, `)||`exec`}),(0,P.jsxs)(`div`,{className:`text-success mt-1`,children:[`+`,G(e.tokens_saved_this_turn),` this turn`]}),(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`Cumulative: `,G(e.cumulative_tokens_saved)]}),(0,P.jsxs)(`div`,{className:`text-cyan-400 mt-0.5`,children:[`Context avoided: `,G(e.context_avoided)]}),(0,P.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:Object.keys(e.mechanisms_this_turn).map(e=>(0,P.jsx)(Vc,{mechanism:e},e))})]})})]},e.turn)})}),(0,P.jsxs)(`div`,{className:`flex justify-between mt-1.5`,children:[(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:[`T`,d.length>60?d.length-59:1]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:[`T`,d.length]})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-3 mt-3 pt-3 border-t border-border-subtle/50`,children:Nc.filter(e=>d.some(t=>e in t.mechanisms_this_turn)).map(e=>(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-sm ${Ic(e).bar}`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:e.replace(/_/g,` `)})]},e))})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,children:`Savings by Mechanism`}),(0,P.jsx)(Bc,{mechanisms:u.by_mechanism,totalSaved:u.total_tokens_saved})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,children:`Turns`}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs mt-0.5`,children:`Click a turn to see all events and mechanisms within it.`})]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[m.length,` turn`,m.length===1?``:`s`]})]}),h.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No turns recorded.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[800px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-2.5 font-medium w-14`,title:`Turn number in the conversation`,children:`Turn`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Summary of what happened in this turn`,children:`Description`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium w-36`,title:`Relative savings compared to the largest turn — wider bar means more tokens saved`,children:`Savings Bar`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Types of optimization applied in this turn`,children:`Mechanisms`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Tokens removed from responses in this turn (direct savings)`,children:`Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Cumulative tokens of context avoided at this point — prior savings carry forward, keeping context smaller for this and future turns`,children:`Context Avoided`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Number of optimization events in this turn`,children:`Events`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 pr-5 font-medium w-16`})]})}),(0,P.jsx)(`tbody`,{children:h.map(([e,n])=>{let r=n.reduce((e,t)=>e+t.tokens_saved,0),i=[...new Set(n.map(e=>e.mechanism))],{label:a,subtitle:o}=Rc(n),s=_.get(e);return(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors cursor-pointer group`,onClick:()=>t(e),children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,children:(0,P.jsxs)(`span`,{className:`t-tertiary font-mono text-xs group-hover:text-violet-400 transition-colors`,children:[`#`,e]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`min-w-0 max-w-[260px]`,children:[(0,P.jsx)(`p`,{className:`text-foreground font-mono text-xs truncate group-hover:text-violet-300 transition-colors`,children:a}),o&&(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] mt-0.5 truncate`,children:o})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`div`,{className:`w-32 h-4 relative rounded-sm bg-surface-secondary overflow-hidden`,children:(()=>{let e=new Map;for(let t of n)e.set(t.mechanism,(e.get(t.mechanism)??0)+t.tokens_saved);let t=0;return[...e.entries()].sort(([,e],[,t])=>t-e).map(([e,n])=>{let r=g>0?n/g*100:0,i=t;return t+=r,(0,P.jsx)(`div`,{className:`absolute inset-y-0 ${Ic(e).bar} opacity-80`,style:{left:`${i}%`,width:`${Math.max(1,r)}%`}},e)})})()})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>(0,P.jsx)(Vc,{mechanism:e},e))})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-xs`,children:G(r)})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:s?(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono font-medium text-xs`,title:`${G(s.context_avoided)} tokens of cumulative context avoided at turn #${e}`,children:G(s.context_avoided)}):(0,P.jsx)(`span`,{className:`t-tertiary font-mono text-xs`,children:`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:n.length})}),(0,P.jsx)(`td`,{className:`pl-4 py-3 pr-5 text-right w-16`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-violet-400 opacity-0 group-hover:opacity-100 transition-opacity font-medium whitespace-nowrap`,children:[`View`,` `,(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]})})]},e)})})]})}),(0,P.jsx)(Gc,{total:m.length,limit:20,offset:i*20,onPageChange:e=>a(Math.floor(e/20))})]})]})}function Jc({sessionId:e,turn:t}){let{url:n,queryKey:r}=I(),i=F({queryKey:r([`token-flow-events`,e,t]),queryFn:()=>o(n(`/api/token-flow/events?session_id=${e}&turn=${t}`))}),a=F({queryKey:r([`token-flow-cumulative`,e]),queryFn:()=>o(n(`/api/token-flow/cumulative?session_id=${e}`))}),s=a.data?.data?.find(e=>e.turn===t),c=a.data?.total_turns??0,l=c>0?c-(a.data?.data?.findIndex(e=>e.turn===t)??0)-1:0,u=i.data?.data??[],[d,f]=(0,N.useState)(0),p=u.slice(d,d+20),m=u.reduce((e,t)=>e+t.tokens_saved,0),h=u.reduce((e,t)=>e+t.tokens_without,0),g=u.reduce((e,t)=>e+t.tokens_with,0),_=[...new Set(u.map(e=>e.tool).filter(Boolean))],v=h>0?Math.round(m/h*100):0,y={};for(let e of u){let t=y[e.mechanism]??{tokens_saved:0,tokens_delivered:0,event_count:0,pct_of_total:0};t.tokens_saved+=e.tokens_saved,t.tokens_delivered+=e.tokens_with,t.event_count++,y[e.mechanism]=t}for(let e of Object.values(y))e.pct_of_total=m>0?Math.round(e.tokens_saved/m*100):0;return i.isLoading?(0,P.jsx)(Ft,{n:4}):(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(()=>{let{label:e,subtitle:t}=Rc(u);return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-4 border-l-4 border-violet-500/60`,children:[(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium`,children:e}),t&&(0,P.jsx)(`p`,{className:`t-tertiary text-xs mt-0.5`,children:t})]})})(),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-5`,children:[(0,P.jsx)(zc,{label:`Tokens Saved`,value:G(m),accent:`text-success`,hint:`Tokens removed in this turn`}),(0,P.jsx)(zc,{label:`Without unerr`,value:G(h),hint:`Tokens that would have been sent without optimization`}),(0,P.jsx)(zc,{label:`Delivered`,value:G(g),hint:`Tokens actually sent to the agent`}),(0,P.jsx)(zc,{label:`Efficiency`,value:`${v}%`,accent:`text-violet-400`,hint:`Percentage of tokens optimized away this turn`}),(0,P.jsx)(zc,{label:`Tools`,value:_.join(`, `)||`exec`,hint:`MCP tools that triggered optimizations in this turn`})]}),s&&(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-4 border-l-4 border-cyan-500/60`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Context Impact`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-1`,children:[`At this point, `,G(s.context_avoided),` tokens of cumulative context avoided`,l>0?` — this turn's ${G(s.tokens_saved_this_turn)} savings carry forward to ${l} more turn${l===1?``:`s`}`:``,`.`]})]}),(0,P.jsxs)(`div`,{className:`flex gap-5 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`This Turn`}),(0,P.jsx)(`p`,{className:`text-success font-mono font-medium`,children:G(s.tokens_saved_this_turn)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Context Avoided`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono font-medium`,children:G(s.context_avoided)})]})]})]})}),Object.keys(y).length>0&&(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,children:`Mechanisms in this Turn`}),(0,P.jsx)(Bc,{mechanisms:y,totalSaved:m})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,children:`Events`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-0.5`,children:[`Every optimization event in turn #`,t,`: tool calls, exec commands, and the mechanism that reduced tokens.`]})]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[u.length,` event`,u.length===1?``:`s`]})]}),u.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No events for this turn.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[900px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-3 font-medium`,title:`When this optimization event occurred`,children:`Time`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,title:`Type of optimization applied (e.g. graph query, shell compression)`,children:`Mechanism`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,title:`MCP tool that triggered this optimization`,children:`Tool`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium text-right`,title:`Tokens that would have been sent without unerr`,children:`Without`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium text-right`,title:`Tokens actually delivered to the agent after optimization`,children:`Delivered`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium text-right`,title:`Tokens removed by this optimization (Without − Delivered)`,children:`Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-3 pr-5 font-medium`,title:`Description of what was optimized`,children:`Detail`})]})}),(0,P.jsx)(`tbody`,{children:p.map(e=>{Ic(e.mechanism);let t=e.tokens_without>0?Math.round(e.tokens_saved/e.tokens_without*100):0;return(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors`,children:[(0,P.jsx)(`td`,{className:`t-tertiary px-5 py-3 font-mono text-xs whitespace-nowrap`,children:Fc(e.ts)}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(Vc,{mechanism:e.mechanism})}),(0,P.jsx)(`td`,{className:`t-secondary px-3 py-3 font-mono text-xs whitespace-nowrap`,children:e.tool??`—`}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums whitespace-nowrap`,children:G(e.tokens_without)}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums whitespace-nowrap`,children:G(e.tokens_with)}),(0,P.jsxs)(`td`,{className:`px-3 py-3 text-right whitespace-nowrap`,children:[(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-xs`,children:G(e.tokens_saved)}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] ml-1`,children:[`(`,t,`%)`]})]}),(0,P.jsx)(`td`,{className:`px-3 py-3 pr-5 font-mono text-xs max-w-[400px]`,children:(0,P.jsx)(`span`,{className:`t-secondary break-words leading-relaxed`,children:Lc(e)})})]},e.id)})}),(0,P.jsx)(`tfoot`,{children:(0,P.jsxs)(`tr`,{className:`border-t border-border-subtle font-medium bg-surface-secondary/30`,children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,colSpan:3,children:(0,P.jsx)(`span`,{className:`t-secondary text-xs uppercase tracking-wider`,children:`Turn Total`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums`,children:G(h)}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums`,children:G(g)}),(0,P.jsxs)(`td`,{className:`px-3 py-3 text-right`,children:[(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-xs`,children:G(m)}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] ml-1`,children:[`(`,v,`%)`]})]}),(0,P.jsx)(`td`,{})]})})]})}),(0,P.jsx)(`div`,{className:`px-5 py-2 border-t border-border-subtle`,children:(0,P.jsx)(Gc,{total:u.length,limit:20,offset:d,onPageChange:f})})]})]})}function Yc(){let[e,t]=(0,N.useState)({level:`global`}),n=()=>t({level:`global`}),r=e=>t({level:`session`,sessionId:e}),i=(e,n)=>t({level:`turn`,sessionId:e,turn:n}),a=[];return(e.level===`session`||e.level===`turn`)&&a.push({label:`All Sessions`,onClick:n},{label:`Session ${e.sessionId.slice(0,12)}`,onClick:e.level===`turn`?()=>r(e.sessionId):void 0}),e.level===`turn`&&a.push({label:`Turn #${e.turn}`}),(0,P.jsxs)(`div`,{children:[a.length>0&&(0,P.jsx)(Hc,{items:a}),e.level===`global`&&(0,P.jsx)(Kc,{onSelectSession:r}),e.level===`session`&&(0,P.jsx)(qc,{sessionId:e.sessionId,onSelectTurn:t=>i(e.sessionId,t)}),e.level===`turn`&&(0,P.jsx)(Jc,{sessionId:e.sessionId,turn:e.turn})]})}function Xc(){let e=ut(),t=dt(),[n,r]=(0,N.useState)(!1),{data:i}=F({queryKey:[`daemon`,`info`],queryFn:()=>o(`/api/daemon`).catch(()=>null),staleTime:6e4,retry:!1}),a=!!i,{data:s}=F({queryKey:[`daemon`,`repos`],queryFn:()=>o(`/api/repos`),refetchInterval:5e3,enabled:a}),c=s?.repos??[];(0,N.useEffect)(()=>{if(!a)return Ct(_t,r)},[a]);let{data:l=[]}=F({queryKey:[`live-feed`],initialData:[]}),{data:u}=F({queryKey:[`session-snapshot`]}),{data:d}=F({queryKey:[`system`,`status`],queryFn:()=>o(`/api/system/status`).catch(()=>null),staleTime:6e4,enabled:!a}),f=t.repoLabel?c.find(e=>e.label===t.repoLabel):null,p=(0,N.useMemo)(()=>({label:t.repoLabel,path:f?.path??null,status:f?.status??null,apiBase:t.repoLabel?`/api/repo/${t.repoLabel}`:``,isDaemonMode:a}),[t.repoLabel,f,a]),m=a&&e===`overview`&&!t.repoLabel?`all-repos`:e,h=st(m),g;switch(m){case`all-repos`:g=(0,P.jsx)(Et,{});break;case`daemon`:g=(0,P.jsx)(Mt,{});break;case`overview`:g=(0,P.jsx)(Gt,{sseConnected:n,liveFeed:l,sessionSnapshot:u});break;case`visual`:g=(0,P.jsx)(lr,{});break;case`graph`:g=(0,P.jsx)(Bn,{});break;case`facts`:g=(0,P.jsx)($t,{});break;case`token-trace`:g=(0,P.jsx)(Yc,{});break;case`reasoning`:g=(0,P.jsx)(Ss,{});break;case`activity`:g=(0,P.jsx)(qs,{});break;case`settings`:g=(0,P.jsx)(jc,{});break}return(0,P.jsxs)(vt.Provider,{value:p,children:[a&&(0,P.jsx)(at,{}),(0,P.jsx)(gt,{title:h,activeRoute:m,statusDot:a?void 0:n?`live`:`reconnecting`,repoPath:a?f?.path:d?.data?.cwd,repoLabel:t.repoLabel,isDaemonMode:a,repos:c,children:g})]})}var Zc=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,E());else{var t=n(l);t!==null&&re(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function te(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&re(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():S=!1}}}var E;if(typeof y==`function`)E=function(){y(te)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,D=ne.port2;ne.port1.onmessage=te,E=function(){D.postMessage(null)}}else E=function(){_(te,0)};function re(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,re(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,E()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Qc=n(((e,t)=>{t.exports=Zc()})),$c=n((e=>{var t=ze();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.5`})),el=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=$c()})),tl=n((e=>{var t=Qc(),n=ze(),r=el();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),E=Symbol.iterator;function ne(e){return typeof e!=`object`||!e?null:(e=E&&e[E]||e[`@@iterator`],typeof e==`function`?e:null)}var D=Symbol.for(`react.client.reference`);function re(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===D?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case ee:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?re(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return re(e(t))}catch{}}return null}var ie=Array.isArray,O=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},oe=[],se=-1;function ce(e){return{current:e}}function A(e){0>se||(e.current=oe[se],oe[se]=null,se--)}function j(e,t){se++,oe[se]=e.current,e.current=t}var le=ce(null),ue=ce(null),M=ce(null),de=ce(null);function fe(e,t){switch(j(M,t),j(ue,e),j(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}A(le),j(le,e)}function pe(){A(le),A(ue),A(M)}function me(e){e.memoizedState!==null&&j(de,e);var t=le.current,n=Hd(t,e.type);t!==n&&(j(ue,e),j(le,n))}function he(e){ue.current===e&&(A(le),A(ue)),de.current===e&&(A(de),Qf._currentValue=ae)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
|
|
2
|
+
`),a=new Blob([i],{type:`text/csv`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`token-economics-${new Date().toISOString().slice(0,10)}.csv`,s.click(),URL.revokeObjectURL(o)})},children:[(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`})}),`Export CSV`]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-5`,children:[(0,P.jsx)(zc,{label:`Total Tokens Saved`,value:G(p.total_tokens_saved),accent:`text-success`,hint:`Total tokens removed from responses across all sessions — direct savings before context compounding`}),(0,P.jsx)(zc,{label:`Context Avoided`,value:G(p.total_context_avoided),accent:`text-cyan-400`,hint:`Total token-turns of context pressure prevented — savings compound because each turn's reduction carries forward to all future turns`}),(0,P.jsx)(zc,{label:`Total Delivered`,value:G(p.total_tokens_with),hint:`Total tokens actually sent to the agent after optimization`}),(0,P.jsx)(zc,{label:`Efficiency`,value:`${p.efficiency_pct}%`,accent:`text-violet-400`,hint:`Percentage of original tokens that were optimized away (saved ÷ original)`}),(0,P.jsx)(zc,{label:`Sessions`,value:p.total_sessions,hint:`Number of distinct agent sessions tracked`})]}),p.avg_context_reduction>0&&(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-cyan-500/60`,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Context Pressure Prevented`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-1 max-w-xl`,children:[`Across `,p.total_sessions,` session`,p.total_sessions===1?``:`s`,` and `,p.total_turns,` turns,`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-medium`,children:G(p.total_context_avoided)}),` `,`total token-turns of context avoided — each turn ran with`,` `,G(p.avg_context_reduction),` fewer tokens on average, peaking at `,G(p.peak_context_reduction),`.`]})]}),(0,P.jsxs)(`div`,{className:`flex gap-6 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Total Context Avoided`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono font-medium text-lg`,children:G(p.total_context_avoided)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Avg / Turn`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono font-medium text-lg`,children:G(p.avg_context_reduction)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Direct Savings`}),(0,P.jsx)(`p`,{className:`text-success font-mono font-medium text-lg`,children:G(p.total_tokens_saved)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Compound Multiplier`}),(0,P.jsx)(`p`,{className:`text-violet-400 font-mono font-medium text-lg`,children:p.total_tokens_saved>0?`${(p.total_context_avoided/p.total_tokens_saved).toFixed(1)}×`:`—`})]})]})]})}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsxs)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,children:[`Savings by Mechanism`,r||a?` (Filtered)`:` (All Time)`]}),(0,P.jsx)(Bc,{mechanisms:p.by_mechanism,totalSaved:p.total_tokens_saved})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,children:`Sessions`}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[h,` session`,h===1?``:`s`]})]}),m.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No sessions recorded.`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[700px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-2.5 font-medium`,title:`Unique session identifier`,children:`Session`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`AI agent that ran this session`,children:`Agent`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`When the last event was recorded`,children:`Last Active`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Number of optimization events in this session`,children:`Events`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Types of optimization applied (e.g. graph query, shell compression)`,children:`Mechanisms`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Total tokens removed from responses (direct savings)`,children:`Tokens Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Average tokens of context pressure avoided per turn — savings compound because each turn's reduction carries to all future turns`,children:`Avg Context Reduced`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 pr-5 font-medium w-16`})]})}),(0,P.jsx)(`tbody`,{children:m.map((t,n)=>(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors cursor-pointer group`,onClick:()=>e(t.session_id),children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-foreground group-hover:text-violet-400 transition-colors`,children:t.session_id.slice(0,12)}),n===0&&c===0&&(0,P.jsx)(`span`,{className:`rounded-full bg-emerald-500/20 text-emerald-400 px-2 py-0.5 text-[10px] font-medium`,children:`latest`})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(Wc,{name:t.agent_name})}),(0,P.jsx)(`td`,{className:`px-3 py-3 t-secondary text-xs`,children:Pc(t.last_ts)}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs tabular-nums`,children:t.event_count}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[t.mechanisms.slice(0,4).map(e=>(0,P.jsx)(Vc,{mechanism:e},e)),t.mechanisms.length>4&&(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px]`,children:[`+`,t.mechanisms.length-4]})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-sm`,children:G(t.total_saved)})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:t.avg_context_reduction>0?(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono font-medium text-sm`,title:`Each turn ran with ~${G(t.avg_context_reduction)} fewer tokens in context on average (across ${t.total_turns} turns)`,children:G(t.avg_context_reduction)}):(0,P.jsx)(`span`,{className:`t-tertiary font-mono text-sm`,children:`—`})}),(0,P.jsx)(`td`,{className:`pl-4 py-3 pr-5 text-right w-16`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-violet-400 opacity-0 group-hover:opacity-100 transition-opacity font-medium whitespace-nowrap`,children:[`View`,` `,(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]})})]},t.session_id))})]})}),(0,P.jsx)(`div`,{className:`px-5 py-2 border-t border-border-subtle`,children:(0,P.jsx)(Gc,{total:h,limit:20,offset:c,onPageChange:l})})]})]})]})}function qc({sessionId:e,onSelectTurn:t}){let{url:n,queryKey:r}=I(),[i,a]=(0,N.useState)(0),s=F({queryKey:r([`token-flow-session`,e]),queryFn:()=>o(n(`/api/token-flow/session${e?`?session_id=${e}`:``}`)),refetchInterval:5e3}),c=F({queryKey:r([`token-flow-cumulative`,e]),queryFn:()=>o(n(`/api/token-flow/cumulative?session_id=${e}`)),refetchInterval:5e3}),l=F({queryKey:r([`token-flow-events`,e]),queryFn:()=>o(n(`/api/token-flow/events?session_id=${e}`)),refetchInterval:5e3});if(s.isLoading)return(0,P.jsx)(Ft,{n:4});let u=s.data?.data,d=c.data?.data??[],f=l.data?.data??[];if(!u)return(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-8 text-center`,children:(0,P.jsxs)(`p`,{className:`t-secondary`,children:[`No data for session `,e.slice(0,12)]})});let p=new Map;for(let e of f){let t=p.get(e.turn)??[];t.push(e),p.set(e.turn,t)}let m=[...p.entries()].sort(([e],[t])=>t-e),h=m.slice(i*20,(i+1)*20),g=h.reduce((e,[,t])=>{let n=t.reduce((e,t)=>e+t.tokens_saved,0);return Math.max(e,n)},1),_=new Map;for(let e of d)_.set(e.turn,e);return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-5`,children:[(0,P.jsx)(zc,{label:`Tokens Saved`,value:G(u.total_tokens_saved),accent:`text-success`,hint:`Tokens removed from responses in this session`}),(0,P.jsx)(zc,{label:`Delivered`,value:G(u.total_tokens_with),hint:`Tokens actually sent to the agent after optimization`}),(0,P.jsx)(zc,{label:`Without unerr`,value:G(u.total_tokens_without),hint:`Tokens that would have been sent without unerr`}),(0,P.jsx)(zc,{label:`Efficiency`,value:`${u.efficiency_pct}%`,accent:`text-violet-400`,hint:`Percentage of original tokens optimized away`}),(0,P.jsx)(zc,{label:`Turns`,value:u.total_turns,hint:`Number of conversation turns in this session`})]}),(c.data?.avg_context_reduction??0)>0&&(()=>{let e=c.data;return(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-5 border-l-4 border-cyan-500/60`,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Context Pressure Prevented`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-1 max-w-xl`,children:[`Across `,u.total_turns,` turns,`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-medium`,children:G(e.total_context_avoided)}),` `,`total token-turns of context avoided — each turn ran with`,` `,G(e.avg_context_reduction),` fewer tokens on average, peaking at `,G(e.peak_context_reduction),`.`]})]}),(0,P.jsxs)(`div`,{className:`flex gap-6 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Total Context Avoided`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono font-medium text-lg`,children:G(e.total_context_avoided)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Avg / Turn`}),(0,P.jsx)(`p`,{className:`text-foreground font-mono font-medium text-lg`,children:G(e.avg_context_reduction)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Direct Savings`}),(0,P.jsx)(`p`,{className:`text-success font-mono font-medium text-lg`,children:G(u.total_tokens_saved)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Compound Multiplier`}),(0,P.jsx)(`p`,{className:`text-violet-400 font-mono font-medium text-lg`,children:u.total_tokens_saved>0?`${(e.total_context_avoided/u.total_tokens_saved).toFixed(1)}×`:`—`})]})]})]})})})(),(0,P.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-1`,children:`Cumulative Savings`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mb-3`,children:[`Each bar = cumulative tokens saved through that turn. Showing latest`,` `,Math.min(60,d.length),` of `,d.length,` turns. Hover for details.`]}),d.length===0?(0,P.jsx)(`div`,{className:`h-[140px] flex items-center justify-center`,children:(0,P.jsx)(`p`,{className:`t-tertiary text-xs`,children:`Loading chart data...`})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`flex gap-[3px]`,style:{height:`140px`},children:d.slice(-60).map(e=>{let n=d[d.length-1]?.cumulative_tokens_saved||1,r=e.cumulative_tokens_saved/n*100;return(0,P.jsxs)(`div`,{className:`group relative flex-1 min-w-[6px] max-w-[28px] h-full flex items-end`,children:[(0,P.jsx)(`div`,{className:`w-full ${Ic(Object.entries(e.mechanisms_this_turn).sort(([,e],[,t])=>t-e)[0]?.[0]??`graph_query`).bar} opacity-70 hover:opacity-100 rounded-t transition-all cursor-pointer`,style:{height:`${Math.max(4,r)}%`},onClick:()=>t(e.turn)}),(0,P.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-20 pointer-events-none`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-xs whitespace-nowrap shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`font-medium text-foreground`,children:[`Turn #`,e.turn]}),(0,P.jsx)(`div`,{className:`t-tertiary mt-0.5`,children:e.tools.join(`, `)||`exec`}),(0,P.jsxs)(`div`,{className:`text-success mt-1`,children:[`+`,G(e.tokens_saved_this_turn),` this turn`]}),(0,P.jsxs)(`div`,{className:`t-secondary`,children:[`Cumulative: `,G(e.cumulative_tokens_saved)]}),(0,P.jsxs)(`div`,{className:`text-cyan-400 mt-0.5`,children:[`Context avoided: `,G(e.context_avoided)]}),(0,P.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:Object.keys(e.mechanisms_this_turn).map(e=>(0,P.jsx)(Vc,{mechanism:e},e))})]})})]},e.turn)})}),(0,P.jsxs)(`div`,{className:`flex justify-between mt-1.5`,children:[(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:[`T`,d.length>60?d.length-59:1]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] font-mono`,children:[`T`,d.length]})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-3 mt-3 pt-3 border-t border-border-subtle/50`,children:Nc.filter(e=>d.some(t=>e in t.mechanisms_this_turn)).map(e=>(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-sm ${Ic(e).bar}`}),(0,P.jsx)(`span`,{className:`t-tertiary text-[10px]`,children:e.replace(/_/g,` `)})]},e))})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,children:`Savings by Mechanism`}),(0,P.jsx)(Bc,{mechanisms:u.by_mechanism,totalSaved:u.total_tokens_saved})]})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,children:`Turns`}),(0,P.jsx)(`p`,{className:`t-tertiary text-xs mt-0.5`,children:`Click a turn to see all events and mechanisms within it.`})]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[m.length,` turn`,m.length===1?``:`s`]})]}),h.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No turns recorded.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[800px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-2.5 font-medium w-14`,title:`Turn number in the conversation`,children:`Turn`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Summary of what happened in this turn`,children:`Description`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium w-36`,title:`Relative savings compared to the largest turn — wider bar means more tokens saved`,children:`Savings Bar`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,title:`Types of optimization applied in this turn`,children:`Mechanisms`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Tokens removed from responses in this turn (direct savings)`,children:`Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Cumulative tokens of context avoided at this point — prior savings carry forward, keeping context smaller for this and future turns`,children:`Context Avoided`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 font-medium text-right`,title:`Number of optimization events in this turn`,children:`Events`}),(0,P.jsx)(`th`,{className:`px-3 py-2.5 pr-5 font-medium w-16`})]})}),(0,P.jsx)(`tbody`,{children:h.map(([e,n])=>{let r=n.reduce((e,t)=>e+t.tokens_saved,0),i=[...new Set(n.map(e=>e.mechanism))],{label:a,subtitle:o}=Rc(n),s=_.get(e);return(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors cursor-pointer group`,onClick:()=>t(e),children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,children:(0,P.jsxs)(`span`,{className:`t-tertiary font-mono text-xs group-hover:text-violet-400 transition-colors`,children:[`#`,e]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`min-w-0 max-w-[260px]`,children:[(0,P.jsx)(`p`,{className:`text-foreground font-mono text-xs truncate group-hover:text-violet-300 transition-colors`,children:a}),o&&(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] mt-0.5 truncate`,children:o})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`div`,{className:`w-32 h-4 relative rounded-sm bg-surface-secondary overflow-hidden`,children:(()=>{let e=new Map;for(let t of n)e.set(t.mechanism,(e.get(t.mechanism)??0)+t.tokens_saved);let t=0;return[...e.entries()].sort(([,e],[,t])=>t-e).map(([e,n])=>{let r=g>0?n/g*100:0,i=t;return t+=r,(0,P.jsx)(`div`,{className:`absolute inset-y-0 ${Ic(e).bar} opacity-80`,style:{left:`${i}%`,width:`${Math.max(1,r)}%`}},e)})})()})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>(0,P.jsx)(Vc,{mechanism:e},e))})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-xs`,children:G(r)})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:s?(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono font-medium text-xs`,title:`${G(s.context_avoided)} tokens of cumulative context avoided at turn #${e}`,children:G(s.context_avoided)}):(0,P.jsx)(`span`,{className:`t-tertiary font-mono text-xs`,children:`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,P.jsx)(`span`,{className:`t-tertiary text-xs`,children:n.length})}),(0,P.jsx)(`td`,{className:`pl-4 py-3 pr-5 text-right w-16`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-violet-400 opacity-0 group-hover:opacity-100 transition-opacity font-medium whitespace-nowrap`,children:[`View`,` `,(0,P.jsx)(`svg`,{"aria-hidden":`true`,className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 5l7 7-7 7`})})]})})]},e)})})]})}),(0,P.jsx)(Gc,{total:m.length,limit:20,offset:i*20,onPageChange:e=>a(Math.floor(e/20))})]})]})}function Jc({sessionId:e,turn:t}){let{url:n,queryKey:r}=I(),i=F({queryKey:r([`token-flow-events`,e,t]),queryFn:()=>o(n(`/api/token-flow/events?session_id=${e}&turn=${t}`))}),a=F({queryKey:r([`token-flow-cumulative`,e]),queryFn:()=>o(n(`/api/token-flow/cumulative?session_id=${e}`))}),s=a.data?.data?.find(e=>e.turn===t),c=a.data?.total_turns??0,l=c>0?c-(a.data?.data?.findIndex(e=>e.turn===t)??0)-1:0,u=i.data?.data??[],[d,f]=(0,N.useState)(0),p=u.slice(d,d+20),m=u.reduce((e,t)=>e+t.tokens_saved,0),h=u.reduce((e,t)=>e+t.tokens_without,0),g=u.reduce((e,t)=>e+t.tokens_with,0),_=[...new Set(u.map(e=>e.tool).filter(Boolean))],v=h>0?Math.round(m/h*100):0,y={};for(let e of u){let t=y[e.mechanism]??{tokens_saved:0,tokens_delivered:0,event_count:0,pct_of_total:0};t.tokens_saved+=e.tokens_saved,t.tokens_delivered+=e.tokens_with,t.event_count++,y[e.mechanism]=t}for(let e of Object.values(y))e.pct_of_total=m>0?Math.round(e.tokens_saved/m*100):0;return i.isLoading?(0,P.jsx)(Ft,{n:4}):(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(()=>{let{label:e,subtitle:t}=Rc(u);return(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-4 border-l-4 border-violet-500/60`,children:[(0,P.jsx)(`p`,{className:`text-foreground font-mono text-sm font-medium`,children:e}),t&&(0,P.jsx)(`p`,{className:`t-tertiary text-xs mt-0.5`,children:t})]})})(),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-5`,children:[(0,P.jsx)(zc,{label:`Tokens Saved`,value:G(m),accent:`text-success`,hint:`Tokens removed in this turn`}),(0,P.jsx)(zc,{label:`Without unerr`,value:G(h),hint:`Tokens that would have been sent without optimization`}),(0,P.jsx)(zc,{label:`Delivered`,value:G(g),hint:`Tokens actually sent to the agent`}),(0,P.jsx)(zc,{label:`Efficiency`,value:`${v}%`,accent:`text-violet-400`,hint:`Percentage of tokens optimized away this turn`}),(0,P.jsx)(zc,{label:`Tools`,value:_.join(`, `)||`exec`,hint:`MCP tools that triggered optimizations in this turn`})]}),s&&(0,P.jsx)(`div`,{className:`el-raised rounded-lg p-4 border-l-4 border-cyan-500/60`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4 flex-wrap`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-foreground text-sm font-medium`,children:`Context Impact`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-1`,children:[`At this point, `,G(s.context_avoided),` tokens of cumulative context avoided`,l>0?` — this turn's ${G(s.tokens_saved_this_turn)} savings carry forward to ${l} more turn${l===1?``:`s`}`:``,`.`]})]}),(0,P.jsxs)(`div`,{className:`flex gap-5 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`This Turn`}),(0,P.jsx)(`p`,{className:`text-success font-mono font-medium`,children:G(s.tokens_saved_this_turn)})]}),(0,P.jsxs)(`div`,{className:`text-right`,children:[(0,P.jsx)(`p`,{className:`t-tertiary text-[10px] uppercase tracking-wider`,children:`Context Avoided`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono font-medium`,children:G(s.context_avoided)})]})]})]})}),Object.keys(y).length>0&&(0,P.jsxs)(`div`,{className:`el-raised rounded-lg p-5`,children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium mb-3`,children:`Mechanisms in this Turn`}),(0,P.jsx)(Bc,{mechanisms:y,totalSaved:m})]}),(0,P.jsxs)(`div`,{className:`el-raised rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-5 py-3 border-b border-border-subtle flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`t-secondary text-sm font-medium`,children:`Events`}),(0,P.jsxs)(`p`,{className:`t-tertiary text-xs mt-0.5`,children:[`Every optimization event in turn #`,t,`: tool calls, exec commands, and the mechanism that reduced tokens.`]})]}),(0,P.jsxs)(`span`,{className:`t-tertiary text-xs`,children:[u.length,` event`,u.length===1?``:`s`]})]}),u.length===0?(0,P.jsx)(`p`,{className:`px-5 py-6 t-secondary text-sm`,children:`No events for this turn.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-sm min-w-[900px]`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle t-tertiary text-xs uppercase`,children:[(0,P.jsx)(`th`,{className:`px-5 py-3 font-medium`,title:`When this optimization event occurred`,children:`Time`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,title:`Type of optimization applied (e.g. graph query, shell compression)`,children:`Mechanism`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,title:`MCP tool that triggered this optimization`,children:`Tool`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium text-right`,title:`Tokens that would have been sent without unerr`,children:`Without`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium text-right`,title:`Tokens actually delivered to the agent after optimization`,children:`Delivered`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium text-right`,title:`Tokens removed by this optimization (Without − Delivered)`,children:`Saved`}),(0,P.jsx)(`th`,{className:`px-3 py-3 pr-5 font-medium`,title:`Description of what was optimized`,children:`Detail`})]})}),(0,P.jsx)(`tbody`,{children:p.map(e=>{Ic(e.mechanism);let t=e.tokens_without>0?Math.round(e.tokens_saved/e.tokens_without*100):0;return(0,P.jsxs)(`tr`,{className:`border-b border-border-subtle hover:bg-surface-secondary transition-colors`,children:[(0,P.jsx)(`td`,{className:`t-tertiary px-5 py-3 font-mono text-xs whitespace-nowrap`,children:Fc(e.ts)}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(Vc,{mechanism:e.mechanism})}),(0,P.jsx)(`td`,{className:`t-secondary px-3 py-3 font-mono text-xs whitespace-nowrap`,children:e.tool??`—`}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums whitespace-nowrap`,children:G(e.tokens_without)}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums whitespace-nowrap`,children:G(e.tokens_with)}),(0,P.jsxs)(`td`,{className:`px-3 py-3 text-right whitespace-nowrap`,children:[(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-xs`,children:G(e.tokens_saved)}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] ml-1`,children:[`(`,t,`%)`]})]}),(0,P.jsx)(`td`,{className:`px-3 py-3 pr-5 font-mono text-xs max-w-[400px]`,children:(0,P.jsx)(`span`,{className:`t-secondary break-words leading-relaxed`,children:Lc(e)})})]},e.id)})}),(0,P.jsx)(`tfoot`,{children:(0,P.jsxs)(`tr`,{className:`border-t border-border-subtle font-medium bg-surface-secondary/30`,children:[(0,P.jsx)(`td`,{className:`px-5 py-3`,colSpan:3,children:(0,P.jsx)(`span`,{className:`t-secondary text-xs uppercase tracking-wider`,children:`Turn Total`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums`,children:G(h)}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right font-mono text-xs tabular-nums`,children:G(g)}),(0,P.jsxs)(`td`,{className:`px-3 py-3 text-right`,children:[(0,P.jsx)(`span`,{className:`text-success font-mono font-medium text-xs`,children:G(m)}),(0,P.jsxs)(`span`,{className:`t-tertiary text-[10px] ml-1`,children:[`(`,v,`%)`]})]}),(0,P.jsx)(`td`,{})]})})]})}),(0,P.jsx)(`div`,{className:`px-5 py-2 border-t border-border-subtle`,children:(0,P.jsx)(Gc,{total:u.length,limit:20,offset:d,onPageChange:f})})]})]})}function Yc(){let[e,t]=(0,N.useState)({level:`global`}),n=()=>t({level:`global`}),r=e=>t({level:`session`,sessionId:e}),i=(e,n)=>t({level:`turn`,sessionId:e,turn:n}),a=[];return(e.level===`session`||e.level===`turn`)&&a.push({label:`All Sessions`,onClick:n},{label:`Session ${e.sessionId.slice(0,12)}`,onClick:e.level===`turn`?()=>r(e.sessionId):void 0}),e.level===`turn`&&a.push({label:`Turn #${e.turn}`}),(0,P.jsxs)(`div`,{children:[a.length>0&&(0,P.jsx)(Hc,{items:a}),e.level===`global`&&(0,P.jsx)(Kc,{onSelectSession:r}),e.level===`session`&&(0,P.jsx)(qc,{sessionId:e.sessionId,onSelectTurn:t=>i(e.sessionId,t)}),e.level===`turn`&&(0,P.jsx)(Jc,{sessionId:e.sessionId,turn:e.turn})]})}function Xc(){let e=ut(),t=dt(),[n,r]=(0,N.useState)(!1),{data:i,isFetched:a}=F({queryKey:[`daemon`,`info`],queryFn:()=>o(`/api/daemon`).catch(()=>null),staleTime:6e4,retry:!1}),s=!!i,{data:c}=F({queryKey:[`daemon`,`repos`],queryFn:()=>o(`/api/repos`),refetchInterval:5e3,enabled:s}),l=c?.repos??[];(0,N.useEffect)(()=>{if(!(!a||s))return Ct(_t,r)},[a,s]);let{data:u=[]}=F({queryKey:[`live-feed`],initialData:[]}),{data:d}=F({queryKey:[`session-snapshot`]}),{data:f}=F({queryKey:[`system`,`status`],queryFn:()=>o(`/api/system/status`).catch(()=>null),staleTime:6e4,enabled:a&&!s}),p=t.repoLabel?l.find(e=>e.label===t.repoLabel):null,m=(0,N.useMemo)(()=>({label:t.repoLabel,path:p?.path??null,status:p?.status??null,apiBase:t.repoLabel?`/api/repo/${t.repoLabel}`:``,isDaemonMode:s}),[t.repoLabel,p,s]),h=s&&e===`overview`&&!t.repoLabel?`all-repos`:e,g=st(h),_;switch(h){case`all-repos`:_=(0,P.jsx)(Et,{});break;case`daemon`:_=(0,P.jsx)(Mt,{});break;case`overview`:_=(0,P.jsx)(Gt,{sseConnected:n,liveFeed:u,sessionSnapshot:d});break;case`visual`:_=(0,P.jsx)(lr,{});break;case`graph`:_=(0,P.jsx)(Bn,{});break;case`facts`:_=(0,P.jsx)($t,{});break;case`token-trace`:_=(0,P.jsx)(Yc,{});break;case`reasoning`:_=(0,P.jsx)(Ss,{});break;case`activity`:_=(0,P.jsx)(qs,{});break;case`settings`:_=(0,P.jsx)(jc,{});break}return(0,P.jsxs)(vt.Provider,{value:m,children:[s&&(0,P.jsx)(at,{}),(0,P.jsx)(gt,{title:g,activeRoute:h,statusDot:s?void 0:n?`live`:`reconnecting`,repoPath:s?p?.path:f?.data?.cwd,repoLabel:t.repoLabel,isDaemonMode:s,repos:l,children:_})]})}var Zc=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,E());else{var t=n(l);t!==null&&re(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function te(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&re(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():S=!1}}}var E;if(typeof y==`function`)E=function(){y(te)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,D=ne.port2;ne.port1.onmessage=te,E=function(){D.postMessage(null)}}else E=function(){_(te,0)};function re(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,re(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,E()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Qc=n(((e,t)=>{t.exports=Zc()})),$c=n((e=>{var t=ze();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.5`})),el=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=$c()})),tl=n((e=>{var t=Qc(),n=ze(),r=el();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),E=Symbol.iterator;function ne(e){return typeof e!=`object`||!e?null:(e=E&&e[E]||e[`@@iterator`],typeof e==`function`?e:null)}var D=Symbol.for(`react.client.reference`);function re(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===D?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case ee:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?re(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return re(e(t))}catch{}}return null}var ie=Array.isArray,O=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},oe=[],se=-1;function ce(e){return{current:e}}function A(e){0>se||(e.current=oe[se],oe[se]=null,se--)}function j(e,t){se++,oe[se]=e.current,e.current=t}var le=ce(null),ue=ce(null),M=ce(null),de=ce(null);function fe(e,t){switch(j(M,t),j(ue,e),j(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}A(le),j(le,e)}function pe(){A(le),A(ue),A(M)}function me(e){e.memoizedState!==null&&j(de,e);var t=le.current,n=Hd(t,e.type);t!==n&&(j(ue,e),j(le,n))}function he(e){ue.current===e&&(A(le),A(ue)),de.current===e&&(A(de),Qf._currentValue=ae)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ge+e+_e}var ye=!1;function be(e,t){if(!e||ye)return``;ye=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
package/dist/ui/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>unerr — intelligence</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-CX4FCWGT.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-S-ySWqyJ.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vis-network-NIJHUFI3.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-7gl3mIuY.css">
|