@tonyclaw/agent-inspector 3.1.22 → 3.1.24

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.
Files changed (23) hide show
  1. package/.output/backend/nitro.json +1 -1
  2. package/.output/cli.js +7 -5
  3. package/.output/server/_ssr/index.mjs +1 -1
  4. package/.output/server/_ssr/{router-DKFaWvAr.mjs → router-Ab7TqMAr.mjs} +1 -1
  5. package/.output/server/index.mjs +1 -1
  6. package/.output/ui/assets/{CompareDrawer-pPcsyvc6.js → CompareDrawer-DS5S-VLf.js} +1 -1
  7. package/.output/ui/assets/{InspectorPet-DR3JEqze.js → InspectorPet-DfaI6G7F.js} +1 -1
  8. package/.output/ui/assets/{ProxyViewerContainer-DOyYRnb-.js → ProxyViewerContainer-BsXWx0-O.js} +4 -4
  9. package/.output/ui/assets/{ReplayDialog-Z-1-gUDm.js → ReplayDialog-CDYTm53e.js} +1 -1
  10. package/.output/ui/assets/{RequestAnatomy-BsnZjE5G.js → RequestAnatomy-Dy8R19-R.js} +1 -1
  11. package/.output/ui/assets/{ResponseView-HY64_ZY2.js → ResponseView-DPLMIyJd.js} +1 -1
  12. package/.output/ui/assets/{StreamingChunkSequence-CfQUFbTA.js → StreamingChunkSequence-ekgIUv3O.js} +1 -1
  13. package/.output/ui/assets/{_sessionId-_F9wwa3a.js → _sessionId-CbUUTv4a.js} +1 -1
  14. package/.output/ui/assets/{_sessionId-Dq97lD86.js → _sessionId-zvAs57Vo.js} +1 -1
  15. package/.output/ui/assets/{index-DOAGzrq2.js → index-BJwDUeBE.js} +1 -1
  16. package/.output/ui/assets/{index-CN-gZDqV.js → index-CbQTPA5b.js} +1 -1
  17. package/.output/ui/assets/{index-B2yLwOEu.js → index-ClIE7bwy.js} +1 -1
  18. package/.output/ui/assets/{index-DYnqmBBx.js → index-vp9_EbPc.js} +2 -2
  19. package/.output/ui/assets/{json-viewer-B2SQN0Lg.js → json-viewer-zMxqETtC.js} +1 -1
  20. package/.output/ui/assets/{jszip.min-Dpks67u2.js → jszip.min-CAvKMGPH.js} +1 -1
  21. package/.output/ui/index.html +1 -1
  22. package/package.json +4 -4
  23. package/src/proxy/identityProxy.ts +6 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-Dpks67u2.js","./index-DYnqmBBx.js","./index-B-Qod-aA.css","./CompareDrawer-pPcsyvc6.js","./InspectorPet-DR3JEqze.js","./ReplayDialog-Z-1-gUDm.js","./ResponseView-HY64_ZY2.js","./RequestAnatomy-BsnZjE5G.js","./StreamingChunkSequence-CfQUFbTA.js","./json-viewer-B2SQN0Lg.js","./index-CN-gZDqV.js"])))=>i.map(i=>d[i]);
2
- import{l as Hh,u as Ut,s as x,n as E,b as ke,_ as Ho,a as W,c as De,o as _,d as ue,e as oe,f as wn,g as Os,h as Ot,i as eu,k as Ze,r as l,j as n,m as qt,p as In,A as Jl,q as Vh,t as na,v as vr,w as ws,x as O,B as ee,y as $n,z as tu,C as Ee,D as nu,E as Nt,F as Ii,G as Wh,H as Le,L as Vo,I as su,J as Gh,K as Wo,M as Kh,N as Yh,O as Jh,P as ou,Q as Pi,T as Xh,U as Zh}from"./index-DYnqmBBx.js";const Ve=Hh(()=>Ut([x(),E(),ke(),Ho(),W(Ve),De(x(),Ve)])),kt=E().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Qh=ue(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),ru=_({index:E(),timestamp:E(),type:x(),data:Ve}),ex=_({id:x(),logId:kt,index:E().int().nonnegative(),provider:ue(["anthropic","openai"]),name:x(),argumentsText:x().nullable(),argumentsPreview:x().nullable()}),tx=ue(["end_turn","tool_use","stop","length"]),nx=tx.nullable(),sx=_({chunks:W(ru),truncated:ke().optional().default(!1)}),ox=ue(["request","response"]),au=_({logId:kt,part:ox,text:x(),offset:E().int().nonnegative(),limit:E().int().positive(),totalBytes:E().int().nonnegative(),textBytes:E().int().nonnegative(),nextOffset:E().int().nonnegative().nullable(),hasMore:ke(),contentMode:ue(["empty","partial","full"])}),Fs=_({id:kt,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:E().nullable(),responseText:x().nullable(),inputTokens:E().nullable(),outputTokens:E().nullable(),cacheCreationInputTokens:E().nullable(),cacheReadInputTokens:E().nullable(),elapsedMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),streaming:ke(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:De(x(),x()).optional(),headers:De(x(),x()).optional(),apiFormat:ue(["anthropic","openai","unknown"]).default("unknown"),isTest:ke().optional().default(!1),replayOfLogId:kt.nullable().optional(),providerName:x().nullable().optional(),clientPort:E().nullable().optional(),clientPid:E().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:sx.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:E().int().nonnegative().nullable().optional(),responseTextBytes:E().int().nonnegative().nullable().optional(),bodyContentMode:ue(["full","compact","truncated"]).optional(),captureIncomplete:ke().optional(),droppedChunks:E().int().nonnegative().optional(),droppedBytes:E().int().nonnegative().optional(),captureIncompleteReason:Qh.nullable().optional(),warnings:W(x()).optional(),toolTraceEvents:W(ex).optional(),stopReason:nx.optional(),error:x().nullable().optional()}),Li=_({type:x(),ttl:x().optional(),scope:x().optional()}),Oi=_({type:oe("text"),text:x(),cache_control:Li.optional()}),iu=_({type:oe("thinking"),thinking:x(),signature:x().optional()}),rx=_({type:oe("think"),thinking:x(),signature:x().optional()}),ax=_({type:oe("base64"),media_type:x(),data:x()}),lu=_({type:oe("image"),source:ax}),cu=_({type:oe("tool_use"),id:x(),name:x(),input:De(x(),Ve)}),ix=wn("type",[Oi,lu]),lx=_({type:oe("tool_result"),tool_use_id:x().optional(),content:Ut([x(),W(ix)]),is_error:ke().optional()}),cx=wn("type",[Oi,iu,lu,cu,lx]),dx=Ut([x(),W(cx)]),ux=_({role:ue(["user","assistant"]),content:dx}),mx=_({type:oe("text"),text:x(),cache_control:Li.optional()}),px=_({type:x(),properties:De(x(),De(x(),Ve)).optional(),required:W(x()).optional(),additionalProperties:ke().optional(),$schema:x().optional()}),fx=_({name:x(),description:x().optional(),input_schema:px.optional(),cache_control:Li.optional()}),hx=wn("type",[_({type:oe("enabled"),budget_tokens:E()}),_({type:oe("disabled")}),_({type:oe("adaptive")})]),xx=_({model:x(),messages:W(ux),system:W(mx).optional(),tools:W(fx).optional(),max_tokens:E().optional(),temperature:E().optional(),stream:ke().optional(),thinking:hx.optional(),metadata:_({user_id:x().optional()}).optional()}),Di=wn("type",[Oi,iu,rx,cu]),gx=_({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),cache_creation_input_tokens:E().nullable().optional(),cache_read_input_tokens:E().nullable().optional()}).passthrough(),bx=_({id:x(),type:oe("message"),model:x(),role:oe("assistant"),content:W(Di),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:gx}).passthrough(),vx=_({type:oe("message_start"),message:_({id:x(),type:oe("message"),model:x(),role:oe("assistant"),content:W(Di),stop_reason:Ho(),stop_sequence:Ho(),usage:_({input_tokens:E(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()})}),yx=_({type:oe("content_block_start"),index:E(),content_block:Di}),wx=wn("type",[_({type:oe("text_delta"),text:x()}),_({type:oe("input_json_delta"),partial_json:x()}),_({type:oe("thinking_delta"),thinking:x()}),_({type:oe("signature_delta"),signature:x()})]),jx=_({type:oe("content_block_delta"),index:E(),delta:wx}),Sx=_({type:oe("content_block_stop"),index:E()}),Nx=_({type:oe("message_delta"),delta:_({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:_({output_tokens:E(),input_tokens:E().optional(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()}),Cx=_({type:oe("message_stop")}),kx=_({type:oe("ping")}),_x=_({type:oe("error"),error:_({type:x(),message:x()})});wn("type",[vx,yx,jx,Sx,Nx,Cx,kx,_x]);const Tx=Ut([x(),W(wn("type",[_({type:oe("text"),text:x()}),_({type:oe("image_url"),image_url:_({url:x(),detail:x().optional()})})]))]),du=_({role:ue(["system","user","assistant","tool"]),content:Tx,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),Ex=_({name:x(),arguments:x()}),uu=_({index:E().optional(),id:x().optional(),type:oe("function").optional(),function:_({name:x().optional(),arguments:x().optional()})});du.extend({content:Ut([x(),W(_({type:oe("text"),text:x()}))]).optional(),function_call:Ex.optional(),tool_calls:W(uu).optional()});const Rx=_({type:oe("function"),function:_({name:x(),description:x().optional(),parameters:De(x(),Ve)})}),Mx=_({model:x(),messages:W(du),temperature:E().optional(),max_tokens:E().optional(),stream:ke().optional(),tools:W(Rx).optional(),tool_choice:Ut([ue(["auto","none","required"]),_({type:oe("auto")}),_({type:oe("none")}),_({type:oe("function"),function:_({name:x()})})]).optional(),user:x().optional()}),Ax=_({type:x(),name:x().optional(),description:x().optional(),parameters:Ve.optional(),function:_({name:x().optional(),description:x().optional(),parameters:Ve.optional()}).optional()}).passthrough(),Ix=_({model:x(),input:Os().optional(),instructions:Ut([x(),Ho()]).optional(),stream:ke().optional(),tools:W(Ax).optional(),tool_choice:Os().optional(),max_output_tokens:E().optional(),temperature:E().optional(),user:x().optional(),metadata:De(x(),Os()).optional()}).passthrough(),mu=_({role:ue(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:_({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:W(_({index:E(),id:x().optional(),type:oe("function").optional(),function:_({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),Px=_({index:E(),message:_({role:ue(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:_({name:x(),arguments:x()}).nullable().optional(),tool_calls:W(uu).optional()}).optional(),delta:mu.optional(),finish_reason:x().nullable()}),Lx=_({id:x(),object:oe("chat.completion"),created:E(),model:x(),choices:W(Px),usage:_({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();_({id:x(),object:oe("chat.completion.chunk"),created:E(),model:x(),choices:W(_({index:E(),delta:mu,finish_reason:x().nullable().optional()})),usage:_({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const Ox=_({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),total_tokens:E().nullable().optional(),input_tokens_details:_({cached_tokens:E().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:_({reasoning_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Dx=_({type:x()}).passthrough(),zx=_({id:x(),object:oe("response").optional(),created_at:E().optional(),status:x().nullable().optional(),model:x().optional(),output:W(Dx).optional(),output_text:x().optional(),usage:Ox.nullable().optional(),error:Os().optional()}).passthrough();_({type:x()}).passthrough();function $x(e){try{const t=JSON.parse(e),s=Lx.safeParse(t);return s.success?s.data:null}catch{return null}}function Fx(e){try{const t=JSON.parse(e),s=zx.safeParse(t);return s.success?s.data:null}catch{return null}}const pu=_({input:E().int().nonnegative(),output:E().int().nonnegative(),cacheCreate:E().int().nonnegative(),cacheRead:E().int().nonnegative(),total:E().int().nonnegative()}),Bx=_({id:kt,sessionLogNumber:E().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:ue(["anthropic","openai","unknown"]),method:x(),path:x(),status:E().nullable(),isStreaming:ke(),hasError:ke(),error:x().nullable(),latencyMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),tokens:_({input:E().nullable(),output:E().nullable(),cacheCreate:E().nullable(),cacheRead:E().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:E().nullable().optional(),clientProjectFolder:x().nullable().optional()}),fu=_({id:x(),status:ue(["active","failed","completed","empty"]),logCoverage:ue(["recent","history"]),source:ue(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:ue(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:E().int().nonnegative(),activeRequests:E().int().nonnegative(),completedRequests:E().int().nonnegative(),failedRequests:E().int().nonnegative(),queuedTasks:E().int().nonnegative(),runningTasks:E().int().nonnegative(),lastTaskError:x().nullable(),logCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),models:W(x()),providers:W(x()),tokenUsage:pu,lastLogId:kt.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:E().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:E().int().positive(),latestLogs:W(Bx)}),Ys=ue(["created","running","completed","failed","cancelled"]),zi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Ux=ue(["run-created","session-started","request","session-finished","evidence-exported"]),qx=ue(["info","success","warning","error"]),Hx=_({timestamp:x(),kind:Ux,severity:qx,title:x(),details:x(),logId:kt.nullable(),status:E().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:E().nullable(),isStreaming:ke().nullable()}),Vx=ue(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),hu=_({outcome:ue(["success","failure","active","unknown"]),severity:ue(["none","low","medium","high"]),category:Vx,summary:x(),evidenceLogIds:W(kt),hints:W(x())}),$i=_({status:ue(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),xu=$i,Fi=_({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:Ys,tags:W(x()),metadata:De(x(),Ve),evidence:zi.nullable(),createdAt:x(),updatedAt:x()});_({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:Ys.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()}).optional();_({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:Ys.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()});_({includeHistory:ke().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();_({run:Fi,evidence:zi,session:fu.nullable(),timeline:W(Hx),classification:hu,jenkinsReport:$i});const Wx=_({run:Fi,classification:hu,evidence:zi.nullable(),jenkinsReport:$i.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});_({failures:W(Wx),total:E().int().nonnegative(),limit:E().int().positive()});const Bi=ue(["created","running","completed","failed","cancelled"]),Ui=ue(["evaluation","batch","manual"]),qi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),gu=_({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:Ys.nullable(),metadata:De(x(),Ve),addedAt:x(),updatedAt:x()}),Hi=_({id:x(),title:x(),kind:Ui,task:x().nullable(),project:x().nullable(),status:Bi,tags:W(x()),metadata:De(x(),Ve),evidence:qi.nullable(),members:W(gu),createdAt:x(),updatedAt:x()});_({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Ui.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Bi.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()}).optional();_({title:x().min(1).optional(),kind:Ui.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Bi.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()});_({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:Ys.nullable().optional(),metadata:De(x(),Ve).optional()});_({includeHistory:ke().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();_({deleteEvidence:ke().optional()});const bu=_({groupId:x(),deleted:ke(),evidenceDeleted:ke(),evidencePath:x().nullable()}),vu=_({deleted:E().int().nonnegative(),groups:W(bu)}),yu=_({member:gu,run:Fi.nullable(),session:fu.nullable()}),wu=_({memberCount:E().int().nonnegative(),sessionsWithData:E().int().nonnegative(),missingSessions:E().int().nonnegative(),requestCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),tokenUsage:pu,models:W(x()),providers:W(x()),completedMembers:E().int().nonnegative(),failedMembers:E().int().nonnegative(),runningMembers:E().int().nonnegative()}),Gx=_({group:Hi,evidence:qi,members:W(yu).nullable(),markdown:x(),summary:wu.nullable(),report:xu.nullable()}),Kx=_({group:Hi,evidence:qi,members:W(yu),summary:wu,jenkinsReport:xu}),ju=_({groups:W(Hi)}),Yx=_({sessionId:x(),imported:E().int().nonnegative(),skipped:E().int().nonnegative(),warnings:W(x()),logs:W(Fs)}),Go=10,Ya=600,Ko=60,Ja=600,Yo="time",Vi="simple",Su=ue(["time","full"]),Jx=ue(["simple","full"]),yr=_({stripClaudeCodeBillingHeader:ke(),hasSeenOnboarding:ke().default(!1),slowResponseThresholdSeconds:E().int().min(0).max(Ya).default(Go),providerTestTimeoutSeconds:E().int().min(1).max(Ja).default(Ko),timeDisplayFormat:Su.default(Yo),captureMode:Jx.default(Vi)}),ns="/api/config";async function Xx(e){return Ze(e,yr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function lo(e){return Ze(ns,yr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Wi(){const e=Ot(ns,Xx,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=eu(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??Vi,r=e.data?.slowResponseThresholdSeconds??Go,a=e.data?.providerTestTimeoutSeconds??Ko,i=e.data?.timeDisplayFormat??Yo,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Go,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Ko,timeDisplayFormat:e.data?.timeDisplayFormat??Yo,captureMode:o,...f}),d=async f=>{await t(ns,lo({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await t(ns,lo({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await t(ns,lo({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await t(ns,lo({providerTestTimeoutSeconds:f}),{optimisticData:c({providerTestTimeoutSeconds:f}),rollbackOnError:!0,revalidate:!1})};return{strip:s,captureMode:o,slowResponseThresholdSeconds:r,providerTestTimeoutSeconds:a,timeDisplayFormat:i,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:d,setSlowResponseThresholdSeconds:m,setProviderTestTimeoutSeconds:p,setTimeDisplayFormat:u}}const Nu=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const Zx=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Qx=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,o)=>o?o.toUpperCase():s.toLowerCase());const Xl=e=>{const t=Qx(e);return t.charAt(0).toUpperCase()+t.slice(1)};var e0={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const t0=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const n0=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...e0,width:t,height:t,stroke:e,strokeWidth:o?Number(s)*24/Number(t):s,className:Nu("lucide",r),...!a&&!t0(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const B=(e,t)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(n0,{ref:a,iconNode:t,className:Nu(`lucide-${Zx(Xl(e))}`,`lucide-${e}`,o),...r}));return s.displayName=Xl(e),s};const s0=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],o0=B("a-large-small",s0);const r0=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],a0=B("activity",r0);const i0=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],l0=B("arrow-down-right",i0);const c0=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],d0=B("arrow-down",c0);const u0=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],m0=B("arrow-left",u0);const p0=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],f0=B("arrow-up-right",p0);const h0=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],x0=B("arrow-up",h0);const g0=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Gi=B("beaker",g0);const b0=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],v0=B("bell",b0);const y0=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],w0=B("blocks",y0);const j0=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],S0=B("brain-circuit",j0);const N0=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Cu=B("brain",N0);const C0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Pe=B("check",C0);const k0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],We=B("chevron-down",k0);const _0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],T0=B("chevron-left",_0);const E0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ft=B("chevron-right",E0);const R0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ki=B("chevron-up",R0);const M0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],A0=B("chevrons-down",M0);const I0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],P0=B("chevrons-left",I0);const L0=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],O0=B("chevrons-right",L0);const D0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],z0=B("chevrons-up",D0);const $0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ps=B("circle-alert",$0);const F0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Js=B("circle-check-big",F0);const B0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Xa=B("circle-check",B0);const U0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],q0=B("circle-question-mark",U0);const H0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],V0=B("circle-stop",H0);const W0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ku=B("circle-x",W0);const G0=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],K0=B("clapperboard",G0);const Y0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],J0=B("clock-3",Y0);const X0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xt=B("clock",X0);const Z0=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Q0=B("cloud-upload",Z0);const eg=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],_u=B("code-xml",eg);const tg=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ng=B("columns-2",tg);const sg=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Et=B("copy",sg);const og=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],rg=B("cpu",og);const ag=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Xs=B("download",ag);const ig=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],lg=B("ellipsis",ig);const cg=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Yi=B("external-link",cg);const dg=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ug=B("eye-off",dg);const mg=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Tu=B("eye",mg);const pg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],fg=B("file-braces",pg);const hg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],xg=B("file-diff",hg);const gg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],bg=B("file-search",gg);const vg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],yg=B("file-terminal",vg);const wg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],jg=B("file-text",wg);const Sg=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Ng=B("flag",Sg);const Cg=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Eu=B("flask-conical",Cg);const kg=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],_g=B("folder-open",kg);const Tg=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ji=B("gauge",Tg);const Eg=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],Rg=B("git-compare-arrows",Eg);const Mg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ru=B("globe",Mg);const Ag=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Mu=B("history",Ag);const Ig=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Pg=B("info",Ig);const Lg=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Zl=B("layers",Lg);const Og=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Oe=B("loader-circle",Og);const Dg=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],zg=B("lock",Dg);const $g=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Fg=B("maximize-2",$g);const Bg=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],wr=B("message-square",Bg);const Ug=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],qg=B("minimize-2",Ug);const Hg=[["path",{d:"M5 12h14",key:"1ays0h"}]],Au=B("minus",Hg);const Vg=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Wg=B("monitor",Vg);const Gg=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Kg=B("moon",Gg);const Yg=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Jg=B("mouse-pointer-click",Yg);const Xg=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Zg=B("network",Xg);const Qg=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],e1=B("octagon-alert",Qg);const t1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],n1=B("package-check",t1);const s1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],o1=B("panel-right-close",s1);const r1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],a1=B("panel-right-open",r1);const i1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Iu=B("pencil",i1);const l1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ql=B("plus",l1);const c1=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ec=B("radio",c1);const d1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ct=B("refresh-cw",d1);const u1=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],Pu=B("rocket",u1);const m1=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Lu=B("rotate-ccw",m1);const p1=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Jo=B("rotate-cw",p1);const f1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],h1=B("rows-3",f1);const x1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],g1=B("save",x1);const b1=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],v1=B("scan",b1);const y1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],w1=B("search",y1);const j1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],S1=B("send",j1);const N1=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],C1=B("server",N1);const k1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_1=B("settings",k1);const T1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],E1=B("shield-alert",T1);const R1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],tc=B("shield-check",R1);const M1=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],Xo=B("siren",M1);const A1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Za=B("sparkles",A1);const I1=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],P1=B("sun",I1);const L1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Fn=B("terminal",L1);const O1=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ou=B("timer",O1);const D1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],gn=B("trash-2",D1);const z1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fn=B("triangle-alert",z1);const $1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Du=B("upload",$1);const F1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],B1=B("wifi-off",F1);const U1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],q1=B("wifi",U1);const H1=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Zs=B("wrench",H1);const V1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qs=B("x",V1);const W1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Bs=B("zap",W1),Qa="/api/config";async function G1(e){return Ze(e,yr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function K1(e){return Ze(Qa,yr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Y1(){const e=Ot(Qa,G1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=eu(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??Vi,r=async()=>{await t(Qa,K1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Go,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Ko,timeDisplayFormat:e.data?.timeDisplayFormat??Yo,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function J1({isLoading:e,hasSeenOnboarding:t,dismissedInView:s}){return!e&&!t&&!s}function X1({expanded:e,onToggle:t,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return n.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Pg,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),n.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),n.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),n.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[n.jsxs("div",{children:[n.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),n.jsxs("div",{children:[n.jsx("strong",{children:"Network"}),": replace ",n.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),n.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:n.jsx(We,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),n.jsxs("button",{type:"button",onClick:s,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[n.jsx(Pe,{className:"size-3.5"}),"Got it"]}),n.jsx("button",{type:"button",onClick:s,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:n.jsx(Qs,{className:"size-3.5"})})]})})}function Z1(){const{hasSeenOnboarding:e,isLoading:t,markSeen:s}=Y1(),[o,r]=l.useState(!1),[a,i]=l.useState(!1);return J1({isLoading:t,hasSeenOnboarding:e,dismissedInView:a})?n.jsx(X1,{expanded:o,onToggle:()=>r(c=>!c),onDismiss:()=>{i(!0),s().catch(()=>{})}}):null}const Q1="3.1.22",zu={version:Q1};function ss(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const $u="[REDACTED]",eb=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,tb=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],nc=200,nb=25e6,Fu=50,sb=1e4,ob=1024*1024,rb=64,ab=1e4;function ib(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function lb(e){let t=0;for(const s of e)t+=s.rawRequestBody?.length??s.rawRequestBodyBytes??0,t+=s.responseText?.length??s.responseTextBytes??0;return t}function cb(e){if(e.length>nc)return`Export is limited to ${nc} logs at once. Narrow the filter and try again.`;const t=lb(e);return t>nb?`Export is too large (${ib(t)} of text). Narrow the filter and try again.`:null}function co(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function db(e,t){try{const s=await In(`/api/logs/${e}/chunks`,sb,{signal:t});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function ub(e,t){switch(t){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function sc(e,t,s){const o=ub(e,t);if(o!==null)return o;let r=0,a="";for(let i=0;i<rb;i+=1){const c=new URLSearchParams({part:t,offset:String(r),limit:String(ob)});try{const d=await In(`/api/logs/${String(e.id)}/body?${c.toString()}`,ab,{signal:s});if(!d.ok)return a.length>0?a:null;const m=await d.json(),u=au.safeParse(m);if(!u.success||(a=`${a}${u.data.text}`,!u.data.hasMore||u.data.nextOffset===null))return a.length>0?a:null;r=u.data.nextOffset}catch{return a.length>0?a:null}}return a.length>0?a:null}function ei(e){if(Array.isArray(e))return e.map(s=>ei(s));if(!ss(e))return e;const t={};for(const[s,o]of Object.entries(e))t[s]=eb.test(s)?$u:ei(o);return t}function mb(e){const t=s=>{let o=s;for(const r of tb)o=o.replace(r,$u);return o};try{const s=JSON.parse(e);return t(JSON.stringify(ei(s),null,2))}catch{return t(e)}}function sa(e,t){return t==="redacted"?mb(e):e}function pb(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function fb(e,t,s,o=new Date().toISOString()){return{version:zu.version,exportedAt:o,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:Fu,streamingChunkLogIds:s.map(r=>r.id)}}async function hb(e,t="redacted",s={}){const o=co(s.signal);if(o!==null)return o;const r=cb(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await qt(async()=>{const{default:h}=await import("./jszip.min-Dpks67u2.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=t==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,Fu);i.file("manifest.json",JSON.stringify(fb(e,t,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>pb(h,t)),null,2));for(const h of e){const g=co(s.signal);if(g!==null)return g;const b=await sc(h,"request",s.signal);b!==null&&i.file(`#${h.id}.Request.json`,sa(b,t));const y=await sc(h,"response",s.signal);y!==null&&i.file(`#${h.id}.Response.json`,sa(y,t))}for(const h of d){const g=co(s.signal);if(g!==null)return g;const b=await db(h.id,s.signal);b!==null&&i.file(`#${h.id}.SSE.Response.json`,sa(b,t))}const m=await i.generateAsync({type:"blob"}),u=co(s.signal);if(u!==null)return u;const p=URL.createObjectURL(m),f=document.createElement("a");return f.href=p,f.download=`agent-inspector-export-${c}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p),{ok:!0}}function xb(e){const t=na(e,"/proxy"),s=na(e,"/proxy/v1"),o=na(e,"/api/mcp");return t===null||s===null||o===null?null:{proxy:t,openAiV1:s,mcp:o}}function gb(){const e=Vh();return e.ok?xb(e.runtime):null}function Xi(e){const t=()=>e(gb());return t(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(Jl,t),()=>globalThis.removeEventListener(Jl,t))}function ti(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function jr(e,t,s){return`${ti(e,s)} - ${ti(t,s)}`}const Zi="agent-inspector.theme";function Bu(e){switch(e){case"light":return"light";case"dark":return"dark";case"eye-care":return"eye-care";case null:return"dark";default:return"dark"}}function oa(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function bb(){if(typeof window>"u")return"dark";try{return Bu(window.localStorage.getItem(Zi))}catch{return"dark"}}function vb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Zi,e)}catch{}}function yb(){const[e,t]=l.useState(bb),s=l.useCallback(o=>{t(o),oa(o),vb(o)},[]);return l.useEffect(()=>{oa(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==Zi)return;const a=Bu(r.newValue);t(a),oa(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const Qi="agent-inspector.uiScale",wb=1.25,jb=2200,Sb=3e3,Nb=12;function ra(e,t){return Number.isFinite(e)&&e>0?e:t}function el(e){switch(e){case"auto":return"auto";case"100":return"100";case"125":return"125";case"150":return"150";case null:return"auto";default:return"auto"}}function Cb(e,t){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=ra(t.viewportWidth,1280),o=ra(t.screenWidth,s),r=ra(t.devicePixelRatio,1),a=Math.min(s,o);return r>wb?1:a>=Sb?1.25:a>=jb?1.125:1}}}function kb(e){return`${Math.round(e*100)}%`}function aa(e,t){return Math.max(Nb,e*t)}function _b(){if(typeof window>"u")return{viewportWidth:1280,screenWidth:1280,devicePixelRatio:1};const e=typeof window.screen>"u"?window.innerWidth:window.screen.availWidth;return{viewportWidth:window.innerWidth,screenWidth:e,devicePixelRatio:window.devicePixelRatio}}function ia(e){const t=Cb(e,_b());if(typeof document>"u")return t;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(t*100)),s.style.setProperty("--inspector-ui-scale",String(t)),s.style.setProperty("--inspector-root-font-size",`${String(16*t)}px`),s.style.setProperty("--inspector-font-9",`${String(aa(9,t))}px`),s.style.setProperty("--inspector-font-10",`${String(aa(10,t))}px`),s.style.setProperty("--inspector-font-11",`${String(aa(11,t))}px`),s.style.setProperty("--inspector-font-13",`${String(13*t)}px`),t}function Tb(){if(typeof window>"u")return"auto";try{return el(window.localStorage.getItem(Qi))}catch{return"auto"}}function Eb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Qi,e)}catch{}}function Rb(){const[e,t]=l.useState(Tb),[s,o]=l.useState(1),r=l.useCallback(a=>{t(a),Eb(a),o(ia(a))},[]);return l.useEffect(()=>{const a=()=>{o(ia(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==Qi)return;const c=el(i.newValue);t(c),o(ia(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const Mb=200,Ab=512,Ib=256,hn=64,ni=256,Uu=64,Pb=32,Lb=2,Ob=4,oc=16,ye=E().int().positive(),Db=_({proxy:_({requestBytes:ye,responseBytes:ye,headerBytes:ye,deadlineMs:ye,idleTimeoutMs:ye,activeRequests:ye}),control:_({requestBytes:ye,responseBytes:ye,headerBytes:ye,deadlineMs:ye,idleTimeoutMs:ye,activeRequests:ye}),upstream:_({fetchResponseBytes:ye,fetchDeadlineMs:ye,replayResponseBytes:ye,replayDeadlineMs:ye,metadataResponseBytes:ye,metadataDeadlineMs:ye,connectTimeoutMs:ye,idleTimeoutMs:ye}),pagination:_({restPageSize:ye,searchQueryChars:ye,searchProjectChars:ye}),sse:_({clients:ye,initLogs:ye,heartbeatMs:ye}),imports:_({archiveBytes:ye,entries:ye,entryBytes:ye,uncompressedBytes:ye,expansionRatio:ye}),fanOut:_({providerModels:ye,providerModelMetadata:ye,providerTestConcurrency:ye,activeProviderTests:ye}),queues:_({proxyRequests:ye,finalizerJobs:ye,rawStreamMessages:ye,rawStreamBytes:ye,backgroundWorkers:ye})}).superRefine((e,t)=>{e.control.requestBytes>e.proxy.requestBytes&&t.addIssue({code:"custom",path:["control","requestBytes"],message:"control request budget must not exceed proxy request budget"}),e.control.responseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["control","responseBytes"],message:"control response budget must not exceed proxy response budget"}),e.control.activeRequests>e.proxy.activeRequests&&t.addIssue({code:"custom",path:["control","activeRequests"],message:"control active request budget must not exceed proxy active request budget"}),e.upstream.fetchResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","fetchResponseBytes"],message:"upstream fetch response budget must not exceed proxy response budget"}),e.upstream.replayResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","replayResponseBytes"],message:"upstream replay response budget must not exceed proxy response budget"}),e.upstream.metadataResponseBytes>e.control.responseBytes&&t.addIssue({code:"custom",path:["upstream","metadataResponseBytes"],message:"upstream metadata response budget must not exceed control response budget"}),e.upstream.metadataDeadlineMs>e.control.deadlineMs&&t.addIssue({code:"custom",path:["upstream","metadataDeadlineMs"],message:"upstream metadata deadline must not exceed control deadline"}),e.queues.proxyRequests<e.proxy.activeRequests&&t.addIssue({code:"custom",path:["queues","proxyRequests"],message:"proxy request queue budget must cover active proxy requests"})});Db.parse({proxy:{requestBytes:64*1024*1024,responseBytes:256*1024*1024,headerBytes:64*1024,deadlineMs:12e4,idleTimeoutMs:3e4,activeRequests:oc},control:{requestBytes:8*1024*1024,responseBytes:64*1024*1024,headerBytes:32*1024,deadlineMs:3e4,idleTimeoutMs:1e4,activeRequests:8},upstream:{fetchResponseBytes:256*1024*1024,fetchDeadlineMs:12e4,replayResponseBytes:256*1024*1024,replayDeadlineMs:12e4,metadataResponseBytes:10*1024*1024,metadataDeadlineMs:3e4,connectTimeoutMs:1e4,idleTimeoutMs:3e4},pagination:{restPageSize:Mb,searchQueryChars:Ab,searchProjectChars:Ib},sse:{clients:Pb,initLogs:500,heartbeatMs:15e3},imports:{archiveBytes:64*1024*1024,entries:5e3,entryBytes:32*1024*1024,uncompressedBytes:256*1024*1024,expansionRatio:20},fanOut:{providerModels:hn,providerModelMetadata:Uu,providerTestConcurrency:Ob,activeProviderTests:Lb},queues:{proxyRequests:oc,finalizerJobs:1e3,rawStreamMessages:16384,rawStreamBytes:64*1024*1024,backgroundWorkers:4}});const zb=ue(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),$b=Ut([oe(400),oe(413),oe(429),oe(503)]);_({error:x().min(1).max(300),code:zb,status:$b,resource:x().min(1).max(80),limit:E().int().positive(),retryable:ke()});function uo(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const tl=x().max(ni),Fb=W(tl).max(hn),Bb=_({model:tl.min(1),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),source:ue(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),Ub=W(Bb).max(Uu),qb=_({id:x(),name:x(),apiKey:x(),model:tl.optional(),models:Fb.optional().default([]),format:ue(["anthropic","openai"]).optional(),baseUrl:uo().optional(),anthropicBaseUrl:uo().optional(),openaiBaseUrl:uo().optional(),openaiResponsesBaseUrl:uo().optional(),authHeader:ue(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:Ub.optional(),source:ue(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),Hb="configured",Zo=qb.extend({apiKey:oe(Hb)});async function Vb(e){return Ze(e,Zo.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function nl(){const e=Ot("/api/providers",Vb,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function rc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Wb(...e){return t=>{let s=!1;const o=e.map(r=>{const a=rc(r,t);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():rc(e[r],null)}}}}function Te(...e){return l.useCallback(Wb(...e),e)}function fs(e){const t=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];ac(r)&&typeof mo=="function"&&(r=mo(r._payload)),l.Children.forEach(r,f=>{if(Zb(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;ac(g)&&typeof mo=="function"&&(g=mo(g._payload)),i=Yb(h,g),d.push(i?.props?.children)}else d.push(f)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(r)===1&&l.isValidElement(r)&&(i=r);const m=i?Xb(i):void 0,u=Te(o,m);if(!i){if(r||r===0)throw new Error(c?nv(e):tv(e));return r}const p=Jb(a,i.props??{});return i.type!==l.Fragment&&(p.ref=o?u:m),l.cloneElement(i,p)});return t.displayName=`${e}.Slot`,t}var Gb=fs("Slot"),qu=Symbol.for("radix.slottable");function Kb(e){const t=s=>"child"in s?s.children(s.child):s.children;return t.displayName=`${e}.Slottable`,t.__radixId=qu,t}var Yb=(e,t)=>{if("child"in e.props){const s=e.props.child;return l.isValidElement(s)?l.cloneElement(s,void 0,e.props.children(s.props.children)):null}return l.isValidElement(t)?t:null};function Jb(e,t){const s={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?s[o]=(...c)=>{const d=a(...c);return r(...c),d}:r&&(s[o]=r):o==="style"?s[o]={...r,...a}:o==="className"&&(s[o]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}function Xb(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function Zb(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qu}var Qb=Symbol.for("react.lazy");function ac(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Qb&&"_payload"in e&&ev(e._payload)}function ev(e){return typeof e=="object"&&e!==null&&"then"in e}var tv=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,nv=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,mo=vr[" use ".trim().toString()],sv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=sv.reduce((e,t)=>{const s=fs(`Primitive.${t}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function ov(e,t){e&&ws.flushSync(()=>e.dispatchEvent(t))}var Hu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),rv="VisuallyHidden",Vu=l.forwardRef((e,t)=>n.jsx(ge.span,{...e,ref:t,style:{...Hu,...e.style}}));Vu.displayName=rv;var av=Vu;function tn(e,t=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return n.jsx(b.Provider,{value:y,children:h})};m.displayName=a+"Provider";function u(p,f,h={}){const{optional:g=!1}=h,b=f?.[e]?.[d]||c,y=l.useContext(b);if(y)return y;if(i!==void 0)return i;if(!g)throw new Error(`\`${p}\` must be used within \`${a}\``)}return[m,u]}const r=()=>{const a=s.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return r.scopeName=e,[o,iv(r,...t)]}function iv(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:m})=>{const p=d(a)[`__scope${m}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return s.scopeName=t.scopeName,s}function Wu(e){const t=e+"CollectionProvider",[s,o]=tn(t),[r,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:y,children:w}=b,v=l.useRef(null),j=l.useRef(new Map).current;return n.jsx(r,{scope:y,itemMap:j,collectionRef:v,children:w})};i.displayName=t;const c=e+"CollectionSlot",d=fs(c),m=l.forwardRef((b,y)=>{const{scope:w,children:v}=b,j=a(c,w),S=Te(y,j.collectionRef);return n.jsx(d,{ref:S,children:v})});m.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",f=fs(u),h=l.forwardRef((b,y)=>{const{scope:w,children:v,...j}=b,S=l.useRef(null),N=Te(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),n.jsx(f,{[p]:"",ref:N,children:v})});h.displayName=u;function g(b){const y=a(e+"CollectionConsumer",b);return l.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,R)=>j.indexOf(C.ref.current)-j.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function de(e,t,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return t?.(r)}}var Fe=globalThis?.document?l.useLayoutEffect:()=>{},lv=vr[" useInsertionEffect ".trim().toString()]||Fe;function Ln({prop:e,defaultProp:t,onChange:s=()=>{},caller:o}){const[r,a,i]=cv({defaultProp:t,onChange:s}),c=e!==void 0,d=c?e:r;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${o} is changing from ${p?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=c},[c,o])}const m=l.useCallback(u=>{if(c){const p=dv(u)?u(e):u;p!==e&&i.current?.(p)}else a(u)},[c,e,a,i]);return[d,m]}function cv({defaultProp:e,onChange:t}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(t);return lv(()=>{a.current=t},[t]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function dv(e){return typeof e=="function"}function uv(e,t){return l.useReducer((s,o)=>t[s][o]??s,e)}var ht=e=>{const{present:t,children:s}=e,o=mv(t),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=pv(o.ref,fv(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};ht.displayName="Presence";function mv(e){const[t,s]=l.useState(),o=l.useRef(null),r=l.useRef(e),a=l.useRef("none"),i=l.useRef(void 0),c=e?"mounted":"unmounted",[d,m]=uv(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{d==="mounted"?(a.current=i.current??_s(o.current),i.current=void 0):a.current="none"},[d]),Fe(()=>{const u=o.current,p=r.current;if(p!==e){const h=a.current,g=_s(u);e?(i.current=g,m("MOUNT")):g==="none"||u?.display==="none"?m("UNMOUNT"):m(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,m]),Fe(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,f=g=>{const y=_s(o.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(m("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(a.current=_s(o.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else m("ANIMATION_END")},[t,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const p=getComputedStyle(u);o.current=p,i.current=_s(p)}else o.current=null;s(u)},[])}}function ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function pv(...e){const t=l.useRef(e);return t.current=e,l.useCallback(s=>{const o=t.current;let r=!1;const a=o.map(i=>{const c=ic(i,s);return!r&&typeof c=="function"&&(r=!0),c});if(r)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():ic(o[i],null)}}},[])}function _s(e){return e?.animationName||"none"}function fv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var hv=vr[" useId ".trim().toString()]||(()=>{}),xv=0;function Dt(e){const[t,s]=l.useState(hv());return Fe(()=>{s(o=>o??String(xv++))},[e]),e||(t?`radix-${t}`:"")}var Sr="Collapsible",[gv]=tn(Sr),[bv,sl]=gv(Sr),Gu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=Ln({prop:o,defaultProp:r??!1,onChange:i,caller:Sr});return n.jsx(bv,{scope:s,disabled:a,contentId:Dt(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:n.jsx(ge.div,{"data-state":rl(d),"data-disabled":a?"":void 0,...c,ref:t})})});Gu.displayName=Sr;var Ku="CollapsibleTrigger",Yu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,...o}=e,r=sl(Ku,s);return n.jsx(ge.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":rl(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:t,onClick:de(e.onClick,r.onOpenToggle)})});Yu.displayName=Ku;var ol="CollapsibleContent",Ju=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=sl(ol,e.__scopeCollapsible);return n.jsx(ht,{present:s||r.open,children:({present:a})=>n.jsx(vv,{...o,ref:t,present:a})})});Ju.displayName=ol;var vv=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=sl(ol,s),[c,d]=l.useState(o),m=l.useRef(null),u=Te(t,m),p=l.useRef(0),f=p.current,h=l.useRef(0),g=h.current,b=i.open||c,y=l.useRef(b),w=l.useRef(void 0);return l.useEffect(()=>{const v=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(v)},[]),Fe(()=>{const v=m.current;if(v){w.current=w.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const j=v.getBoundingClientRect();p.current=j.height,h.current=j.width,y.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),d(o)}},[i.open,o]),n.jsx(ge.div,{"data-state":rl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:b&&r})});function rl(e){return e?"open":"closed"}var yv=Gu,wv=l.createContext(void 0);function Nr(e){const t=l.useContext(wv);return e||t||"ltr"}function He(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>((...s)=>t.current?.(...s)),[])}var jv="DismissableLayer",si="dismissableLayer.update",Sv="dismissableLayer.pointerDownOutside",Nv="dismissableLayer.focusOutside",lc,al=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Cr=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(al),[p,f]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=l.useState({}),b=Te(t,f),y=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?y.indexOf(w):-1,j=p?y.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=v,C=l.useRef(!1),R=Ev(k=>{a?.(k),c?.(k),k.defaultPrevented||d?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:l.useCallback(k=>{if(!(k instanceof Node))return!1;const A=[...u.branches].some(D=>D.contains(k));return N&&!A},[u.branches,N])}),P=Rv(k=>{if(o&&C.current)return;const A=k.target;[...u.branches].some(F=>F.contains(A))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),L=p?j===y.length-1:!1,M=He(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(L)return h.addEventListener("keydown",M,{capture:!0}),()=>h.removeEventListener("keydown",M,{capture:!0})},[h,L,M]),l.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(lc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),cc(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=lc))}},[p,h,s,u]),l.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),cc())},[p,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(si,k),()=>document.removeEventListener(si,k)},[]),n.jsx(ge.div,{...m,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,P.onFocusCapture),onBlurCapture:de(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,R.onPointerDownCapture)})});Cr.displayName=jv;var Cv="DismissableLayerBranch",kv=l.forwardRef((e,t)=>{const s=l.useContext(al),o=l.useRef(null),r=Te(t,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),n.jsx(ge.div,{...e,ref:r})});kv.displayName=Cv;function _v(){const e=l.useContext(al),[t,s]=l.useState(null);return l.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}var Tv=()=>!0;function Ev(e,t){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Tv}=t,c=He(e),d=l.useRef(!1),m=l.useRef(!1),u=l.useRef(new Map),p=l.useRef(()=>{});return l.useEffect(()=>{function f(){m.current=!1,r.current=!1,u.current.clear()}function h(){return Array.from(u.current.values()).some(Boolean)}function g(j){if(!m.current)return;const S=j.target;S instanceof Node&&[...a].some(C=>C.contains(S))||u.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{m.current&&p.current()},0)}function b(j){m.current&&u.current.set(j.type,!1)}const y=j=>{if(j.target&&!d.current){let S=function(){s.removeEventListener("click",p.current);const C=h();f(),C||Xu(Sv,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",p.current),f(),d.current=!1;return}const N={originalEvent:j};m.current=!0,r.current=o&&j.button===0,u.current.clear(),!o||j.button!==0?S():(s.removeEventListener("click",p.current),p.current=S,s.addEventListener("click",p.current,{once:!0}))}else s.removeEventListener("click",p.current),f();d.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)s.addEventListener(j,g,!0),s.addEventListener(j,b);const v=window.setTimeout(()=>{s.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(v),s.removeEventListener("pointerdown",y),s.removeEventListener("click",p.current);for(const j of w)s.removeEventListener(j,g,!0),s.removeEventListener(j,b)}},[s,c,o,r,a,i]),{onPointerDownCapture:()=>d.current=!0}}function Rv(e,t=globalThis?.document){const s=He(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&Xu(Nv,s,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function cc(){const e=new CustomEvent(si);document.dispatchEvent(e)}function Xu(e,t,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&r.addEventListener(e,t,{once:!0}),o?ov(r,a):r.dispatchEvent(a)}var la="focusScope.autoFocusOnMount",ca="focusScope.autoFocusOnUnmount",dc={bubbles:!1,cancelable:!0},Mv="FocusScope",il=l.forwardRef((e,t)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=He(r),u=He(a),p=l.useRef(null),f=Te(t,d),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(o){let b=function(j){if(h.paused||!c)return;const S=j.target;c.contains(S)?p.current=S:cn(p.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||cn(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&cn(c)};document.addEventListener("focusin",b),document.addEventListener("focusout",y);const v=new MutationObserver(w);return c&&v.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",y),v.disconnect()}}},[o,c,h.paused]),l.useEffect(()=>{if(c){mc.add(h);const b=document.activeElement;if(!c.contains(b)){const w=new CustomEvent(la,dc);c.addEventListener(la,m),c.dispatchEvent(w),w.defaultPrevented||(Av(Dv(Zu(c)),{select:!0}),document.activeElement===b&&cn(c))}return()=>{c.removeEventListener(la,m),setTimeout(()=>{const w=new CustomEvent(ca,dc);c.addEventListener(ca,u),c.dispatchEvent(w),w.defaultPrevented||cn(b??document.body,{select:!0}),c.removeEventListener(ca,u),mc.remove(h)},0)}}},[c,m,u,h]);const g=l.useCallback(b=>{if(!s&&!o||h.paused)return;const y=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,w=document.activeElement;if(y&&w){const v=b.currentTarget,[j,S]=Iv(v);j&&S?!b.shiftKey&&w===S?(b.preventDefault(),s&&cn(j,{select:!0})):b.shiftKey&&w===j&&(b.preventDefault(),s&&cn(S,{select:!0})):w===v&&b.preventDefault()}},[s,o,h.paused]);return n.jsx(ge.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});il.displayName=Mv;function Av(e,{select:t=!1}={}){const s=document.activeElement;for(const o of e)if(cn(o,{select:t}),document.activeElement!==s)return}function Iv(e){const t=Zu(e),s=uc(t,e),o=uc(t.reverse(),e);return[s,o]}function Zu(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)t.push(s.currentNode);return t}function uc(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):Pv(o,{upTo:t})))return o}function Pv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Lv(e){return e instanceof HTMLInputElement&&"select"in e}function cn(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Lv(e)&&t&&e.select()}}var mc=Ov();function Ov(){let e=[];return{add(t){const s=e[0];t!==s&&s?.pause(),e=pc(e,t),e.unshift(t)},remove(t){e=pc(e,t),e[0]?.resume()}}}function pc(e,t){const s=[...e],o=s.indexOf(t);return o!==-1&&s.splice(o,1),s}function Dv(e){return e.filter(t=>t.tagName!=="A")}var zv="Portal",kr=l.forwardRef((e,t)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);Fe(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?ws.createPortal(n.jsx(ge.div,{...o,ref:t}),i):null});kr.displayName=zv;var po=0,Vn=null;function Qu(){l.useEffect(()=>{Vn||(Vn={start:fc(),end:fc()});const{start:e,end:t}=Vn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),po++,()=>{po===1&&(Vn?.start.remove(),Vn?.end.remove(),Vn=null),po=Math.max(0,po-1)}},[])}function fc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var s,o=1,r=arguments.length;o<r;o++){s=arguments[o];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},Pt.apply(this,arguments)};function em(e,t){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(s[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function $v(e,t,s){if(s||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var Do="right-scroll-bar-position",zo="width-before-scroll-bar",Fv="with-scroll-bars-hidden",Bv="--removed-body-scroll-bar-size";function da(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uv(e,t){var s=l.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(o){var r=s.value;r!==o&&(s.value=o,s.callback(o,r))}}}})[0];return s.callback=t,s.facade}var qv=typeof window<"u"?l.useLayoutEffect:l.useEffect,hc=new WeakMap;function Hv(e,t){var s=Uv(null,function(o){return e.forEach(function(r){return da(r,o)})});return qv(function(){var o=hc.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||da(c,null)}),a.forEach(function(c){r.has(c)||da(c,i)})}hc.set(s,e)},[e]),s}function Vv(e){return e}function Wv(e,t){t===void 0&&(t=Vv);var s=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var i=t(a,o);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(o=!0;s.length;){var i=s;s=[],i.forEach(a)}s={push:function(c){return a(c)},filter:function(){return s}}},assignMedium:function(a){o=!0;var i=[];if(s.length){var c=s;s=[],c.forEach(a),i=s}var d=function(){var u=i;i=[],u.forEach(a)},m=function(){return Promise.resolve().then(d)};m(),s={push:function(u){i.push(u),m()},filter:function(u){return i=i.filter(u),s}}}};return r}function Gv(e){e===void 0&&(e={});var t=Wv(null);return t.options=Pt({async:!0,ssr:!1},e),t}var tm=function(e){var t=e.sideCar,s=em(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,Pt({},s))};tm.isSideCarExport=!0;function Kv(e,t){return e.useMedium(t),tm}var nm=Gv(),ua=function(){},_r=l.forwardRef(function(e,t){var s=l.useRef(null),o=l.useState({onScrollCapture:ua,onWheelCapture:ua,onTouchMoveCapture:ua}),r=o[0],a=o[1],i=e.forwardProps,c=e.children,d=e.className,m=e.removeScrollBar,u=e.enabled,p=e.shards,f=e.sideCar,h=e.noRelative,g=e.noIsolation,b=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,S=em(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=Hv([s,t]),R=Pt(Pt({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:nm,removeScrollBar:m,shards:p,noRelative:h,noIsolation:g,inert:b,setCallbacks:a,allowPinchZoom:!!y,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),Pt(Pt({},R),{ref:C})):l.createElement(v,Pt({},R,{className:d,ref:C}),c))});_r.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};_r.classNames={fullWidth:zo,zeroRight:Do};var Yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Yv();return t&&e.setAttribute("nonce",t),e}function Xv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Zv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Qv=function(){var e=0,t=null;return{add:function(s){e==0&&(t=Jv())&&(Xv(t,s),Zv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},e2=function(){var e=Qv();return function(t,s){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},sm=function(){var e=e2(),t=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return t},t2={left:0,top:0,right:0,gap:0},ma=function(e){return parseInt(e||"",10)||0},n2=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[ma(s),ma(o),ma(r)]},s2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return t2;var t=n2(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-s+t[2]-t[0])}},o2=sm(),is="data-scroll-locked",r2=function(e,t,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-CAvKMGPH.js","./index-vp9_EbPc.js","./index-B-Qod-aA.css","./CompareDrawer-DS5S-VLf.js","./InspectorPet-DfaI6G7F.js","./ReplayDialog-CDYTm53e.js","./ResponseView-DPLMIyJd.js","./RequestAnatomy-Dy8R19-R.js","./StreamingChunkSequence-ekgIUv3O.js","./json-viewer-zMxqETtC.js","./index-CbQTPA5b.js"])))=>i.map(i=>d[i]);
2
+ import{l as Hh,u as Ut,s as x,n as E,b as ke,_ as Ho,a as W,c as De,o as _,d as ue,e as oe,f as wn,g as Os,h as Ot,i as eu,k as Ze,r as l,j as n,m as qt,p as In,A as Jl,q as Vh,t as na,v as vr,w as ws,x as O,B as ee,y as $n,z as tu,C as Ee,D as nu,E as Nt,F as Ii,G as Wh,H as Le,L as Vo,I as su,J as Gh,K as Wo,M as Kh,N as Yh,O as Jh,P as ou,Q as Pi,T as Xh,U as Zh}from"./index-vp9_EbPc.js";const Ve=Hh(()=>Ut([x(),E(),ke(),Ho(),W(Ve),De(x(),Ve)])),kt=E().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Qh=ue(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),ru=_({index:E(),timestamp:E(),type:x(),data:Ve}),ex=_({id:x(),logId:kt,index:E().int().nonnegative(),provider:ue(["anthropic","openai"]),name:x(),argumentsText:x().nullable(),argumentsPreview:x().nullable()}),tx=ue(["end_turn","tool_use","stop","length"]),nx=tx.nullable(),sx=_({chunks:W(ru),truncated:ke().optional().default(!1)}),ox=ue(["request","response"]),au=_({logId:kt,part:ox,text:x(),offset:E().int().nonnegative(),limit:E().int().positive(),totalBytes:E().int().nonnegative(),textBytes:E().int().nonnegative(),nextOffset:E().int().nonnegative().nullable(),hasMore:ke(),contentMode:ue(["empty","partial","full"])}),Fs=_({id:kt,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:E().nullable(),responseText:x().nullable(),inputTokens:E().nullable(),outputTokens:E().nullable(),cacheCreationInputTokens:E().nullable(),cacheReadInputTokens:E().nullable(),elapsedMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),streaming:ke(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:De(x(),x()).optional(),headers:De(x(),x()).optional(),apiFormat:ue(["anthropic","openai","unknown"]).default("unknown"),isTest:ke().optional().default(!1),replayOfLogId:kt.nullable().optional(),providerName:x().nullable().optional(),clientPort:E().nullable().optional(),clientPid:E().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:sx.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:E().int().nonnegative().nullable().optional(),responseTextBytes:E().int().nonnegative().nullable().optional(),bodyContentMode:ue(["full","compact","truncated"]).optional(),captureIncomplete:ke().optional(),droppedChunks:E().int().nonnegative().optional(),droppedBytes:E().int().nonnegative().optional(),captureIncompleteReason:Qh.nullable().optional(),warnings:W(x()).optional(),toolTraceEvents:W(ex).optional(),stopReason:nx.optional(),error:x().nullable().optional()}),Li=_({type:x(),ttl:x().optional(),scope:x().optional()}),Oi=_({type:oe("text"),text:x(),cache_control:Li.optional()}),iu=_({type:oe("thinking"),thinking:x(),signature:x().optional()}),rx=_({type:oe("think"),thinking:x(),signature:x().optional()}),ax=_({type:oe("base64"),media_type:x(),data:x()}),lu=_({type:oe("image"),source:ax}),cu=_({type:oe("tool_use"),id:x(),name:x(),input:De(x(),Ve)}),ix=wn("type",[Oi,lu]),lx=_({type:oe("tool_result"),tool_use_id:x().optional(),content:Ut([x(),W(ix)]),is_error:ke().optional()}),cx=wn("type",[Oi,iu,lu,cu,lx]),dx=Ut([x(),W(cx)]),ux=_({role:ue(["user","assistant"]),content:dx}),mx=_({type:oe("text"),text:x(),cache_control:Li.optional()}),px=_({type:x(),properties:De(x(),De(x(),Ve)).optional(),required:W(x()).optional(),additionalProperties:ke().optional(),$schema:x().optional()}),fx=_({name:x(),description:x().optional(),input_schema:px.optional(),cache_control:Li.optional()}),hx=wn("type",[_({type:oe("enabled"),budget_tokens:E()}),_({type:oe("disabled")}),_({type:oe("adaptive")})]),xx=_({model:x(),messages:W(ux),system:W(mx).optional(),tools:W(fx).optional(),max_tokens:E().optional(),temperature:E().optional(),stream:ke().optional(),thinking:hx.optional(),metadata:_({user_id:x().optional()}).optional()}),Di=wn("type",[Oi,iu,rx,cu]),gx=_({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),cache_creation_input_tokens:E().nullable().optional(),cache_read_input_tokens:E().nullable().optional()}).passthrough(),bx=_({id:x(),type:oe("message"),model:x(),role:oe("assistant"),content:W(Di),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:gx}).passthrough(),vx=_({type:oe("message_start"),message:_({id:x(),type:oe("message"),model:x(),role:oe("assistant"),content:W(Di),stop_reason:Ho(),stop_sequence:Ho(),usage:_({input_tokens:E(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()})}),yx=_({type:oe("content_block_start"),index:E(),content_block:Di}),wx=wn("type",[_({type:oe("text_delta"),text:x()}),_({type:oe("input_json_delta"),partial_json:x()}),_({type:oe("thinking_delta"),thinking:x()}),_({type:oe("signature_delta"),signature:x()})]),jx=_({type:oe("content_block_delta"),index:E(),delta:wx}),Sx=_({type:oe("content_block_stop"),index:E()}),Nx=_({type:oe("message_delta"),delta:_({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:_({output_tokens:E(),input_tokens:E().optional(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()}),Cx=_({type:oe("message_stop")}),kx=_({type:oe("ping")}),_x=_({type:oe("error"),error:_({type:x(),message:x()})});wn("type",[vx,yx,jx,Sx,Nx,Cx,kx,_x]);const Tx=Ut([x(),W(wn("type",[_({type:oe("text"),text:x()}),_({type:oe("image_url"),image_url:_({url:x(),detail:x().optional()})})]))]),du=_({role:ue(["system","user","assistant","tool"]),content:Tx,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),Ex=_({name:x(),arguments:x()}),uu=_({index:E().optional(),id:x().optional(),type:oe("function").optional(),function:_({name:x().optional(),arguments:x().optional()})});du.extend({content:Ut([x(),W(_({type:oe("text"),text:x()}))]).optional(),function_call:Ex.optional(),tool_calls:W(uu).optional()});const Rx=_({type:oe("function"),function:_({name:x(),description:x().optional(),parameters:De(x(),Ve)})}),Mx=_({model:x(),messages:W(du),temperature:E().optional(),max_tokens:E().optional(),stream:ke().optional(),tools:W(Rx).optional(),tool_choice:Ut([ue(["auto","none","required"]),_({type:oe("auto")}),_({type:oe("none")}),_({type:oe("function"),function:_({name:x()})})]).optional(),user:x().optional()}),Ax=_({type:x(),name:x().optional(),description:x().optional(),parameters:Ve.optional(),function:_({name:x().optional(),description:x().optional(),parameters:Ve.optional()}).optional()}).passthrough(),Ix=_({model:x(),input:Os().optional(),instructions:Ut([x(),Ho()]).optional(),stream:ke().optional(),tools:W(Ax).optional(),tool_choice:Os().optional(),max_output_tokens:E().optional(),temperature:E().optional(),user:x().optional(),metadata:De(x(),Os()).optional()}).passthrough(),mu=_({role:ue(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:_({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:W(_({index:E(),id:x().optional(),type:oe("function").optional(),function:_({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),Px=_({index:E(),message:_({role:ue(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:_({name:x(),arguments:x()}).nullable().optional(),tool_calls:W(uu).optional()}).optional(),delta:mu.optional(),finish_reason:x().nullable()}),Lx=_({id:x(),object:oe("chat.completion"),created:E(),model:x(),choices:W(Px),usage:_({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();_({id:x(),object:oe("chat.completion.chunk"),created:E(),model:x(),choices:W(_({index:E(),delta:mu,finish_reason:x().nullable().optional()})),usage:_({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const Ox=_({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),total_tokens:E().nullable().optional(),input_tokens_details:_({cached_tokens:E().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:_({reasoning_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Dx=_({type:x()}).passthrough(),zx=_({id:x(),object:oe("response").optional(),created_at:E().optional(),status:x().nullable().optional(),model:x().optional(),output:W(Dx).optional(),output_text:x().optional(),usage:Ox.nullable().optional(),error:Os().optional()}).passthrough();_({type:x()}).passthrough();function $x(e){try{const t=JSON.parse(e),s=Lx.safeParse(t);return s.success?s.data:null}catch{return null}}function Fx(e){try{const t=JSON.parse(e),s=zx.safeParse(t);return s.success?s.data:null}catch{return null}}const pu=_({input:E().int().nonnegative(),output:E().int().nonnegative(),cacheCreate:E().int().nonnegative(),cacheRead:E().int().nonnegative(),total:E().int().nonnegative()}),Bx=_({id:kt,sessionLogNumber:E().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:ue(["anthropic","openai","unknown"]),method:x(),path:x(),status:E().nullable(),isStreaming:ke(),hasError:ke(),error:x().nullable(),latencyMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),tokens:_({input:E().nullable(),output:E().nullable(),cacheCreate:E().nullable(),cacheRead:E().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:E().nullable().optional(),clientProjectFolder:x().nullable().optional()}),fu=_({id:x(),status:ue(["active","failed","completed","empty"]),logCoverage:ue(["recent","history"]),source:ue(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:ue(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:E().int().nonnegative(),activeRequests:E().int().nonnegative(),completedRequests:E().int().nonnegative(),failedRequests:E().int().nonnegative(),queuedTasks:E().int().nonnegative(),runningTasks:E().int().nonnegative(),lastTaskError:x().nullable(),logCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),models:W(x()),providers:W(x()),tokenUsage:pu,lastLogId:kt.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:E().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:E().int().positive(),latestLogs:W(Bx)}),Ys=ue(["created","running","completed","failed","cancelled"]),zi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Ux=ue(["run-created","session-started","request","session-finished","evidence-exported"]),qx=ue(["info","success","warning","error"]),Hx=_({timestamp:x(),kind:Ux,severity:qx,title:x(),details:x(),logId:kt.nullable(),status:E().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:E().nullable(),isStreaming:ke().nullable()}),Vx=ue(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),hu=_({outcome:ue(["success","failure","active","unknown"]),severity:ue(["none","low","medium","high"]),category:Vx,summary:x(),evidenceLogIds:W(kt),hints:W(x())}),$i=_({status:ue(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),xu=$i,Fi=_({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:Ys,tags:W(x()),metadata:De(x(),Ve),evidence:zi.nullable(),createdAt:x(),updatedAt:x()});_({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:Ys.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()}).optional();_({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:Ys.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()});_({includeHistory:ke().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();_({run:Fi,evidence:zi,session:fu.nullable(),timeline:W(Hx),classification:hu,jenkinsReport:$i});const Wx=_({run:Fi,classification:hu,evidence:zi.nullable(),jenkinsReport:$i.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});_({failures:W(Wx),total:E().int().nonnegative(),limit:E().int().positive()});const Bi=ue(["created","running","completed","failed","cancelled"]),Ui=ue(["evaluation","batch","manual"]),qi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),gu=_({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:Ys.nullable(),metadata:De(x(),Ve),addedAt:x(),updatedAt:x()}),Hi=_({id:x(),title:x(),kind:Ui,task:x().nullable(),project:x().nullable(),status:Bi,tags:W(x()),metadata:De(x(),Ve),evidence:qi.nullable(),members:W(gu),createdAt:x(),updatedAt:x()});_({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Ui.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Bi.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()}).optional();_({title:x().min(1).optional(),kind:Ui.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Bi.optional(),tags:W(x()).optional(),metadata:De(x(),Ve).optional()});_({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:Ys.nullable().optional(),metadata:De(x(),Ve).optional()});_({includeHistory:ke().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();_({deleteEvidence:ke().optional()});const bu=_({groupId:x(),deleted:ke(),evidenceDeleted:ke(),evidencePath:x().nullable()}),vu=_({deleted:E().int().nonnegative(),groups:W(bu)}),yu=_({member:gu,run:Fi.nullable(),session:fu.nullable()}),wu=_({memberCount:E().int().nonnegative(),sessionsWithData:E().int().nonnegative(),missingSessions:E().int().nonnegative(),requestCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),tokenUsage:pu,models:W(x()),providers:W(x()),completedMembers:E().int().nonnegative(),failedMembers:E().int().nonnegative(),runningMembers:E().int().nonnegative()}),Gx=_({group:Hi,evidence:qi,members:W(yu).nullable(),markdown:x(),summary:wu.nullable(),report:xu.nullable()}),Kx=_({group:Hi,evidence:qi,members:W(yu),summary:wu,jenkinsReport:xu}),ju=_({groups:W(Hi)}),Yx=_({sessionId:x(),imported:E().int().nonnegative(),skipped:E().int().nonnegative(),warnings:W(x()),logs:W(Fs)}),Go=10,Ya=600,Ko=60,Ja=600,Yo="time",Vi="simple",Su=ue(["time","full"]),Jx=ue(["simple","full"]),yr=_({stripClaudeCodeBillingHeader:ke(),hasSeenOnboarding:ke().default(!1),slowResponseThresholdSeconds:E().int().min(0).max(Ya).default(Go),providerTestTimeoutSeconds:E().int().min(1).max(Ja).default(Ko),timeDisplayFormat:Su.default(Yo),captureMode:Jx.default(Vi)}),ns="/api/config";async function Xx(e){return Ze(e,yr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function lo(e){return Ze(ns,yr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Wi(){const e=Ot(ns,Xx,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=eu(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??Vi,r=e.data?.slowResponseThresholdSeconds??Go,a=e.data?.providerTestTimeoutSeconds??Ko,i=e.data?.timeDisplayFormat??Yo,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Go,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Ko,timeDisplayFormat:e.data?.timeDisplayFormat??Yo,captureMode:o,...f}),d=async f=>{await t(ns,lo({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await t(ns,lo({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await t(ns,lo({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await t(ns,lo({providerTestTimeoutSeconds:f}),{optimisticData:c({providerTestTimeoutSeconds:f}),rollbackOnError:!0,revalidate:!1})};return{strip:s,captureMode:o,slowResponseThresholdSeconds:r,providerTestTimeoutSeconds:a,timeDisplayFormat:i,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:d,setSlowResponseThresholdSeconds:m,setProviderTestTimeoutSeconds:p,setTimeDisplayFormat:u}}const Nu=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const Zx=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Qx=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,o)=>o?o.toUpperCase():s.toLowerCase());const Xl=e=>{const t=Qx(e);return t.charAt(0).toUpperCase()+t.slice(1)};var e0={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const t0=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const n0=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...e0,width:t,height:t,stroke:e,strokeWidth:o?Number(s)*24/Number(t):s,className:Nu("lucide",r),...!a&&!t0(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const B=(e,t)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(n0,{ref:a,iconNode:t,className:Nu(`lucide-${Zx(Xl(e))}`,`lucide-${e}`,o),...r}));return s.displayName=Xl(e),s};const s0=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],o0=B("a-large-small",s0);const r0=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],a0=B("activity",r0);const i0=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],l0=B("arrow-down-right",i0);const c0=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],d0=B("arrow-down",c0);const u0=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],m0=B("arrow-left",u0);const p0=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],f0=B("arrow-up-right",p0);const h0=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],x0=B("arrow-up",h0);const g0=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Gi=B("beaker",g0);const b0=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],v0=B("bell",b0);const y0=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],w0=B("blocks",y0);const j0=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],S0=B("brain-circuit",j0);const N0=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Cu=B("brain",N0);const C0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Pe=B("check",C0);const k0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],We=B("chevron-down",k0);const _0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],T0=B("chevron-left",_0);const E0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ft=B("chevron-right",E0);const R0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ki=B("chevron-up",R0);const M0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],A0=B("chevrons-down",M0);const I0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],P0=B("chevrons-left",I0);const L0=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],O0=B("chevrons-right",L0);const D0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],z0=B("chevrons-up",D0);const $0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ps=B("circle-alert",$0);const F0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Js=B("circle-check-big",F0);const B0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Xa=B("circle-check",B0);const U0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],q0=B("circle-question-mark",U0);const H0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],V0=B("circle-stop",H0);const W0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ku=B("circle-x",W0);const G0=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],K0=B("clapperboard",G0);const Y0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],J0=B("clock-3",Y0);const X0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xt=B("clock",X0);const Z0=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Q0=B("cloud-upload",Z0);const eg=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],_u=B("code-xml",eg);const tg=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ng=B("columns-2",tg);const sg=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Et=B("copy",sg);const og=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],rg=B("cpu",og);const ag=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Xs=B("download",ag);const ig=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],lg=B("ellipsis",ig);const cg=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Yi=B("external-link",cg);const dg=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ug=B("eye-off",dg);const mg=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Tu=B("eye",mg);const pg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],fg=B("file-braces",pg);const hg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],xg=B("file-diff",hg);const gg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],bg=B("file-search",gg);const vg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],yg=B("file-terminal",vg);const wg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],jg=B("file-text",wg);const Sg=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Ng=B("flag",Sg);const Cg=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Eu=B("flask-conical",Cg);const kg=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],_g=B("folder-open",kg);const Tg=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ji=B("gauge",Tg);const Eg=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],Rg=B("git-compare-arrows",Eg);const Mg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ru=B("globe",Mg);const Ag=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Mu=B("history",Ag);const Ig=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Pg=B("info",Ig);const Lg=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Zl=B("layers",Lg);const Og=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Oe=B("loader-circle",Og);const Dg=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],zg=B("lock",Dg);const $g=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Fg=B("maximize-2",$g);const Bg=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],wr=B("message-square",Bg);const Ug=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],qg=B("minimize-2",Ug);const Hg=[["path",{d:"M5 12h14",key:"1ays0h"}]],Au=B("minus",Hg);const Vg=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Wg=B("monitor",Vg);const Gg=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Kg=B("moon",Gg);const Yg=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Jg=B("mouse-pointer-click",Yg);const Xg=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Zg=B("network",Xg);const Qg=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],e1=B("octagon-alert",Qg);const t1=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],n1=B("package-check",t1);const s1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],o1=B("panel-right-close",s1);const r1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],a1=B("panel-right-open",r1);const i1=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Iu=B("pencil",i1);const l1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ql=B("plus",l1);const c1=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ec=B("radio",c1);const d1=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ct=B("refresh-cw",d1);const u1=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],Pu=B("rocket",u1);const m1=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Lu=B("rotate-ccw",m1);const p1=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Jo=B("rotate-cw",p1);const f1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],h1=B("rows-3",f1);const x1=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],g1=B("save",x1);const b1=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],v1=B("scan",b1);const y1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],w1=B("search",y1);const j1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],S1=B("send",j1);const N1=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],C1=B("server",N1);const k1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_1=B("settings",k1);const T1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],E1=B("shield-alert",T1);const R1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],tc=B("shield-check",R1);const M1=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],Xo=B("siren",M1);const A1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Za=B("sparkles",A1);const I1=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],P1=B("sun",I1);const L1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Fn=B("terminal",L1);const O1=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ou=B("timer",O1);const D1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],gn=B("trash-2",D1);const z1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fn=B("triangle-alert",z1);const $1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Du=B("upload",$1);const F1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],B1=B("wifi-off",F1);const U1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],q1=B("wifi",U1);const H1=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Zs=B("wrench",H1);const V1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qs=B("x",V1);const W1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Bs=B("zap",W1),Qa="/api/config";async function G1(e){return Ze(e,yr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function K1(e){return Ze(Qa,yr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Y1(){const e=Ot(Qa,G1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=eu(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??Vi,r=async()=>{await t(Qa,K1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Go,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Ko,timeDisplayFormat:e.data?.timeDisplayFormat??Yo,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function J1({isLoading:e,hasSeenOnboarding:t,dismissedInView:s}){return!e&&!t&&!s}function X1({expanded:e,onToggle:t,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return n.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Pg,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),n.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),n.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),n.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[n.jsxs("div",{children:[n.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),n.jsxs("div",{children:[n.jsx("strong",{children:"Network"}),": replace ",n.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),n.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:n.jsx(We,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),n.jsxs("button",{type:"button",onClick:s,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[n.jsx(Pe,{className:"size-3.5"}),"Got it"]}),n.jsx("button",{type:"button",onClick:s,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:n.jsx(Qs,{className:"size-3.5"})})]})})}function Z1(){const{hasSeenOnboarding:e,isLoading:t,markSeen:s}=Y1(),[o,r]=l.useState(!1),[a,i]=l.useState(!1);return J1({isLoading:t,hasSeenOnboarding:e,dismissedInView:a})?n.jsx(X1,{expanded:o,onToggle:()=>r(c=>!c),onDismiss:()=>{i(!0),s().catch(()=>{})}}):null}const Q1="3.1.24",zu={version:Q1};function ss(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const $u="[REDACTED]",eb=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,tb=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],nc=200,nb=25e6,Fu=50,sb=1e4,ob=1024*1024,rb=64,ab=1e4;function ib(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function lb(e){let t=0;for(const s of e)t+=s.rawRequestBody?.length??s.rawRequestBodyBytes??0,t+=s.responseText?.length??s.responseTextBytes??0;return t}function cb(e){if(e.length>nc)return`Export is limited to ${nc} logs at once. Narrow the filter and try again.`;const t=lb(e);return t>nb?`Export is too large (${ib(t)} of text). Narrow the filter and try again.`:null}function co(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function db(e,t){try{const s=await In(`/api/logs/${e}/chunks`,sb,{signal:t});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function ub(e,t){switch(t){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function sc(e,t,s){const o=ub(e,t);if(o!==null)return o;let r=0,a="";for(let i=0;i<rb;i+=1){const c=new URLSearchParams({part:t,offset:String(r),limit:String(ob)});try{const d=await In(`/api/logs/${String(e.id)}/body?${c.toString()}`,ab,{signal:s});if(!d.ok)return a.length>0?a:null;const m=await d.json(),u=au.safeParse(m);if(!u.success||(a=`${a}${u.data.text}`,!u.data.hasMore||u.data.nextOffset===null))return a.length>0?a:null;r=u.data.nextOffset}catch{return a.length>0?a:null}}return a.length>0?a:null}function ei(e){if(Array.isArray(e))return e.map(s=>ei(s));if(!ss(e))return e;const t={};for(const[s,o]of Object.entries(e))t[s]=eb.test(s)?$u:ei(o);return t}function mb(e){const t=s=>{let o=s;for(const r of tb)o=o.replace(r,$u);return o};try{const s=JSON.parse(e);return t(JSON.stringify(ei(s),null,2))}catch{return t(e)}}function sa(e,t){return t==="redacted"?mb(e):e}function pb(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function fb(e,t,s,o=new Date().toISOString()){return{version:zu.version,exportedAt:o,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:Fu,streamingChunkLogIds:s.map(r=>r.id)}}async function hb(e,t="redacted",s={}){const o=co(s.signal);if(o!==null)return o;const r=cb(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await qt(async()=>{const{default:h}=await import("./jszip.min-CAvKMGPH.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=t==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,Fu);i.file("manifest.json",JSON.stringify(fb(e,t,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>pb(h,t)),null,2));for(const h of e){const g=co(s.signal);if(g!==null)return g;const b=await sc(h,"request",s.signal);b!==null&&i.file(`#${h.id}.Request.json`,sa(b,t));const y=await sc(h,"response",s.signal);y!==null&&i.file(`#${h.id}.Response.json`,sa(y,t))}for(const h of d){const g=co(s.signal);if(g!==null)return g;const b=await db(h.id,s.signal);b!==null&&i.file(`#${h.id}.SSE.Response.json`,sa(b,t))}const m=await i.generateAsync({type:"blob"}),u=co(s.signal);if(u!==null)return u;const p=URL.createObjectURL(m),f=document.createElement("a");return f.href=p,f.download=`agent-inspector-export-${c}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p),{ok:!0}}function xb(e){const t=na(e,"/proxy"),s=na(e,"/proxy/v1"),o=na(e,"/api/mcp");return t===null||s===null||o===null?null:{proxy:t,openAiV1:s,mcp:o}}function gb(){const e=Vh();return e.ok?xb(e.runtime):null}function Xi(e){const t=()=>e(gb());return t(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(Jl,t),()=>globalThis.removeEventListener(Jl,t))}function ti(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function jr(e,t,s){return`${ti(e,s)} - ${ti(t,s)}`}const Zi="agent-inspector.theme";function Bu(e){switch(e){case"light":return"light";case"dark":return"dark";case"eye-care":return"eye-care";case null:return"dark";default:return"dark"}}function oa(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function bb(){if(typeof window>"u")return"dark";try{return Bu(window.localStorage.getItem(Zi))}catch{return"dark"}}function vb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Zi,e)}catch{}}function yb(){const[e,t]=l.useState(bb),s=l.useCallback(o=>{t(o),oa(o),vb(o)},[]);return l.useEffect(()=>{oa(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==Zi)return;const a=Bu(r.newValue);t(a),oa(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const Qi="agent-inspector.uiScale",wb=1.25,jb=2200,Sb=3e3,Nb=12;function ra(e,t){return Number.isFinite(e)&&e>0?e:t}function el(e){switch(e){case"auto":return"auto";case"100":return"100";case"125":return"125";case"150":return"150";case null:return"auto";default:return"auto"}}function Cb(e,t){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=ra(t.viewportWidth,1280),o=ra(t.screenWidth,s),r=ra(t.devicePixelRatio,1),a=Math.min(s,o);return r>wb?1:a>=Sb?1.25:a>=jb?1.125:1}}}function kb(e){return`${Math.round(e*100)}%`}function aa(e,t){return Math.max(Nb,e*t)}function _b(){if(typeof window>"u")return{viewportWidth:1280,screenWidth:1280,devicePixelRatio:1};const e=typeof window.screen>"u"?window.innerWidth:window.screen.availWidth;return{viewportWidth:window.innerWidth,screenWidth:e,devicePixelRatio:window.devicePixelRatio}}function ia(e){const t=Cb(e,_b());if(typeof document>"u")return t;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(t*100)),s.style.setProperty("--inspector-ui-scale",String(t)),s.style.setProperty("--inspector-root-font-size",`${String(16*t)}px`),s.style.setProperty("--inspector-font-9",`${String(aa(9,t))}px`),s.style.setProperty("--inspector-font-10",`${String(aa(10,t))}px`),s.style.setProperty("--inspector-font-11",`${String(aa(11,t))}px`),s.style.setProperty("--inspector-font-13",`${String(13*t)}px`),t}function Tb(){if(typeof window>"u")return"auto";try{return el(window.localStorage.getItem(Qi))}catch{return"auto"}}function Eb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Qi,e)}catch{}}function Rb(){const[e,t]=l.useState(Tb),[s,o]=l.useState(1),r=l.useCallback(a=>{t(a),Eb(a),o(ia(a))},[]);return l.useEffect(()=>{const a=()=>{o(ia(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==Qi)return;const c=el(i.newValue);t(c),o(ia(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const Mb=200,Ab=512,Ib=256,hn=64,ni=256,Uu=64,Pb=32,Lb=2,Ob=4,oc=16,ye=E().int().positive(),Db=_({proxy:_({requestBytes:ye,responseBytes:ye,headerBytes:ye,deadlineMs:ye,idleTimeoutMs:ye,activeRequests:ye}),control:_({requestBytes:ye,responseBytes:ye,headerBytes:ye,deadlineMs:ye,idleTimeoutMs:ye,activeRequests:ye}),upstream:_({fetchResponseBytes:ye,fetchDeadlineMs:ye,replayResponseBytes:ye,replayDeadlineMs:ye,metadataResponseBytes:ye,metadataDeadlineMs:ye,connectTimeoutMs:ye,idleTimeoutMs:ye}),pagination:_({restPageSize:ye,searchQueryChars:ye,searchProjectChars:ye}),sse:_({clients:ye,initLogs:ye,heartbeatMs:ye}),imports:_({archiveBytes:ye,entries:ye,entryBytes:ye,uncompressedBytes:ye,expansionRatio:ye}),fanOut:_({providerModels:ye,providerModelMetadata:ye,providerTestConcurrency:ye,activeProviderTests:ye}),queues:_({proxyRequests:ye,finalizerJobs:ye,rawStreamMessages:ye,rawStreamBytes:ye,backgroundWorkers:ye})}).superRefine((e,t)=>{e.control.requestBytes>e.proxy.requestBytes&&t.addIssue({code:"custom",path:["control","requestBytes"],message:"control request budget must not exceed proxy request budget"}),e.control.responseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["control","responseBytes"],message:"control response budget must not exceed proxy response budget"}),e.control.activeRequests>e.proxy.activeRequests&&t.addIssue({code:"custom",path:["control","activeRequests"],message:"control active request budget must not exceed proxy active request budget"}),e.upstream.fetchResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","fetchResponseBytes"],message:"upstream fetch response budget must not exceed proxy response budget"}),e.upstream.replayResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","replayResponseBytes"],message:"upstream replay response budget must not exceed proxy response budget"}),e.upstream.metadataResponseBytes>e.control.responseBytes&&t.addIssue({code:"custom",path:["upstream","metadataResponseBytes"],message:"upstream metadata response budget must not exceed control response budget"}),e.upstream.metadataDeadlineMs>e.control.deadlineMs&&t.addIssue({code:"custom",path:["upstream","metadataDeadlineMs"],message:"upstream metadata deadline must not exceed control deadline"}),e.queues.proxyRequests<e.proxy.activeRequests&&t.addIssue({code:"custom",path:["queues","proxyRequests"],message:"proxy request queue budget must cover active proxy requests"})});Db.parse({proxy:{requestBytes:64*1024*1024,responseBytes:256*1024*1024,headerBytes:64*1024,deadlineMs:12e4,idleTimeoutMs:3e4,activeRequests:oc},control:{requestBytes:8*1024*1024,responseBytes:64*1024*1024,headerBytes:32*1024,deadlineMs:3e4,idleTimeoutMs:1e4,activeRequests:8},upstream:{fetchResponseBytes:256*1024*1024,fetchDeadlineMs:12e4,replayResponseBytes:256*1024*1024,replayDeadlineMs:12e4,metadataResponseBytes:10*1024*1024,metadataDeadlineMs:3e4,connectTimeoutMs:1e4,idleTimeoutMs:3e4},pagination:{restPageSize:Mb,searchQueryChars:Ab,searchProjectChars:Ib},sse:{clients:Pb,initLogs:500,heartbeatMs:15e3},imports:{archiveBytes:64*1024*1024,entries:5e3,entryBytes:32*1024*1024,uncompressedBytes:256*1024*1024,expansionRatio:20},fanOut:{providerModels:hn,providerModelMetadata:Uu,providerTestConcurrency:Ob,activeProviderTests:Lb},queues:{proxyRequests:oc,finalizerJobs:1e3,rawStreamMessages:16384,rawStreamBytes:64*1024*1024,backgroundWorkers:4}});const zb=ue(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),$b=Ut([oe(400),oe(413),oe(429),oe(503)]);_({error:x().min(1).max(300),code:zb,status:$b,resource:x().min(1).max(80),limit:E().int().positive(),retryable:ke()});function uo(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const tl=x().max(ni),Fb=W(tl).max(hn),Bb=_({model:tl.min(1),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),source:ue(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),Ub=W(Bb).max(Uu),qb=_({id:x(),name:x(),apiKey:x(),model:tl.optional(),models:Fb.optional().default([]),format:ue(["anthropic","openai"]).optional(),baseUrl:uo().optional(),anthropicBaseUrl:uo().optional(),openaiBaseUrl:uo().optional(),openaiResponsesBaseUrl:uo().optional(),authHeader:ue(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:Ub.optional(),source:ue(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),Hb="configured",Zo=qb.extend({apiKey:oe(Hb)});async function Vb(e){return Ze(e,Zo.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function nl(){const e=Ot("/api/providers",Vb,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function rc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Wb(...e){return t=>{let s=!1;const o=e.map(r=>{const a=rc(r,t);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():rc(e[r],null)}}}}function Te(...e){return l.useCallback(Wb(...e),e)}function fs(e){const t=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];ac(r)&&typeof mo=="function"&&(r=mo(r._payload)),l.Children.forEach(r,f=>{if(Zb(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;ac(g)&&typeof mo=="function"&&(g=mo(g._payload)),i=Yb(h,g),d.push(i?.props?.children)}else d.push(f)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(r)===1&&l.isValidElement(r)&&(i=r);const m=i?Xb(i):void 0,u=Te(o,m);if(!i){if(r||r===0)throw new Error(c?nv(e):tv(e));return r}const p=Jb(a,i.props??{});return i.type!==l.Fragment&&(p.ref=o?u:m),l.cloneElement(i,p)});return t.displayName=`${e}.Slot`,t}var Gb=fs("Slot"),qu=Symbol.for("radix.slottable");function Kb(e){const t=s=>"child"in s?s.children(s.child):s.children;return t.displayName=`${e}.Slottable`,t.__radixId=qu,t}var Yb=(e,t)=>{if("child"in e.props){const s=e.props.child;return l.isValidElement(s)?l.cloneElement(s,void 0,e.props.children(s.props.children)):null}return l.isValidElement(t)?t:null};function Jb(e,t){const s={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?s[o]=(...c)=>{const d=a(...c);return r(...c),d}:r&&(s[o]=r):o==="style"?s[o]={...r,...a}:o==="className"&&(s[o]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}function Xb(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function Zb(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qu}var Qb=Symbol.for("react.lazy");function ac(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Qb&&"_payload"in e&&ev(e._payload)}function ev(e){return typeof e=="object"&&e!==null&&"then"in e}var tv=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,nv=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,mo=vr[" use ".trim().toString()],sv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=sv.reduce((e,t)=>{const s=fs(`Primitive.${t}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function ov(e,t){e&&ws.flushSync(()=>e.dispatchEvent(t))}var Hu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),rv="VisuallyHidden",Vu=l.forwardRef((e,t)=>n.jsx(ge.span,{...e,ref:t,style:{...Hu,...e.style}}));Vu.displayName=rv;var av=Vu;function tn(e,t=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return n.jsx(b.Provider,{value:y,children:h})};m.displayName=a+"Provider";function u(p,f,h={}){const{optional:g=!1}=h,b=f?.[e]?.[d]||c,y=l.useContext(b);if(y)return y;if(i!==void 0)return i;if(!g)throw new Error(`\`${p}\` must be used within \`${a}\``)}return[m,u]}const r=()=>{const a=s.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return r.scopeName=e,[o,iv(r,...t)]}function iv(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:m})=>{const p=d(a)[`__scope${m}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return s.scopeName=t.scopeName,s}function Wu(e){const t=e+"CollectionProvider",[s,o]=tn(t),[r,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:y,children:w}=b,v=l.useRef(null),j=l.useRef(new Map).current;return n.jsx(r,{scope:y,itemMap:j,collectionRef:v,children:w})};i.displayName=t;const c=e+"CollectionSlot",d=fs(c),m=l.forwardRef((b,y)=>{const{scope:w,children:v}=b,j=a(c,w),S=Te(y,j.collectionRef);return n.jsx(d,{ref:S,children:v})});m.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",f=fs(u),h=l.forwardRef((b,y)=>{const{scope:w,children:v,...j}=b,S=l.useRef(null),N=Te(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),n.jsx(f,{[p]:"",ref:N,children:v})});h.displayName=u;function g(b){const y=a(e+"CollectionConsumer",b);return l.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,R)=>j.indexOf(C.ref.current)-j.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function de(e,t,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return t?.(r)}}var Fe=globalThis?.document?l.useLayoutEffect:()=>{},lv=vr[" useInsertionEffect ".trim().toString()]||Fe;function Ln({prop:e,defaultProp:t,onChange:s=()=>{},caller:o}){const[r,a,i]=cv({defaultProp:t,onChange:s}),c=e!==void 0,d=c?e:r;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${o} is changing from ${p?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=c},[c,o])}const m=l.useCallback(u=>{if(c){const p=dv(u)?u(e):u;p!==e&&i.current?.(p)}else a(u)},[c,e,a,i]);return[d,m]}function cv({defaultProp:e,onChange:t}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(t);return lv(()=>{a.current=t},[t]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function dv(e){return typeof e=="function"}function uv(e,t){return l.useReducer((s,o)=>t[s][o]??s,e)}var ht=e=>{const{present:t,children:s}=e,o=mv(t),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=pv(o.ref,fv(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};ht.displayName="Presence";function mv(e){const[t,s]=l.useState(),o=l.useRef(null),r=l.useRef(e),a=l.useRef("none"),i=l.useRef(void 0),c=e?"mounted":"unmounted",[d,m]=uv(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{d==="mounted"?(a.current=i.current??_s(o.current),i.current=void 0):a.current="none"},[d]),Fe(()=>{const u=o.current,p=r.current;if(p!==e){const h=a.current,g=_s(u);e?(i.current=g,m("MOUNT")):g==="none"||u?.display==="none"?m("UNMOUNT"):m(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,m]),Fe(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,f=g=>{const y=_s(o.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(m("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(a.current=_s(o.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else m("ANIMATION_END")},[t,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const p=getComputedStyle(u);o.current=p,i.current=_s(p)}else o.current=null;s(u)},[])}}function ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function pv(...e){const t=l.useRef(e);return t.current=e,l.useCallback(s=>{const o=t.current;let r=!1;const a=o.map(i=>{const c=ic(i,s);return!r&&typeof c=="function"&&(r=!0),c});if(r)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():ic(o[i],null)}}},[])}function _s(e){return e?.animationName||"none"}function fv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var hv=vr[" useId ".trim().toString()]||(()=>{}),xv=0;function Dt(e){const[t,s]=l.useState(hv());return Fe(()=>{s(o=>o??String(xv++))},[e]),e||(t?`radix-${t}`:"")}var Sr="Collapsible",[gv]=tn(Sr),[bv,sl]=gv(Sr),Gu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=Ln({prop:o,defaultProp:r??!1,onChange:i,caller:Sr});return n.jsx(bv,{scope:s,disabled:a,contentId:Dt(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:n.jsx(ge.div,{"data-state":rl(d),"data-disabled":a?"":void 0,...c,ref:t})})});Gu.displayName=Sr;var Ku="CollapsibleTrigger",Yu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,...o}=e,r=sl(Ku,s);return n.jsx(ge.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":rl(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:t,onClick:de(e.onClick,r.onOpenToggle)})});Yu.displayName=Ku;var ol="CollapsibleContent",Ju=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=sl(ol,e.__scopeCollapsible);return n.jsx(ht,{present:s||r.open,children:({present:a})=>n.jsx(vv,{...o,ref:t,present:a})})});Ju.displayName=ol;var vv=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=sl(ol,s),[c,d]=l.useState(o),m=l.useRef(null),u=Te(t,m),p=l.useRef(0),f=p.current,h=l.useRef(0),g=h.current,b=i.open||c,y=l.useRef(b),w=l.useRef(void 0);return l.useEffect(()=>{const v=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(v)},[]),Fe(()=>{const v=m.current;if(v){w.current=w.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const j=v.getBoundingClientRect();p.current=j.height,h.current=j.width,y.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),d(o)}},[i.open,o]),n.jsx(ge.div,{"data-state":rl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:b&&r})});function rl(e){return e?"open":"closed"}var yv=Gu,wv=l.createContext(void 0);function Nr(e){const t=l.useContext(wv);return e||t||"ltr"}function He(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>((...s)=>t.current?.(...s)),[])}var jv="DismissableLayer",si="dismissableLayer.update",Sv="dismissableLayer.pointerDownOutside",Nv="dismissableLayer.focusOutside",lc,al=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Cr=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(al),[p,f]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=l.useState({}),b=Te(t,f),y=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?y.indexOf(w):-1,j=p?y.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=v,C=l.useRef(!1),R=Ev(k=>{a?.(k),c?.(k),k.defaultPrevented||d?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:l.useCallback(k=>{if(!(k instanceof Node))return!1;const A=[...u.branches].some(D=>D.contains(k));return N&&!A},[u.branches,N])}),P=Rv(k=>{if(o&&C.current)return;const A=k.target;[...u.branches].some(F=>F.contains(A))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),L=p?j===y.length-1:!1,M=He(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(L)return h.addEventListener("keydown",M,{capture:!0}),()=>h.removeEventListener("keydown",M,{capture:!0})},[h,L,M]),l.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(lc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),cc(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=lc))}},[p,h,s,u]),l.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),cc())},[p,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(si,k),()=>document.removeEventListener(si,k)},[]),n.jsx(ge.div,{...m,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,P.onFocusCapture),onBlurCapture:de(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,R.onPointerDownCapture)})});Cr.displayName=jv;var Cv="DismissableLayerBranch",kv=l.forwardRef((e,t)=>{const s=l.useContext(al),o=l.useRef(null),r=Te(t,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),n.jsx(ge.div,{...e,ref:r})});kv.displayName=Cv;function _v(){const e=l.useContext(al),[t,s]=l.useState(null);return l.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}var Tv=()=>!0;function Ev(e,t){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Tv}=t,c=He(e),d=l.useRef(!1),m=l.useRef(!1),u=l.useRef(new Map),p=l.useRef(()=>{});return l.useEffect(()=>{function f(){m.current=!1,r.current=!1,u.current.clear()}function h(){return Array.from(u.current.values()).some(Boolean)}function g(j){if(!m.current)return;const S=j.target;S instanceof Node&&[...a].some(C=>C.contains(S))||u.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{m.current&&p.current()},0)}function b(j){m.current&&u.current.set(j.type,!1)}const y=j=>{if(j.target&&!d.current){let S=function(){s.removeEventListener("click",p.current);const C=h();f(),C||Xu(Sv,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",p.current),f(),d.current=!1;return}const N={originalEvent:j};m.current=!0,r.current=o&&j.button===0,u.current.clear(),!o||j.button!==0?S():(s.removeEventListener("click",p.current),p.current=S,s.addEventListener("click",p.current,{once:!0}))}else s.removeEventListener("click",p.current),f();d.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)s.addEventListener(j,g,!0),s.addEventListener(j,b);const v=window.setTimeout(()=>{s.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(v),s.removeEventListener("pointerdown",y),s.removeEventListener("click",p.current);for(const j of w)s.removeEventListener(j,g,!0),s.removeEventListener(j,b)}},[s,c,o,r,a,i]),{onPointerDownCapture:()=>d.current=!0}}function Rv(e,t=globalThis?.document){const s=He(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&Xu(Nv,s,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function cc(){const e=new CustomEvent(si);document.dispatchEvent(e)}function Xu(e,t,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&r.addEventListener(e,t,{once:!0}),o?ov(r,a):r.dispatchEvent(a)}var la="focusScope.autoFocusOnMount",ca="focusScope.autoFocusOnUnmount",dc={bubbles:!1,cancelable:!0},Mv="FocusScope",il=l.forwardRef((e,t)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=He(r),u=He(a),p=l.useRef(null),f=Te(t,d),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(o){let b=function(j){if(h.paused||!c)return;const S=j.target;c.contains(S)?p.current=S:cn(p.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||cn(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&cn(c)};document.addEventListener("focusin",b),document.addEventListener("focusout",y);const v=new MutationObserver(w);return c&&v.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",y),v.disconnect()}}},[o,c,h.paused]),l.useEffect(()=>{if(c){mc.add(h);const b=document.activeElement;if(!c.contains(b)){const w=new CustomEvent(la,dc);c.addEventListener(la,m),c.dispatchEvent(w),w.defaultPrevented||(Av(Dv(Zu(c)),{select:!0}),document.activeElement===b&&cn(c))}return()=>{c.removeEventListener(la,m),setTimeout(()=>{const w=new CustomEvent(ca,dc);c.addEventListener(ca,u),c.dispatchEvent(w),w.defaultPrevented||cn(b??document.body,{select:!0}),c.removeEventListener(ca,u),mc.remove(h)},0)}}},[c,m,u,h]);const g=l.useCallback(b=>{if(!s&&!o||h.paused)return;const y=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,w=document.activeElement;if(y&&w){const v=b.currentTarget,[j,S]=Iv(v);j&&S?!b.shiftKey&&w===S?(b.preventDefault(),s&&cn(j,{select:!0})):b.shiftKey&&w===j&&(b.preventDefault(),s&&cn(S,{select:!0})):w===v&&b.preventDefault()}},[s,o,h.paused]);return n.jsx(ge.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});il.displayName=Mv;function Av(e,{select:t=!1}={}){const s=document.activeElement;for(const o of e)if(cn(o,{select:t}),document.activeElement!==s)return}function Iv(e){const t=Zu(e),s=uc(t,e),o=uc(t.reverse(),e);return[s,o]}function Zu(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)t.push(s.currentNode);return t}function uc(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):Pv(o,{upTo:t})))return o}function Pv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Lv(e){return e instanceof HTMLInputElement&&"select"in e}function cn(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Lv(e)&&t&&e.select()}}var mc=Ov();function Ov(){let e=[];return{add(t){const s=e[0];t!==s&&s?.pause(),e=pc(e,t),e.unshift(t)},remove(t){e=pc(e,t),e[0]?.resume()}}}function pc(e,t){const s=[...e],o=s.indexOf(t);return o!==-1&&s.splice(o,1),s}function Dv(e){return e.filter(t=>t.tagName!=="A")}var zv="Portal",kr=l.forwardRef((e,t)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);Fe(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?ws.createPortal(n.jsx(ge.div,{...o,ref:t}),i):null});kr.displayName=zv;var po=0,Vn=null;function Qu(){l.useEffect(()=>{Vn||(Vn={start:fc(),end:fc()});const{start:e,end:t}=Vn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),po++,()=>{po===1&&(Vn?.start.remove(),Vn?.end.remove(),Vn=null),po=Math.max(0,po-1)}},[])}function fc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var s,o=1,r=arguments.length;o<r;o++){s=arguments[o];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},Pt.apply(this,arguments)};function em(e,t){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(s[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function $v(e,t,s){if(s||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var Do="right-scroll-bar-position",zo="width-before-scroll-bar",Fv="with-scroll-bars-hidden",Bv="--removed-body-scroll-bar-size";function da(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uv(e,t){var s=l.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(o){var r=s.value;r!==o&&(s.value=o,s.callback(o,r))}}}})[0];return s.callback=t,s.facade}var qv=typeof window<"u"?l.useLayoutEffect:l.useEffect,hc=new WeakMap;function Hv(e,t){var s=Uv(null,function(o){return e.forEach(function(r){return da(r,o)})});return qv(function(){var o=hc.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||da(c,null)}),a.forEach(function(c){r.has(c)||da(c,i)})}hc.set(s,e)},[e]),s}function Vv(e){return e}function Wv(e,t){t===void 0&&(t=Vv);var s=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var i=t(a,o);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(o=!0;s.length;){var i=s;s=[],i.forEach(a)}s={push:function(c){return a(c)},filter:function(){return s}}},assignMedium:function(a){o=!0;var i=[];if(s.length){var c=s;s=[],c.forEach(a),i=s}var d=function(){var u=i;i=[],u.forEach(a)},m=function(){return Promise.resolve().then(d)};m(),s={push:function(u){i.push(u),m()},filter:function(u){return i=i.filter(u),s}}}};return r}function Gv(e){e===void 0&&(e={});var t=Wv(null);return t.options=Pt({async:!0,ssr:!1},e),t}var tm=function(e){var t=e.sideCar,s=em(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,Pt({},s))};tm.isSideCarExport=!0;function Kv(e,t){return e.useMedium(t),tm}var nm=Gv(),ua=function(){},_r=l.forwardRef(function(e,t){var s=l.useRef(null),o=l.useState({onScrollCapture:ua,onWheelCapture:ua,onTouchMoveCapture:ua}),r=o[0],a=o[1],i=e.forwardProps,c=e.children,d=e.className,m=e.removeScrollBar,u=e.enabled,p=e.shards,f=e.sideCar,h=e.noRelative,g=e.noIsolation,b=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,S=em(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=Hv([s,t]),R=Pt(Pt({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:nm,removeScrollBar:m,shards:p,noRelative:h,noIsolation:g,inert:b,setCallbacks:a,allowPinchZoom:!!y,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),Pt(Pt({},R),{ref:C})):l.createElement(v,Pt({},R,{className:d,ref:C}),c))});_r.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};_r.classNames={fullWidth:zo,zeroRight:Do};var Yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Yv();return t&&e.setAttribute("nonce",t),e}function Xv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Zv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Qv=function(){var e=0,t=null;return{add:function(s){e==0&&(t=Jv())&&(Xv(t,s),Zv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},e2=function(){var e=Qv();return function(t,s){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},sm=function(){var e=e2(),t=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return t},t2={left:0,top:0,right:0,gap:0},ma=function(e){return parseInt(e||"",10)||0},n2=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[ma(s),ma(o),ma(r)]},s2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return t2;var t=n2(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-s+t[2]-t[0])}},o2=sm(),is="data-scroll-locked",r2=function(e,t,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
3
3
  .`.concat(Fv,` {
4
4
  overflow: hidden `).concat(o,`;
5
5
  padding-right: `).concat(c,"px ").concat(o,`;
@@ -46,7 +46,7 @@ import{l as Hh,u as Ut,s as x,n as E,b as ke,_ as Ho,a as W,c as De,o as _,d as
46
46
  `)}function g5(e){const t=[],s=gi(e.content);s.length>0&&t.push(s);const o=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";o.length>0&&t.push(o);const r=e.tool_calls;if(Array.isArray(r))for(const a of r){if(a===null||typeof a!="object")continue;const i=a.function;if(i===void 0)continue;const c=typeof i.name=="string"?i.name:"",d=typeof i.arguments=="string"?i.arguments:"";t.push(`${c} ${d}`.trim())}return t.join(`
47
47
  `)}function b5(e){if(!Array.isArray(e))return"";const t=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=G(s,"function"),r=G(o,"name")??G(s,"name"),a=G(o,"description")??G(s,"description"),i=G(o,"parameters")??G(s,"parameters");typeof r=="string"&&t.push(r),typeof a=="string"&&t.push(a),i!==void 0&&t.push(JSON.stringify(i))}return t.join(`
48
48
  `)}function v5(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function y5(e){if(typeof e=="string")return e;const t=G(e,"text");if(typeof t=="string")return t;const s=gi(G(e,"content"));if(s.length>0)return s;const o=gi(G(e,"output"));if(o.length>0)return o;const r=G(e,"arguments");return typeof r=="string"?r:""}function w5(e){const t=G(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const s=G(e,"type");return s==="function_call_output"?"tool":"user"}function j5(e){const t=G(e,"output");if(!Array.isArray(t))return[];const s=[];for(const o of t){if(G(o,"type")!=="function_call")continue;const r=G(o,"name");typeof r=="string"&&r.length>0&&s.push(r)}return s}function Ts(e,t,s,o){return{role:e,label:t,text:s,size:Tl(s),characters:El(s),path:o}}const S5={format:"openai",analyzeRequest(e){if(e===null)return Pn(e);try{const t=JSON.parse(e),s=Ml(t)?.tools.length??null,o=Mx.safeParse(t);if(!o.success){const r=Ix.safeParse(t);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:v5(r.data.input),toolCount:s}:Pn(e)}return{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}}catch{return Pn(e)}},analyzeResponse(e){if(e===null)return cs;const t=$x(e);if(t===null){const o=Fx(e);if(o===null)return cs;const r=j5(o);return{parsed:o,toolNames:r.length>0?r:null}}const s=t.choices[0]?.message?.tool_calls?.map(o=>o.function?.name??"").filter(o=>o!=="")??[];return{parsed:t,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,s=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&s.push(Ts("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"||a.role==="system"||a.role==="tool"?a.role:"user",c=g5(a);s.push(Ts(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?s.push(Ts("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((o,r)=>{const a=w5(o),i=y5(o);s.push(Ts(a,`[${r}] ${a}`,i,`/input/${r}`))})),Array.isArray(t.tools)&&t.tools.length>0){const o=b5(t.tools);s.push(Ts("tools","tools",o,"/tools"))}return s.length>0?s:null}},N5={format:"unknown",analyzeRequest(e){return Pn(e)},analyzeResponse(){return cs},anatomySegments(){return null}},C5={anthropic:x5,openai:S5,unknown:N5};function gf(e){return C5[e]}function ir(e){const t=uf(e.path);return t==="unknown"?e.apiFormat:t}const Ac="inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground";function bf(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function k5(e){return bf(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function va({icon:e,children:t,title:s,className:o}){return n.jsxs("span",{className:O("inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",o),title:s,children:[e,n.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function _5(){return n.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 font-mono text-[10px] uppercase text-[var(--inspector-status-watch)] ring-1 ring-border/50",title:"This session has a turn that has not finished yet",children:[n.jsx(Oe,{className:"size-3 animate-spin"}),"Turn open"]})}function T5({conversationId:e,startTime:t,endTime:s,totalCalls:o,totalInputTokens:r,totalOutputTokens:a,expanded:i,onToggle:c,providers:d,isLoading:m=!1,userAgent:u,clientPid:p,clientProjectFolder:f,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:b,onClear:y}){const[w,v]=l.useState(!1),j=Y=>{Y.stopPropagation(),y!==void 0&&v(!0)},S=l.useCallback(Y=>{Y.stopPropagation(),window.open(tu(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:Y,models:X})=>({provider:Y,tooltip:X.length===1?X[0]??Y:X.join(", ")}))??[],C=_l({userAgent:u,conversationId:e,clientProjectFolder:f}),R=qr(C),P=u!=null&&u!=="",L=R??u??null,M=R!==null&&P?`${R} - ${u}`:null,k=bf(e),A=k5(e),D=jr(t,s,b),F=`${o} call${o!==1?"s":""}`;return n.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:O("relative flex cursor-pointer items-start gap-2.5 overflow-hidden rounded-md bg-[var(--inspector-surface-low)] px-3 py-2.5 transition-colors","hover:bg-[var(--inspector-surface-medium)]","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),onClick:c,onKeyDown:Y=>{Y.target===Y.currentTarget&&(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),c())},children:[n.jsx(s5,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:"Session"}),k&&g?p!=null?n.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):n.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):n.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:A}),!k&&g&&p!==null&&p!==void 0&&n.jsxs("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${p}`,children:["PID ",p]}),k&&g&&f!==null&&f!==void 0&&f!==""&&n.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:f,children:f}),h&&L!==null&&L!==""&&n.jsxs("span",{className:"inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 text-xs text-muted-foreground",title:M??L,children:[n.jsx(Hr,{client:C,className:"size-4 shrink-0",decorative:!0}),n.jsx("span",{className:"font-mono leading-snug tabular-nums",children:L})]}),m&&n.jsx(_5,{})]}),n.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[n.jsx(va,{icon:n.jsx(Xt,{className:"size-3 shrink-0"}),title:D,children:D}),n.jsx(va,{icon:n.jsx(wr,{className:"size-3 shrink-0"}),children:F}),n.jsxs(va,{icon:n.jsx(Bs,{className:"size-3 shrink-0"}),className:"max-w-full",children:[n.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ee(r)})," / ",n.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ee(a)})]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[n.jsx("button",{type:"button",onClick:S,onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&S(Y)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Ac,children:n.jsx(Yi,{className:"size-3.5"})}),y!==void 0&&n.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${o} request${o!==1?"s":""})`,title:"Clear this group from the current view",className:Ac,children:n.jsx(gn,{className:"size-3.5"})}),n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground","aria-hidden":"true",children:i?n.jsx(We,{className:"size-4 shrink-0"}):m?n.jsx(Oe,{className:"size-4 shrink-0 animate-spin"}):n.jsx(ft,{className:"size-4 shrink-0"})})]}),m&&n.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-[var(--inspector-surface-medium)]","aria-hidden":"true",children:n.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),n.jsx(df,{open:w,onOpenChange:v,title:"Clear this group from the current view?",description:`This will hide ${o} request${o!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{y?.()}})]})}function E5(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const t=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!s)return"default";const o=t?`PID:${e.clientPid}`:"unknown",r=s?e.clientProjectFolder:"no-folder";return`${o}|${r}`}function R5(e){const t=new Map;for(const o of e){const r=E5(o),a=t.get(r);a!==void 0?a.push(o):t.set(r,[o])}const s=[];for(const[o,r]of t){const a=[...r].sort((i,c)=>i.timestamp.localeCompare(c.timestamp));s.push({id:o,conversationId:o,logs:a})}return s.sort((o,r)=>(o.logs[0]?.timestamp??"").localeCompare(r.logs[0]?.timestamp??"")),s}function M5(e,t,s){const o=new Array(e);return new Proxy(o,{get(r,a,i){if(typeof a=="string"){const c=a.charCodeAt(0);if(c>=48&&c<=57){const d=+a;if(Number.isInteger(d)&&d>=0&&d<e){let m=r[d];if(!m){const u=t[d*2];m=r[d]={index:d,key:s(d),start:u,size:t[d*2+1],end:u+t[d*2+1],lane:0}}return m}}if(a==="length")return e}return Reflect.get(r,a,i)}})}function Xn(e,t,s){let o=s.initialDeps??[],r,a=!0;function i(){const c=e();return(c.length!==o.length||c.some((m,u)=>o[u]!==m))&&(o=c,r=t(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(r),a=!1),r}return i.updateDeps=c=>{o=c},i}function Ic(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const A5=(e,t)=>Math.abs(e-t)<1.01,I5=(e,t,s)=>{let o;return function(...r){e.clearTimeout(o),o=e.setTimeout(()=>t.apply(this,r),s)}};let Es;const ya=()=>{if(Es!==void 0)return Es;if(typeof navigator>"u")return Es=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Es=!0;const e=navigator.maxTouchPoints;return Es=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Pc=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},P5=e=>e,L5=e=>{const t=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(o);for(let a=0;a<o;a++)r[a]=t+a;return r},O5=(e,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const r=i=>{const{width:c,height:d}=i;t({width:Math.round(c),height:Math.round(d)})};if(r(Pc(s)),!o.ResizeObserver)return()=>{};const a=new o.ResizeObserver(i=>{const c=()=>{const d=i[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){r({width:m.inlineSize,height:m.blockSize});return}}r(Pc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},Hs={passive:!0},D5=(e,t)=>{const s=e.scrollElement;if(!s)return;const o=()=>{t({width:s.innerWidth,height:s.innerHeight})};return o(),s.addEventListener("resize",o,Hs),()=>{s.removeEventListener("resize",o)}},z5=typeof window>"u"?!0:"onscrollend"in window,vf=(e,t,s)=>{const o=e.scrollElement;if(!o)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&z5;let i=0;const c=a?null:I5(r,()=>t(i,!1),e.options.isScrollingResetDelay),d=p=>()=>{i=s(o),c?.(),t(i,p)},m=d(!0),u=d(!1);return o.addEventListener("scroll",m,Hs),a&&o.addEventListener("scrollend",u,Hs),()=>{o.removeEventListener("scroll",m),a&&o.removeEventListener("scrollend",u)}},$5=(e,t)=>vf(e,t,s=>{const{horizontal:o,isRtl:r}=e.options;return o?s.scrollLeft*(r&&-1||1):s.scrollTop}),F5=(e,t)=>vf(e,t,s=>e.options.horizontal?s.scrollX:s.scrollY),B5=(e,t,s)=>{if(s.options.useCachedMeasurements){const o=s.indexFromElement(e),r=s.options.getItemKey(o);return s.itemSizeCache.get(r)??s.options.estimateSize(o)}if(t?.borderBoxSize){const o=t.borderBoxSize[0];if(o)return Math.round(o[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){const o=s.indexFromElement(e),r=s.options.getItemKey(o),a=s.itemSizeCache.get(r);if(a!==void 0)return a}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},yf=(e,{adjustments:t=0,behavior:s},o)=>{var r,a;(a=(r=o.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[o.options.horizontal?"left":"top"]:e+t,behavior:s})},U5=yf,q5=yf;class H5{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,o,r;return((r=(o=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:o.now)==null?void 0:r.call(o))??Date.now()},this.observer=(()=>{let s=null;const o=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const i=()=>{const c=a.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[m,u]of this.elementsCache)if(u===c){this.elementsCache.delete(m);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var r;(r=o())==null||r.disconnect(),s=null},observe:r=>{var a;return(a=o())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=o())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{var o,r;const a={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:P5,rangeExtractor:L5,onChange:()=>{},measureElement:B5,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const f in s){const h=s[f];h!==void 0&&(a[f]=h)}const i=this.options;let c=null,d=null,m=!1;if(i!==void 0&&i.enabled&&a.enabled&&a.anchorTo==="end"&&this.scrollElement!==null){const f=i.count,h=a.count,g=this.getMeasurements(),b=f>0?((o=g[0])==null?void 0:o.key)??i.getItemKey(0):null,y=f>0?((r=g[f-1])==null?void 0:r.key)??i.getItemKey(f-1):null;if(h!==f||f>0&&h>0&&(a.getItemKey(0)!==b||a.getItemKey(h-1)!==y)){m=!0;const j=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;j&&(c=[j.key,this.getScrollOffset()-j.start]);const S=a.followOnAppend===!0?"auto":a.followOnAppend||null;S&&h>f&&this.isAtEnd(i.scrollEndThreshold)&&(f===0||a.getItemKey(h-1)!==y)&&(d=S)}}this.options=a,m&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,p=0;if(c&&this.scrollOffset!==null){const[f,h]=c,g=this.getMeasurements(),{count:b,getItemKey:y}=this.options;let w=0;for(;w<b&&y(w)!==f;)w++;if(w<b){const v=g[w];if(v){const j=v.start+h;j!==this.scrollOffset&&(p=j-this.scrollOffset,this.scrollOffset=j,u=!0)}}}(u||d)&&(this.pendingScrollAnchor=[u?c[0]:null,u?c[1]:0,d,p])},this.notify=s=>{var o,r;(r=(o=this.options).onChange)==null||r.call(o,this,s)},this.maybeNotify=Xn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const o=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==o){if(this.cleanup(),!o){this.maybeNotify();return}if(this.scrollElement=o,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{if(i&&this._intendedScrollOffset===null&&a===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(a-this._intendedScrollOffset)<1.5&&(a=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=i?c===a?this.scrollDirection:c<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const a=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!ya()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,Hs),a.addEventListener("touchend",c,Hs),this.unsubs.push(()=>{a.removeEventListener("touchstart",i),a.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[a,i,c,d]=r;a!==null&&!c&&(ya()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),o=this.getMaxScrollOffset();if(s<0||s>o)return;const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Xn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,o,r,a,i,c,d,m)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m}),{key:!1}),this.getMeasurements=Xn(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m},u)=>{const p=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const w of this.laneAssignments.keys())w>=s&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),c===1){const w=s*2;let v=this._flatMeasurements;if(!v||v.length<w){const N=new Float64Array(w);v&&f>0&&N.set(v.subarray(0,f*2)),v=N,this._flatMeasurements=v}let j;if(f===0)j=o+r;else{const N=f-1;j=v[N*2]+v[N*2+1]+m}for(let N=f;N<s;N++){const C=a(N),R=p.get(C),P=typeof R=="number"?R:this.options.estimateSize(N);v[N*2]=j,v[N*2+1]=P,j+=P+m}const S=M5(s,v,a);return this.measurementsCache=S,S}const h=this.measurementsCache.slice(0,f),g=new Array(c).fill(void 0),b=new Float64Array(c);let y=0;for(let w=0;w<f;w++){const v=h[w];v&&(g[v.lane]===void 0&&y++,g[v.lane]=w,b[v.lane]=v.end)}for(let w=f;w<s;w++){const v=a(w),j=this.laneAssignments.get(w);let S,N;const C=d==="estimate"||p.has(v);if(j!==void 0&&this.options.lanes>1){S=j;const M=g[S],k=M!==void 0?h[M]:void 0;N=k?k.end+m:o+r}else if(y===c){let M=0,k=b[0],A=g[0];for(let D=1;D<c;D++){const F=b[D];(F<k||F===k&&g[D]<A)&&(M=D,k=F,A=g[D])}S=M,N=k+m,C&&this.laneAssignments.set(w,S)}else S=w%this.options.lanes,N=o+r,C&&this.laneAssignments.set(w,S);const R=p.get(v),P=typeof R=="number"?R:this.options.estimateSize(w),L=N+P;h[w]={index:w,start:N,size:P,end:L,key:v,lane:S},g[S]===void 0&&y++,g[S]=w,b[S]=L}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Xn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,o,r,a)=>s.length===0||o===0?(this.range=null,null):(this.range=W5(s,o,r,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Xn(()=>{let s=null,o=null;const r=this.calculateRange();return r&&(s=r.startIndex,o=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,o]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,o]},(s,o,r,a,i)=>a===null||i===null?[]:s({startIndex:a,endIndex:i,overscan:o,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const o=this.options.indexAttribute,r=s.getAttribute(o);return r?parseInt(r,10):(console.warn(`Missing attribute name '${o}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var o;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((o=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:o.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,r-a),c=Math.min(this.options.count-1,r+a);return s>=i&&s<=c}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((i,c)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(c))});return}const o=this.indexFromElement(s),r=this.options.getItemKey(o),a=this.elementsCache.get(r);a!==s&&(a&&this.observer.unobserve(a),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(o)&&this.resizeItem(o,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,o)=>{var r,a;if(s<0||s>=this.options.count)return;let i,c,d;const m=this._flatMeasurements;if(this.options.lanes===1&&m!==null)d=this.options.getItemKey(s),c=m[s*2],i=m[s*2+1];else{const f=this.measurementsCache[s];if(!f)return;d=f.key,c=f.start,i=f.size}const u=this.itemSizeCache.get(d)??i,p=o-u;if(p!==0){const f=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=f?this.getTotalSize():0,g=((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:d,start:c,size:i,end:c+i,lane:0},p,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(d,o),this.itemSizeCacheVersion++,f?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=Xn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,o)=>{const r=[];for(let a=0,i=s.length;a<i;a++){const c=s[a],d=o[c];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const o=this.getMeasurements();if(o.length===0)return;const r=this._flatMeasurements,a=this.options.lanes===1&&r!=null,i=wf(0,o.length-1,a?c=>r[c*2]:c=>Ic(o[c]).start,s);return Ic(o[i])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,o,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),i=this.getScrollOffset();o==="auto"&&(o=s>=i+a?"end":"start"),o==="center"?s+=(r-a)/2:o==="end"&&(s-=a);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,o="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),i=this.measurementsCache[s];if(!i)return;if(o==="auto")if(i.end>=a+r-this.options.scrollPaddingEnd)o="end";else if(i.start<=a+this.options.scrollPaddingStart)o="start";else return[a,o];if(o==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),o];const c=o==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,o,i.size),o]},this.scrollToOffset=(s,{align:o="start",behavior:r="auto"}={})=>{const a=this.getOffsetForAlignment(s,o),i=this.now();this.scrollState={index:null,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:o="auto",behavior:r="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getOffsetForIndex(s,o);if(!a)return;const[i,c]=a,d=this.now();this.scrollState={index:s,align:c,behavior:r,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:o="auto"}={})=>{const r=this.getScrollOffset()+s,a=this.now();this.scrollState={index:null,align:"start",behavior:o,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const o=this.getMeasurements();let r;if(o.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const a=o.length-1,i=this._flatMeasurements;i!=null?r=i[a*2]+i[a*2+1]:r=((s=o[a])==null?void 0:s.end)??0}else{const a=Array(this.options.lanes).fill(null);let i=o.length-1;for(;i>=0&&a.some(c=>c===null);){const c=o[i];a[c.lane]===null&&(a[c.lane]=c.end),i--}r=Math.max(...a.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const o=this.getMeasurements();for(const r of o)r&&this.itemSizeCache.has(r.key)&&s.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return s},this._scrollToOffset=(s,{adjustments:o,behavior:r})=>{this._intendedScrollOffset=s+(o??0),this.options.scrollToFn(s,{behavior:r,adjustments:o},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,s){t!==0&&(ya()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const o=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=o?o[0]:this.scrollState.lastTargetOffset,a=1,i=r!==this.scrollState.lastTargetOffset;if(!i&&A5(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const c=this.getSize()||600,d=Math.abs(r-this.getScrollOffset()),m=this.scrollState.behavior==="smooth"&&d>c;this.scrollState.lastTargetOffset=r,m||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:m?"smooth":"auto"})}this.scheduleScrollReconcile()}}const wf=(e,t,s,o)=>{for(;e<=t;){const r=(e+t)/2|0,a=s(r);if(a<o)e=r+1;else if(a>o)t=r-1;else return r}return e>0?e-1:0};function V5(e,t,s){let o=0;for(;o<=t;){const r=(o+t)/2|0,a=e[r*2];if(a<s)o=r+1;else if(a>s)t=r-1;else return r}return o>0?o-1:0}function W5(e,t,s,o,r){const a=e.length-1;if(e.length<=o)return{startIndex:0,endIndex:a};if(o===1&&r!==null){const m=V5(r,a,s);let u=m;const p=s+t;for(;u<a&&r[u*2]+r[u*2+1]<p;)u++;return{startIndex:m,endIndex:u}}let c=wf(0,a,m=>e[m].start,s),d=c;if(o===1)for(;d<a&&e[d].end<s+t;)d++;else if(o>1){const m=Array(o).fill(0);for(;d<a&&m.some(p=>p<s+t);){const p=e[d];m[p.lane]=p.end,d++}const u=Array(o).fill(s+t);for(;c>=0&&u.some(p=>p>=s);){const p=e[c];u[p.lane]=p.start,c--}c=Math.max(0,c-c%o),d=Math.min(a,d+(o-1-d%o))}return{startIndex:c,endIndex:d}}const wa=typeof document<"u"?l.useLayoutEffect:l.useEffect;function jf({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...o}){const r=l.useReducer(m=>m+1,0)[1],a=l.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=s;const i=m=>{const u=a.current;if(!u.enabled||!u.container)return;const p=m.getTotalSize();if(p!==u.lastSize){u.lastSize=p;const w=m.options.horizontal?"width":"height";u.container.style[w]=`${p}px`}const f=!!m.options.horizontal,h=u.mode==="transform",g=f?"left":"top",b=m.options.scrollMargin,y=m.getVirtualItems();for(const w of y){const v=w.start-b,j=m.elementsCache.get(w.key);j&&u.lastPositions.get(j)!==v&&(u.lastPositions.set(j,v),h?j.style.transform=f?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:j.style[g]=`${v}px`)}},c={...o,onChange:(m,u)=>{var p;const f=a.current;let h=!0;if(f.enabled){i(m);const g=m.range,b=f.prevRange;h=!b||b.isScrolling!==m.isScrolling||b.startIndex!==g?.startIndex||b.endIndex!==g?.endIndex,h&&(f.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:m.isScrolling}:null)}h&&(e&&u?ws.flushSync(r):r()),(p=o.onChange)==null||p.call(o,m,u)}},[d]=l.useState(()=>{const m=new H5(c);return Object.assign(m,{containerRef:u=>{const p=a.current;if(p.container=u,p.lastSize=null,u&&p.enabled){const f=m.getTotalSize();p.lastSize=f;const h=m.options.horizontal?"width":"height";u.style[h]=`${f}px`}}})});return d.setOptions(c),wa(()=>d._didMount(),[]),wa(()=>d._willUpdate()),wa(()=>{i(d)}),d}function G5(e){return jf({observeElementRect:O5,observeElementOffset:$5,scrollToFn:q5,...e})}function K5(e){return jf({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:D5,observeElementOffset:F5,scrollToFn:U5,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const en="agent-inspector:focus-log";function vs(e){window.dispatchEvent(new CustomEvent(en,{detail:e}))}function Vr(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,s=G(t,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const o=G(t,"tab");switch(o){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const r=G(t,"source"),a=G(t,"toolCallIndex"),i=typeof a=="number"&&Number.isInteger(a)&&a>=0?{logId:s,tab:o??"request",toolCallIndex:a}:{logId:s,tab:o??"request"};switch(r){case"virtualizer":return{...i,source:r};case void 0:return i;default:return null}}function Lc(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function Sf(e){if(!ss(e))return null;if(typeof e.stop_reason=="string")return Lc(e.stop_reason);if(ss(e.delta)&&typeof e.delta.stop_reason=="string")return Lc(e.delta.stop_reason);if(Array.isArray(e.choices))for(const t of e.choices){if(!ss(t)||typeof t.finish_reason!="string")continue;const s=J5(t.finish_reason);if(s!==null)return s}if(Array.isArray(e.output)){for(const t of e.output)if(ss(t)&&t.type==="function_call")return"tool_use";if(e.status==="completed")return"stop"}if(e.status==="incomplete"&&ss(e.incomplete_details)){const t=e.incomplete_details.reason;if(typeof t=="string"&&X5(t))return"length"}return null}function Y5(e){let t=null;for(const s of e.split(`
49
- `)){const o=s.trim();if(!o.startsWith("data: "))continue;const r=o.slice(6).trim();if(r==="[DONE]")break;try{const a=Sf(JSON.parse(r));a!==null&&(t=a)}catch{}}return t}function J5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function X5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Nf(e){if(e.stopReason!==void 0)return e.stopReason;if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);return typeof t=="string"&&(t=JSON.parse(t)),Sf(t)}catch{return Y5(e.responseText)}}function Al(e){return e==="end_turn"||e==="stop"||e==="length"}function vt({className:e,style:t,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:O("inline-block size-5",e),children:[n.jsx("path",{d:s}),o,r,a,i]})}const Nn=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),n.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),n.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),n.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),Cf=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),n.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),n.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),n.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function kf({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function Z5({className:e}){return n.jsx(vt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),n.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:Cf,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),n.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function Q5({className:e}){return n.jsx(vt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),n.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),n.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function eS({className:e}){return n.jsx(vt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),n.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),n.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),n.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),n.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),n.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function tS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function nS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function sS({className:e}){return n.jsx(vt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),n.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),n.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:Cf,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),n.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function oS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),n.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function rS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function aS({className:e}){return n.jsx(vt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),n.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),n.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),n.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),n.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),n.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function iS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),n.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),n.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function lS({className:e}){return n.jsx(vt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),n.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),n.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),n.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),n.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),n.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const bi=[kf,Z5,Q5,eS,tS,nS,sS,oS,rS,aS,iS,lS];function Il(e){return bi[Math.abs(e)%bi.length]??kf}function cS(e){const t=bi.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function dS(e){return Il(cS(e))}const uS="x-anthropic-billing-header:";function mS(e){return e.trimStart().toLowerCase().startsWith(uS)}function pS(e){return Rl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function fS(e){if(!Rl(e))return!1;const t=G(e,"type"),s=G(e,"text");return typeof t!="string"||t!=="text"||typeof s!="string"?!1:mS(s)}function hS(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!pS(t))return{body:e,removed:0};const s=t.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(fS(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete t.system:t.system=o,{body:JSON.stringify(t),removed:r})}const xS=400,Oc=2e3;function gS(e){return Array.isArray(e)}function bS(e,t){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>t)return o;if(!(r===null||typeof r!="object")){if(gS(r)){for(const a of r)s.push(a);continue}for(const a of Object.keys(r)){const i=r[a];i!==void 0&&s.push(i)}}}}return o}function vS(e){const t=bS(e,Oc+1);return t<=xS?{depth:Number.POSITIVE_INFINITY}:t<=Oc?{depth:3}:{depth:2}}function yS(e){try{const t=JSON.parse(e);return{kind:"json",data:lr(t)}}catch{return{kind:"text"}}}function ja(e){const t=l.useMemo(()=>e===null?null:yS(e),[e]),s=t?.kind==="json"?t.data:null,o=l.useMemo(()=>s===null?null:vS(s),[s]),[r,a]=l.useState(!1),[i,c]=l.useState(0),[d,m]=l.useState(0),[u,p]=l.useTransition(),f=l.useCallback(()=>{const h=!r,g=h&&o!==null?o.depth:0;p(()=>{a(h),c(g),m(b=>b+1)})},[r,o]);return{parsedData:s,policy:o,isExpanded:r,toggle:f,isPending:u,bulkDepth:i,bulkRevision:d}}function lr(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(s=>lr(s));const t={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);t[s]=lr(o?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function _f({className:e,orientation:t="horizontal",...s}){return n.jsx(tj,{"data-slot":"tabs","data-orientation":t,orientation:t,className:O("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const wS=nu("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Tf({className:e,variant:t="default",...s}){return n.jsx(nj,{"data-slot":"tabs-list","data-variant":t,className:O(wS({variant:t}),e),...s})}function Yt({className:e,...t}){return n.jsx(sj,{"data-slot":"tabs-trigger",className:O("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function at({className:e,...t}){return n.jsx(oj,{"data-slot":"tabs-content",className:O("flex-1 outline-none",e),...t})}function un(e){const[t,s]=l.useState(!1),o=l.useRef(null);l.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);const r=l.useCallback(a=>{a.stopPropagation(),e!==null&&Nt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:t,copy:r}}const jS=l.lazy(()=>qt(()=>import("./CompareDrawer-pPcsyvc6.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),SS=l.lazy(()=>qt(()=>import("./InspectorPet-DR3JEqze.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),NS=l.lazy(()=>qt(()=>import("./ReplayDialog-Z-1-gUDm.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),CS=l.lazy(()=>qt(()=>import("./RequestAnatomy-BsnZjE5G.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),kS=l.lazy(()=>qt(()=>import("./ResponseView-HY64_ZY2.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),_S=l.lazy(()=>qt(()=>import("./StreamingChunkSequence-CfQUFbTA.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),vi=l.lazy(()=>qt(()=>import("./json-viewer-B2SQN0Lg.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),TS=l.lazy(()=>qt(()=>import("./json-viewer-B2SQN0Lg.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),ES=1200,RS=12;function MS(e){const{containerRef:t,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=p=>{p.scrollIntoView({behavior:"smooth",block:"center"}),p.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},r??ES)},m=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=p=>{const f=t.current;if(f!==null){const h=f.querySelector(m);if(h!==null){c(h);return}}p>0?window.requestAnimationFrame(()=>u(p-1)):s(null)};window.requestAnimationFrame(()=>u(RS))},[t,o,r,s])}var AS={};const Dc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.",zc=64,Jt=new Map,Fo=new Map;function os(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function IS(e,t){const s=[];return e!=null&&s.push(`Request ${os(e)}`),t!=null&&s.push(`Response ${os(t)}`),s.length===0?null:s.join(" · ")}function PS(e){if(e instanceof Ii)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?Dc:t}}return{title:"Full bodies could not be loaded",detail:Dc}}function LS(){const e=AS.AGENT_INSPECTOR_UI_DETAIL_CACHE_LIMIT;if(e===void 0||e==="")return zc;const t=Number(e);return!Number.isSafeInteger(t)||t<1||t>1e3?zc:t}function OS(e){for(Jt.delete(e.id),Jt.set(e.id,e);Jt.size>LS();){const t=Jt.keys().next().value;if(typeof t!="number")break;Jt.delete(t)}return e}function Ef(e){const t=Jt.get(e);return t===void 0?null:(Jt.delete(e),Jt.set(e,t),t)}function DS(e){Jt.delete(e),Fo.delete(e)}async function zS(e,t){const s=Ef(e);if(s!==null)return s;const o=Fo.get(e);if(o!==void 0)return await o;const r=t().then(OS).finally(()=>{Fo.delete(e)});return Fo.set(e,r),await r}class Rf{diff(t,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(t,o),i=this.castInput(s,o),c=this.removeEmpty(this.tokenize(a,o)),d=this.removeEmpty(this.tokenize(i,o));return this.diffWithOptionsObj(c,d,o,r)}diffWithOptionsObj(t,s,o,r){var a;const i=v=>{if(v=this.postProcess(v,o),r){setTimeout(function(){r(v)},0);return}else return v},c=s.length,d=t.length;let m=1,u=c+d;o.maxEditLength!=null&&(u=Math.min(u,o.maxEditLength));const p=(a=o.timeout)!==null&&a!==void 0?a:1/0,f=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,t,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,t));let b=-1/0,y=1/0;const w=()=>{for(let v=Math.max(b,-m);v<=Math.min(y,m);v+=2){let j;const S=h[v-1],N=h[v+1];S&&(h[v-1]=void 0);let C=!1;if(N){const P=N.oldPos-v;C=N&&0<=P&&P<c}const R=S&&S.oldPos+1<d;if(!C&&!R){h[v]=void 0;continue}if(!R||C&&S.oldPos<N.oldPos?j=this.addToPath(N,!0,!1,0,o):j=this.addToPath(S,!1,!0,1,o),g=this.extractCommon(j,s,t,v,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,t))||!0;h[v]=j,j.oldPos+1>=d&&(y=Math.min(y,v-1)),g+1>=c&&(b=Math.max(b,v+1))}m++};if(r)(function v(){setTimeout(function(){if(m>u||Date.now()>f)return r(void 0);w()||v()},0)})();else for(;m<=u&&Date.now()<=f;){const v=w();if(v)return v}}addToPath(t,s,o,r,a){const i=t.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:t.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(t,s,o,r,a){const i=s.length,c=o.length;let d=t.oldPos,m=d-r,u=0;for(;m+1<i&&d+1<c&&this.equals(o[d+1],s[m+1],a);)m++,d++,u++,a.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=d,m}equals(t,s,o){return o.comparator?o.comparator(t,s):t===s||!!o.ignoreCase&&t.toLowerCase()===s.toLowerCase()}removeEmpty(t){const s=[];for(let o=0;o<t.length;o++)t[o]&&s.push(t[o]);return s}castInput(t,s){return t}tokenize(t,s){return Array.from(t)}join(t){return t.join("")}postProcess(t,s){return t}get useLongestToken(){return!1}buildValues(t,s,o){const r=[];let a;for(;t;)r.push(t),a=t.previousComponent,delete t.previousComponent,t=a;r.reverse();const i=r.length;let c=0,d=0,m=0;for(;c<i;c++){const u=r[c];if(u.removed)u.value=this.join(o.slice(m,m+u.count)),m+=u.count;else{if(!u.added&&this.useLongestToken){let p=s.slice(d,d+u.count);p=p.map(function(f,h){const g=o[m+h];return g.length>f.length?g:f}),u.value=this.join(p)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(m+=u.count)}}return r}}class $S extends Rf{constructor(){super(...arguments),this.tokenize=Af}equals(t,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!t.includes(`
49
+ `)){const o=s.trim();if(!o.startsWith("data: "))continue;const r=o.slice(6).trim();if(r==="[DONE]")break;try{const a=Sf(JSON.parse(r));a!==null&&(t=a)}catch{}}return t}function J5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function X5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Nf(e){if(e.stopReason!==void 0)return e.stopReason;if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);return typeof t=="string"&&(t=JSON.parse(t)),Sf(t)}catch{return Y5(e.responseText)}}function Al(e){return e==="end_turn"||e==="stop"||e==="length"}function vt({className:e,style:t,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:O("inline-block size-5",e),children:[n.jsx("path",{d:s}),o,r,a,i]})}const Nn=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),n.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),n.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),n.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),Cf=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),n.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),n.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),n.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function kf({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function Z5({className:e}){return n.jsx(vt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),n.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:Cf,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),n.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function Q5({className:e}){return n.jsx(vt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),n.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),n.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function eS({className:e}){return n.jsx(vt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),n.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),n.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),n.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),n.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),n.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function tS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function nS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function sS({className:e}){return n.jsx(vt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),n.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),n.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:Cf,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),n.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function oS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),n.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function rS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function aS({className:e}){return n.jsx(vt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),n.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),n.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),n.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),n.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),n.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function iS({className:e}){return n.jsx(vt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),n.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),n.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:Nn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function lS({className:e}){return n.jsx(vt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),n.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),n.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),n.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),n.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),n.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const bi=[kf,Z5,Q5,eS,tS,nS,sS,oS,rS,aS,iS,lS];function Il(e){return bi[Math.abs(e)%bi.length]??kf}function cS(e){const t=bi.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function dS(e){return Il(cS(e))}const uS="x-anthropic-billing-header:";function mS(e){return e.trimStart().toLowerCase().startsWith(uS)}function pS(e){return Rl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function fS(e){if(!Rl(e))return!1;const t=G(e,"type"),s=G(e,"text");return typeof t!="string"||t!=="text"||typeof s!="string"?!1:mS(s)}function hS(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!pS(t))return{body:e,removed:0};const s=t.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(fS(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete t.system:t.system=o,{body:JSON.stringify(t),removed:r})}const xS=400,Oc=2e3;function gS(e){return Array.isArray(e)}function bS(e,t){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>t)return o;if(!(r===null||typeof r!="object")){if(gS(r)){for(const a of r)s.push(a);continue}for(const a of Object.keys(r)){const i=r[a];i!==void 0&&s.push(i)}}}}return o}function vS(e){const t=bS(e,Oc+1);return t<=xS?{depth:Number.POSITIVE_INFINITY}:t<=Oc?{depth:3}:{depth:2}}function yS(e){try{const t=JSON.parse(e);return{kind:"json",data:lr(t)}}catch{return{kind:"text"}}}function ja(e){const t=l.useMemo(()=>e===null?null:yS(e),[e]),s=t?.kind==="json"?t.data:null,o=l.useMemo(()=>s===null?null:vS(s),[s]),[r,a]=l.useState(!1),[i,c]=l.useState(0),[d,m]=l.useState(0),[u,p]=l.useTransition(),f=l.useCallback(()=>{const h=!r,g=h&&o!==null?o.depth:0;p(()=>{a(h),c(g),m(b=>b+1)})},[r,o]);return{parsedData:s,policy:o,isExpanded:r,toggle:f,isPending:u,bulkDepth:i,bulkRevision:d}}function lr(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(s=>lr(s));const t={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);t[s]=lr(o?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function _f({className:e,orientation:t="horizontal",...s}){return n.jsx(tj,{"data-slot":"tabs","data-orientation":t,orientation:t,className:O("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const wS=nu("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Tf({className:e,variant:t="default",...s}){return n.jsx(nj,{"data-slot":"tabs-list","data-variant":t,className:O(wS({variant:t}),e),...s})}function Yt({className:e,...t}){return n.jsx(sj,{"data-slot":"tabs-trigger",className:O("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function at({className:e,...t}){return n.jsx(oj,{"data-slot":"tabs-content",className:O("flex-1 outline-none",e),...t})}function un(e){const[t,s]=l.useState(!1),o=l.useRef(null);l.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);const r=l.useCallback(a=>{a.stopPropagation(),e!==null&&Nt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:t,copy:r}}const jS=l.lazy(()=>qt(()=>import("./CompareDrawer-DS5S-VLf.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),SS=l.lazy(()=>qt(()=>import("./InspectorPet-DfaI6G7F.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),NS=l.lazy(()=>qt(()=>import("./ReplayDialog-CDYTm53e.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),CS=l.lazy(()=>qt(()=>import("./RequestAnatomy-Dy8R19-R.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),kS=l.lazy(()=>qt(()=>import("./ResponseView-DPLMIyJd.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),_S=l.lazy(()=>qt(()=>import("./StreamingChunkSequence-ekgIUv3O.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),vi=l.lazy(()=>qt(()=>import("./json-viewer-zMxqETtC.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),TS=l.lazy(()=>qt(()=>import("./json-viewer-zMxqETtC.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),ES=1200,RS=12;function MS(e){const{containerRef:t,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=p=>{p.scrollIntoView({behavior:"smooth",block:"center"}),p.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},r??ES)},m=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=p=>{const f=t.current;if(f!==null){const h=f.querySelector(m);if(h!==null){c(h);return}}p>0?window.requestAnimationFrame(()=>u(p-1)):s(null)};window.requestAnimationFrame(()=>u(RS))},[t,o,r,s])}var AS={};const Dc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.",zc=64,Jt=new Map,Fo=new Map;function os(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function IS(e,t){const s=[];return e!=null&&s.push(`Request ${os(e)}`),t!=null&&s.push(`Response ${os(t)}`),s.length===0?null:s.join(" · ")}function PS(e){if(e instanceof Ii)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?Dc:t}}return{title:"Full bodies could not be loaded",detail:Dc}}function LS(){const e=AS.AGENT_INSPECTOR_UI_DETAIL_CACHE_LIMIT;if(e===void 0||e==="")return zc;const t=Number(e);return!Number.isSafeInteger(t)||t<1||t>1e3?zc:t}function OS(e){for(Jt.delete(e.id),Jt.set(e.id,e);Jt.size>LS();){const t=Jt.keys().next().value;if(typeof t!="number")break;Jt.delete(t)}return e}function Ef(e){const t=Jt.get(e);return t===void 0?null:(Jt.delete(e),Jt.set(e,t),t)}function DS(e){Jt.delete(e),Fo.delete(e)}async function zS(e,t){const s=Ef(e);if(s!==null)return s;const o=Fo.get(e);if(o!==void 0)return await o;const r=t().then(OS).finally(()=>{Fo.delete(e)});return Fo.set(e,r),await r}class Rf{diff(t,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(t,o),i=this.castInput(s,o),c=this.removeEmpty(this.tokenize(a,o)),d=this.removeEmpty(this.tokenize(i,o));return this.diffWithOptionsObj(c,d,o,r)}diffWithOptionsObj(t,s,o,r){var a;const i=v=>{if(v=this.postProcess(v,o),r){setTimeout(function(){r(v)},0);return}else return v},c=s.length,d=t.length;let m=1,u=c+d;o.maxEditLength!=null&&(u=Math.min(u,o.maxEditLength));const p=(a=o.timeout)!==null&&a!==void 0?a:1/0,f=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,t,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,t));let b=-1/0,y=1/0;const w=()=>{for(let v=Math.max(b,-m);v<=Math.min(y,m);v+=2){let j;const S=h[v-1],N=h[v+1];S&&(h[v-1]=void 0);let C=!1;if(N){const P=N.oldPos-v;C=N&&0<=P&&P<c}const R=S&&S.oldPos+1<d;if(!C&&!R){h[v]=void 0;continue}if(!R||C&&S.oldPos<N.oldPos?j=this.addToPath(N,!0,!1,0,o):j=this.addToPath(S,!1,!0,1,o),g=this.extractCommon(j,s,t,v,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,t))||!0;h[v]=j,j.oldPos+1>=d&&(y=Math.min(y,v-1)),g+1>=c&&(b=Math.max(b,v+1))}m++};if(r)(function v(){setTimeout(function(){if(m>u||Date.now()>f)return r(void 0);w()||v()},0)})();else for(;m<=u&&Date.now()<=f;){const v=w();if(v)return v}}addToPath(t,s,o,r,a){const i=t.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:t.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(t,s,o,r,a){const i=s.length,c=o.length;let d=t.oldPos,m=d-r,u=0;for(;m+1<i&&d+1<c&&this.equals(o[d+1],s[m+1],a);)m++,d++,u++,a.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=d,m}equals(t,s,o){return o.comparator?o.comparator(t,s):t===s||!!o.ignoreCase&&t.toLowerCase()===s.toLowerCase()}removeEmpty(t){const s=[];for(let o=0;o<t.length;o++)t[o]&&s.push(t[o]);return s}castInput(t,s){return t}tokenize(t,s){return Array.from(t)}join(t){return t.join("")}postProcess(t,s){return t}get useLongestToken(){return!1}buildValues(t,s,o){const r=[];let a;for(;t;)r.push(t),a=t.previousComponent,delete t.previousComponent,t=a;r.reverse();const i=r.length;let c=0,d=0,m=0;for(;c<i;c++){const u=r[c];if(u.removed)u.value=this.join(o.slice(m,m+u.count)),m+=u.count;else{if(!u.added&&this.useLongestToken){let p=s.slice(d,d+u.count);p=p.map(function(f,h){const g=o[m+h];return g.length>f.length?g:f}),u.value=this.join(p)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(m+=u.count)}}return r}}class $S extends Rf{constructor(){super(...arguments),this.tokenize=Af}equals(t,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!t.includes(`
50
50
  `))&&(t=t.trim()),(!o.newlineIsToken||!s.includes(`
51
51
  `))&&(s=s.trim())):o.ignoreNewlineAtEof&&!o.newlineIsToken&&(t.endsWith(`
52
52
  `)&&(t=t.slice(0,-1)),s.endsWith(`
@@ -57,4 +57,4 @@ import{l as Hh,u as Ut,s as x,n as E,b as ke,_ as Ho,a as W,c as De,o as _,d as
57
57
  `);if(s===o)return{lines:[],isEmpty:!0};const r=Mf(s,o);return{lines:wi(r),isEmpty:!1}}function Bc(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function VS(e,t){const s=e??"",o=t??"";if(s===o)return{lines:[],isEmpty:!0};const r=Bc(s),a=Bc(o);if(r!==null&&a!==null){const c=qS(r,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:wi(c),isEmpty:!1}}const i=Mf(s,o);return{lines:wi(i),isEmpty:!1}}const WS=22,Sa=1e4;function GS(e){return e==="added"?"+":e==="removed"?"-":" "}function KS(e){return e==="added"?"bg-green-500/10 text-green-700 dark:text-green-300":e==="removed"?"bg-red-500/10 text-red-700 dark:text-red-300":"text-foreground/80"}const YS=function({result:t,emptyLabel:s}){const[o,r]=l.useState("unified"),a=l.useRef(null),i=G5({count:t.lines.length,getScrollElement:()=>a.current,estimateSize:()=>WS,overscan:10});if(t.isEmpty)return n.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:s??"No transformation applied — raw and processed are identical."});const c=t.lines.length,d=c>Sa,m=d?t.lines.slice(0,Sa):t.lines;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${Sa.toLocaleString()})`]}),n.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":o==="unified",className:O("flex items-center gap-1 px-2 py-1 transition-colors",o==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[n.jsx(h1,{className:"size-3"}),"Unified"]}),n.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":o==="split",className:O("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",o==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[n.jsx(ng,{className:"size-3"}),"Split"]})]})]}),n.jsx("div",{ref:a,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:o==="unified"?n.jsx(JS,{virtualizer:i,lines:m}):n.jsx(QS,{lines:m})})]})};function JS({virtualizer:e,lines:t}){return n.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const o=t[s.index];return o===void 0?null:n.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:O("flex items-start gap-3 px-2",KS(o.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.oldLineNumber??""}),n.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.newLineNumber??""}),n.jsx("span",{className:O("select-none w-3 text-right font-bold",o.kind==="added"&&"text-green-600 dark:text-green-400",o.kind==="removed"&&"text-red-600 dark:text-red-400"),children:GS(o.kind)}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:o.text})]},s.key)})})}function XS(e){const t=[];let s=0;for(;s<e.length;){const o=e[s];if(o===void 0)break;if(o.kind==="context"){t.push({left:{text:o.text,lineNumber:o.oldLineNumber},right:{text:o.text,lineNumber:o.newLineNumber},kind:"equal"}),s+=1;continue}const r=[],a=[];for(;s<e.length&&e[s]?.kind==="removed";){const c=e[s];c!==void 0&&r.push(c),s+=1}for(;s<e.length&&e[s]?.kind==="added";){const c=e[s];c!==void 0&&a.push(c),s+=1}const i=Math.max(r.length,a.length);for(let c=0;c<i;c+=1){const d=r[c],m=a[c];d!==void 0&&m!==void 0?t.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:m.text,lineNumber:m.newLineNumber},kind:"changed"}):d!==void 0?t.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):m!==void 0&&t.push({left:null,right:{text:m.text,lineNumber:m.newLineNumber},kind:"added"})}}return t}function ZS(e){switch(e){case"changed":return"bg-amber-500/10";case"removed":return"bg-red-500/10";case"added":return"bg-green-500/10";case"equal":return""}}function QS({lines:e}){const t=XS(e);return n.jsx("div",{"data-testid":"diff-split",children:t.map((s,o)=>n.jsxs("div",{className:O("grid grid-cols-2 font-mono text-xs",ZS(s.kind)),children:[n.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),n.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="removed"||s.kind==="changed")&&"text-red-600 dark:text-red-400"),children:s.left!==null?"-":" "}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),n.jsxs("div",{className:"flex items-start gap-2 px-2",children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),n.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="added"||s.kind==="changed")&&"text-green-600 dark:text-green-400"),children:s.right!==null?"+":" "}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},o))})}const If=l.memo(YS),eN=nu("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function Ce({className:e,variant:t="default",asChild:s=!1,...o}){const r=s?Gb:"span";return n.jsx(r,{"data-slot":"badge","data-variant":t,className:O(eN({variant:t}),e),...o})}const tN=3;function nN({event:e}){const t=s=>{s.stopPropagation(),vs({logId:e.logId,tab:"response",toolCallIndex:e.index})};return n.jsx("button",{type:"button",className:"inline-flex h-5 min-w-0 max-w-[8.5rem] items-center rounded px-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-background/65 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:n.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function sN({events:e}){if(e.length===0)return null;const t=e.slice(0,tN),s=Math.max(0,e.length-t.length);return n.jsxs("span",{className:"inline-flex h-7 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-md border border-cyan-300/10 bg-cyan-300/[0.055] px-1 sm:max-w-[26rem]",role:"group","aria-label":`${e.length} response tool ${e.length===1?"call":"calls"}`,onClick:o=>o.stopPropagation(),onKeyDown:o=>o.stopPropagation(),children:[n.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center gap-1 px-1 font-mono text-[9px] font-semibold uppercase text-cyan-300",children:[n.jsx(Zs,{className:"size-3"}),"Call ",e.length]}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[t.map(o=>n.jsx(nN,{event:o},o.id)),s>0&&n.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",s]})]})]})}const oN={success:"bg-slate-300/[0.08] text-slate-100 border-transparent",client_error:"bg-amber-300/[0.10] text-amber-100 border-transparent",server_error:"bg-rose-400/[0.10] text-rose-100 border-transparent",pending:"bg-cyan-300/[0.08] text-cyan-100 border-transparent"},rN={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-text-strong"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100"}},Rs="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",jt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Ms(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function aN(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function iN(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function Uc({trend:e}){if(e===null)return null;const t=e.direction==="up",s=t?x0:d0,o=t?"+":"-";return n.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[n.jsx(s,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),n.jsxs("span",{className:"font-mono",children:[o,Ee(e.delta)]})]})}const lN=l.memo(function({log:e,displayNumber:t,messageCount:s=null,toolCount:o=null,toolEvents:r=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:m,onReplay:u,slowResponseThresholdSeconds:p=0,showClientMetadata:f=!0,timeDisplayFormat:h}){const g=Wh(e.responseStatus),b=e.elapsedMs!==null&&p>0&&e.elapsedMs>p*1e3,y=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,v=e.tokensPerSecond??null,j=w===null?null:Ms(w),S=v===null||v<=0?null:aN(v),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,R=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const P=rN[g],L=iN(g,e.responseStatus),M=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return n.jsx(Ns,{children:n.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:O("group/header relative isolate flex min-w-0 cursor-pointer items-start gap-2 overflow-hidden px-3 py-2 transition-[background-color,border-color,box-shadow]",a?"bg-white/[0.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:i,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),i())},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:O("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",P.frame),children:n.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),n.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[n.jsx(Xt,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:ti(e.timestamp,h)})]}),M&&n.jsxs(Ce,{variant:"outline",className:O("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",oN[g]),children:[g==="success"?n.jsx(Pe,{className:"size-3","aria-label":"Success"}):g==="server_error"?n.jsx(e1,{className:"size-3","aria-label":"Server error"}):g==="client_error"?n.jsx(fn,{className:"size-3","aria-label":"Client error"}):n.jsx(Oe,{className:"size-3 animate-spin","aria-label":"Pending"}),L]}),N>0&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsxs(Ce,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[n.jsx(fn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),n.jsx(ct,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(b?n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsxs("span",{className:O(jt,"shrink-0 border-amber-300/25 text-amber-200"),children:[n.jsx(Xt,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ms(e.elapsedMs)}),n.jsx(fn,{className:"size-3","aria-label":"Slow response"})]})}),n.jsxs(ct,{children:["Slow response: ",Ms(e.elapsedMs)," exceeds"," ",Ms(p*1e3)]})]}):n.jsxs("span",{className:O(jt,"shrink-0 text-muted-foreground"),children:[n.jsx(Xt,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ms(e.elapsedMs)})]})),e.streaming&&j!==null&&n.jsxs("span",{className:O(jt,"shrink-0 text-cyan-300"),children:[n.jsx(ec,{className:"size-3"}),n.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&n.jsxs("span",{className:O(jt,"shrink-0 text-cyan-300"),children:[n.jsx(Ji,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:S})]}),y&&n.jsxs("span",{className:O(jt,"min-w-0 sm:shrink-0"),children:[n.jsx(Bs,{className:"size-3 text-muted-foreground"}),n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[n.jsxs("span",{className:O("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ee(e.inputTokens):"n/a"]}),n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsxs("span",{className:O("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ee(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&n.jsxs("span",{className:O(jt,"shrink-0"),children:[n.jsx(Uc,{trend:c?.creation??null}),n.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ee(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&n.jsxs("span",{className:O(jt,"shrink-0"),children:[n.jsx(Uc,{trend:c?.read??null}),n.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ee(e.cacheReadInputTokens)]})]}),s!==null&&n.jsxs("span",{className:O(jt,"shrink-0 text-muted-foreground"),children:[n.jsx(wr,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:s})]}),o!==null&&n.jsxs("span",{className:O(jt,"shrink-0 text-muted-foreground"),children:[n.jsx(Zs,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:o})]}),n.jsx(sN,{events:r}),e.origin!==null&&n.jsxs("span",{className:O(jt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[n.jsx(Ru,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(C||R)&&n.jsxs("span",{className:O(jt,"hidden shrink-0 text-purple-300 xl:flex"),children:[n.jsx(yg,{className:"size-3"}),R?n.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):n.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&n.jsx(ec,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),n.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&n.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:A=>A.stopPropagation(),onKeyDown:A=>A.stopPropagation(),children:[m!==void 0&&d!==void 0&&(()=>{const A=m[d];return A===void 0?null:n.jsxs(n.Fragment,{children:[A.expansion!==null&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsx(ee,{variant:"outline",size:"icon",className:Rs,onClick:A.expansion.onToggle,disabled:A.expansion.isPending,"aria-pressed":A.expansion.isExpanded,"aria-label":A.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:A.expansion.isExpanded?n.jsx(z0,{className:"size-3.5"}):n.jsx(A0,{className:"size-3.5"})})}),n.jsx(ct,{children:A.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),A.diffWithRaw!==void 0&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsx(ee,{variant:"outline",size:"icon",className:O(Rs,A.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:A.diffWithRaw.onToggle,"aria-pressed":A.diffWithRaw.active,"aria-label":A.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:n.jsx(xg,{className:"size-3.5"})})}),n.jsx(ct,{children:A.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),A.diffWithPrevious!==void 0&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsx(ee,{variant:"outline",size:"icon",className:Rs,onClick:A.diffWithPrevious,"aria-label":"Diff with previous",children:n.jsx(Mu,{className:"size-3.5"})})}),n.jsx(ct,{children:"Compare this request with the immediately preceding one"})]}),A.copyText!==null&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsx(ee,{variant:"outline",size:"icon",className:Rs,onClick:A.onCopy,"aria-label":A.copyCopied?"Copied":A.copyLabel,children:A.copyCopied?n.jsx(Pe,{className:"size-3.5 text-cyan-300"}):n.jsx(Et,{className:"size-3.5"})})}),n.jsx(ct,{children:A.copyCopied?"Copied to clipboard":A.copyLabel})]})]})})(),u!==void 0&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsx(ee,{variant:"outline",size:"icon",className:Rs,onClick:u,"aria-label":"Replay request",children:n.jsx(Lu,{className:"size-3.5"})})}),n.jsx(ct,{children:"Re-send this request to the provider"})]})]}),n.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:a?n.jsx(We,{className:"size-4 shrink-0"}):n.jsx(ft,{className:"size-4 shrink-0"})})]})]})})});function cN({...e}){return n.jsx(yv,{"data-slot":"collapsible",...e})}function QE({...e}){return n.jsx(Yu,{"data-slot":"collapsible-trigger",...e})}function dN({...e}){return n.jsx(Ju,{"data-slot":"collapsible-content",...e})}function uN({className:e,children:t,...s}){return n.jsxs(Cw,{"data-slot":"scroll-area",className:O("relative overflow-hidden",e),...s,children:[n.jsx(kw,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),n.jsx(mN,{}),n.jsx(_w,{})]})}function mN({className:e,orientation:t="vertical",...s}){return n.jsx(rp,{"data-slot":"scroll-area-scrollbar",orientation:t,className:O("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:n.jsx(cp,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Pf={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},pN={file:"border-transparent bg-blue-400/5 text-blue-300",shell:"border-transparent bg-teal-400/5 text-teal-300",browser:"border-transparent bg-cyan-400/5 text-cyan-300",web:"border-transparent bg-sky-400/5 text-sky-300",mcp:"border-transparent bg-violet-400/5 text-violet-300",code:"border-transparent bg-emerald-400/5 text-emerald-300",other:"border-transparent bg-muted/30 text-muted-foreground"};function fN({category:e}){switch(e){case"file":return n.jsx(jg,{className:"size-3.5"});case"shell":return n.jsx(Fn,{className:"size-3.5"});case"browser":return n.jsx(Jg,{className:"size-3.5"});case"web":return n.jsx(Ru,{className:"size-3.5"});case"mcp":return n.jsx(w0,{className:"size-3.5"});case"code":return n.jsx(_u,{className:"size-3.5"});case"other":return n.jsx(lg,{className:"size-3.5"})}}function hN({names:e}){return e.length===0?null:n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[n.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>n.jsx(Ce,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function xN({tool:e,called:t}){const[s,o]=l.useState(!1),r=un(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return n.jsx(cN,{open:s,onOpenChange:o,children:n.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[n.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>o(i=>!i),"aria-expanded":s,disabled:!a,children:[n.jsx(fN,{category:e.category}),n.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&n.jsx(Ce,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&n.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),n.jsx("span",{className:"flex-1"}),a&&(s?n.jsx(We,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(ft,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),n.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:r.copy,"aria-label":r.copied?"Copied tool name":"Copy tool name",children:r.copied?n.jsx(Pe,{className:"size-3.5 text-emerald-400"}):n.jsx(Et,{className:"size-3.5"})})]}),n.jsx(dN,{children:s&&n.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&n.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),n.jsx(hN,{names:e.requiredParameters}),e.schema!==null&&n.jsx(uN,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:n.jsx(vi,{data:lr(e.schema),defaultExpandDepth:0})})})]})})]})})}function gN(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${Pf[e.category]}`.toLowerCase().trim().includes(t)}const bN=l.memo(function({summary:t,calledToolNames:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(""),c=l.useMemo(()=>new Set(s),[s]),d=a.trim().toLowerCase(),m=l.useMemo(()=>t===null?[]:t.tools.filter(f=>gN(f,d)),[d,t]);if(t===null)return null;const u=t.tools.slice(0,6),p=t.tools.length-u.length;return n.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx(Zs,{className:"size-4 shrink-0 text-sky-300/80"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),n.jsx(Ce,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&n.jsxs(Ce,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),n.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(f=>n.jsxs(Ce,{variant:"outline",className:O("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",pN[f.category]),children:[f.count," ",Pf[f.category]]},f.category))})]})]}),n.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>r(f=>!f),"aria-expanded":o,children:[o?n.jsx(We,{className:"size-3.5"}):n.jsx(ft,{className:"size-3.5"}),o?"Hide":"Show"]})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(f=>n.jsx(Ce,{variant:"outline",className:O("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",c.has(f.name)&&"border-emerald-400/20 text-emerald-300"),children:f.name},f.name)),p>0&&n.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),o&&n.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[n.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[n.jsx(w1,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("input",{value:a,onChange:f=>i(f.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),n.jsx("div",{className:"grid gap-1.5",children:m.length>0?m.map(f=>n.jsx(xN,{tool:f,called:c.has(f.name)},f.name)):n.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function qc(e,t,s){return e==="anthropic"&&t==="full"&&s}function vN(e,t){return e==="full"&&t}function Na(e,t){return e==="full"&&t}function Ca(e,t){return e==="full"&&t}function yN(e,t){return e==="full"&&t===!0}function wN(e,t,s,o){return e==="anthropic"&&t==="full"&&s&&o}function Zn(){return n.jsx("div",{className:"h-1","aria-hidden":"true"})}function jN(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const SN=15e3,NN=15e3,CN=256*1024,mn=1024*1024,Hc=256*1024,ka=512*1024,sn="h-9 flex-none rounded-md border border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-white/[0.045] hover:text-foreground data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function yo(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function cr(e){return e??0}function rs(e,t){return t??e?.length??0}function Pl(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Lf(e){return Pl(e)?cr(e.rawRequestBodyBytes)>mn||cr(e.responseTextBytes)>mn:!1}function kN(e){return Pl(e)&&!Lf(e)}function _N(e,t){return Pl(e)?!1:t?rs(e.rawRequestBody,e.rawRequestBodyBytes)<=mn&&rs(e.responseText,e.responseTextBytes)<=mn:rs(e.rawRequestBody,e.rawRequestBodyBytes)<=Hc&&rs(e.responseText,e.responseTextBytes)<=Hc}function TN(e){switch(e){case"request":case"raw-request":case"anatomy":case"raw":case"parsed":return!0;case"headers":case"raw-headers":case"sse":return!1;default:return!1}}function EN(e){switch(e){case"request":case"anatomy":return!0;case"headers":case"raw-headers":case"raw-request":case"raw":case"parsed":case"sse":return!1;default:return!1}}function RN(e){return e instanceof Ii?"Body preview timed out. The log is still available on disk; try loading again.":e instanceof Error?e.message:"Body preview could not be loaded."}function wo({status:e,error:t,footprint:s,onRetry:o}){switch(e){case"idle":return null;case"loading":return n.jsx(zn,{tone:"loading",title:"Loading full bodies",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Oe,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),n.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&n.jsx("span",{className:"rounded border border-cyan-300/15 bg-cyan-300/[0.06] px-2 py-0.5 font-mono text-[11px] text-cyan-100",children:s})]})});case"failed":return n.jsx(zn,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{children:t?.detail??"Compact metadata is still available."}),n.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 gap-1.5 text-xs text-amber-100",onClick:o,children:[n.jsx(Ct,{className:"size-3"}),"Retry"]})]})})}}function Vc(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function on({children:e,className:t}){return n.jsx("div",{className:O("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function Bo({children:e}){return n.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function jo({children:e}){const[t,s]=l.useState(!1),o=typeof e=="string"?e:null,r=o!==null&&o.length>ka,a=o!==null&&r&&!t?o.slice(0,ka):e;return l.useEffect(()=>{s(!1)},[o]),n.jsxs("div",{className:"space-y-2",children:[r&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",ka.toLocaleString()," characters for fast rendering. The full body is preserved and can still be copied from the tab action."]}),n.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:a}),r&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(i=>!i),children:t?"Collapse fast preview":`Render full body (${o.length.toLocaleString()} chars)`})]})}const MN={loading:"border-transparent bg-cyan-400/[0.06] text-cyan-100",warning:"border-transparent bg-amber-400/[0.08] text-amber-100",danger:"border-transparent bg-rose-400/[0.08] text-rose-100"};function zn({tone:e,title:t,children:s}){return n.jsxs("div",{className:O("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",MN[e]),children:[t!==void 0&&n.jsx("div",{className:"mb-1 font-semibold",children:t}),n.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function So({label:e,state:t,expectedBytes:s,onLoadMore:o}){const r=t.totalBytes??s,a=r===null?os(t.offset):`${os(t.offset)} / ${os(r)}`,i=t.status!=="loading"&&t.hasMore,c=t.status==="failed"?"Retry":"Load more";return n.jsx(zn,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{children:[t.status==="idle"&&r!==null?`${e} body is ${os(r)}. Loading the first preview chunk.`:`Loaded ${a}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),i&&n.jsx(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:o,children:c})]})})}function Wc({error:e,onOpenSse:t}){return e==null?null:n.jsx(zn,{tone:"danger",title:"SSE Error",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono",children:e}),t!==void 0&&n.jsx(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-rose-100",onClick:t,children:"View SSE"})]})})}function AN({onOpenSse:e}){return n.jsx(zn,{tone:"loading",title:"SSE chunks",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{children:"Streaming chunks are available in the SSE tab."}),n.jsx(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:e,children:"View SSE"})]})})}function Gc({headers:e,emptyLabel:t}){const s=e===void 0?[]:Object.entries(e).sort(([o],[r])=>o.localeCompare(r));return s.length===0?n.jsx(Bo,{children:t}):n.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([o,r])=>n.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/[0.055] last:border-b-0",children:[n.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:o}),n.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:r,children:r})]},o))})}function IN({active:e,onClick:t}){return n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsxs(ee,{variant:e?"default":"outline",size:"sm",className:O("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"border border-input bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground hover:text-cyan-100"),onClick:t,"aria-pressed":e,children:[n.jsx(Rg,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),n.jsx(ct,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const PN=l.memo(function({rawBody:e,displayedBody:t,emptyLabel:s}){const o=l.useMemo(()=>VS(e,t),[e,t]);return n.jsx(If,{result:o,emptyLabel:s})}),LN=l.memo(function({rawHeaders:e,headers:t,emptyLabel:s}){const o=l.useMemo(()=>HS(e,t),[e,t]);return n.jsx(If,{result:o,emptyLabel:s})}),ON=l.memo(function({log:e,displayNumber:t,viewMode:s="simple",strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:m=[]}){const[u,p]=l.useState(!1),[f,h]=l.useState(!1),[g,b]=l.useState(!1),[y,w]=l.useState(!1),[v,j]=l.useState("request"),[S,N]=l.useState(null),[C,R]=l.useState(0),[P,L]=l.useState(null),[M,k]=l.useState(null),[A,D]=l.useState("idle"),[F,Y]=l.useState(null),[X,$]=l.useState(0),[V,J]=l.useState(()=>yo(e.rawRequestBodyBytes??null)),[U,K]=l.useState(()=>yo(e.responseTextBytes??null)),ae=l.useRef(null),be=l.useRef(e.id),ve=l.useRef(!1),ie=l.useRef(!1),z=M??e,Z=M===null&&Lf(e),we=l.useMemo(()=>IS(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Ne=Vc(Z,V),pe=Vc(Z,U),re=z.rawRequestBody??Ne,le=z.responseText??pe,Re=z.rawRequestBody===null&&Ne!==null,he=z.responseText===null&&pe!==null,ze=rs(re,e.rawRequestBodyBytes)<=mn,rt=rs(le,e.responseTextBytes)<=mn,$e=ze&&(!Re||V.hasMore===!1&&cr(V.totalBytes)<=mn),Ge=rt&&(!he||U.hasMore===!1&&cr(U.totalBytes)<=mn),Ke=ir(z),Ue=gf(Ke),Ye=_N(z,u),Qe=l.useMemo(()=>Ue.analyzeRequest(Ye?z.rawRequestBody:null),[Ue,Ye,z.rawRequestBody]),et=l.useMemo(()=>Ue.analyzeResponse(Ye?z.responseText:null),[Ue,Ye,z.responseText]),te=l.useMemo(()=>!o||Ke!=="anthropic"||z.rawRequestBody===null?null:hS(z.rawRequestBody).body,[z.rawRequestBody,Ke,o])??re,fe=ja(u&&EN(v)&&$e?te:null),me=ja(v==="raw-request"&&$e?re:null),je=ja(v==="raw"&&Ge?le:null),Me=yN(s,z.streaming),Ie=fe.parsedData??Qe.parsed,T=l.useMemo(()=>{const _e=et.toolNames;return _e!==null?_e:m.map(xt=>xt.name)},[et.toolNames,m]),I=l.useMemo(()=>z.headers&&Object.keys(z.headers).length>0?JSON.stringify(z.headers,null,2):null,[z.headers]),q=l.useMemo(()=>z.rawHeaders&&Object.keys(z.rawHeaders).length>0?JSON.stringify(z.rawHeaders,null,2):null,[z.rawHeaders]),ne=un(te),xe=un(re),ce=un(I),Q=un(q),se=un(le),Ae=l.useMemo(()=>({request:{copyLabel:Re?"Copy loaded request preview":"Copy request body",copyText:te,copyCopied:ne.copied,onCopy:ne.copy,expansion:$e?{isExpanded:fe.isExpanded,isPending:fe.isPending,onToggle:fe.toggle}:null,diffWithRaw:wN(Ke,s,o,z.rawRequestBody!==null)?{active:y,onToggle:()=>w(!y)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(z)}},"raw-request":{copyLabel:Re?"Copy loaded raw request preview":"Copy raw request",copyText:re,copyCopied:xe.copied,onCopy:xe.copy,expansion:$e?{isExpanded:me.isExpanded,isPending:me.isPending,onToggle:me.toggle}:null},...Ca(s,z.headers!==void 0&&Object.keys(z.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:I,copyCopied:ce.copied,onCopy:ce.copy,expansion:null}}:{},...Na(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:q,copyCopied:Q.copied,onCopy:Q.copy,expansion:null}}:{},raw:{copyLabel:he?"Copy loaded response preview":"Copy response",copyText:le,copyCopied:se.copied,onCopy:se.copy,expansion:Ge?{isExpanded:je.isExpanded,isPending:je.isPending,onToggle:je.toggle}:null}}),[te,Re,$e,ne,fe,y,z,z.rawRequestBody,re,xe,me,I,ce,q,Q,z.responseText,he,Ge,le,se,je,Ke,s,o,c]),qe=l.useMemo(()=>Ie!==null?Ue.anatomySegments(Ie):null,[Ue,Ie]),Kr=l.useMemo(()=>Ml(Ie),[Ie]),io=z.warnings??[],Yr=l.useMemo(()=>{if(qe!==null)return new Set(qe.map(_e=>_e.path))},[qe]),Jr=MS({containerRef:ae,setExpandToPath:L,ensureTabActive:()=>{v!=="request"&&(ie.current=!0,j("request"))}}),Mt=l.useCallback((_e,xt)=>{const Je=_e==="request"?J:K;Je(tt=>({...tt,status:"loading",error:null}));const Cs=new URLSearchParams({part:_e,offset:String(xt),limit:String(CN)});Le(`/api/logs/${String(e.id)}/body?${Cs.toString()}`,au,NN).then(tt=>{be.current===e.id&&Je(yt=>({status:"success",text:tt.offset===0?tt.text:`${yt.text}${tt.text}`,offset:tt.nextOffset??tt.totalBytes,totalBytes:tt.totalBytes,hasMore:tt.hasMore,error:null}))}).catch(tt=>{be.current===e.id&&Je(yt=>({...yt,status:"failed",error:RN(tt)}))})},[e.id]),nn=l.useCallback(()=>{ve.current||(DS(e.id),k(null),D("idle"),Y(null),$(_e=>_e+1))},[e.id]),Xr=l.useCallback(()=>{const _e=!u;_e&&(ie.current=!1,j(qe!==null?"anatomy":"request")),p(_e)},[qe,u]),qn=l.useCallback(()=>{Me&&(ie.current=!0,j("sse"))},[Me]),Zr=l.useCallback(_e=>{ie.current=!0,j(_e)},[]);return l.useEffect(()=>{be.current=e.id,ve.current=!1,k(null),D("idle"),Y(null),$(0),ie.current=!1,J(yo(e.rawRequestBodyBytes??null)),K(yo(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{u&&(ie.current||v==="request"&&qe!==null&&j("anatomy"))},[v,qe,u]),l.useEffect(()=>{v!=="sse"||Me||j("parsed")},[v,Me]),l.useEffect(()=>{if(!u||!TN(v)||!kN(e)||M!==null||ve.current)return;const _e=Ef(e.id);if(_e!==null){k(_e),D("idle"),Y(null);return}let xt=!1;return ve.current=!0,D("loading"),Y(null),zS(e.id,()=>Le(`/api/logs/${String(e.id)}`,Fs,SN)).then(Je=>{xt||(ve.current=!1,k(Je),D("idle"),Y(null))}).catch(Je=>{xt||(ve.current=!1,D("failed"),Y(PS(Je)))}),()=>{xt=!0,ve.current=!1}},[v,u,M,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,X]),l.useEffect(()=>{u&&Z&&V.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||Mt("request",0))},[v,u,Mt,V.status,Z]),l.useEffect(()=>{u&&Z&&U.status==="idle"&&(v!=="parsed"&&v!=="raw"||Mt("response",0))},[v,u,Mt,U.status,Z]),l.useEffect(()=>{const _e=xt=>{const Je=Vr(xt);Je!==null&&Je.logId===e.id&&(p(!0),ie.current=!0,j(jN(Je.tab,qe)),Je.tab==="response"&&Je.toolCallIndex!==void 0&&(N(Je.toolCallIndex),R(Cs=>Cs+1)))};return window.addEventListener(en,_e),()=>{window.removeEventListener(en,_e)}},[qe,e.id]),n.jsxs(Ns,{children:[n.jsxs("div",{className:O("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",u?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[n.jsx(lN,{log:z,displayNumber:t,messageCount:Qe.messageCount,toolCount:Qe.toolCount,toolEvents:m,expanded:u,onToggle:Xr,cacheTrend:i,slowResponseThresholdSeconds:r,showClientMetadata:d,timeDisplayFormat:a,activeTab:v,tabActions:Ae,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&n.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:_e=>_e.stopPropagation(),onKeyDown:_e=>_e.stopPropagation(),children:[n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-white/[0.05] to-transparent","aria-hidden":"true"}),n.jsx(Vo,{feature:"Log details",children:n.jsxs(_f,{value:v,onValueChange:Zr,className:"gap-2",children:[n.jsxs(Tf,{variant:"line",className:"bg-white/[0.04] inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[Na(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&n.jsx(Yt,{className:sn,value:"raw-headers",children:"Raw Headers"}),Ca(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&n.jsx(Yt,{className:sn,value:"headers",children:"Headers"}),qe!==null&&n.jsx(Yt,{className:sn,value:"anatomy",children:"Context"}),qc(Ke,s,o)&&n.jsx(Yt,{className:sn,value:"raw-request",children:"Raw Request"}),n.jsx(Yt,{className:sn,value:"request",children:"Request"}),s==="full"&&n.jsx(Yt,{className:sn,value:"raw",children:"Raw Response"}),n.jsx(Yt,{className:sn,value:"parsed",children:"Response"}),Me&&n.jsx(Yt,{className:sn,value:"sse",children:"SSE"})]}),qc(Ke,s,o)&&n.jsx(at,{value:"raw-request",children:v==="raw-request"&&n.jsxs(on,{children:[n.jsx(wo,{status:A,error:F,footprint:we,onRetry:nn}),Z&&n.jsx(So,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Mt("request",V.offset)}),re===null?n.jsx(Bo,{children:Z?"Request preview is loading":"No request body"}):me.parsedData!==null?n.jsx(l.Suspense,{fallback:n.jsx(Zn,{}),children:n.jsx(vi,{data:me.parsedData,bulkDepth:me.bulkDepth,bulkRevision:me.bulkRevision})}):n.jsx(jo,{children:re})]})}),n.jsx(at,{value:"request",children:v==="request"&&n.jsxs(on,{children:[n.jsx(wo,{status:A,error:F,footprint:we,onRetry:nn}),Z&&n.jsx(So,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Mt("request",V.offset)}),io.length>0&&n.jsxs(zn,{tone:"warning",children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[n.jsx(fn,{className:"size-3.5"}),"Tool schema warnings"]}),n.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:io.map(_e=>n.jsx("li",{children:_e},_e))})]}),n.jsx(bN,{summary:Kr,calledToolNames:T}),y?n.jsx(PN,{rawBody:z.rawRequestBody,displayedBody:te,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):n.jsx("div",{ref:ae,children:te===null?n.jsx(Bo,{children:Z?"Request preview is loading":"No request body"}):fe.parsedData!==null?n.jsx(l.Suspense,{fallback:n.jsx(Zn,{}),children:n.jsx(vi,{data:fe.parsedData,bulkDepth:fe.bulkDepth,bulkRevision:fe.bulkRevision,anatomyPaths:Yr,expandToPath:P})}):n.jsx(jo,{children:te})})]})}),qe!==null&&n.jsx(at,{value:"anatomy",children:v==="anatomy"&&n.jsx(on,{className:"p-0",children:n.jsx(l.Suspense,{fallback:n.jsx(Zn,{}),children:n.jsx(CS,{parsed:fe.parsedData,inputTokens:z.inputTokens??null,model:z.model,segments:qe,onSegmentActivate:Jr})})})}),Ca(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&n.jsx(at,{value:"headers",children:v==="headers"&&n.jsxs(on,{children:[n.jsx("div",{className:"flex justify-end gap-2 mb-2",children:vN(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&n.jsx(IN,{active:g,onClick:_e=>{_e.stopPropagation(),b(!g)}})}),g?n.jsx(LN,{rawHeaders:z.rawHeaders,headers:z.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):n.jsx(Gc,{headers:z.headers,emptyLabel:"No headers captured"})]})}),Na(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&n.jsx(at,{value:"raw-headers",children:v==="raw-headers"&&n.jsx(on,{children:n.jsx(Gc,{headers:z.rawHeaders,emptyLabel:"No raw headers captured"})})}),n.jsx(at,{value:"raw",children:v==="raw"&&n.jsxs(on,{className:"space-y-3",children:[n.jsx(wo,{status:A,error:F,footprint:we,onRetry:nn}),Z&&n.jsx(So,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Mt("response",U.offset)}),n.jsx(Wc,{error:z.error,onOpenSse:Me?qn:void 0}),le!==null&&Ge?n.jsx(l.Suspense,{fallback:n.jsx(Zn,{}),children:n.jsx(TS,{text:le,defaultExpandDepth:0,bulkDepth:je.bulkDepth,bulkRevision:je.bulkRevision})}):le!==null?n.jsx(jo,{children:le}):n.jsx(Bo,{children:Z?"Response preview is loading":"No response"}),Me&&n.jsx(AN,{onOpenSse:qn})]})}),Me&&n.jsx(at,{value:"sse",children:v==="sse"&&n.jsxs(on,{className:"space-y-3",children:[z.error!==void 0&&z.error!==null&&n.jsx(zn,{tone:"danger",title:"SSE Error",children:n.jsx("span",{className:"font-mono",children:z.error})}),n.jsx(l.Suspense,{fallback:n.jsx(Zn,{}),children:n.jsx(_S,{logId:z.id,truncated:z.streamingChunksPath!==null})})]})}),n.jsx(at,{value:"parsed",children:v==="parsed"&&n.jsxs(on,{children:[n.jsx(wo,{status:A,error:F,footprint:we,onRetry:nn}),Z&&n.jsx(So,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Mt("response",U.offset)}),n.jsx(Wc,{error:z.error,onOpenSse:Me?qn:void 0}),he&&!Ge?n.jsx(jo,{children:le}):n.jsx(l.Suspense,{fallback:n.jsx(Zn,{}),children:n.jsx(kS,{responseText:le,responseStatus:z.responseStatus,streaming:z.streaming,inputTokens:z.inputTokens,outputTokens:z.outputTokens,cacheCreationInputTokens:z.cacheCreationInputTokens,cacheReadInputTokens:z.cacheReadInputTokens,apiFormat:Ke,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),n.jsx(Vo,{feature:"Replay",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(NS,{log:z,displayNumber:t,open:f,onOpenChange:h})})})]})});function DN(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function _a(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function zN({stopReason:e,isPending:t,isFirst:s,isTurnStart:o,isOnlyEntry:r=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const m=Al(e),u=r&&o&&m,p=t&&!m,f=c&&d!==void 0,h=l.useMemo(()=>Il(i),[i]),g=l.useMemo(()=>dS(i),[i]),b=w=>{!f||d===void 0||(w.stopPropagation(),d())},y=w=>{!f||d===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),d())};return n.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[n.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&n.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:_a(f),onClick:b,onKeyDown:y,children:n.jsx(g,{className:O("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):m?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:DN(e),className:_a(f),onClick:b,onKeyDown:y,children:n.jsx(h,{className:O("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):o?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:_a(f),onClick:b,onKeyDown:y,children:n.jsx(h,{className:O("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?n.jsx("span",{title:t?"Current end of open turn (processing)":"Current end of open turn",children:n.jsx(h,{className:O("size-3.5 text-cyan-300/85",p?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):p?n.jsx("span",{title:"Processing",children:n.jsx(h,{className:O("size-3.5 text-amber-300/80","animate-crab-crawl")})}):n.jsx("span",{title:"Request in turn",children:n.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),n.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!m&&!a&&n.jsx("div",{className:O("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Kc=180;function $N(e){const t=uf(e.path);return t==="unknown"?e.apiFormat:t}function FN(e,t){const s=e.responseText;if(s===null)return!1;switch(t){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function Of(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function BN(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const s=t.replace(/\s+/g," ").trim();return s.length===0?null:s.length>Kc?`${s.slice(0,Kc-1)}...`:s}function UN(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function xn({log:e,provider:t,index:s,name:o,input:r}){return{id:`${String(e.id)}-${t}-tool-${String(s)}`,logId:e.id,index:s,provider:t,name:o,argumentsText:UN(r),argumentsPreview:BN(r)}}function qN(e){const t=Of(e.responseText),s=G(t,"content");if(!Array.isArray(s))return[];const o=[];for(const r of s){if(G(r,"type")!=="tool_use")continue;const i=G(r,"name");if(typeof i!="string"||i.length===0)continue;const c=G(r,"input");o.push(xn({log:e,provider:"anthropic",index:o.length,name:i,input:c}))}return o}function HN(e){const t=Of(e.responseText),s=G(t,"choices"),o=[];if(Array.isArray(s))for(const a of s){const i=G(a,"message"),c=G(i,"tool_calls");if(Array.isArray(c))for(const u of c){const p=G(u,"function"),f=G(p,"name");if(typeof f!="string"||f.length===0)continue;const h=G(p,"arguments");o.push(xn({log:e,provider:"openai",index:o.length,name:f,input:h}))}const d=G(i,"function_call"),m=G(d,"name");if(typeof m=="string"&&m.length>0){const u=G(d,"arguments");o.push(xn({log:e,provider:"openai",index:o.length,name:m,input:u}))}}const r=G(t,"output");if(Array.isArray(r))for(const a of r){if(G(a,"type")!=="function_call")continue;const i=G(a,"name");if(typeof i!="string"||i.length===0)continue;const c=G(a,"arguments");o.push(xn({log:e,provider:"openai",index:o.length,name:i,input:c}))}return o}function Df(e){if(typeof e.data=="string")try{return JSON.parse(e.data)}catch{return e.data}return e.data}function Uo(e,t,s){const o=`${s.provider}:${s.name}:${s.index}`;t.has(o)||(t.add(o),e.push(s))}function VN(e){const t=e.streamingChunks?.chunks??[],s=[],o=new Set;for(const r of t){const a=Df(r),i=G(a,"content_block");if(G(i,"type")!=="tool_use")continue;const c=G(i,"name");if(typeof c!="string"||c.length===0)continue;const d=G(i,"input");Uo(s,o,xn({log:e,provider:"anthropic",index:r.index,name:c,input:d}))}return s.map((r,a)=>({...r,id:`${String(e.id)}-anthropic-tool-${String(a)}`,index:a}))}function WN(e){const t=e.streamingChunks?.chunks??[],s=[],o=new Set;for(const r of t){const a=Df(r),i=G(a,"choices");if(Array.isArray(i))for(const d of i){const m=G(d,"delta"),u=G(m,"tool_calls");if(Array.isArray(u))for(const h of u){const g=G(h,"function"),b=G(g,"name");if(typeof b!="string"||b.length===0)continue;const y=G(g,"arguments");Uo(s,o,xn({log:e,provider:"openai",index:s.length,name:b,input:y}))}const p=G(m,"function_call"),f=G(p,"name");if(typeof f=="string"&&f.length>0){const h=G(p,"arguments");Uo(s,o,xn({log:e,provider:"openai",index:s.length,name:f,input:h}))}}const c=G(a,"item");if(G(c,"type")==="function_call"){const d=G(c,"name");if(typeof d=="string"&&d.length>0){const m=G(c,"arguments");Uo(s,o,xn({log:e,provider:"openai",index:s.length,name:d,input:m}))}}}return s.map((r,a)=>({...r,id:`${String(e.id)}-openai-tool-${String(a)}`,index:a}))}function GN(e){if(e.toolTraceEvents!==void 0&&e.toolTraceEvents.length>0)return e.toolTraceEvents;const t=$N(e);if(FN(e,t))switch(t){case"anthropic":return qN(e);case"openai":return HN(e);case"unknown":return[]}switch(t){case"anthropic":return VN(e);case"openai":return WN(e);case"unknown":return[]}}const Yc=new WeakMap;function KN(e){return e>1}function ji(e){const t=[];let s=[],o=0;for(let r=0;r<e.length;r+=1){const a=e[r];if(a===void 0)continue;s.push({log:a,stopReason:Nf(a),sessionLogNumber:r+1});const i=s[s.length-1];i!==void 0&&Al(i.stopReason)&&(t.push({entries:s,turnIndex:o}),s=[],o+=1)}return s.length>0&&t.push({entries:s,turnIndex:o}),t}function YN(e){const t=new Map;for(const s of e)for(let o=1;o<s.logs.length;o+=1){const r=s.logs[o],a=s.logs[o-1];if(r===void 0||a===void 0)continue;const i=ir(r),c=ir(a);i==="unknown"||i!==c||t.set(r.id,a)}return t}function Ll(e){const t=Yc.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText&&t.toolTraceEvents===e.toolTraceEvents)return t.events;const s=GN(e);return Yc.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,toolTraceEvents:e.toolTraceEvents,events:s}),s}function JN(e,t,s=0){let o=0,r=0,a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=0;for(const h of e)h.responseStatus===null?r+=1:h.responseStatus>=400&&(o+=1),h.elapsedMs!==null&&t>0&&h.elapsedMs>t*1e3&&(a+=1),h.inputTokens!==null&&(i+=h.inputTokens),h.outputTokens!==null&&(c+=h.outputTokens),h.cacheCreationInputTokens!==null&&(d+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(m+=h.cacheReadInputTokens),h.elapsedMs!==null&&(u+=h.elapsedMs,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),f+=Ll(h).length;return{llmCallCount:e.length,toolCallCount:f,failedCallCount:o,pendingCallCount:r,slowCallCount:a,totalInputTokens:i,totalOutputTokens:c,totalCacheCreationInputTokens:d,totalCacheReadInputTokens:m,totalElapsedMs:u,maxElapsedMs:p,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:s}}function Ta(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const XN=l.memo(function({entries:t,viewMode:s,strip:o,slowResponseThresholdSeconds:r,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:m,pendingFocusRequest:u,showLogClientMetadata:p=!0}){const f=t.length-1,h=t[f]?.stopReason??null,g=h!==null?Al(h):!1,b=t[f]?.log.responseStatus===null,y=t.length===1,w=KN(t.length),[v,j]=l.useState(!1),S=l.useRef(!1);l.useEffect(()=>{w?g&&!S.current&&j(!0):j(!1),S.current=g},[w,g]),l.useEffect(()=>{const $=V=>{const J=Vr(V);J!==null&&t.some(U=>U.log.id===J.logId)&&w&&j(!1)};return window.addEventListener(en,$),()=>{window.removeEventListener(en,$)}},[w,t]),l.useEffect(()=>{if(u===void 0||!t.some(V=>V.log.id===u.logId))return;w&&j(!1);const $=window.setTimeout(()=>{vs({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout($)},[w,t,u]);const N=l.useCallback(()=>{w&&j($=>!$)},[w]),C=l.useMemo(()=>{let $=0,V=0,J=null,U=!1;for(const K of t)K.log.inputTokens!==null&&($+=K.log.inputTokens,U=!0),K.log.outputTokens!==null&&(V+=K.log.outputTokens,U=!0),K.log.elapsedMs!==null&&(J=J===null?K.log.elapsedMs:Math.max(J,K.log.elapsedMs));return{totalInput:$,totalOutput:V,hasTokens:U,maxElapsed:J}},[t,f]),R=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",P=C.maxElapsed!==null&&r>0&&C.maxElapsed>r*1e3,L=l.useMemo(()=>{const $=new Map;for(const V of t){const J=Ll(V.log);J.length>0&&$.set(V.log.id,J)}return $},[t]),[M,k]=l.useState(0),A=l.useRef(null);l.useEffect(()=>{const $=A.current;if(!$)return;let V=0;const J=new ResizeObserver(()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(()=>k(U=>U+1))});return J.observe($),()=>{J.disconnect(),window.cancelAnimationFrame(V)}},[]);const D=t[0]?.log.id??d,F=`Turn ${String(d+1)}`,Y=l.useMemo(()=>Il(D%12),[D]),X=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return n.jsx("div",{ref:A,style:X,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:F,"data-nav-id":v?void 0:`turn-${String(D)}`,className:O("rounded-[8px] transition-[background-color,box-shadow]",b?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!v&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:v?n.jsxs("div",{"data-nav-id":`turn-collapsed-${String(D)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:N,onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),N())},children:[n.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[n.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),n.jsx(Y,{className:O("size-3.5",b?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",b?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),n.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:n.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?n.jsx(Y,{className:O("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):n.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:n.jsx(Y,{className:O("size-3.5 text-cyan-300/85",b?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),t.length>1&&n.jsxs("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs","bg-card/80 transition-colors hover:bg-card",R),children:[n.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:F}),n.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[f]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[f]?.sessionLogNumber??"?"]}),n.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),C.maxElapsed!==null&&n.jsx(Ns,{children:n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsxs("span",{className:O("flex items-center gap-1 shrink-0",P?"text-amber-400":"text-muted-foreground"),children:[n.jsx(Xt,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ta(C.maxElapsed)}),P&&n.jsx(fn,{className:"size-3","aria-label":"Slow response"})]})}),n.jsx(ct,{children:P?`Slow response: ${Ta(C.maxElapsed)} exceeds ${Ta(r*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&n.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(Bs,{className:"size-3 text-muted-foreground"}),n.jsxs("span",{className:"font-mono tabular-nums",children:[n.jsxs("span",{className:"text-blue-400",children:["IN ",Ee(C.totalInput)]})," / ",n.jsxs("span",{className:"text-amber-400",children:["OUT ",Ee(C.totalOutput)]})]})]}),n.jsx("span",{className:"flex-1 min-w-0"}),n.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:n.jsx(ft,{className:"size-4 shrink-0"})})]})]}):t.map(($,V)=>{const{log:J,stopReason:U}=$,K=V===0;return n.jsxs("div",{className:"flex items-stretch",children:[n.jsx(zN,{stopReason:U,isPending:J.responseStatus===null,isFirst:V===0,isTurnStart:K,isOnlyEntry:y,isOpenTurnTail:V===f&&!g,crabIndex:J.id%12,collapsible:w&&K,onToggle:N}),n.jsx("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px]",R),children:n.jsx(ON,{log:J,displayNumber:$.sessionLogNumber,viewMode:s,strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrend:a?.get(J.id)??null,showClientMetadata:p,toolEvents:L.get(J.id),onCompareWithPrevious:c.has(J.id)?i:void 0})})]},J.id)})})}),ZN=24,QN=132,eC=8;function tC(e){return e>ZN}function nC(e){const t=new Map;for(let s=0;s<e.length;s++){const o=e[s];if(o!==void 0)for(const r of o.entries)t.set(r.log.id,s)}return t}function zf(e,t,s){return n.jsx(XN,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:t.showLogClientMetadata},e.turnIndex)}function sC(e){return tC(e.turnGroups.length)?n.jsx(oC,{...e}):n.jsx(n.Fragment,{children:e.turnGroups.map(t=>zf(t,e))})}function oC(e){const{turnGroups:t}=e,[s,o]=l.useState(null),r=K5({count:t.length,estimateSize:()=>QN,overscan:eC,getItemKey:i=>t[i]?.turnIndex??i}),a=l.useMemo(()=>nC(t),[t]);return l.useEffect(()=>{const i=c=>{const d=Vr(c);if(d===null||d.source==="virtualizer")return;const m=a.get(d.logId);m!==void 0&&(r.scrollToIndex(m,{align:"center"}),o(u=>({...d,turnIndex:m,nonce:u===null?1:u.nonce+1})))};return window.addEventListener(en,i),()=>{window.removeEventListener(en,i)}},[a,r]),n.jsx("div",{className:"relative w-full",style:{height:`${r.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:r.getVirtualItems().map(i=>{const c=t[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return n.jsx("div",{"data-index":i.index,ref:r.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:zf(c,e,d)},i.key)})})}const Ol=ue(["episode","procedure","preference","project-fact"]),rC=ue(["draft","promoted","failed"]),$f=_({source:oe("agent-inspector"),sessionId:x(),logIds:W(kt),project:x().nullable(),models:W(x())}),aC=_({redacted:ke(),patterns:W(x())}),ro=_({id:x(),type:Ol,title:x(),content:x(),tags:W(x()),source:oe("agent-inspector"),sessionId:x(),logIds:W(kt),evidence:$f,status:rC,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:aC});_({idempotencyKey:x(),type:Ol,title:x(),content:x(),tags:W(x()),source:oe("agent-inspector"),project:x().nullable(),evidence:$f});const iC=_({id:x(),type:Ol.or(x()),title:x(),content:x(),score:E().nullable(),source:x().nullable(),project:x().nullable(),evidence:Os().optional()});_({results:W(iC),warning:x().nullable()});const lC=_({candidates:W(ro)}),cC=_({candidate:ro}),dC=_({error:x().optional(),candidate:ro.optional()}),uC=_({candidate:ro}),mC=3e4,pC=15e3,fC=15e3,hC={draft:"border-amber-500/30 bg-amber-500/10 text-amber-500",promoted:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",failed:"border-destructive/30 bg-destructive/10 text-destructive"};function Si(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function xC(e,t,s){return e===null||t===null?null:jr(e,t,s)}function gC(e){return`${String(e)} candidate${e===1?"":"s"}`}function Ff(e){return`log-${String(e)}`}function Bf(e){const t=Ff(e),s=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function bC(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function vC(e){let t=null,s=-1;for(const o of e)o.elapsedMs!==null&&o.elapsedMs>s&&(t=o,s=o.elapsedMs);return t}function yC(e){for(const t of e)if(Ll(t).length>0)return t;return null}function wC(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s+1)}return t}function ds(e,t){return String(t.get(e)??e)}function jC(e){const t=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],s=yC(e.logs);e.summary.toolCallCount>0&&s!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${ds(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=bC(e.logs);o!==null&&t.push({kind:"failure",title:`Failure #${String(o.responseStatus)}`,detail:`First failed request is #${ds(o.id,e.displayNumberByLogId)}`,logId:o.id});const r=vC(e.logs);if(r!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${Si(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${ds(r.id,e.displayNumberByLogId)}`,logId:r.id}),e.candidates.length>0){const a=e.candidates.filter(c=>c.status==="draft").length,i=e.candidates.filter(c=>c.status==="promoted").length;t.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(a)} draft / ${String(i)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return t}function SC(e){switch(e){case"session":return n.jsx(wr,{className:"size-3.5 text-blue-400"});case"tool":return n.jsx(Zs,{className:"size-3.5 text-sky-400/70"});case"slow":return n.jsx(Xt,{className:"size-3.5 text-amber-400"});case"failure":return n.jsx(ku,{className:"size-3.5 text-destructive"});case"candidate":return n.jsx(Cu,{className:"size-3.5 text-emerald-400"})}}function NC({insights:e}){return e.length===0?null:n.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(t=>n.jsxs("button",{type:"button",className:O("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{t.logId!==null&&Bf(t.logId)},disabled:t.logId===null,children:[SC(t.kind),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),n.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function CC(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function kC(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function _C(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function TC(e,t){const s=e.replace(/\s+/g," ").trim();return s.length<=t?s:`${s.slice(0,t-3)}...`}function EC(e,t){const s=e[0],o=e[e.length-1];if(s===void 0)return"No evidence logs";const r=ds(s,t);return o===void 0||s===o?`#${r}`:`#${r}-#${ds(o,t)}`}function Jc(e){return e.join(", ")}function RC(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function MC({candidate:e,isPromoting:t,isUpdating:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,m]=l.useState(e.type),[u,p]=l.useState(e.title),[f,h]=l.useState(e.content),[g,b]=l.useState(Jc(e.tags)),[y,w]=l.useState(null),v=e.status!=="promoted",j=e.status!=="promoted",S=l.useCallback(()=>{m(e.type),p(e.title),h(e.content),b(Jc(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),R=f.trim(),P=RC(g);if(C.length===0){w("Title is required.");return}if(R.length===0){w("Content is required.");return}if(P.length===0){w("At least one tag is required.");return}w(null),await r(e.id,{type:d,title:C,content:R,tags:P})&&c(!1)},[e.id,f,g,u,d,r]);return i?n.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("select",{value:d,disabled:s,onChange:C=>{const R=ro.shape.type.safeParse(C.currentTarget.value);R.success&&m(R.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[n.jsx("option",{value:"episode",children:"episode"}),n.jsx("option",{value:"procedure",children:"procedure"}),n.jsx("option",{value:"preference",children:"preference"}),n.jsx("option",{value:"project-fact",children:"project-fact"})]}),n.jsx("input",{value:u,disabled:s,onChange:C=>p(C.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 min-w-[220px] flex-1 rounded-md px-2 text-xs","aria-label":"Candidate title"})]}),n.jsx("textarea",{value:f,disabled:s,onChange:C=>h(C.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground min-h-28 rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed","aria-label":"Candidate content"}),n.jsx("input",{value:g,disabled:s,onChange:C=>b(C.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate tags"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx(tc,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),n.jsx("span",{className:"flex-1"}),y!==null&&n.jsx("span",{className:"text-[10px] text-destructive",children:y}),n.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{S(),c(!1)},children:[n.jsx(Qs,{className:"size-3.5"}),"Cancel"]}),n.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?n.jsx(Ct,{className:"size-3.5 animate-spin"}):n.jsx(g1,{className:"size-3.5"}),"Save"]})]})]})}):n.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Ce,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),n.jsx(Ce,{variant:"outline",className:O("h-5 shrink-0 px-1.5 text-[10px] font-mono",hC[e.status]),children:CC(e.status)})]}),n.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:TC(e.content,360)}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(bg,{className:"size-3"}),EC(e.logIds,a)]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(tc,{className:"size-3"}),_C(e)]}),e.status==="promoted"&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[n.jsx(Xa,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[n.jsx(ku,{className:"size-3"}),e.error]})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const R=ds(C,a);return n.jsxs("a",{href:`#${Ff(C)}`,onClick:P=>{P.preventDefault(),Bf(C)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${R}`,title:`Log ID ${String(C)}`,children:["#",R]},C)}),n.jsx("span",{className:"flex-1"}),j&&n.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||t,onClick:()=>c(!0),children:[n.jsx(Iu,{className:"size-3"}),"Review"]}),n.jsxs(ee,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>o(e.id),disabled:!v||t||s,children:[t?n.jsx(Ct,{className:"size-3 animate-spin"}):v?n.jsx(Q0,{className:"size-3"}):n.jsx(Xa,{className:"size-3"}),kC(e,t)]})]})]})}function AC({candidates:e,promotingCandidateIds:t,updatingCandidateIds:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){return e.length===0?null:n.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>n.jsx(MC,{candidate:i,isPromoting:t.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a},i.id))})}function IC({logs:e,scopeId:t,slowResponseThresholdSeconds:s,showRollupMetrics:o,timeDisplayFormat:r}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[m,u]=l.useState({status:"idle",error:null}),[p,f]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),b=a.length>0,y=l.useMemo(()=>JN(e,s,a.length),[a.length,e,s]),w=l.useMemo(()=>wC(e),[e]),v=l.useMemo(()=>jC({logs:e,scopeId:t,summary:y,candidates:a,displayNumberByLogId:w}),[a,w,e,t,y]),j=o||y.maxElapsedMs!==null,S=l.useMemo(()=>xC(y.startedAt,y.endedAt,r),[y.endedAt,y.startedAt,r]),N=l.useCallback(()=>{e.length===0||m.status==="loading"||(u({status:"loading",error:null}),(async()=>{try{const P=await Le(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,lC,mC,{method:"POST"},L=>`Candidate generation failed with ${String(L.status)}`);i(P.candidates),d(P.candidates.length>0),u(P.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(P){u({status:"failed",error:P instanceof Error?P.message:"Candidate response was invalid"})}})())},[m.status,e.length,t]),C=l.useCallback(P=>{f(L=>{if(L.has(P))return L;const M=new Set(L);return M.add(P),M}),(async()=>{try{const L=await In(`/api/knowledge/candidates/${encodeURIComponent(P)}/promote`,pC,{method:"POST"}),M=await L.json().catch(()=>null),k=cC.safeParse(M);if(L.ok&&k.success){i(D=>D.map(F=>F.id===k.data.candidate.id?k.data.candidate:F)),u({status:"ready",error:null});return}const A=dC.safeParse(M);A.success&&A.data.candidate!==void 0&&i(D=>D.map(F=>F.id===A.data.candidate?.id?A.data.candidate:F)),u({status:"failed",error:A.success?A.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(L.status)}`})}catch(L){u({status:"failed",error:L instanceof Error?L.message:"Candidate promotion failed"})}finally{f(L=>{const M=new Set(L);return M.delete(P),M})}})()},[]),R=l.useCallback(async(P,L)=>{g(M=>{if(M.has(P))return M;const k=new Set(M);return k.add(P),k});try{const M=await Le(`/api/knowledge/candidates/${encodeURIComponent(P)}`,uC,fC,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(A=>A.id===M.candidate.id?M.candidate:A)),u({status:"ready",error:null}),!0}catch(M){return u({status:"failed",error:M instanceof Error?M.message:"Candidate update failed"}),!1}finally{g(M=>{const k=new Set(M);return k.delete(P),k})}},[]);return e.length===0?null:n.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[o&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[n.jsx(wr,{className:"size-3.5 text-blue-400"}),y.llmCallCount," LLM"]}),n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Zs,{className:"size-3.5 text-sky-400/70"}),y.toolCallCount," tools"]}),o&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Bs,{className:"size-3.5 text-emerald-400"}),n.jsxs("span",{className:"font-mono",children:[Ee(y.totalInputTokens)," / ",Ee(y.totalOutputTokens)]})]}),(y.totalCacheCreationInputTokens>0||y.totalCacheReadInputTokens>0)&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Bs,{className:"size-3.5 text-purple-400"}),n.jsxs("span",{className:"font-mono",children:["KV Cache +",Ee(y.totalCacheCreationInputTokens)," / ~",Ee(y.totalCacheReadInputTokens)]})]}),j&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Xt,{className:"size-3.5"}),o&&n.jsx("span",{className:"font-mono",children:Si(y.totalElapsedMs)}),y.maxElapsedMs!==null&&n.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Si(y.maxElapsedMs)]})]}),o&&S!==null&&n.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(y.failedCallCount>0||y.pendingCallCount>0||y.slowCallCount>0)&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[n.jsx(fn,{className:"size-3.5"}),n.jsxs("span",{className:"font-mono",children:[y.failedCallCount," fail / ",y.pendingCallCount," pending /"," ",y.slowCallCount," slow"]})]}),n.jsx("span",{className:"flex-1"}),b&&n.jsx(Ce,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:gC(y.knowledgeCandidateCount)}),n.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:N,disabled:m.status==="loading",children:[m.status==="loading"?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Cu,{className:"size-3.5"}),"Candidate"]}),b&&n.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(P=>!P),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?n.jsx(We,{className:"size-3.5"}):n.jsx(ft,{className:"size-3.5"})})]}),m.status==="failed"&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:m.error}),n.jsx(NC,{insights:v}),c&&n.jsx(AC,{candidates:a,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:R,displayNumberByLogId:w})]})}function PC(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalInputTokens:t,totalOutputTokens:s}}function LC(e){const t=new Map;for(const s of e){if(s.model===null)continue;const o=Gj(s.model);if(o==="unknown")continue;let r=t.get(o);r===void 0&&(r=new Set,t.set(o,r)),r.add(s.model)}return[...t.entries()].map(([s,o])=>({provider:s,models:[...o]}))}function OC(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function DC(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const zC=l.memo(function({group:e,viewMode:t="simple",strip:s,slowResponseThresholdSeconds:o,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:m=!0,showLogClientMetadata:u=!0,defaultExpanded:p=!1,timeDisplayFormat:f,expanded:h,onExpandedChange:g}){const[b,y]=l.useState(p),w=h??b,v=l.useCallback(k=>{if(g!==void 0){g(k);return}y(k)},[g]);l.useEffect(()=>{!p||h!==void 0||y(!0)},[h,p]);const j=l.useMemo(()=>PC(e.logs),[e.logs]),S=l.useMemo(()=>LC(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),R=e.logs.some(k=>k.responseStatus===null),P=l.useMemo(()=>OC(e.logs),[e.logs]),L=l.useMemo(()=>DC(e.logs),[e.logs]),M=l.useMemo(()=>ji(e.logs),[e.logs]);return l.useEffect(()=>{const k=A=>{const D=Vr(A);D!==null&&e.logs.some(F=>F.id===D.logId)&&v(!0)};return window.addEventListener(en,k),()=>{window.removeEventListener(en,k)}},[e.logs,v]),n.jsxs("div",{className:"mb-1.5",children:[n.jsx(T5,{conversationId:e.conversationId,startTime:N,endTime:C,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>v(!w),providers:S,isLoading:R,userAgent:e.logs[0]?.userAgent??null,clientPid:P,clientProjectFolder:L,showClientIdentity:d,showProcessMetadata:m,timeDisplayFormat:f,onClear:()=>c(e.logs.map(k=>k.id))}),w&&n.jsxs("div",{children:[n.jsx(IC,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:o,showRollupMetrics:!1,timeDisplayFormat:f}),n.jsx(sC,{turnGroups:M,viewMode:t,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:f,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),$C="flex w-full min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/35 px-3 py-2 sm:w-auto sm:max-w-full",FC="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function BC(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function UC(e){return e==="full"}function qC(e){return e==="raw"}function HC(e,t){const s=t>0;return{redacted:s,raw:s&&UC(e)}}function VC(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:jr(s.timestamp,o.timestamp,t)}function WC(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function GC(e){const t=new Set;for(const o of e)o.model!==null&&o.model.length>0&&t.add(o.model);const s=[...t].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function KC(e){const t=new Set;for(const o of e)o.providerName!==null&&o.providerName!==void 0&&o.providerName.length>0&&t.add(o.providerName);const s=[...t].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function YC(e){if(e<1e3)return`${e}ms`;if(e<6e4){const r=e/1e3;return`${r<10?r.toFixed(1):r.toFixed(0)}s`}const t=Math.round(e/1e3),s=Math.floor(t/60),o=t%60;return`${s}m ${o}s`}function JC(e,t){return`${Ee(e)} in / ${Ee(t)} out`}function XC(e,t){if(e.length===0)return 0;if(t.length===0)return ji(e).length;let s=0;for(const o of t)s+=ji(o.logs).length;return s}function ZC({stopReason:e,pending:t,lastFailureLogNumber:s}){if(t>0)return{label:"In flight",detail:`${t} request${t===1?"":"s"} pending`,tone:"cool"};if(s!==null&&e===null)return{label:"Error",detail:`Last failed request #${s}`,tone:"danger"};switch(e){case"end_turn":return{label:"End turn",detail:"Assistant completed the turn",tone:"neutral"};case"stop":return{label:"Stop",detail:"Model reached a stop condition",tone:"neutral"};case"length":return{label:"Output limit",detail:"Turn ended at max output tokens",tone:"watch"};case"tool_use":return{label:"Tool call",detail:"Assistant requested a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No finish reason captured",tone:"neutral"}}}function QC(e){if(e===null)return!1;const t=e.toLowerCase();return t.includes("abort")||t.includes("cancel")||t.includes("client disconnected")||t.includes("stream disconnected")||t.includes("connection closed")}function ek({pending:e,failures:t,lengthStops:s,stopReason:o,lastFailure:r}){if(r!==null&&(r.status===499||QC(r.error)))return{label:"Client aborted",detail:`Request #${r.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(r!==null&&r.status!==null&&r.status>=500)return{label:"Provider error",detail:`Request #${r.logNumber} returned HTTP ${r.status}`,tone:"danger"};if(t>0&&r!==null)return{label:"Failed",detail:`Request #${r.logNumber} needs attention`,tone:"danger"};if(s>0||o==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(o){case"end_turn":case"stop":return{label:"Completed",detail:"Assistant completed normally",tone:"neutral"};case"tool_use":return{label:"Tool requested",detail:"Assistant handed off to a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No terminal signal captured",tone:"neutral"}}}function tk({logs:e,conversationGroups:t,isLoading:s,timeDisplayFormat:o,slowResponseThresholdSeconds:r}){let a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=null,h=null,g=null,b=null,y=0,w=0,v=0,j=null;const S=r*1e3;for(let L=0;L<e.length;L+=1){const M=e[L];if(M===void 0)continue;const k=L+1,A=Nf(M);A!==null&&(p=A),A==="length"&&(d+=1),WC(M)&&(a+=1,f=k,h={logNumber:k,status:M.responseStatus,error:M.error??null}),M.responseStatus===null&&(i+=1),r>0&&M.elapsedMs!==null&&M.elapsedMs>=S&&(c+=1),M.inputTokens!==null&&(m+=M.inputTokens),M.outputTokens!==null&&(u+=M.outputTokens),M.elapsedMs!==null&&(g===null||M.elapsedMs>g)&&(g=M.elapsedMs,b=k);const D=M.inputTokens??0,F=M.outputTokens??0,Y=D+F;Y>y&&(y=Y,w=D,v=F,j=k)}const N=s||i>0&&a===0?"rolling":a>0?"failed":c>0||d>0?"watch":"clear",C=N==="rolling"?"Rolling":N==="failed"?"Failure":N==="watch"?"Watch":"Clear",R=ZC({stopReason:p,pending:i,lastFailureLogNumber:f}),P=ek({pending:i,failures:a,lengthStops:d,stopReason:p,lastFailure:h});return{status:N,statusLabel:C,modelLabel:GC(e),providerLabel:KC(e),requests:e.length,turns:XC(e,t),failures:a,pending:i,slow:c,lengthStops:d,timeRange:VC(e,o),tokenLabel:`${Ee(m)} in / ${Ee(u)} out`,finishLabel:R.label,finishDetail:R.detail,finishTone:R.tone,outcomeLabel:P.label,outcomeDetail:P.detail,outcomeTone:P.tone,slowestLabel:g===null?"n/a":YC(g),slowestDetail:b===null?"Latency pending":`Request #${b}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${JC(w,v)}`}}function nk({pinnedSessionId:e,selectedSession:t,sessions:s,logs:o}){if(e!==void 0){const i=o.filter(c=>c.sessionId===e);return i.length===0?null:{label:e,logs:i,showBackLink:!0}}if(t!=="__all__"){const i=o.filter(c=>c.sessionId===t);return i.length===0?null:{label:t,logs:i,showBackLink:!0}}const r=s.length===1?s[0]??null:null;return r!==null&&o.every(c=>c.sessionId===r)?{label:r,logs:[...o],showBackLink:!1}:s.length===0&&o.length>0&&o.every(i=>i.sessionId===null)?{label:"Visible requests",logs:[...o],showBackLink:!1}:null}function sk({logs:e,pagination:t}){if(t.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const s=e[0],o=e[e.length-1],r=s===void 0||o===void 0?"Current page":`#${s.id}-#${o.id}`;return t.total===null?`Showing ${e.length} logs (${r})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${r})`}function Vs({...e}){return n.jsx(hp,{"data-slot":"select",...e})}function dr({...e}){return n.jsx(vp,{"data-slot":"select-value",...e})}function Ws({className:e,size:t="default",children:s,...o}){return n.jsxs(gp,{"data-slot":"select-trigger","data-size":t,className:O("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[s,n.jsx(yp,{asChild:!0,children:n.jsx(We,{className:"size-4 opacity-50"})})]})}function Gs({className:e,children:t,position:s="popper",align:o="center",...r}){return n.jsx(jp,{children:n.jsxs(Sp,{"data-slot":"select-content",className:O("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:o,...r,children:[n.jsx(ok,{}),n.jsx(Tp,{className:O("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),n.jsx(rk,{})]})})}function ot({className:e,children:t,...s}){return n.jsxs(Ap,{"data-slot":"select-item",className:O("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[n.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:n.jsx(Lp,{children:n.jsx(Pe,{className:"size-4"})})}),n.jsx(Ip,{children:t})]})}function ok({className:e,...t}){return n.jsx(Op,{"data-slot":"select-scroll-up-button",className:O("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(Ki,{className:"size-4"})})}function rk({className:e,...t}){return n.jsx(Dp,{"data-slot":"select-scroll-down-button",className:O("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(We,{className:"size-4"})})}const ak=ue(["critical","warning","notice"]),ik=ue(["open"]),lk=ue(["proxy","tool-schema","run","group"]),Uf=ue(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),ck=ue(["log","session","run","group"]),dk=ue(["anthropic","openai","unknown"]),uk=_({kind:ck,id:x(),label:x(),href:x().nullable()}),mk=_({id:x(),fingerprint:x(),severity:ak,category:Uf,source:lk,status:ik,title:x(),message:x(),count:E().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:W(kt),sessionIds:W(x()),runIds:W(x()),groupIds:W(x()),provider:x().nullable(),model:x().nullable(),apiFormat:dk.nullable(),evidence:W(uk),metadata:De(x(),Ve)}),pk=_({category:Uf,count:E().int().nonnegative()}),qf=_({total:E().int().nonnegative(),open:E().int().nonnegative(),critical:E().int().nonnegative(),warning:E().int().nonnegative(),notice:E().int().nonnegative(),byCategory:W(pk)}),fk=_({alerts:W(mk),total:E().int().nonnegative(),limit:E().int().positive(),summary:qf}),hk=8e3,xk=1e4;function gk(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const s=t.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function bk(e,t){const s=Ot(t?gk(e):null,o=>Le(o,fk,xk));return{alerts:s.data?.alerts??[],total:s.data?.total??0,summary:s.data?.summary??null,isLoading:s.isLoading,error:s.error,mutate:s.mutate}}function vk(){const e=Ot("/api/alerts/summary",t=>Le(t,qf,hk),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const ao="relative size-9 rounded-md border border-border/70 bg-muted/60 text-muted-foreground transition-colors hover:bg-muted hover:text-accent-foreground focus-visible:ring-ring/50 max-lg:size-11",yk=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Hf(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function wk(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Dl(e){switch(e){case"request-failure":return"Request failure";case"request-timeout":return"Timeout";case"slow-response":return"Slow response";case"tool-schema":return"Tool calling";case"run-failure":return"Run failure";case"group-failure":return"Group failure";case"group-incomplete":return"Group incomplete"}}function jk(e){switch(e){case"critical":return"border-status-danger/40 bg-status-danger/10 text-status-danger";case"warning":return"border-status-watch/40 bg-status-watch/10 text-status-watch";case"notice":return"border-status-cool/40 bg-status-cool/10 text-status-cool"}}function Sk(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function Nk(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function Ck(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return n.jsx(E1,{className:"size-3.5"});case"request-timeout":case"slow-response":return n.jsx(J0,{className:"size-3.5"});case"tool-schema":return n.jsx(fn,{className:"size-3.5"});case"group-incomplete":return n.jsx(v0,{className:"size-3.5"})}}function Ni(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function mt(e){return e.toLocaleString()}function Vf(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function kk(e,t){const s={limit:100};return e!=="all"&&(s.severity=e),t!=="all"&&(s.category=t),s}function _k(e,t){if(t!==null){const s=e.find(o=>o.id===t);if(s!==void 0)return s}return e[0]??null}function No({label:e,count:t,tone:s}){const o=s==="critical"?"border-status-danger/30 bg-status-danger/10 text-status-danger":s==="warning"?"border-status-watch/30 bg-status-watch/10 text-status-watch":s==="notice"?"border-status-cool/30 bg-status-cool/10 text-status-cool":"border-border bg-muted/40 text-foreground";return n.jsxs("div",{className:O("rounded-md border px-3 py-2",o),children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),n.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:mt(t)})]})}function Co({value:e,active:t,label:s,count:o,onClick:r}){return n.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[s,o!==null?n.jsx(Ce,{variant:"outline",children:mt(o)}):null]})}function Tk({category:e,active:t,count:s,onClick:o}){return n.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[Ck(e),Dl(e),n.jsx(Ce,{variant:"outline",children:mt(s)})]})}function Ek({alerts:e,selectedAlertId:t,isLoading:s,error:o,onSelect:r}){return s?n.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[n.jsx(Oe,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):o!==void 0?n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?n.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):n.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===t;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-3 text-left transition-colors",i?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:O("size-2 rounded-full",Sk(a.severity))}),n.jsx("span",{className:O("text-xs font-semibold",Nk(a.severity)),children:Hf(a.severity)}),n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Dl(a.category)})]}),n.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),n.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?n.jsxs(Ce,{variant:"outline",className:"shrink-0",children:["x",mt(a.count)]}):null]}),n.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 leading-snug",children:Vf(a)}),n.jsx("span",{className:"shrink-0",children:Ni(a.lastSeenAt)})]})]},a.id)})})}function Rk({alert:e,onNavigate:t}){return e.evidence.length===0?n.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):n.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?n.jsx(Ce,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):n.jsx(Ce,{variant:"outline",asChild:!0,children:n.jsx("a",{href:s.href,onClick:t,children:s.label})},`${s.kind}:${s.id}`))})}function Mk({alert:e,onNavigate:t}){return e===null?n.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):n.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[n.jsx("div",{className:O("border-b px-4 py-3",jk(e.severity)),children:n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(Ce,{variant:"outline",children:Hf(e.severity)}),n.jsx(Ce,{variant:"outline",children:wk(e.source)}),n.jsx(Ce,{variant:"outline",children:Dl(e.category)})]}),n.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),n.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?n.jsxs(Ce,{variant:"outline",className:"shrink-0",children:[mt(e.count)," hits"]}):null]})}),n.jsxs("div",{className:"space-y-4 p-4",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsx(rn,{label:"Target",value:Vf(e)}),n.jsx(rn,{label:"Last seen",value:Ni(e.lastSeenAt)}),n.jsx(rn,{label:"First seen",value:Ni(e.firstSeenAt)}),n.jsx(rn,{label:"Protocol",value:e.apiFormat??"n/a"})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),n.jsx(Rk,{alert:e,onNavigate:t})]}),n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsx(rn,{label:"Logs",value:e.logIds.length===0?"n/a":mt(e.logIds.length)}),n.jsx(rn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":mt(e.sessionIds.length)}),n.jsx(rn,{label:"Runs",value:e.runIds.length===0?"n/a":mt(e.runIds.length)}),n.jsx(rn,{label:"Groups",value:e.groupIds.length===0?"n/a":mt(e.groupIds.length)})]})]})]})}function rn({label:e,value:t}){return n.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),n.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function Ak(){const[e,t]=l.useState(!1),[s,o]=l.useState("all"),[r,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:m}=vk(),u=l.useMemo(()=>kk(s,r),[r,s]),{alerts:p,total:f,isLoading:h,error:g,mutate:b}=bk(u,e),y=l.useMemo(()=>_k(p,i),[p,i]);l.useEffect(()=>{!e||i!==null&&p.some(R=>R.id===i)||c(p[0]?.id??null)},[p,e,i]);const w=d?.total??0,v=d?.critical??0,j=d?.warning??0,S=d?.notice??0,N=v>0?"bg-status-danger text-primary-foreground":j>0?"bg-status-watch text-primary-foreground":"bg-status-cool text-primary-foreground";return n.jsxs(Ft,{open:e,onOpenChange:t,children:[n.jsx(so,{asChild:!0,children:n.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ao,"aria-label":"Alerts",title:"Alerts",children:[n.jsx(Xo,{className:"size-4"}),m?n.jsx(Oe,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?n.jsx("span",{className:O("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:mt(w)}):null,n.jsx("span",{className:"sr-only",children:"Alerts"})]})}),n.jsxs(Bt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[n.jsxs(Wt,{children:[n.jsxs(Gt,{className:"flex items-center gap-2 pr-8",children:[n.jsx(Xo,{className:"size-5 text-status-danger"}),n.jsx("span",{children:"Alerts"}),n.jsx(Ce,{variant:"outline",children:mt(w)})]}),n.jsx(oo,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(No,{label:"Open",count:d?.open??0,tone:"neutral"}),n.jsx(No,{label:"Critical",count:v,tone:"critical"}),n.jsx(No,{label:"Warning",count:j,tone:"warning"}),n.jsx(No,{label:"Notice",count:S,tone:"notice"})]}),n.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.jsx(Co,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:o}),n.jsx(Co,{value:"critical",active:s==="critical",label:"Critical",count:v,onClick:o}),n.jsx(Co,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:o}),n.jsx(Co,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:o})]}),n.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{b()},children:[n.jsx(Ct,{className:"size-3.5"}),"Refresh"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.jsx(ee,{type:"button",variant:r==="all"?"secondary":"ghost",size:"sm","aria-pressed":r==="all",onClick:()=>a("all"),className:"h-7 px-2",children:"All categories"}),yk.map(C=>{const R=d?.byCategory.find(P=>P.category===C)?.count??0;return R===0?null:n.jsx(Tk,{category:C,active:r===C,count:R,onClick:a},C)})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[mt(f)," matched"]}),n.jsx("span",{children:p.length<f?`${mt(p.length)} shown`:"Latest"})]}),n.jsx(Ek,{alerts:p,selectedAlertId:y?.id??null,isLoading:h,error:g,onSelect:c})]}),n.jsx(Mk,{alert:y,onNavigate:()=>t(!1)})]})]})]})}const Ik=12e3;function Pk(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function Lk(e){const t=Ot(Pk(e),s=>Le(s,Gx,Ik));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const Ok=8e3;function Dk(){const e=Ot("/api/groups",t=>Le(t,ju,Ok));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const zk=3e3;function $k(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function Wf(){const[e,t]=l.useState(null),s=l.useCallback(r=>{t(a=>$k(a,r))},[]),o=l.useCallback(()=>{t(null)},[]);return l.useEffect(()=>{if(e===null)return;const r=window.setTimeout(()=>{t(null)},zk);return()=>{window.clearTimeout(r)}},[e]),{notice:e,showToast:s,dismissToast:o}}function Gf({notice:e,onDismiss:t}){if(e===null)return null;const s=e.tone==="error",o=s?fn:Xa;return n.jsx("div",{"aria-atomic":"true","aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[100] w-[min(calc(100vw-2rem),26rem)]",role:"status",children:n.jsxs("div",{className:O("pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",s?"border-status-danger/35":"border-status-success/35"),children:[n.jsx(o,{className:O("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),n.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),n.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/10 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none","aria-label":"Dismiss notification",onClick:t,children:n.jsx(Qs,{className:"size-3.5"})})]},e.id)})}const Ea=2e4;function Fk(e,t){const s=`/api/groups/${encodeURIComponent(e)}`;return t?`${s}?deleteEvidence=1`:s}function Bk(e){return"/api/groups"}function Kf(e){let t=0,s=0,o=0,r=0;for(const a of e.members)switch(a.status){case"completed":t+=1;break;case"failed":case"cancelled":s+=1;break;case"running":o+=1;break;case"created":break;case null:r+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:s,runningMembers:o,missingStatusMembers:r}}function Uk(e,t,s=null){return t!==null&&t.group.id===e.id?t.members.map(o=>({member:o.member,exportMember:o,source:"export"})):s!==null&&s.group.id===e.id&&s.members!==null?s.members.map(o=>({member:o.member,exportMember:o,source:"evidence"})):e.members.map(o=>({member:o,exportMember:null,source:"group"}))}function zl(e){switch(e){case"completed":return"border-status-success/30 bg-status-success/10 text-status-success";case"failed":case"cancelled":return"border-status-danger/30 bg-status-danger/10 text-status-danger";case"running":return"border-status-cool/30 bg-status-cool/10 text-status-cool";case"created":return"border-border bg-muted/30 text-muted-foreground";case null:return"border-border bg-muted/30 text-muted-foreground"}}function $l(e){return e??"unknown"}function qk(e){switch(e){case"PASS":return"border-status-success/30 bg-status-success/10 text-status-success";case"FAIL":return"border-status-danger/30 bg-status-danger/10 text-status-danger";case"RUNNING":return"border-status-cool/30 bg-status-cool/10 text-status-cool";case"UNKNOWN":return"border-border bg-muted/30 text-muted-foreground"}}function Wr(e){return e===null||e.trim().length===0?"-":e}function ut(e){return e.toLocaleString()}function Ci(e){return e==null?"-":e<1e3?`${ut(e)} ms`:`${(e/1e3).toFixed(1)} s`}function ys(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function Xc(e){return e===null?"-":ys(e)}function Hk(e){const t=JSON.stringify(e),s=t===void 0?String(e):t;return s.length<=160?s:`${s.slice(0,157)}...`}function Yf(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function Vk(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function Wk(e){const t=e.provider,s=e.model;return t!==null&&t.length>0&&s!==null&&s.length>0?`${t} / ${s}`:Yf(t,s)}function Gk(e,t){if(t!==null){const s=e.find(o=>o.id===t);if(s!==void 0)return s}return e[0]??null}function Kk(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function Yk(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function Jk(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function Xk(e,t,s){return t!==null&&t.group.id===e.id?t.summary:s!==null&&s.group.id===e.id?s.summary:null}function Zk(e,t,s){return t!==null&&t.group.id===e.id?t.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function Qk({labelledTrigger:e=!1}){const[t,s]=l.useState(!1),[o,r]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(!1),[b,y]=l.useState(null),[w,v]=l.useState(null),[j,S]=l.useState(!1),{notice:N,showToast:C,dismissToast:R}=Wf(),{groups:P,isLoading:L,error:M,mutate:k}=Dk(),A=l.useMemo(()=>Gk(P,o),[P,o]);l.useEffect(()=>{!t||o!==null&&P.some(z=>z.id===o)||r(P[0]?.id??null)},[P,t,o]);const D=A!==null&&m!==null&&m.group.id===A.id?m:null,{evidenceResponse:F,isLoading:Y,error:X,mutate:$}=Lk(A),V=l.useCallback(()=>{k()},[k]),J=l.useCallback(async()=>{if(!(P.length===0||j)){S(!0),f(null),g(!1),v(null),d(null);try{const ie=await Le(Bk(!1),vu,Ea,{method:"DELETE"},z=>`Clear failed with status ${String(z.status)}`);u(null),r(null),await k(),await $(),C({message:`Cleared ${ut(ie.deleted)} group${ie.deleted===1?"":"s"}.`,tone:"success"})}catch(ie){C({message:ie instanceof Error?ie.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,P.length,k,$,C]),U=l.useCallback(async ie=>{i(ie.id),d(null);try{const z=await Le(`/api/groups/${encodeURIComponent(ie.id)}/evidence`,Kx,Ea,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},Z=>`Export failed with status ${String(Z.status)}`);u(z),await k(),await $()}catch(z){d(z instanceof Error?z.message:String(z))}finally{i(null)}},[k,$]),K=l.useCallback(ie=>{f(ie),g(!1),v(null)},[]),ae=l.useCallback(()=>{b===null&&(f(null),g(!1),v(null))},[b]),be=l.useCallback(ie=>{r(ie),f(null),g(!1),v(null)},[]),ve=l.useCallback(async()=>{const ie=p;if(ie!==null){y(ie.id),v(null);try{await Le(Fk(ie.id,h),bu,Ea,{method:"DELETE"},z=>`Delete failed with status ${String(z.status)}`),u(z=>z!==null&&z.group.id===ie.id?null:z),r(z=>z===ie.id?null:z),f(null),g(!1),await k(),await $()}catch(z){v(z instanceof Error?z.message:String(z))}finally{y(null)}}},[h,p,k,$]);return n.jsxs(Ft,{open:t,onOpenChange:s,children:[n.jsx(Gf,{notice:N,onDismiss:R}),n.jsx(so,{asChild:!0,children:n.jsxs(ee,{type:"button",variant:"ghost",size:e?"default":"icon",className:O(ao,e&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"Evaluation groups",title:"Evaluation groups",children:[n.jsx(Zl,{className:"size-4"}),L?n.jsx(Oe,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):P.length>0?n.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:P.length}):null,n.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),n.jsxs(Bt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Wt,{children:n.jsxs(Gt,{className:"flex items-center gap-2 pr-8",children:[n.jsx(Zl,{className:"size-5 text-muted-foreground"}),n.jsx("span",{children:"Groups"}),n.jsx(Ce,{variant:"outline",children:ut(P.length)})]})}),n.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:P.length===0||j,onClick:()=>{J()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(gn,{className:"size-3.5"}),"Clear"]}),n.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:V,children:[n.jsx(Ct,{className:"size-3.5"}),"Refresh"]})]})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[n.jsx(e3,{groups:P,selectedGroupId:A?.id??null,isLoading:L,error:M,onSelect:be}),n.jsx(t3,{group:A,deleteTarget:p,deleteEvidence:h,exportResult:D,evidenceResponse:F,evidenceLoading:Y,evidenceError:X,exportError:c,deleteError:w,exportingGroupId:a,deletingGroupId:b,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:K,onCancelDelete:ae,onConfirmDelete:()=>{ve()}})]})]})]})}function e3({groups:e,selectedGroupId:t,isLoading:s,error:o,onSelect:r}){return s?n.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):o!==void 0?n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?n.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):n.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:n.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=Kf(a),c=t===a.id;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",c?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),n.jsx(Ce,{variant:"outline",className:zl(a.status),children:$l(a.status)})]}),n.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[n.jsxs("span",{children:[i.memberCount," sessions"]}),n.jsx("span",{children:ys(a.updatedAt)})]})]},a.id)})})})}function t3({group:e,deleteTarget:t,deleteEvidence:s,exportResult:o,evidenceResponse:r,evidenceLoading:a,evidenceError:i,exportError:c,deleteError:d,exportingGroupId:m,deletingGroupId:u,onDeleteEvidenceChange:p,onExport:f,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:b}){if(e===null)return n.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const y=Kf(e),w=Xk(e,o,r),v=Zk(e,o,r),j=Jk(e,o),S=Uk(e,o,r),N=m===e.id,C=u===e.id,R=t?.id===e.id;return n.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),n.jsx(Ce,{variant:"outline",className:zl(e.status),children:$l(e.status)}),n.jsx(Ce,{variant:"outline",children:e.kind})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:Wr(e.project)}),n.jsxs("span",{children:["updated ",ys(e.updatedAt)]})]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(ee,{type:"button",variant:"outline",size:"icon",className:"size-8 text-status-danger hover:text-status-danger/80","aria-label":"Delete group",title:"Delete group",disabled:C,onClick:()=>h(e),children:C?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(gn,{className:"size-3.5"})}),n.jsxs(ee,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{f(e)},children:[N?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Xs,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&n.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),R&&n.jsx(n3,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:p,onCancel:g,onConfirm:b}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(an,{label:"Members",value:y.memberCount}),n.jsx(an,{label:"Done",value:y.completedMembers}),n.jsx(an,{label:"Failed",value:y.failedMembers}),n.jsx(an,{label:"Running",value:y.runningMembers})]}),w!==null&&n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(an,{label:"Requests",value:w.requestCount}),n.jsx(an,{label:"Errors",value:w.errorCount}),n.jsx(an,{label:"Tokens",value:w.tokenUsage.total}),n.jsx(an,{label:"Missing",value:w.missingSessions})]}),n.jsx(s3,{report:v,loading:a,error:i,hasEvidence:j!==null}),n.jsx(o3,{evidence:j}),c!==null&&n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:c}),d!==null&&!R&&n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:d}),n.jsx(r3,{rows:S})]})})}function n3({group:e,deleteEvidence:t,isDeleting:s,error:o,onDeleteEvidenceChange:r,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:n.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[n.jsx(gn,{className:"size-4 text-status-danger"}),n.jsx("span",{children:"Delete group?"})]}),n.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",n.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),n.jsxs("label",{className:O("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[n.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!c||s,onChange:m=>r(m.currentTarget.checked)}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),n.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),o!==null&&n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:o})]}),n.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[n.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),n.jsxs(ee,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(gn,{className:"size-3.5"}),"Delete"]})]})]})})}function an({label:e,value:t}){return n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),n.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:ut(t)})]})}function s3({report:e,loading:t,error:s,hasEvidence:o}){const{copied:r,copy:a}=un(e?.markdown??null);return e===null&&!t&&s===void 0?null:t?n.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx(Oe,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&o?n.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:["Failed to load evidence report: ",s.message]}):e===null?null:n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),n.jsx(Ce,{variant:"outline",className:qk(e.status),children:e.status})]}),n.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":r?"Copied evidence report":"Copy evidence report",onClick:a,children:r?n.jsx(Pe,{className:"size-3.5 text-status-success"}):n.jsx(Et,{className:"size-3.5"})})]}),n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function o3({evidence:e}){return e===null?n.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):n.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),n.jsx("span",{className:"text-[11px] text-muted-foreground",children:ys(e.exportedAt)})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Ra,{label:"JSON",value:e.jsonPath}),n.jsx(Ra,{label:"Markdown",value:e.markdownPath}),n.jsx(Ra,{label:"HTML",value:e.htmlPath})]})]})}function Ra({label:e,value:t}){const{copied:s,copy:o}=un(t);return n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[n.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),n.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":s?`Copied ${e} path`:`Copy ${e} path`,onClick:o,children:s?n.jsx(Pe,{className:"size-3.5 text-status-success"}):n.jsx(Et,{className:"size-3.5"})})]})}function r3({rows:e}){const[t,s]=l.useState(null),o=l.useCallback(r=>{s(a=>a===r?null:r)},[]);return e.length===0?n.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[n.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),n.jsx("tbody",{children:e.map(r=>{const a=t===r.member.id;return n.jsxs(l.Fragment,{children:[n.jsx(a3,{row:r,isExpanded:a,onToggleDetails:o}),n.jsx(i3,{row:r,isExpanded:a})]},r.member.id)})})]})})]})}function a3({row:e,isExpanded:t,onToggleDetails:s}){const o=e.member,r=e.exportMember?.session??null,a=Kk(e),i=r?.inspectorPath??tu(o.sessionId),c=e.source!=="evidence",d=r?.requestCount??null,m=r?.errorCount??null,u=r?.tokenUsage.total??null,p=a?.firstChunkMs??null,f=Yf(o.label,o.sessionId),h=Vk(r?.clientUserAgent,a?.userAgent,o.agent),g=r?.clientProjectFolder??null,b=_l({userAgent:h,conversationId:o.sessionId,clientProjectFolder:g}),y=qr(b);return n.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[n.jsxs("td",{className:"max-w-56 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${f}`:`Show member ${f}`,title:t?"Hide member details":"Show member details",onClick:()=>{s(o.id)},children:t?n.jsx(We,{className:"size-3.5"}):n.jsx(ft,{className:"size-3.5"})}),y!==null&&n.jsx(Hr,{client:b,className:"size-5"}),c?n.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${f}`,title:`Open session ${f}`,children:[n.jsx("span",{className:"min-w-0 truncate",children:f}),n.jsx(Yi,{className:"size-3 shrink-0 text-muted-foreground"})]}):n.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${f}`,"aria-label":`Show evidence snapshot for ${f}`,onClick:()=>{s(o.id)},children:[n.jsx("span",{className:"min-w-0 truncate",children:f}),n.jsx(Ce,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),n.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Wr(o.agent)})]}),n.jsx("td",{className:"max-w-52 px-3 py-2",children:n.jsx("span",{className:"block whitespace-normal leading-snug",children:Wk(o)})}),n.jsx("td",{className:"px-3 py-2",children:n.jsx(Ce,{variant:"outline",className:zl(o.status),children:$l(o.status)})}),n.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ut(d)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:m===null?"-":ut(m)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:Ci(p)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ut(u)})]})}function i3({row:e,isExpanded:t}){if(!t)return null;const s=e.member,o=e.exportMember,r=o?.session??null,a=o?.run??null,i=Object.entries(s.metadata);return n.jsx("tr",{className:"border-b border-border bg-muted/10",children:n.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:n.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[n.jsx(Xe,{label:"Source",value:Yk(e.source)}),n.jsx(Xe,{label:"Member ID",value:s.id,mono:!0}),n.jsx(Xe,{label:"Session ID",value:s.sessionId,mono:!0}),n.jsx(Xe,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),n.jsx(Xe,{label:"Created",value:ys(s.addedAt)}),n.jsx(Xe,{label:"Updated",value:ys(s.updatedAt)}),n.jsx(Xe,{label:"Session created",value:Xc(r?.createdAt??null)}),n.jsx(Xe,{label:"Session updated",value:Xc(r?.updatedAt??null)})]}),r===null?n.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[n.jsx(Xe,{label:"Log coverage",value:r.logCoverage}),n.jsx(Xe,{label:"Runtime",value:Wr(r.runtimeMode)}),n.jsx(Xe,{label:"Requests",value:ut(r.requestCount),mono:!0}),n.jsx(Xe,{label:"Errors",value:ut(r.errorCount),mono:!0}),n.jsx(Xe,{label:"Input tokens",value:ut(r.tokenUsage.input),mono:!0}),n.jsx(Xe,{label:"Output tokens",value:ut(r.tokenUsage.output),mono:!0}),n.jsx(Xe,{label:"Cache read",value:ut(r.tokenUsage.cacheRead),mono:!0}),n.jsx(Xe,{label:"Total tokens",value:ut(r.tokenUsage.total),mono:!0})]}),n.jsx(l3,{logs:r?.latestLogs??[]}),n.jsx(c3,{entries:i})]})})})}function Xe({label:e,value:t,mono:s=!1}){return n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),n.jsx("div",{className:O("truncate text-xs text-foreground",s?"font-mono":""),title:t,children:t})]})}function l3({logs:e}){const t=e.slice(0,5);return t.length===0?n.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),n.jsx("div",{className:"divide-y divide-border",children:t.map(s=>{const o=s.sessionLogNumber??s.id;return n.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[n.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",o]}),n.jsxs("span",{className:"min-w-0 truncate",children:[Wr(s.model)," · ",s.apiFormat," · ",s.path]}),n.jsx("span",{className:"font-mono text-muted-foreground",children:Ci(s.firstChunkMs)}),n.jsx("span",{className:"font-mono text-muted-foreground",children:Ci(s.latencyMs)})]},s.id)})})]})}function c3({entries:e}){return e.length===0?null:n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),n.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,s])=>{const o=Hk(s);return n.jsxs("div",{className:"min-w-0",children:[n.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),n.jsx("span",{className:"font-mono text-foreground",title:o,children:o})]},t)})})]})}const d3=_({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:ue(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:W(x()),sourceTool:ue(["claude-code","opencode","mimo-code"]),alreadyExists:ke()}),u3=_({scanId:x().uuid(),providers:W(d3),warnings:W(x()).optional()});_({scanId:x().uuid(),selectionIds:W(x().uuid()).min(1).max(100)});const m3=_({success:ke().optional(),imported:E().optional(),message:x().optional(),errors:W(x()).optional()}),Zc=2e4;function p3({open:e,onOpenChange:t,onImportComplete:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState([]),[p,f]=l.useState([]),[h,g]=l.useState(new Set),[b,y]=l.useState(!1),[w,v]=l.useState(null),[j,S]=l.useState(null),N=l.useRef(0),C=l.useRef(0),R=l.useCallback(()=>{const k=N.current+1;N.current=k,r(!0),i(null),f([]),d(null),u([]),g(new Set),v(null),S(null),Le("/api/providers/scan",u3,Zc,{method:"POST"},A=>`Scan failed (${String(A.status)})`).then(A=>{if(N.current!==k)return;d(A.scanId),u(A.providers),f(A.warnings??[]);const D=new Set;A.providers.forEach((F,Y)=>{F.alreadyExists||D.add(Y)}),g(D)}).catch(A=>{N.current===k&&i(A instanceof Error?A.message:String(A))}).finally(()=>{N.current===k&&r(!1)})},[]);l.useEffect(()=>{e&&R()},[e,R]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,r(!1),y(!1))},[e]);const P=l.useCallback(k=>{g(A=>{const D=new Set(A);return D.has(k)?D.delete(k):D.add(k),D})},[]),L=l.useCallback(()=>{const k=m.filter((D,F)=>h.has(F));if(k.length===0||c===null)return;const A=C.current+1;C.current=A,y(!0),S(null),v(null),Le("/api/providers/import",m3,Zc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(D=>D.selectionId)})},D=>`Import failed (${String(D.status)})`).then(D=>{C.current===A&&(u(F=>F.map((Y,X)=>h.has(X)?{...Y,alreadyExists:!0}:Y)),g(new Set),D.errors!==void 0&&D.errors.length>0&&D.message!==void 0?v(D.message):v(`Imported ${D.imported??k.length} provider(s)`),s())}).catch(D=>{C.current===A&&S(D instanceof Error?D.message:String(D))}).finally(()=>{C.current===A&&y(!1)})},[m,c,h,s]),M=m.some(k=>!k.alreadyExists);return n.jsx(Ft,{open:e,onOpenChange:t,children:n.jsxs(Bt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Import from External Tools"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[o&&n.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[n.jsx(Oe,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&n.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[n.jsx(ps,{className:"size-4"}),a]}),!o&&a===null&&m.length===0&&n.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",n.jsx("br",{}),n.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!o&&m.map((k,A)=>n.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&n.jsx("input",{type:"checkbox",checked:h.has(A),disabled:b,onChange:()=>P(A),className:"mt-0.5 size-4"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Hr,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&n.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),n.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[k.models.slice(0,4).join(", "),k.models.length>4?` +${k.models.length-4} more`:""]}),n.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),n.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),p.length>0&&n.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((k,A)=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(ps,{className:"size-3"}),k]},A))}),w!==null&&n.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&n.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),n.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[n.jsxs(ee,{variant:"outline",size:"sm",onClick:R,disabled:o,children:[n.jsx(Oe,{className:`size-3 mr-1 ${o?"animate-spin":""}`}),"Rescan"]}),n.jsxs(ee,{size:"sm",onClick:L,disabled:!M||h.size===0||b,children:[n.jsx(Xs,{className:"size-3 mr-1"}),b?"Importing...":`Import Selected (${h.size})`]})]})]})})}const Jf=_({id:x().min(1).max(ni),aliases:W(x().max(ni)).max(hn).optional().default([]),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),sourceUrl:x().optional()}),f3=_({name:x().min(1).optional(),aliases:W(x()).max(hn).optional().default([]),baseUrls:W(x()).max(hn).optional().default([]),models:W(Jf).min(1).max(hn)});_({version:E().int().positive().optional(),updatedAt:x().optional(),providers:W(f3).max(hn).optional().default([]),models:W(Jf).max(hn).optional().default([])});function Qc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function h3(e){const t=e.models.filter(s=>s.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Fl(e,t){const s=Qc(t);return(e.modelMetadata??[]).find(r=>Qc(r.model)===s)??null}function x3(e){const t=h3(e);return t.length===0?!1:t.every(s=>{const o=Fl(e,s);return o!==null&&o.contextWindow!==void 0})}function g3(e,t){if(e===null)return null;for(const s of t){const o=Fl(s,e);if(o!==null&&o.contextWindow!==void 0)return{providerName:s.name,model:o.model,tokens:o.contextWindow,sourceUrl:o.sourceUrl}}return null}function Ks(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Gr(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function gt(e){return e!==void 0&&e!==""}function nt(e){return e!==void 0&&e.trim()!==""}function us(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Xf(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function Zf(e){switch(e){case"timeout":return"Timeout";case"network_unreachable":return"Offline";case"connection_refused":return"Refused";case"auth_failed":return"Auth";case"rate_limited":return"Rate limit";case"server_error":return"Server";case"invalid_response":return"Invalid";case"unknown":return"Failed"}}function b3(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?us(e.firstChunkMs):e.latencyMs!==void 0?us(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?us(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Xf(e.tokensPerSecond):null}function v3(e){return Gr(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:Ks(e)?e.success?{tone:"success",label:"Pass",metric:b3(e),hasDetails:!0}:{tone:"failure",label:Zf(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function y3(e,t){if(t===void 0)return[];const s=[];return gt(e.anthropicBaseUrl)&&s.push(t.anthropic),gt(e.openaiBaseUrl)&&s.push(t.openaiChat),gt(e.openaiResponsesBaseUrl)&&s.push(t.openaiResponses),s}function w3(e,t){const s={total:0,passed:0,failed:0,testing:0};for(const o of y3(e,t))for(const r of[o.nonStreaming,o.streaming])Gr(r)||(s.total+=1,Ks(r)?r.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function ed(e){if(e===void 0)return;const t=Object.entries(e).map(([s,o])=>`${s}: ${o}`);return t.length===0?void 0:t.join(`
58
58
  `)}function ln({title:e,children:t}){return n.jsxs("section",{className:"space-y-1.5",children:[n.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),t]})}function kn({value:e}){return n.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function _n({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[n.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),n.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:t,children:t})]})}function j3({result:e}){const t=e.inputTokens!==void 0||e.outputTokens!==void 0,s=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return nt(e.model)||t||s||e.latencyMs!==void 0||e.firstChunkMs!==void 0&&e.firstChunkMs!==null||e.totalStreamMs!==void 0&&e.totalStreamMs!==null||e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?n.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[nt(e.model)&&n.jsx(_n,{label:"Model",value:e.model}),e.latencyMs!==void 0&&n.jsx(_n,{label:"Latency",value:us(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&n.jsx(_n,{label:"First chunk",value:us(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&n.jsx(_n,{label:"Stream total",value:us(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&n.jsx(_n,{label:"Token rate",value:`${Xf(e.tokensPerSecond)} tok`}),t&&n.jsx(_n,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&n.jsx(_n,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function S3({result:e}){const t=e.debug,s=t?.requestUrl,o=t?.requestMethod??"POST",r=ed(t?.requestHeaders),a=ed(t?.responseHeaders),i=t?.responseStatus===void 0?void 0:`${String(t.responseStatus)}${nt(t.responseStatusText)?` ${t.responseStatusText}`:""}`,c=t?.responseBody??e.rawResponse;return nt(e.error?.hint)||nt(e.error?.details)||nt(s)||r!==void 0||nt(t?.requestBody)||nt(i)||a!==void 0||nt(c)?n.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[nt(e.error?.hint)&&n.jsx(ln,{title:"Hint",children:n.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),nt(e.error?.details)&&n.jsx(ln,{title:"Error details",children:n.jsx(kn,{value:e.error.details})}),nt(s)&&n.jsx(ln,{title:"Request",children:n.jsx(kn,{value:`${o} ${s}`})}),r!==void 0&&n.jsx(ln,{title:"Request headers",children:n.jsx(kn,{value:r})}),nt(t?.requestBody)&&n.jsx(ln,{title:"Request body",children:n.jsx(kn,{value:t.requestBody})}),nt(i)&&n.jsx(ln,{title:"Response status",children:n.jsx(kn,{value:i})}),a!==void 0&&n.jsx(ln,{title:"Response headers",children:n.jsx(kn,{value:a})}),nt(c)&&n.jsx(ln,{title:"Response body",children:n.jsx(kn,{value:c})})]}):null}function N3({result:e,probeLabel:t,children:s}){const o=e.error?.message??"Connection failed";return n.jsxs(Ft,{children:[n.jsx(so,{asChild:!0,children:s}),n.jsxs(Bt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[n.jsxs(Wt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[e.success?n.jsx(Js,{className:"size-4 text-status-success"}):n.jsx(ps,{className:"size-4 text-status-danger"}),n.jsx(Gt,{className:"text-base",children:t})]}),n.jsx(oo,{children:e.success?"Connection probe passed.":o})]}),n.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&n.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[n.jsx("div",{className:"font-medium",children:Zf(e.error?.type??"unknown")}),n.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:o})]}),n.jsx(j3,{result:e}),n.jsx(S3,{result:e})]})]})]})}function C3(e){const t="size-3 shrink-0";switch(e){case"timeout":return n.jsx(Xt,{className:t});case"network_unreachable":return n.jsx(B1,{className:t});case"connection_refused":return n.jsx(q1,{className:t});case"auth_failed":return n.jsx(zg,{className:t});case"rate_limited":return n.jsx(Ji,{className:t});case"server_error":return n.jsx(C1,{className:t});case"invalid_response":return n.jsx(q0,{className:t});case"unknown":return n.jsx(ps,{className:t})}}const k3={success:"bg-status-success/10 text-status-success hover:bg-status-success/15",failure:"bg-status-danger/10 text-status-danger hover:bg-status-danger/15",pending:"bg-muted/40 text-foreground/80",quiet:"bg-transparent text-muted-foreground/70"};function td({result:e,probeLabel:t}){const s=v3(e),o=Gr(e)?n.jsx(Au,{className:"size-3 shrink-0"}):Ks(e)?e.success?n.jsx(Js,{className:"size-3 shrink-0"}):C3(e.error?.type??"unknown"):n.jsx(Jo,{className:"size-3 shrink-0 animate-spin"}),r=n.jsxs(n.Fragment,{children:[o,n.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&n.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=O("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",k3[s.tone]);return Ks(e)&&s.hasDetails?n.jsx(N3,{result:e,probeLabel:t,children:n.jsx("button",{type:"button",className:a,"aria-label":`Open ${t} result: ${s.label}`,children:r})}):n.jsx("div",{className:a,children:r})}function nd({label:e}){return n.jsxs("div",{className:"inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground/70",children:[n.jsx(Au,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:e})]})}function Ma({label:e,results:t,configured:s=!0}){return n.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] items-center gap-2 border-t border-border/60 px-2 py-2",children:[n.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&t!==void 0?n.jsx(td,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):n.jsx(nd,{label:s?"Not tested":"Off"}),s&&t!==void 0?n.jsx(td,{result:t.streaming,probeLabel:`${e} stream`}):n.jsx(nd,{label:s?"Not tested":"Off"})]})}function Qf({provider:e,results:t}){const s=gt(e.anthropicBaseUrl),o=gt(e.openaiBaseUrl),r=gt(e.openaiResponsesBaseUrl);return!s&&!o&&!r?n.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):n.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:n.jsxs("div",{className:"min-w-[20rem]",children:[n.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] gap-2 bg-muted/25 px-2 py-1.5 text-[10px] text-muted-foreground",children:[n.jsx("span",{children:"Protocol"}),n.jsx("span",{children:"Non-stream"}),n.jsx("span",{children:"Stream"})]}),s&&n.jsx(Ma,{label:"Anthropic",results:t?.anthropic}),o&&n.jsx(Ma,{label:"OpenAI Chat",results:t?.openaiChat}),r&&n.jsx(Ma,{label:"OpenAI Responses",results:t?.openaiResponses})]})})}function _3(e){const t={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])Gr(s)||(t.total+=1,Ks(s)?s.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function Aa({label:e,results:t}){const s=_3(t),o=s.failed>0?"border-status-danger/30 bg-status-danger/10 text-status-danger":s.testing>0?"border-status-watch/30 bg-status-watch/10 text-status-watch":s.total>0&&s.passed===s.total?"border-status-success/30 bg-status-success/10 text-status-success":"border-border/60 bg-transparent text-muted-foreground",r=s.failed>0?`${s.failed} fail`:s.testing>0?"running":s.total===0?"off":`${s.passed}/${s.total}`;return n.jsxs("span",{className:O("rounded border px-1.5 py-0.5 text-[10px]",o),children:[e," ",r]})}function T3({provider:e,modelName:t,results:s,expanded:o,onToggle:r}){return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 flex-wrap items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-muted/20","aria-expanded":o,children:[o?n.jsx(We,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(ft,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:t,children:t}),n.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[gt(e.anthropicBaseUrl)&&n.jsx(Aa,{label:"A",results:s.anthropic}),gt(e.openaiBaseUrl)&&n.jsx(Aa,{label:"Chat",results:s.openaiChat}),gt(e.openaiResponsesBaseUrl)&&n.jsx(Aa,{label:"Resp",results:s.openaiResponses})]})]}),o&&n.jsx("div",{className:"px-2 pb-3",children:n.jsx(Qf,{provider:e,results:s})})]})}function E3({provider:e,testResults:t}){const s=Object.entries(t.models??{}),[o,r]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:n.jsxs("section",{className:"space-y-2",children:[n.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:"flex w-full items-center gap-1.5 text-left text-xs font-medium text-foreground/80 transition-colors hover:text-foreground","aria-expanded":o,children:[o?n.jsx(We,{className:"size-3.5"}):n.jsx(ft,{className:"size-3.5"}),"Model probes",n.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),o&&n.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>n.jsx(T3,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(m=>m===c?null:c)},c))})]})}function R3({provider:e,testResults:t,isTesting:s}){const o=gt(e.anthropicBaseUrl)||gt(e.openaiBaseUrl)||gt(e.openaiResponsesBaseUrl),r=w3(e,t);return s?n.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-cool/30 bg-status-cool/10 px-2 py-1 text-xs text-status-cool",children:[n.jsx(Jo,{className:"size-3 animate-spin"}),"Testing"]}):o?t===void 0||r.total===0?n.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):r.failed>0?n.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-danger/30 bg-status-danger/10 px-2 py-1 text-xs text-status-danger",children:[n.jsx(ps,{className:"size-3"}),r.failed," failed"]}):r.testing>0||r.passed<r.total?n.jsxs("span",{className:"rounded border border-status-watch/30 bg-status-watch/10 px-2 py-1 text-xs text-status-watch",children:[r.passed,"/",r.total]}):n.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-success/30 bg-status-success/10 px-2 py-1 text-xs text-status-success",children:[n.jsx(Js,{className:"size-3"}),r.passed,"/",r.total]}):n.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const M3={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function Ia(e){return e!==void 0&&e!==""}function Pa({label:e}){return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:[n.jsx(Js,{className:"size-3"}),e]})}function A3({provider:e}){const t=Ia(e.anthropicBaseUrl),s=Ia(e.openaiBaseUrl),o=Ia(e.openaiResponsesBaseUrl);return!t&&!s&&!o?n.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t&&n.jsx(Pa,{label:"Anthropic"}),s&&n.jsx(Pa,{label:"OpenAI Chat"}),o&&n.jsx(Pa,{label:"OpenAI Responses"})]})}function I3(e){const t=e.models??[];if(t.length===0)return"No models configured";const s=t.slice(0,2).join(", "),o=t.length-2;return o>0?`${s} +${o} more`:s}function P3({provider:e,model:t}){const s=Fl(e,t),o=O3(s?.sourceUrl);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.jsx("span",{children:t}),s!==null&&s.contextWindow!==void 0&&n.jsx("span",{className:"font-mono text-foreground/80",children:su(s.contextWindow)}),o!==null&&n.jsx(Ns,{children:n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":o.title,children:o.label})}),n.jsx(ct,{children:o.title})]})})]})}function L3(e){const t=Date.now(),s=new Date(e).getTime(),o=t-s,r=Math.floor(o/1e3);if(r<60)return"just now";const a=Math.floor(r/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function O3(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const s=t.hostname.toLowerCase(),o=s==="huggingface.co"||s.endsWith(".huggingface.co");return{label:o?"HF":"Source",title:o?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function D3({provider:e,testResults:t,isTesting:s,testingTimeLeft:o,isHighlighted:r,onEdit:a,onDelete:i,onTest:c,onRefreshMetadata:d,isRefreshingMetadata:m=!1}){const[u,p]=l.useState(!1),f=e.apiDocsUrl??Object.entries(M3).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=x3(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",b=g?"Refresh":"Import defaults",y=s??!1,w=e.source==="company"?n.jsx("span",{className:"shrink-0 rounded border border-status-cool/30 bg-status-cool/10 px-1.5 py-0.5 text-xs text-status-cool",children:"Company"}):e.source==="personal"?n.jsx("span",{className:"shrink-0 rounded border border-status-accent/30 bg-status-accent/10 px-1.5 py-0.5 text-xs text-status-accent",children:"Personal"}):null;return n.jsxs("div",{"data-provider-id":e.id,className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${r===!0?"ring-2 ring-primary shadow-md":""}`,children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),n.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:I3(e)})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(R3,{provider:e,testResults:t,isTesting:y}),f!==void 0&&n.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"View API documentation",children:[n.jsx(Yi,{className:"size-3"}),n.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[n.jsx(A3,{provider:e}),t?.testedAt!==void 0&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(Xt,{className:"size-3"}),L3(t.testedAt)]})]}),!h&&n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-status-watch/30 bg-status-watch/10 px-2 py-1.5 text-xs text-status-watch",children:[n.jsx("span",{children:"Context window metadata missing"}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:m,children:[n.jsx(Jo,{className:`size-3 ${m?"animate-spin":""}`}),b]}),!g&&n.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&n.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx(Js,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>n.jsx(P3,{provider:e,model:v},v))}),n.jsxs("section",{className:"space-y-2",children:[n.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),n.jsx(Qf,{provider:e,results:t})]}),t!==void 0&&n.jsx(E3,{provider:e,testResults:t})]}),n.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[n.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,children:[u?n.jsx(We,{className:"size-3"}):n.jsx(ft,{className:"size-3"}),"Details"]}),n.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&n.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:y,children:[n.jsx(Jo,{className:`size-3 ${y?"animate-spin":""}`}),y?o!==void 0?`Testing (${o}s)`:"Testing...":"Test"]}),n.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:y,children:[n.jsx(Iu,{className:"size-3"}),"Edit"]}),n.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:y,children:[n.jsx(gn,{className:"size-3"}),"Delete"]})]})]})]})}const ms="/v1/chat/completions",ki="/v1/responses",z3="/v1/messages";function $3(e,t){const s=e.endsWith("/")?e.slice(0,-1):e,o=eh(t),r=t.indexOf("?"),a=r>=0?t.slice(r):"";return o!==""&&s.endsWith(o)?s+a:nh(s)&&th(t)||s.endsWith("/v1")&&t.startsWith("/v1/")?s+t.slice(3):s+t}function F3(e,t,s={}){const o=e.trim().replace(/\/+$/,""),r=eh(t),a=$3(o,t),i=[];return r!==""&&o.endsWith(r)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):nh(o)&&th(t)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):o.endsWith("/v1")&&t.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),sd(r)&&U3(o)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),B3(r)&&q3(o)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),sd(r)&&H3(o,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function eh(e){return e.split("?")[0]??e}function th(e){return e===ms||e.startsWith(`${ms}?`)||e.startsWith(`${ms}/`)}function B3(e){return e===ms||e.startsWith(`${ms}/`)}function sd(e){return e===ki||e.startsWith(`${ki}/`)}function U3(e){return e.toLowerCase().endsWith("/chat/completions")}function q3(e){return e.toLowerCase().endsWith("/responses")}function H3(e,t){const s=t?.toLowerCase();if(s!==void 0&&s.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function nh(e){try{const t=new URL(e),s=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function La(e){return e!==void 0&&e.trim()!==""}function od(e){const t=La(e?.anthropicBaseUrl),s=La(e?.openaiBaseUrl),o=La(e?.openaiResponsesBaseUrl);return{anthropic:t,openai:s||o,openaiChat:s,openaiResponses:o}}function Oa(e,t,s){if(!e)return s?"":void 0;const o=t.trim();return o===""?void 0:o}const rd=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],ad=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],ko=z3,_o=ms,To=ki,V3={deepseek:{openaiBaseUrl:"https://api.deepseek.com"},minimax:{anthropicBaseUrl:"https://api.minimaxi.com/anthropic",openaiBaseUrl:"https://api.minimaxi.com",openaiResponsesBaseUrl:"https://api.minimaxi.com",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},"zhipu coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"glm coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"bigmodel coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"z.ai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"zai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},zhipu:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zhipuai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},bigmodel:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},"z.ai":{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},glm:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},alibaba:{openaiBaseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},id=["MiniMax M3","MiniMax M2.7","MiniMax M2.7-highspeed","MiniMax M2.5","MiniMax M2.5-highspeed","MiniMax M2.1","MiniMax M2.1-highspeed","MiniMax M2"],ld=["qwen3.6-plus","qwen3.7-max"],cd=["glm-5.2","glm-5.1","glm-5","glm-5-turbo","glm-4.7","glm-4.7-flashx","glm-4.6","glm-4.5","glm-4.5-air","glm-4.5-x","glm-4.5-airx","glm-4.5-flash"],_i="__unset__",ur="__custom__",sh=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function Tn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function dd(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function oh(e,t){const s=dd(t);return e?.modelMetadata?.find(o=>dd(o.model)===s)??null}function rh(e){const t=Wo(e);if(t===null)return null;for(const s of sh)if(Wo(s.value)===t)return s.value;return null}function W3(e){return e.trim()===""?"unset":rh(e)!==null?"preset":"custom"}function G3(e){switch(e.contextWindowMode){case"unset":return _i;case"custom":return ur;case"preset":return rh(e.contextWindow)??ur}}function Da(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(s===null)return{amount:t,unit:"K"};const o=s[1];if(o===void 0)return{amount:t,unit:"K"};const r=s[2];if(r===void 0||r==="")return{amount:o,unit:"tokens"};switch(r.toLowerCase()){case"k":return{amount:o,unit:"K"};case"m":return{amount:o,unit:"M"};default:return{amount:t,unit:"K"}}}function ud(e,t){const s=e.trim();if(s==="")return"";switch(t){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function md(e,t){return t.map(s=>{const o=oh(e,s),r=o?.contextWindow!==void 0?Gh(o.contextWindow):"";return{contextWindow:r,contextWindowMode:W3(r),outputLimit:o?.outputLimit?.toString()??""}})}function pd(e){const t=e.trim();if(t==="")return null;const s=Number(t);return!Number.isInteger(s)||s<=0?null:s}function Qn(e,t){if(e===void 0)return"";const s=e.trim(),o=s.replace(/\/+$/,"");return o.endsWith(t)?o.slice(0,-t.length).replace(/\/+$/,""):s}function K3(e,t,s){const o=e.trim();return o===""?null:F3(o,t,{providerName:s})}function za({baseUrl:e,endpoint:t,providerName:s}){const o=K3(e,t,s);return o===null?null:n.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[n.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),n.jsx("div",{className:"break-all font-mono text-foreground",children:o.finalUrl}),o.diagnostics.length>0&&n.jsx("div",{className:"mt-2 space-y-1",children:o.diagnostics.map(r=>n.jsx("div",{className:r.severity==="warning"?"text-status-watch":"text-muted-foreground",children:r.message},`${r.severity}:${r.message}`))})]})}function Y3({provider:e,onSubmit:t,onCancel:s}){const o=od(e),[r,a]=l.useState(e?.name??""),[i,c]=l.useState(""),[d,m]=l.useState(!1),[u,p]=l.useState(!1),f=e?.models,[h,g]=l.useState(f!==void 0&&f.length>0?f:[""]),[b,y]=l.useState(()=>md(e,f!==void 0&&f.length>0?f:[""])),[w,v]=l.useState(o.anthropic),[j,S]=l.useState(o.openai),[N,C]=l.useState(o.openaiChat),[R,P]=l.useState(o.openaiResponses),[L,M]=l.useState(Qn(e?.anthropicBaseUrl,ko)),[k,A]=l.useState(Qn(e?.openaiBaseUrl,_o)),[D,F]=l.useState(Qn(e?.openaiResponsesBaseUrl,To)),[Y,X]=l.useState(e?.apiDocsUrl??""),[$,V]=l.useState(e?.modelMetadataUrl??""),[J,U]=l.useState(e?.source),[K,ae]=l.useState({}),[be,ve]=l.useState(!1),[ie,z]=l.useState(null),Z=l.useRef([]);l.useEffect(()=>{if(ie===null)return;const T=ie;function I(q){if(!(q.target instanceof Node))return;const ne=Z.current[T];ne!=null&&!ne.contains(q.target)&&z(null)}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[ie]);const[we,Ne]=l.useState(!1),[pe,re]=l.useState(!1),[le,Re]=l.useState(!1),he=r.toLowerCase().includes("minimax"),ze=r.toLowerCase().includes("alibaba"),rt=[...rd,...ad].some(T=>r.toLowerCase().includes(T)),$e=he?id:rt?cd:ze?ld:[],Ge=e?.modelMetadata?.some(T=>T.contextWindow!==void 0)??!1;function Ke(){Nt(i).then(T=>{T&&(p(!0),setTimeout(()=>p(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),m(!1);const T=(e.models?.length??0)>0?e.models:[""];g(T),y(md(e,T));const I=od(e);v(I.anthropic),S(I.openai),C(I.openaiChat),P(I.openaiResponses),M(Qn(e.anthropicBaseUrl,ko)),A(Qn(e.openaiBaseUrl,_o)),F(Qn(e.openaiResponsesBaseUrl,To)),X(e.apiDocsUrl??""),V(e.modelMetadataUrl??""),U(e.source),Ne(!1),re(!1),Re(!1)}},[e]),l.useEffect(()=>{const T=r.toLowerCase();for(const[I,q]of Object.entries(V3))if(T.includes(I)){q.anthropicBaseUrl!==void 0&&!we&&M(q.anthropicBaseUrl),q.openaiBaseUrl!==void 0&&!pe&&A(q.openaiBaseUrl),q.openaiResponsesBaseUrl!==void 0&&!le&&F(q.openaiResponsesBaseUrl),q.apiDocsUrl!==void 0&&!Y&&X(q.apiDocsUrl),I==="minimax"&&h.length===1&&h[0]===""&&g([id[0]??""]),I==="alibaba"&&h.length===1&&h[0]===""&&g([ld[0]??""]),(rd.includes(I)||ad.includes(I))&&h.length===1&&h[0]===""&&g([cd[0]??""]);break}},[r]);function Ue(){const T={};return r.trim()||(T.name="Name is required"),e===void 0&&!i.trim()&&(T.apiKey="API key is required"),(h.length===0||h.every(I=>!I.trim()))&&(T.models="At least one model is required"),!w&&!j&&(T.capabilities="Select at least one API capability"),j&&!N&&!R&&(T.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(L.trim()===""?T.anthropicBaseUrl="Anthropic base URL is required":Ye(L.trim())||(T.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?T.openaiBaseUrl="OpenAI Chat base URL is required":Ye(k.trim())||(T.openaiBaseUrl="Invalid URL format")),j&&R&&(D.trim()===""?T.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Ye(D.trim())||(T.openaiResponsesBaseUrl="Invalid URL format")),$.trim()&&!Ye($.trim())&&(T.modelMetadataUrl="Invalid URL format"),b.forEach((I,q)=>{const ne=Wo(I.contextWindow),xe=pd(I.outputLimit);I.contextWindow.trim()!==""&&ne===null&&(T[`modelMetadata.${q}.contextWindow`]="Context window must be a positive number, optionally using K or M"),I.outputLimit.trim()!==""&&xe===null&&(T[`modelMetadata.${q}.outputLimit`]="Output limit must be a positive integer"),ne!==null&&xe!==null&&xe>ne&&(T[`modelMetadata.${q}.outputLimit`]="Output limit should not exceed context window")}),ae(T),Object.keys(T).length===0}function Ye(T){try{return new URL(T),!0}catch{return!1}}function Qe(T,I){g(q=>{const ne=[...q];return ne[T]=I,ne})}function et(T,I){y(q=>{const ne=[...q];return ne[T]={...ne[T]??Tn(),...I},ne})}function H(T,I){switch(I){case _i:et(T,{contextWindow:"",contextWindowMode:"unset"});return;case ur:{const q=b[T]??Tn();et(T,{contextWindow:q.contextWindow,contextWindowMode:"custom"});return}default:et(T,{contextWindow:I,contextWindowMode:"preset"});return}}function te(T,I){const q=b[T]??Tn(),ne=Da(q.contextWindow);et(T,{contextWindow:ud(I,ne.unit),contextWindowMode:"custom"})}function fe(T,I){const q=b[T]??Tn(),ne=Da(q.contextWindow);switch(I){case"K":case"M":case"tokens":et(T,{contextWindow:ud(ne.amount,I),contextWindowMode:"custom"});return;default:return}}function me(T){g(I=>I.filter((q,ne)=>ne!==T)),y(I=>I.filter((q,ne)=>ne!==T))}function je(){g(T=>[...T,""]),y(T=>[...T,Tn()])}function Me(){const T=new Date().toISOString(),I=[];return h.forEach((q,ne)=>{const xe=q.trim();if(xe==="")return;const ce=b[ne]??Tn(),Q=Wo(ce.contextWindow),se=pd(ce.outputLimit);if(Q===null&&se===null)return;const Ae=oh(e,xe);if(Ae!==null&&Ae.contextWindow===(Q??void 0)&&Ae.outputLimit===(se??void 0)){I.push({...Ae,model:xe});return}const qe={model:xe,source:"manual",updatedAt:T};Q!==null&&(qe.contextWindow=Q),se!==null&&(qe.outputLimit=se),I.push(qe)}),I.length>0?I:e?.modelMetadata!==void 0?[]:void 0}function Ie(T){if(T.preventDefault(),!Ue())return;ve(!0);const I=e!==void 0;try{t({name:r.trim(),apiKey:i.trim(),models:h.map(q=>q.trim()).filter(q=>q!==""),anthropicBaseUrl:Oa(w,L,I),openaiBaseUrl:Oa(j&&N,k,I),openaiResponsesBaseUrl:Oa(j&&R,D,I),apiDocsUrl:Y.trim()||void 0,modelMetadataUrl:$.trim()||void 0,modelMetadata:Me(),source:J})}finally{ve(!1)}}return n.jsxs("form",{onSubmit:Ie,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx("input",{id:"provider-name",type:"text",value:r,onChange:T=>a(T.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),K.name!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.name})]}),n.jsxs("fieldset",{className:"space-y-3",children:[n.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[n.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[n.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[n.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:T=>S(T.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&n.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[n.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[n.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:T=>C(T.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),n.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[n.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:R,onChange:T=>P(T.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),K.openaiCapabilities!==void 0&&j&&n.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:K.openaiCapabilities})]}),n.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[n.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:T=>v(T.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),K.capabilities!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.capabilities})]}),(w||j&&(N||R))&&n.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[n.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[n.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:L,onChange:T=>{Ne(!0),M(T.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:ko})]}),K.anthropicBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.anthropicBaseUrl}),n.jsx(za,{baseUrl:L,endpoint:ko,providerName:r})]}),j&&N&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[n.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:T=>{re(!0),A(T.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:_o})]}),K.openaiBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.openaiBaseUrl}),n.jsx(za,{baseUrl:k,endpoint:_o,providerName:r})]}),j&&R&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[n.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:D,onChange:T=>{Re(!0),F(T.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:To})]}),K.openaiResponsesBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.openaiResponsesBaseUrl}),n.jsx(za,{baseUrl:D,endpoint:To,providerName:r})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),n.jsxs("select",{id:"provider-source",value:J??"",onChange:T=>U(T.target.value==="company"||T.target.value==="personal"?T.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[n.jsx("option",{value:"",children:"Unspecified"}),n.jsx("option",{value:"personal",children:"个人 (Personal)"}),n.jsx("option",{value:"company",children:"公司 (Company)"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),n.jsx("input",{id:"provider-model-metadata-url",type:"text",value:$,onChange:T=>V(T.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),K.modelMetadataUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.modelMetadataUrl}),$.trim()===""&&n.jsx("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!Ge&&$.trim()===""&&n.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),$.trim()!==""&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:T=>c(T.target.value),placeholder:e===void 0?"sk-ant-...":"Leave blank to keep current key",className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("button",{type:"button",onClick:()=>m(T=>!T),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?n.jsx(ug,{className:"size-4"}):n.jsx(Tu,{className:"size-4"})}),n.jsx("button",{type:"button",onClick:Ke,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?n.jsx(Pe,{className:"size-4 text-status-success"}):n.jsx(Et,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),K.apiKey!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.apiKey})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"text-sm font-medium",children:["Models ",n.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((T,I)=>{const q=b[I]??Tn(),ne=K[`modelMetadata.${I}.contextWindow`],xe=K[`modelMetadata.${I}.outputLimit`],ce=G3(q),Q=Da(q.contextWindow);return n.jsxs("div",{ref:se=>{Z.current[I]=se},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("input",{type:"text",value:T,onChange:se=>Qe(I,se.target.value),placeholder:$e.length>0?"Type or select a model...":"Model name",className:"w-full rounded-md border border-input bg-background px-4 py-3 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),$e.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:()=>z(ie===I?null:I),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:n.jsx(We,{className:"size-4"})}),ie===I&&n.jsx("div",{className:"bg-popover text-popover-foreground absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-y-auto rounded-md border shadow-md",children:$e.map(se=>n.jsx("button",{type:"button",onClick:()=>{Qe(I,se),z(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:se},se))})]})]}),h.length>1&&n.jsx("button",{type:"button",onClick:()=>me(I),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M3 6h18"}),n.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),n.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[n.jsx("span",{children:"Context Window"}),n.jsxs(Vs,{value:ce,onValueChange:se=>H(I,se),children:[n.jsx(Ws,{size:"sm",className:"w-full bg-background font-mono text-xs",children:n.jsx(dr,{})}),n.jsxs(Gs,{className:"max-h-64",children:[n.jsx(ot,{value:_i,children:"Not set"}),sh.map(se=>n.jsxs(ot,{value:se.value,children:[se.label," · ",se.value]},se.value)),n.jsx(ot,{value:ur,children:"Custom"})]})]}),q.contextWindowMode==="custom"&&n.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[n.jsx("input",{type:"text",inputMode:"decimal",value:Q.amount,onChange:se=>te(I,se.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),n.jsxs(Vs,{value:Q.unit,onValueChange:se=>fe(I,se),children:[n.jsx(Ws,{size:"sm",className:"w-full bg-background font-mono text-xs",children:n.jsx(dr,{})}),n.jsxs(Gs,{children:[n.jsx(ot,{value:"K",children:"K"}),n.jsx(ot,{value:"M",children:"M"}),n.jsx(ot,{value:"tokens",children:"tokens"})]})]})]}),ne!==void 0&&n.jsx("span",{className:"block text-destructive",children:ne})]}),n.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[n.jsx("span",{children:"Output Limit"}),n.jsx("input",{type:"number",min:1,step:1e3,value:q.outputLimit,onChange:se=>et(I,{outputLimit:se.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),xe!==void 0&&n.jsx("span",{className:"block text-destructive",children:xe})]})]})]},I)}),n.jsx("button",{type:"button",onClick:je,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),K.models!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:K.models})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),n.jsx("input",{id:"provider-api-docs-url",type:"text",value:Y,onChange:T=>X(T.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),n.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky bottom-0 flex justify-end gap-2 rounded-[8px] px-3 py-2",children:[n.jsx(ee,{type:"button",variant:"outline",onClick:s,disabled:be,children:"Cancel"}),n.jsx(ee,{type:"submit",disabled:be,children:be?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const J3=ue(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),X3=_({message:x(),type:J3,details:x().optional(),hint:x().optional()}),Z3=_({type:ue(["text","thinking"]),text:x().optional(),thinking:x().optional()}),Q3=_({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:De(x(),x()).optional(),requestBody:x().optional(),responseStatus:E().optional(),responseStatusText:x().optional(),responseHeaders:De(x(),x()).optional(),responseBody:x().optional()}),e4=_({success:ke(),error:X3.optional(),model:x().optional(),inputTokens:E().optional(),outputTokens:E().optional(),cacheCreationInputTokens:E().optional(),cacheReadInputTokens:E().optional(),latencyMs:E().optional(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),content:W(Z3).optional(),rawResponse:x().optional(),streaming:ke().optional(),streamingChunks:_({chunks:W(ru),truncated:ke().default(!1)}).optional(),requestHeaders:De(x(),x()).optional(),debug:Q3.optional()}),fd=Ut([e4,_({notConfigured:oe(!0)}),_({testing:oe(!0)})]),pn=_({nonStreaming:fd,streaming:fd});function mr(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const t4=_({anthropic:pn,openai:pn.optional(),openaiChat:pn.optional(),openaiResponses:pn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??mr();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??mr()}}),n4=_({anthropic:pn,openai:pn.optional(),openaiChat:pn.optional(),openaiResponses:pn.optional(),models:De(x(),t4).optional(),testedAt:x().optional()}).transform(e=>{const t=e.openaiChat??e.openai??mr();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??mr()}});function s4(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiChat:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiResponses:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function hd(e,t){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const o4=_({providerConfig:x()}),r4=_({success:ke().optional(),imported:E().optional(),message:x().optional(),errors:W(x()).optional()}),a4=_({provider:Zo,imported:E(),matchedModels:W(x()),missingModels:W(x()),sourceUrl:x()}),Eo="Network error: could not reach the server. Is the proxy running?",i4=5e3,l4=5e3,xd=15e3,c4=1e4,d4=2e4,u4=2e4,m4=3e4;function $a(e,t){return(e?.length??0)>0?e:t&&e!==void 0?"":void 0}function gd(e,t=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:$a(e.anthropicBaseUrl,t),openaiBaseUrl:$a(e.openaiBaseUrl,t),openaiResponsesBaseUrl:$a(e.openaiResponsesBaseUrl,t),apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function p4(e,t){const s=e?.models?.map(o=>o.trim()).filter(o=>o!=="").length??0;return Math.max(1,s)*t}async function f4(e,t){if(t.models!==void 0)try{await In(`/api/providers/${e}/test/log`,l4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function h4({externalProviders:e,isLoading:t=!1,externalTestResults:s,externalTestingProviders:o,externalTestingTimeLeft:r,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[m,u]=l.useState(!1),[p,f]=l.useState(),[h,g]=l.useState(null),[b,y]=l.useState({}),[w,v]=l.useState(new Set),[j,S]=l.useState({}),[N,C]=l.useState(null),[R,P]=l.useState(!1),[L,M]=l.useState(null),[k,A]=l.useState(!1),[D,F]=l.useState(!1),[Y,X]=l.useState(null),[$,V]=l.useState("all"),[J,U]=l.useState(new Set),{providerTestTimeoutSeconds:K}=Wi(),ae=l.useRef(null),be=l.useRef(null),ve=e??[],ie=l.useMemo(()=>{const H=$==="all"?ve:ve.filter(te=>te.source===$);return $==="all"?[...H].sort((te,fe)=>{const me={personal:0,company:1};return(me[te.source??""]??2)-(me[fe.source??""]??2)}):H},[ve,$]),z=s??b,Z=o??w,we=r??j,Ne=d?(H,te)=>d(H,te):(H,te)=>{S(te===void 0?fe=>{const me={...fe};return delete me[H],me}:fe=>({...fe,[H]:te}))};l.useEffect(()=>{(async()=>{try{const H=await Le("/api/config/paths",o4,i4);C(H.providerConfig)}catch{}})()},[]);const pe=l.useCallback(H=>{be.current!==null&&clearTimeout(be.current),M(H),ae.current?.scrollTo({top:ae.current.scrollHeight,behavior:"smooth"}),be.current=setTimeout(()=>{M(null),be.current=null},2e3)},[]);l.useEffect(()=>()=>{be.current!==null&&clearTimeout(be.current)},[]);const re=l.useCallback(()=>{a?.().catch(()=>{})},[a]),le=l.useCallback((H,te)=>{i?i(H,te):y(fe=>({...fe,[H]:te}))},[i]),Re=l.useCallback((H,te)=>{if(c){c(H,te);return}v(fe=>{const me=new Set(fe);return te?me.add(H):me.delete(H),me})},[c]),he=l.useCallback(async H=>{le(H,s4()),Re(H,!0);const te=new AbortController,fe=ve.find(Ie=>Ie.id===H),me=p4(fe,K);let je=me;Ne(H,je);const Me=setInterval(()=>{je--,Ne(H,je),je<=0&&(clearInterval(Me),te.abort())},1e3);try{const Ie=await Le(`/api/providers/${H}/test`,n4,me*1e3+1e3,{method:"POST",signal:te.signal},T=>`HTTP ${T.status}: ${T.statusText}`);le(H,Ie),await f4(H,Ie)}catch(Ie){const T=Ie instanceof Error&&Ie.name==="AbortError",I=Ie instanceof Ii;T||I?le(H,hd("Request timed out","timeout")):Ie instanceof Error&&le(H,hd(Ie.message,"server_error"))}finally{clearInterval(Me),Ne(H,void 0),Re(H,!1)}},[K,ve,Ne,le,Re]),ze=l.useCallback(async(H,te,fe=!0)=>{U(me=>{const je=new Set(me);return je.add(H),je});try{const me=te!==void 0&&te.trim()!==""?{url:te}:{},je=await Le(`/api/providers/${H}/model-metadata`,a4,m4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(me)},()=>"Failed to refresh model metadata");return je.imported===0&&fe?g("No matching model metadata found for this provider."):g(null),pe(je.provider.id),re(),je.imported>0}catch(me){return fe&&g(me instanceof Error?me.message:Eo),!1}finally{U(me=>{const je=new Set(me);return je.delete(H),je})}},[re,pe]);function rt(H){(async()=>{try{const te=await Le("/api/providers",Zo,xd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(gd(H))},()=>"Failed to add provider");u(!1),pe(te.id),H.modelMetadataUrl!==void 0&&H.modelMetadataUrl.trim()!==""&&await ze(te.id,H.modelMetadataUrl,!1),re(),await he(te.id)}catch(te){g(te instanceof Error?te.message:Eo)}})()}function $e(H){p&&(async()=>{try{const te=await Le(`/api/providers/${p.id}`,Zo,xd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(gd(H,!0))},()=>"Failed to update provider");f(void 0),pe(te.id),H.modelMetadataUrl!==void 0&&H.modelMetadataUrl.trim()!==""&&await ze(te.id,H.modelMetadataUrl,!1),re(),(H.apiKey.trim()!==""||JSON.stringify(H.models)!==JSON.stringify(p.models)||(H.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(H.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(H.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await he(te.id)}catch(te){g(te instanceof Error?te.message:Eo)}})()}function Ge(H){X(H),F(!0)}function Ke(){const H=Y;H!==null&&(async()=>{let te;try{te=await In(`/api/providers/${H}`,c4,{method:"DELETE"})}catch{g(Eo);return}if(!te.ok){g(await Yh(te,"Failed to delete provider"));return}re()})()}const Ue=l.useRef(null);function Ye(H){const te="/api/providers/export";(async()=>{try{const fe=await In(te,d4);if(!fe.ok){g("Failed to export providers");return}const me=await fe.blob(),je=URL.createObjectURL(me),Me=document.createElement("a");Me.href=je,Me.download=fe.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),URL.revokeObjectURL(je)}catch{g("Failed to export providers")}})()}function Qe(){Ue.current?.click()}function et(H){const te=H.target.files?.[0];te&&(async()=>{try{const fe=await te.text(),me=await In("/api/providers/import",u4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fe)}),je=await Kh(me,r4);me.ok&&je.imported!==void 0&&je.imported>0?(re(),g(null)):je.errors&&je.errors.length>0?g(je.errors.join("; ")):g(je.message??"Import failed")}catch{g("Failed to import providers")}H.target.value=""})()}return t?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):m||p?n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:n.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),n.jsx(Y3,{provider:p,onSubmit:p?$e:rt,onCancel:()=>{u(!1),f(void 0)}})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{"data-provider-toolbar":"true",className:"sticky top-0 z-10 flex min-w-0 flex-wrap items-center justify-start gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur sm:justify-end",children:[n.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>Ye(),className:"gap-1 hover:bg-muted",children:[n.jsx(Xs,{className:"size-3"}),"Export"]}),n.jsxs(ee,{variant:"outline",size:"sm",onClick:Qe,className:"gap-1 hover:bg-muted",children:[n.jsx(Du,{className:"size-3"}),"Import"]}),n.jsx("input",{type:"file",ref:Ue,accept:".json",onChange:et,style:{display:"none"}}),n.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>A(!0),className:"gap-1",children:[n.jsx(v1,{className:"size-3"}),"Scan"]}),n.jsxs(ee,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[n.jsx(Ql,{className:"size-4"}),"Add Provider"]})]}),N!==null&&n.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-mono truncate",title:N,children:N}),n.jsx("button",{type:"button",onClick:()=>{Nt(N).then(H=>{H&&(P(!0),setTimeout(()=>P(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":R?"Copied config file path":"Copy config file path",children:R?n.jsx(Pe,{className:"size-3 text-status-success"}):n.jsx(Et,{className:"size-3"})})]}),h!==null&&n.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-sm text-destructive",children:[n.jsx(ps,{className:"size-4 shrink-0"}),h]}),ve.length===0?n.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),n.jsxs(ee,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[n.jsx(Ql,{className:"size-4"}),"Add Your First Provider"]})]}):n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(H=>n.jsx("button",{type:"button",onClick:()=>V(H),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${$===H?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:H==="all"?"All":H==="personal"?"Personal":"Company"},H))}),n.jsx("div",{ref:ae,className:"space-y-3",children:ie.map(H=>n.jsx(D3,{provider:H,testResults:z[H.id],isTesting:Z.has(H.id),testingTimeLeft:we[H.id],isHighlighted:H.id===L,onEdit:te=>f(te),onDelete:Ge,onRefreshMetadata:te=>{ze(te)},isRefreshingMetadata:J.has(H.id),onTest:te=>{he(te)}},H.id))})]}),n.jsx(p3,{open:k,onOpenChange:A,onImportComplete:()=>{a!==void 0&&a()}}),n.jsx(df,{open:D,onOpenChange:F,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:Ke})]})}const x4=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function g4(){return n.jsx(Tf,{"aria-label":"Settings sections",className:"grid w-full grid-cols-3 justify-stretch gap-1 bg-muted/35 p-1 group-data-[orientation=horizontal]/tabs:h-auto sm:grid-cols-5",children:x4.map(e=>n.jsx(Yt,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function b4(){const[e,t]=l.useState(!1),[s,o]=l.useState("providers"),{providers:r,isLoading:a,mutate:i}=nl(),[c,d]=l.useState({}),[m,u]=l.useState(new Set),[p,f]=l.useState({}),h=l.useCallback((y,w)=>{d(v=>({...v,[y]:w}))},[]),g=l.useCallback((y,w)=>{u(v=>{const j=new Set(v);return w?j.add(y):j.delete(y),j})},[]),b=l.useCallback((y,w)=>{f(v=>{if(w===void 0){const j={...v};return delete j[y],j}return{...v,[y]:w}})},[]);return n.jsxs(Ft,{open:e,onOpenChange:t,children:[n.jsx(so,{asChild:!0,children:n.jsxs(ee,{variant:"ghost",size:"icon",className:ao,"aria-label":"Settings",title:"Settings",children:[n.jsx(_1,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:"Settings"})]})}),n.jsxs(Bt,{className:"flex max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-2xl flex-col overflow-hidden p-4 sm:max-h-[80vh] sm:p-6",children:[n.jsx(Wt,{children:n.jsx(Gt,{children:"Settings"})}),n.jsxs(_f,{value:s,onValueChange:o,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[n.jsx(g4,{}),n.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[n.jsx(at,{value:"providers",children:n.jsx(h4,{externalProviders:r,isLoading:a,externalTestResults:c,externalTestingProviders:m,externalTestingTimeLeft:p,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:b})}),n.jsx(at,{value:"proxy",children:n.jsx(k4,{})}),n.jsx(at,{value:"storage",children:n.jsx(w4,{})}),n.jsx(at,{value:"mcp",children:n.jsx(C4,{})}),n.jsx(at,{value:"onboarding",children:n.jsx(N4,{})})]})]})]})]})}const v4=_({kind:x(),root:x(),sensitivity:x(),cleanupBehavior:x(),fileCount:E(),bytes:E(),oldestModifiedAt:x().nullable(),newestModifiedAt:x().nullable()}),bd=_({memoryCount:E(),inventory:_({checkedAt:x(),totalFiles:E(),totalBytes:E(),artifacts:W(v4)}),policy:_({maxAgeMs:E(),maxTotalBytes:E()}),reclaimableBytes:E(),lastGc:_({checkedAt:x(),filesDeleted:E(),bytesDeleted:E(),errors:E(),beforeTotalBytes:E(),afterTotalBytes:E()}).nullable()}),vd=1e4;function Ls(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function y4(e){return`${Math.round(e/1e3/60/60/24).toLocaleString()} days`}function w4(){const[e,t]=l.useState(null),[s,o]=l.useState(null),[r,a]=l.useState(!1),[i,c]=l.useState(!1),[d,m]=l.useState(null),u=l.useCallback(async()=>{a(!0),o(null);try{const h=await Le("/api/storage",bd,vd,void 0,g=>`Failed to load storage stats: HTTP ${String(g.status)}`);t(h)}catch(h){o(h instanceof Error?h.message:String(h))}finally{a(!1)}},[]);l.useEffect(()=>{u()},[u]);const p=l.useCallback((h,g)=>{Nt(g).then(b=>{b&&(m(h),setTimeout(()=>m(null),1600))})},[]),f=l.useCallback(async()=>{c(!0),o(null);try{const h=await Le("/api/storage",bd,vd,{method:"POST"},g=>`Failed to run storage GC: HTTP ${String(g.status)}`);t(h)}catch(h){o(h instanceof Error?h.message:String(h))}finally{c(!1)}},[]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Storage lifecycle"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local captured-data footprint, retention policy, and safe reclaim actions."})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{f()},disabled:i,children:i?"Running...":"Run GC now"}),n.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:r?"Refreshing...":"Refresh"})]})]}),e!==null&&n.jsxs("div",{className:"grid gap-2 text-xs",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsx(Ro,{label:"Persisted footprint",value:`${e.inventory.totalFiles.toLocaleString()} files / ${Ls(e.inventory.totalBytes)}`,detail:`Checked ${new Date(e.inventory.checkedAt).toLocaleString()}`}),n.jsx(Ro,{label:"Auto-reclaimable",value:Ls(e.reclaimableBytes),detail:`Retention ${y4(e.policy.maxAgeMs)} / max ${Ls(e.policy.maxTotalBytes)}`}),n.jsx(Ro,{label:"In-memory logs",value:`${e.memoryCount.toLocaleString()} loaded`,detail:"Recent completed entries kept hot for the UI"}),n.jsx(Ro,{label:"Last GC",value:e.lastGc===null?"Not run yet":`${e.lastGc.filesDeleted.toLocaleString()} files / ${Ls(e.lastGc.bytesDeleted)}`,detail:e.lastGc===null?"Runs at startup, on schedule, or manually here":`${new Date(e.lastGc.checkedAt).toLocaleString()} · ${e.lastGc.errors} errors`})]}),e.inventory.artifacts.map(h=>n.jsx(S4,{artifact:h,copiedId:d,onCopy:p},`${h.kind}:${h.root}`))]}),s!==null&&n.jsx("p",{className:"text-xs text-destructive",children:s})]})}function j4(e){switch(e){case"retention-gc":return"Retention GC";case"orphan-reclaim":return"Orphan reclaim";case"rotation":return"Rotation-owned";case"manual-owner-delete":return"Manual only";default:return e}}function Ro({label:e,value:t,detail:s}){return n.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[n.jsx("div",{className:"font-medium",children:e}),n.jsx("div",{className:"mt-1 font-mono text-muted-foreground",children:t}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:s})]})}function S4({artifact:e,copiedId:t,onCopy:s}){const o=`storage-${e.kind}`,r=e.oldestModifiedAt===null?"none":new Date(e.oldestModifiedAt),a=e.newestModifiedAt===null?"none":new Date(e.newestModifiedAt);return n.jsxs("div",{className:"rounded-md border border-border/45 bg-muted/15 px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:e.kind}),n.jsxs("div",{className:"mt-1 text-[11px] text-muted-foreground",children:[j4(e.cleanupBehavior)," · ",e.sensitivity]})]}),n.jsxs("div",{className:"text-right font-mono text-muted-foreground",children:[e.fileCount.toLocaleString()," files / ",Ls(e.bytes)]})]}),n.jsxs("div",{className:"mt-2 grid gap-1 text-[11px] text-muted-foreground sm:grid-cols-2",children:[n.jsxs("div",{children:["Oldest: ",r instanceof Date?r.toLocaleString():r]}),n.jsxs("div",{children:["Newest: ",a instanceof Date?a.toLocaleString():a]})]}),n.jsx("div",{className:"mt-2",children:n.jsx(Bl,{id:o,label:"Root path",value:e.root,copiedId:t,onCopy:s})})]})}function Bl({id:e,label:t,value:s,copiedId:o,onCopy:r}){const a=o===e;return n.jsxs("div",{className:"min-w-0 rounded-md border border-border/45 bg-muted/15 px-3 py-2 transition-colors hover:bg-muted/25",children:[n.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),n.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>r(e,s),"aria-label":a?`Copied ${t}`:`Copy ${t}`,children:a?n.jsx(Pe,{className:"size-3.5 text-status-success"}):n.jsx(Et,{className:"size-3.5"})})]})]})}function N4(){const[e,t]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Xi(o),[]);const r=l.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"doctor",label:"Backend doctor",value:"agent-inspector doctor --verbose"},{id:"support-bundle",label:"Redacted support bundle",value:"agent-inspector doctor --support-bundle"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},...s===null?[]:[{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${s.proxy}`},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${s.openAiV1}`},{id:"mcp",label:"MCP URL",value:s.mcp},{id:"proxy",label:"Proxy URL",value:s.proxy},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${s.proxy}`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${s.openAiV1}`}]],[s]),a=l.useCallback((i,c)=>{Nt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(Bl,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),n.jsxs("div",{className:"grid gap-2 rounded-md border border-status-info/25 bg-status-info/10 px-3 py-2 text-xs",children:[n.jsx("div",{className:"font-medium text-foreground",children:"Verified first trace flow"}),n.jsxs("ol",{className:"ml-4 list-decimal space-y-1 text-muted-foreground",children:[n.jsx("li",{children:"Start Agent Inspector and confirm the application bar shows Live."}),n.jsx("li",{children:"Copy the Proxy URL or MCP URL that matches your coding agent."}),n.jsx("li",{children:"Run a tiny coding-agent prompt such as “say hello and stop”."}),n.jsx("li",{children:"Return to Logs and confirm one new request appears with request, response, tokens, and tool activity when present."})]})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Pe,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Pe,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",n.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["OpenCode onboarding safely merges"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["If the first trace does not appear, run"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector doctor --verbose"})," ","and compare the agent base URL with the current Proxy URL. A base-path mismatch such as"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/"})," ","versus"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/inspector"})," ","means the tool is talking to a different Inspector surface."]})]})]})]})}function C4(){const[e,t]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Xi(i=>{o(i?.mcp??null)}),[]);const r=l.useMemo(()=>s===null?[]:[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:s},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${s}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${s}`},{id:"writes",label:"Enable write tools",value:"AGENT_INSPECTOR_MCP_WRITES=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:s}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",s]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
59
59
  command = "agent-inspector-mcp"
60
- args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{Nt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),n.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),s===null?n.jsx("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"The browser runtime does not provide a valid agent-facing MCP endpoint."}):n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(Bl,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function k4(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Wi(),[m,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useCallback(async w=>{u(null),f(!0);try{await a(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[a]),g=l.useCallback(async w=>{u(null),f(!0);try{await i(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[i]),b=l.useCallback(async w=>{u(null),f(!0);try{await c(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[c]),y=l.useCallback(async w=>{u(null),f(!0);try{await d(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[d]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",n.jsx("code",{children:"config.json"}),"."]})]}),n.jsxs("label",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",n.jsx("code",{children:"0"})," to disable it."]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Ya,step:1,value:t,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>Ya||g(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Ja,step:1,value:s,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>Ja||b(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),n.jsxs("select",{id:"time-display-format",value:o,disabled:r||p,onChange:w=>{const v=Su.safeParse(w.currentTarget.value);v.success&&y(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[n.jsx("option",{value:"time",children:"Time only"}),n.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&n.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const _4=ue(["installed","update-available","available","planned","unknown"]),T4=_({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:_4,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:ke()}),E4=_({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:W(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),R4=_({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:ke(),runnable:ke()}),M4=_({checkedAt:x(),packages:W(T4),runnerPresets:W(E4),recipes:W(R4)}),ah=ue(["install","upgrade","help","runner-presets","recipe"]),ih="RUN_LOCAL_COMMAND",A4=_({action:ah,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:E().int().positive(),scope:x()}),I4=_({nonce:x().uuid(),phrase:oe(ih),expiresAt:x().datetime(),plan:A4}),lh=_({confirmation:I4});wn("intent",[_({intent:oe("prepare")}),_({intent:oe("confirm"),nonce:x().uuid(),confirmation:oe(ih)})]);const P4=ue(["queued","running","succeeded","failed"]),ch=_({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:ah,status:P4,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:E().nullable(),error:x().nullable()}),dh=_({task:ch}),L4=_({tasks:W(ch)}),O4=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:a0},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Ct},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Gi},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:Zg}];async function D4(e){return Ze(e,M4,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function z4(e){return Ze(e,dh,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function $4(e){return Ze(e,L4,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function F4(e,t){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,o=await Ze(s,lh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},r=>`Failed to prepare ecosystem task: ${String(r.status)}`);return{endpoint:s,confirmation:o.confirmation}}async function B4(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ze(t,lh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:t,confirmation:s.confirmation}}async function U4(e){return(await Ze(e.endpoint,dh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},s=>`Failed to start ecosystem task: ${String(s.status)}`)).task}function q4(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function H4(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function V4(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function Ds(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets";case"recipe":return"Recipe"}}function W4(e){switch(e.status){case"queued":return"Queued";case"running":return`${Ds(e.action)} running`;case"succeeded":return`${Ds(e.action)} complete`;case"failed":return`${Ds(e.action)} failed`}}function uh(e){switch(e){case"queued":case"running":return"border-cyan-300/20 bg-cyan-300/8 text-cyan-100";case"succeeded":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-100";case"failed":return"border-red-400/20 bg-red-400/8 text-red-100"}}function G4(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function K4({pkg:e,activeTask:t,onStartTask:s}){const o=G4(e),r=t!==null&&t.packageId===e.id&&t.status==="running";return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(n1,{className:"size-4 shrink-0 text-white/55"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),n.jsx(Ce,{className:O("shrink-0",H4(e.state)),variant:"outline",children:q4(e.state)})]}),n.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:V4(e)}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&n.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Xs,{className:"size-3.5"}),Ds(o)]}),n.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[n.jsx(Fn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&n.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[n.jsx(Gi,{className:"size-3.5"}),"Presets"]})]})]})}function Y4({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return n.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?n.jsx(Oe,{className:"size-4 animate-spin text-cyan-200/75"}):n.jsx(Fn,{className:"size-4 text-white/55"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-semibold",children:W4(e)}),n.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),n.jsx(Ce,{variant:"outline",className:O("shrink-0",uh(e.status)),children:e.status})]}),n.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&n.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function J4({workflow:e}){const t=e.icon;return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),n.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),n.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function X4(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function Z4({preset:e}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Pu,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),n.jsxs(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[n.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function Q4({recipe:e,copied:t,running:s,onCopy:o,onRun:r}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Eu,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),n.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),n.jsx(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),n.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),n.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[t?n.jsx(Pe,{className:"size-3.5"}):n.jsx(Et,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&n.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Pu,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function e_({task:e,selected:t,onSelect:s}){const o=e.recipeId??Ds(e.action);return n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Mu,{className:"size-3.5 shrink-0 text-white/40"}),n.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),n.jsx(Ce,{variant:"outline",className:O("shrink-0",uh(e.status)),children:e.status})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[n.jsx("span",{children:e.packageId}),n.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&n.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),n.jsx(ee,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>s(e),children:t?"Open":"View"})]})}function t_({pending:e,busy:t,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return n.jsx(Ft,{open:e!==null,onOpenChange:s,children:n.jsxs(Bt,{className:"max-w-xl",children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Confirm local command"}),n.jsx(oo,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Source"}),n.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),n.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[n.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),n.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),n.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:r.command})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",n.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(ee,{type:"button",variant:"outline",disabled:t,onClick:()=>s(!1),children:"Cancel"}),n.jsxs(ee,{type:"button",variant:"secondary",disabled:t||r===null,onClick:o,children:[t?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Fn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function n_({currentSessionId:e,logCount:t,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(!1),j=Ot("/api/ecosystem/packages",D4,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=Ot(p===null?null:`/api/ecosystem/tasks/${p}`,z4,{refreshInterval:U=>{const K=U?.task;return K!==void 0&&(K.status==="queued"||K.status==="running")?900:0},revalidateOnFocus:!1}),N=Ot(o?"/api/ecosystem/tasks":null,$4,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],R=j.data?.runnerPresets??[],P=j.data?.recipes??[],L=(N.data?.tasks??[]).slice(0,6),M=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=X4(e),A="npx @tonyclaw/eval-harness runner-presets",D=()=>{Nt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},F=()=>{Nt(A).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},Y=U=>{Nt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},X=U=>{g(null),B4(U.id).then(K=>{y(K)}).catch(K=>{g(K instanceof Error?K.message:"Failed to prepare ecosystem recipe")})},$=S.data?.task??null;l.useEffect(()=>{$!==null&&(N.mutate(),$.status==="succeeded"&&j.mutate())},[$,j,N]);const V=(U,K)=>{g(null),F4(U,K).then(ae=>{y(ae)}).catch(ae=>{g(ae instanceof Error?ae.message:"Failed to prepare ecosystem task")})},J=()=>{b!==null&&(g(null),v(!0),U4(b).then(U=>{f(U.id),y(null),S.mutate({task:U},{revalidate:!0}),N.mutate()}).catch(U=>{g(U instanceof Error?U.message:"Failed to start ecosystem task")}).finally(()=>{v(!1)}))};return n.jsxs(Ft,{open:o,onOpenChange:r,children:[n.jsx(so,{asChild:!0,children:n.jsxs(ee,{variant:"ghost",size:s?"default":"icon",className:O(ao,s&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[n.jsx(Eu,{className:"size-4"}),n.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),n.jsxs(Bt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Wt,{children:n.jsxs(Gt,{className:"flex items-center gap-2",children:[n.jsx(Za,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),n.jsxs("div",{className:"overflow-y-auto pr-2",children:[n.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),n.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),n.jsxs(Ce,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(M),"/",String(C.length)," packages"]})]}),n.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:O4.map(U=>n.jsx(J4,{workflow:U},U.id))})]}),n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),n.jsxs(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),n.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:k}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[n.jsxs(ee,{size:"sm",variant:"secondary",onClick:D,children:[a?n.jsx(Pe,{className:"size-3.5"}):n.jsx(Et,{className:"size-3.5"}),a?"Copied":"Copy"]}),n.jsxs(ee,{size:"sm",variant:"outline",onClick:F,children:[n.jsx(Gi,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(Za,{className:"size-3.5"}),"copy-ready workflows"]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[P.map(U=>n.jsx(Q4,{recipe:U,copied:m===U.id,running:$!==null&&$.recipeId===U.id&&($.status==="queued"||$.status==="running"),onCopy:Y,onRun:X},U.id)),j.isLoading&&P.length===0&&[0,1].map(U=>n.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(Fn,{className:"size-3.5"}),A]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[R.map(U=>n.jsx(Z4,{preset:U},U.id)),j.isLoading&&R.length===0&&[0,1,2,3].map(U=>n.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&n.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&n.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>n.jsx(K4,{pkg:U,activeTask:$,onStartTask:V},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>n.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),h!==null&&n.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:h}),L.length>0&&n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),n.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(L.length)]})]}),n.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:L.map(U=>n.jsx(e_,{task:U,selected:p===U.id,onSelect:K=>{f(K.id),S.mutate({task:K},{revalidate:!0})}},U.id))})]}),n.jsx(Y4,{task:$})]})]}),n.jsx(t_,{pending:b,busy:w,onOpenChange:U=>{!U&&!w&&y(null)},onConfirm:J})]})}function s_(e){return[...new Set(e.evidence.map(t=>t.logId).filter(t=>t!==null))]}const o_=[{id:"reliability",label:"Reliability",question:"Which requests failed, stalled, or look most likely to hang, and why?"},{id:"performance",label:"Performance",question:"Summarize latency and identify the slowest requests with supporting evidence."},{id:"tokens",label:"Token usage",question:"Where are tokens being spent, and which requests have unusually high usage?"},{id:"providers",label:"Providers",question:"Compare Provider and model reliability, latency, and token usage in this scope."},{id:"tools",label:"Tool activity",question:"Which tools were used most, and where did tool calls fail or produce warnings?"}],r_=4e3,Fa=12;function yd(){return{messages:[],question:"",error:null}}function a_(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,r_)}))}function st(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function dn(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function i_(e,t){const s=G(e,t);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function l_(e){const t=st(e,"source")??"log",s=st(e,"id")??"",o=dn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=dn(e,"inputTokens"),a=dn(e,"outputTokens"),i=dn(e,"totalTokens","tokenCount"),c=dn(e,"responseStatus","status"),d=st(e,"responseStatus","status");return{source:t,id:s!==""?s:String(o),logId:o,sessionId:st(e,"sessionId"),timestamp:st(e,"timestamp"),model:st(e,"model"),providerName:st(e,"providerName","provider"),path:st(e,"path"),status:c??d,elapsedMs:dn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:dn(e,"score","relevanceScore"),matchedFields:i_(e,"matchedFields"),excerpt:st(e,"excerpt","snippet")??"No excerpt available."}}function Ba(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function wd(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const t=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return t.length>0?t.join(", "):null}return null}function jd(e){return Object.getOwnPropertyNames(e).map(t=>[t,G(e,t)])}function Sd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[s,o]of jd(e)){const r=wd(o);if(r!==null){if(t.push({key:s,label:Ba(s),value:r}),t.length>=Fa)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of jd(o)){const c=wd(i);if(c===null)continue;const d=`${s}.${a}`;if(t.push({key:d,label:`${Ba(s)} ${Ba(a).toLowerCase()}`,value:c}),t.length>=Fa)break}if(t.length>=Fa)break}}return t}function c_(e){const t=st(e,"answer"),s=st(e,"providerId"),o=st(e,"providerName"),r=st(e,"model"),a=st(e,"protocol"),i=dn(e,"logCount");if(t===null||s===null||o===null||r===null||a===null||i===null)return null;const c=G(e,"evidence"),d=Array.isArray(c)?c.map(l_).filter(m=>m!==null).slice(0,12):[];return{answer:t,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:Sd(G(e,"summary")),queryMetrics:Sd(G(e,"queryStats"))}}const d_=l.lazy(()=>qt(()=>import("./index-CN-gZDqV.js"),__vite__mapDeps([10,1,2]),import.meta.url)),u_="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]",Ua=96*1024;function m_({text:e}){const[t,s]=l.useState(!1),o=e.length>Ua,r=o&&!t?e.slice(0,Ua):e;return l.useEffect(()=>{s(!1)},[e]),n.jsxs("div",{className:"space-y-2",children:[o&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Ua.toLocaleString()," characters for fast rendering. The full response is preserved."]}),n.jsx("div",{className:u_,children:n.jsx(l.Suspense,{fallback:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:n.jsx(d_,{children:r})})}),o&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(a=>!a),children:t?"Collapse fast preview":`Render full response (${e.length.toLocaleString()} chars)`})]})}const Nd="What looks abnormal, slow, or likely to hang?";function p_(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function f_(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function h_(e){return e.toSorted((t,s)=>{const o=t.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:t.name.localeCompare(s.name)})}function Cd(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Rn({label:e,value:t,tone:s="muted"}){return n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[n.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),t!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/55",children:":"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t})]})]})}function x_({metrics:e}){return e.length===0?null:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>n.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[n.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:t.label}),n.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:t.value})]},t.key))})}function g_({evidence:e}){const t=()=>{e.logId!==null&&vs({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return n.jsxs("button",{type:"button",onClick:t,disabled:e.logId===null,className:"w-full rounded-sm bg-black/25 px-2 py-2 text-left shadow-[inset_2px_0_0_rgba(103,232,249,0.22),inset_0_0_0_1px_rgba(255,255,255,0.045)] transition-colors hover:bg-black/35 disabled:cursor-default disabled:hover:bg-black/25",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&n.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&n.jsx("span",{children:e.providerName}),e.model!==null&&n.jsx("span",{children:e.model}),e.status!==null&&n.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&n.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),n.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function b_({response:e}){return n.jsxs("div",{className:"overflow-hidden rounded-md bg-[#050b12]/85 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.12),0_10px_24px_rgba(0,0,0,0.18)]",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-cyan-100/[0.08] bg-cyan-400/[0.045] px-3 py-2",children:[n.jsx(Rn,{label:"assistant@inspector",value:"output",tone:"cyan"}),n.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),n.jsxs("div",{className:"space-y-3 p-3",children:[n.jsx("div",{className:"rounded-sm bg-black/20 px-2.5 py-2 text-xs leading-5 shadow-[inset_2px_0_0_rgba(103,232,249,0.28)]",children:n.jsx(m_,{text:e.answer})}),n.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[n.jsx(Rn,{label:"provider",value:e.providerName}),n.jsx(Rn,{label:"model",value:e.model}),n.jsx(Rn,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Rn,{label:"metrics",tone:"cyan"}),n.jsx(x_,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Rn,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(t=>n.jsx(g_,{evidence:t},`${t.source}-${t.id}`))]})]})]})}function v_({message:e}){return e.role==="assistant"&&e.response!==null?n.jsx(b_,{response:e.response}):n.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:n.jsx(Rn,{label:"user@inspector",value:"query",tone:"cyan"})}),n.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[n.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function y_({currentSessionId:e,logCount:t,onResultChange:s}){const{providers:o}=nl(),r=l.useMemo(()=>h_(o.filter(p_)),[o]),[a,i]=l.useState(()=>({...yd(),question:Nd})),[c,d]=l.useState("__auto__"),[m,u]=l.useState("__auto__"),[p,f]=l.useState(!1),g=r.find(C=>C.id===c)?.models??[],b=a.question,y=b.trim()!==""&&r.length>0&&!p;if(r.length===0)return null;const w=C=>{i(R=>({...R,question:C.currentTarget.value}))},v=C=>{d(C),u("__auto__")},j=()=>{i({...yd(),question:Nd}),s(null)},S=C=>{i(R=>({...R,question:C,error:null}))},N=()=>{if(!y)return;const C=b.trim(),R=a_(a.messages),P={id:Cd("user"),role:"user",content:C,response:null};f(!0),i(M=>({...M,messages:[...M.messages,P],question:"",error:null}));const L={question:C,history:R,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};Jh("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(L)}).then(async M=>{const k=await M.text();if(!M.ok){i(F=>({...F,error:`Inspector Assistant failed: HTTP ${String(M.status)} ${k}`}));return}const A=JSON.parse(k),D=c_(A);if(D===null){i(F=>({...F,error:"Inspector Assistant returned an unexpected response."}));return}i(F=>({...F,messages:[...F.messages,{id:Cd("assistant"),role:"assistant",content:D.answer,response:D}]})),s({question:C,logIds:s_(D),reportedLogCount:D.logCount})}).catch(M=>{i(k=>({...k,error:M instanceof Error?M.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return n.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(S0,{className:"size-4 text-cyan-200"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),n.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),n.jsx("button",{type:"button",onClick:j,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:n.jsx(Lu,{className:"size-3.5"})})]}),a.messages.length===0&&n.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[n.jsxs(Vs,{value:c,onValueChange:v,children:[n.jsx(Ws,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(dr,{placeholder:"Provider"})}),n.jsxs(Gs,{children:[n.jsx(ot,{value:"__auto__",children:"Auto provider"}),r.map(C=>n.jsxs(ot,{value:C.id,children:[C.name," / ",f_(C)]},C.id))]})]}),n.jsxs(Vs,{value:m,onValueChange:u,children:[n.jsx(Ws,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(dr,{placeholder:"Model"})}),n.jsxs(Gs,{children:[n.jsx(ot,{value:"__auto__",children:"Auto model"}),g.map(C=>n.jsx(ot,{value:C,children:C},C))]})]})]}),a.messages.length===0&&n.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:o_.map(C=>n.jsxs("button",{type:"button",onClick:()=>{S(C.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[n.jsx(Za,{className:"size-3"}),n.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&n.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>n.jsx(v_,{message:C},C.id)),p&&n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx(Oe,{className:"size-3.5 animate-spin"}),n.jsx("span",{children:"Searching Inspector..."})]})]}),n.jsx("textarea",{value:b,onChange:w,className:"mt-3 min-h-20 w-full resize-y rounded-md bg-black/25 px-3 py-2 text-xs leading-5 text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring",placeholder:"Ask about this Inspector data..."}),n.jsxs("button",{type:"button",onClick:N,disabled:!y,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[p?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(S1,{className:"size-3.5"}),n.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),a.error!==null&&n.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),t===0&&n.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function w_(e){const t=new Map;for(const s of e){const o=s.logs;for(let r=1;r<o.length;r++){const a=o[r-1],i=o[r];a===void 0||i===void 0||t.set(i.id,{creation:kd(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:kd(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return t}function kd(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function mh(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function es(e,t,s){const o=mh(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${t}${i}${r}${a}`}function ph(e,t,s){switch(e){case"connecting":return{label:"Connecting",description:es(t,"Waiting for the first live update.",s),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:es(t,"Live updates are current.",s),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:es(t,"Live updates were interrupted.",s),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:es(t,"Live updates have not resumed.",s),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:es(t,t.errorMessage??"Live updates are paused.",s),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:es(t,t.errorMessage??"The live stream reported a recoverable error.",s),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function j_({state:e}){const t=ph(e.status,e,!1),s=mh(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return n.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:O("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[n.jsx("span",{className:O("size-1.5 shrink-0 rounded-full",t.dotClass)}),n.jsx("span",{className:"shrink-0",children:t.label}),o!==null&&n.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&n.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function S_({state:e,hasLogs:t,onRetry:s,onStop:o}){const r=ph(e.status,e,t);return n.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:O("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",r.toneClass),children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:O("size-2 shrink-0 rounded-full",r.dotClass)}),n.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),n.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&n.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[n.jsx(Ct,{className:"size-3"}),"Retry now"]}),r.canStop&&n.jsxs("button",{type:"button",onClick:o,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[n.jsx(V0,{className:"size-3"}),"Stop retrying"]})]})]})}function N_(){const[e,t]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{t(document.fullscreenElement!==null),o(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return i(),document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]);const r=l.useCallback(()=>{if(s){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{t(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{t(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return n.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ao,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?n.jsx(qg,{className:"size-4"}):n.jsx(Fg,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:a})]})}function C_({liveConnection:e,alertsAction:t,settingsAction:s}){return n.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:n.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[n.jsxs("a",{href:Pi("/"),"aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[n.jsx(ou,{className:"size-7 shrink-0 text-amber-500"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),n.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),n.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",zu.version]})]}),n.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?n.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[n.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):n.jsx(j_,{state:e})}),n.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[n.jsx(N_,{}),t,s]})]})})}function k_(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function qo({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(t*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=t>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${k_(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return n.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 truncate",children:e.label}),n.jsx("span",{className:O("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),n.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":i,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:n.jsx("div",{className:O("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",r?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${s.toString()}%`}})})]})}function fh(e){return e?"auto":"smooth"}function hh(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function __(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function It(e,t){switch(t.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:t.message}:{...e,status:"offline",retryCount:s,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:t.message}}}function T_(e){return e===void 0||e.status==="live"?"empty":e.status}function E_(e){switch(e){case"connecting":return{title:"Connecting to the live stream...",description:"Waiting for the first successful initialization before checking for logs.",showConnectionCommands:!1};case"empty":return{title:"No logs captured yet.",description:"Connect an AI coding tool to capture its first request.",showConnectionCommands:!0};case"reconnecting":return{title:"Reconnecting to live updates...",description:"The stream was interrupted. Agent Inspector is retrying automatically.",showConnectionCommands:!1};case"stale":return{title:"Live data is stale.",description:"No logs are hidden; retry the connection to resume live updates.",showConnectionCommands:!1};case"offline":return{title:"Live updates are offline.",description:"Check the browser and Inspector connection, then retry.",showConnectionCommands:!1};case"error":return{title:"Live updates could not initialize.",description:"The error is recoverable. Retry without reloading the page.",showConnectionCommands:!1}}}const _d="agent-inspector.hierarchy.collapsedClients",Td="agent-inspector.hierarchy.collapsedProcesses";function pr(e){return e.some(t=>t.responseStatus===null)}function xh(e){return e.filter(t=>t.responseStatus===null).length}function gh(e){for(const t of e){const s=t.userAgent;if(s!=null&&s!=="")return s}return null}function R_(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function bh(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function M_(e){return _l({userAgent:gh(e.logs),conversationId:e.conversationId,clientProjectFolder:bh(e.logs)})}function A_(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function I_(e,t){const s=qr(e);return s!==null?s:A_(t)}function fr(e){return e===null||e===""?"unknown":String(e)}function P_(e,t,s){return e!=="unknown"?e:`unknown:${fr(t)}:${fr(s)}`}function L_(e,t){return`${fr(e)}:${fr(t)}`}function Ed(e){return[...e].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}function Rd(e){let t="";for(const s of e)s.timestamp>t&&(t=s.timestamp);return t}function Md(e){return pr(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function qa(e){return[...e].sort((t,s)=>{const o=Md(t.logs)-Md(s.logs);if(o!==0)return o;const r=Rd(s.logs).localeCompare(Rd(t.logs));return r!==0?r:t.id.localeCompare(s.id)})}function O_(e){const t=new Map;for(const o of e){const r=gh(o.logs),a=bh(o.logs),i=M_(o),c=P_(i,r,a);let d=t.get(c);d===void 0&&(d={id:c,client:i,label:I_(i,r),userAgent:r,processes:new Map,logs:[]},t.set(c,d)),d.logs.push(...o.logs);const m=R_(o.logs),u=`${c}:${L_(m,a)}`;let p=d.processes.get(u);p===void 0&&(p={id:u,clientPid:m,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,p)),p.sessions.push(o),p.logs.push(...o.logs)}const s=[];for(const o of t.values()){const r=qa([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:qa(a.sessions),logs:Ed(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:Ed(o.logs)})}return qa(s)}function hr(e){return e<=0?"0":Ee(e)}function vh(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(t+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:t,outputTokens:s}}function D_(e){let t=0;for(const s of e)t+=s.sessions.length;return t}function Ad(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const s=JSON.parse(t);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function Id(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Pd(e,t){let s=!1;const o=new Set(e);for(const r of t)o.delete(r)&&(s=!0);return s?o:e}function z_(e){const t=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!pr(r.logs)&&t.add(r.id)}return t}function $_(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=t[t.length-1];if(s===void 0)return e;const o=t[t.length-2];return o===void 0?s:`${o}/${s}`}function xr({label:e,value:t,className:s}){return n.jsxs("span",{className:O("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),n.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function yh({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return n.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":t,title:t,children:[n.jsx(Oe,{className:"size-3 animate-spin"}),e>1&&n.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function F_({groups:e,...t}){const s=l.useMemo(()=>O_(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>z_(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const p=Ad(_d),f=Ad(Td);p!==null&&r(p),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(Id(_d,o),Id(Td,a))},[o,a,c]),l.useEffect(()=>{const p=new Set(s.filter(h=>pr(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>pr(g.logs)).map(g=>g.id)));r(h=>Pd(h,p)),i(h=>Pd(h,f))},[s]);const m=l.useCallback(p=>{r(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),u=l.useCallback(p=>{i(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]);return n.jsx("div",{className:"space-y-2",children:s.map(p=>n.jsx(B_,{group:p,collapsed:o.has(p.id),collapsedProcessIds:a,onToggleClient:()=>m(p.id),onToggleProcess:u,conversationProps:t},p.id))})}function B_({group:e,collapsed:t,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=vh(e.logs),c=D_(e.processes),d=e.logs.length,m=xh(e.logs),u=m>0;return n.jsxs("section",{className:O("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[n.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:o,"aria-expanded":!t,children:[e.client==="unknown"?n.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:n.jsx(Wg,{className:"size-4"})}):n.jsx(Hr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),n.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:Pj(e.client)}),u&&n.jsx(yh,{count:m})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),n.jsxs("span",{children:[c," session",c!==1?"s":""]}),n.jsxs("span",{children:[d," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(xr,{label:"IN",value:hr(i.inputTokens)}),n.jsx(xr,{label:"OUT",value:hr(i.outputTokens)})]}),n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:t?n.jsx(ft,{className:"size-4"}):n.jsx(We,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>n.jsx(U_,{group:p,collapsed:s.has(p.id),onToggle:()=>r(p.id),conversationProps:a},p.id))})]})}function U_({group:e,collapsed:t,onToggle:s,conversationProps:o}){const r=vh(e.logs),a=$_(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=xh(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return n.jsxs("section",{className:"relative pl-3",children:[n.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:s,"aria-expanded":!t,children:[n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:n.jsx(rg,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&n.jsx(yh,{count:d}),a!==null&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[n.jsx(_g,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",children:a})]})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[i," session",i!==1?"s":""]}),n.jsxs("span",{children:[c," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(xr,{label:"IN",value:hr(r.inputTokens)}),n.jsx(xr,{label:"OUT",value:hr(r.outputTokens)})]}),n.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:t?n.jsx(ft,{className:"size-4"}):n.jsx(We,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>n.jsx(zC,{group:p,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const q_="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",H_=[{label:"Headers",detail:"request and response headers, including authorization or cookie values"},{label:"Prompts",detail:"system instructions, user prompts, model responses, and conversation history"},{label:"Source content",detail:"source code, file contents, tool inputs, and tool output"},{label:"Secrets",detail:"API keys, access tokens, credentials, and other sensitive values"}];function V_({onCancel:e,onExportRedacted:t,onConfirmRaw:s}){return n.jsxs(n.Fragment,{children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Export unredacted logs?"}),n.jsx(oo,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),n.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[n.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),n.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:H_.map(o=>n.jsxs("li",{children:[n.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),n.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),n.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),n.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const gr="data-nav-id",W_="data-nav-action";function Ld(e){return Array.from(e.querySelectorAll(`[${gr}]`))}function Od(e){return e instanceof HTMLElement}function G_(e,t){let s=e;for(;s!==null&&s!==t;){if(s.hasAttribute(gr))return s;s=s.parentElement}return e.hasAttribute(gr)?e:null}function Ha(e){const t=e.getAttribute(W_);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function As(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Is(e,t){return e[t]??null}function wh(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function Dd(e){const t=e.tagName;return t==="BUTTON"||t==="A"||wh(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function K_(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function Y_(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Mo(e,t){return e.key===t&&e.shiftKey}function J_(e,t,s={}){const o=t??e,r=s.pageWide===!0,a=l.useCallback(i=>{const c=e.current,d=o.current;if(!c||!d)return;const m=i.target;if(!Od(m)||m!==d)return;const u=Ld(c),p=Is(u,0);p!==null&&As(p)},[e,o]);l.useEffect(()=>{const i=c=>{if(c.altKey||c.ctrlKey||c.metaKey)return;const d=e.current;if(!d)return;const m=c.target;if(!Od(m)||wh(m)||Y_())return;const u=d.contains(m);if(u&&Dd(m)&&!m.hasAttribute(gr)||!u&&(!r||Dd(m)||K_(m)))return;const p=Ld(d);if(p.length===0)return;const f=G_(m,d),h=f!==null?p.indexOf(f):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!Mo(c,"W"))break;c.preventDefault();const b=h>0?h-1:h===-1?p.length-1:-1;if(b!==-1){const y=Is(p,b);y!==null&&As(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!Mo(c,"S"))break;c.preventDefault();const b=h<p.length-1?h+1:h===-1?0:-1;if(b!==-1){const y=Is(p,b);y!==null&&As(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!Mo(c,"A")||f===null)break;if(c.preventDefault(),Ha(f)==="collapse")f.click();else if(h>0){const y=Is(p,h-1);y!==null&&As(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!Mo(c,"D")||f===null)break;if(c.preventDefault(),Ha(f)==="expand")f.click();else if(h<p.length-1){const y=Is(p,h+1);y!==null&&As(y)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Ha(f)!==null&&f.click(),g=!0;break}}g&&c.stopPropagation()};return document.addEventListener("keydown",i,{capture:!0}),()=>document.removeEventListener("keydown",i,{capture:!0})},[e,r,o]),l.useEffect(()=>(document.addEventListener("focusin",a),()=>document.removeEventListener("focusin",a)),[a])}const X_={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},Z_={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},Q_={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},Va=12,Ao=1,zd=80,$d=24;function eT(e){return e.length<=$d?e:`${e.slice(0,$d-3)}...`}function tT(e){const t=e.replace(/\s+/g," ").trim();return t.length<=zd?t:`${t.slice(0,zd)}...`}function Io(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const nT=l.memo(function({segments:t,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:t.reduce((y,w)=>y+w.size,0),[t,s]),i=t.slice(0,Va),c=t.slice(Va),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=Va,p=u+m-1,f=m>0,h=r!==void 0,g=l.useMemo(()=>i.reduce((y,w)=>y+w.size,0),[i]),b=l.useMemo(()=>`Request context: ~${Ee(a)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,a]);return t.length===0||a<=0?n.jsx("div",{role:"img","aria-label":b,className:"h-6"}):n.jsx(Ns,{delayDuration:150,children:n.jsxs("div",{role:"img","aria-label":b,className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Ao,v),S=O("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",Z_[y.role],h?Q_[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${Io(v)}, ~${Ee(y.size)} tokens`;return n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:h?n.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):n.jsx("span",{"aria-label":C,className:S,style:N})}),n.jsxs(ct,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[n.jsxs("div",{className:"font-semibold",children:[y.label," - ",Io(v)," - ~",Ee(y.size)," ","tokens"]}),n.jsx("div",{className:"text-muted-foreground",children:X_[y.role]}),n.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&n.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:tT(y.text)})]})]},`${y.path}-${w}`)}),f&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsxs("div",{role:"img","aria-label":`${m} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(Ao,d/a*100)}%`},children:["... +",m]})}),n.jsxs(ct,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",p,")"]})]})]}),o&&n.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Ao,v);return n.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${Io(v)} - ~${Ee(y.size)} tokens`,children:[n.jsx("span",{className:"truncate font-mono text-foreground/80",children:eT(y.label)}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Io(v)," - ~",Ee(y.size)]})]},`label-${y.path}-${w}`)}),f&&n.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Ao,d/a*100)}%`},children:[n.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ee(d)]})]})]}),g<a*.1&&n.jsx("div",{className:"h-0"})]})})}),jh=.75,Sh=.9,Ti=8e3,sT=.35,Nh=40,Ch=160,oT=5,rT=8,aT=18,iT=6e4,lT=.7,Fd=3e3,cT=.3,Bd=160,dT=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),uT=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],mT=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],pT=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],fT={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function hT(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function kh(e,t){for(const s of t){const o=hT(G(e,s));if(o!==null)return o}return null}function xT(e){const t=G(e,"model");if(typeof t!="string")return null;const s=t.trim();return s===""?null:s}function gT(e,t){switch(t.mode){case"prefix":return t.patterns.some(s=>e.startsWith(s));case"includes":return t.patterns.some(s=>e.includes(s))}}function bT(e,t,s=[]){const o=kh(t,uT);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=g3(e,s);if(r!==null)return{tokens:r.tokens,label:`${r.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const a=e.trim().toLowerCase().replace(/\s+/g,"-");for(const i of pT)if(gT(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function vT(e){return e<0?0:e>1?1:e}function yT(e){return e===null?"unknown":e>=Sh?"danger":e>=jh?"watch":"ok"}function wT(e,t){return e.filter(s=>s.role===t).reduce((s,o)=>s+o.size,0)}function jT(e,t){return["system","user","assistant","tool","tools"].map(o=>{const r=wT(e,o);return{role:o,label:fT[o],tokens:r,percent:t>0?r/t:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function Ei(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function ST(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Bd?t:`${t.slice(0,Bd-3)}...`}function NT(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function CT(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function kT(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function _T(e){if(!kT(e))return null;try{return JSON.parse(e)}catch{return null}}function TT(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function ET(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function RT(e){const t=ET(e);return t===null?!1:dT.has(TT(t))}function MT(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function AT(e,t,s){const o=El(t);if(o<Ch)return null;const r=Tl(t);return r<Nh?null:{role:e.role,label:`${e.label} ${MT(s)}`,path:e.path,tokens:r,characters:o,text:t}}function Ri({value:e,segment:t,path:s,depth:o,candidates:r}){if(!(r.length>=rT)&&!(o>oT)){if(typeof e=="string"){if(!RT(s))return;const a=AT(t,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Ri({value:a,segment:t,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}Rl(e)&&Object.entries(e).forEach(([a,i])=>Ri({value:i,segment:t,path:[...s,a],depth:o+1,candidates:r}))}}function IT(e){const t=CT(e),s=_T(e.text);if(s===null)return[t];const o=[];Ri({value:s,segment:e,path:[],depth:0,candidates:o});const r=Ei(e.text),a=new Set([r]),i=o.filter(c=>{const d=Ei(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[t,...i]}function PT(e){const t=new Map;for(const o of e){const r=IT(o);for(const a of r){if(a.tokens<Nh||a.characters<Ch)continue;const i=Ei(a.text);if(i==="")continue;const c=t.get(i);if(c===void 0){t.set(i,{tokens:a.tokens,candidates:[a]});continue}t.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of t.values()){if(o.candidates.length<2)continue;const r=o.candidates[0]??null;if(r===null)continue;const a=o.tokens-r.tokens;s.push({key:`${r.path}:${r.label}:${String(o.candidates.length)}:${String(o.tokens)}`,count:o.candidates.length,totalTokens:o.tokens,repeatedTokens:a,preview:ST(r.text),firstLabel:r.label,segments:o.candidates.map(NT)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function LT(e){if(e.length===0)return null;const t=e.length,s=e.reduce((r,a)=>r+a.count,0),o=e.reduce((r,a)=>r+a.repeatedTokens,0);return{kind:"duplicate",severity:o>=Ti?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(o)} repeated tokens.`}}function OT(e){return e.reduce((t,s)=>t+s.repeatedTokens,0)}function DT(e,t,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=Ti||r.percent>=sT&&r.tokens>=Fd)&&o.push({kind:"tool-schema",severity:r.tokens>=Ti?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(r.percent*100)}% of request context.`});const a=e.find(d=>d.role==="system")??null;a!==null&&a.tokens>=Fd&&a.percent>=cT&&o.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(a.percent*100)}% of request context.`});const i=e.filter(d=>d.role==="user"||d.role==="assistant"||d.role==="tool").reduce((d,m)=>d+m.tokens,0),c=t>0?i/t:0;return s>=aT&&(i>=iT||c>=lT)&&o.push({kind:"history-bloat",severity:c>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(s)} message blocks take ${Math.round(c*100)}% of request context.`}),o}function zT({risk:e,contextWindow:t,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),t.source==="unknown"&&(a+=1);const i=s.some(d=>d.severity==="danger");return{level:e==="danger"||i?"risk":a>0?"optimizable":"ok",opportunityCount:a,reclaimableTokens:OT(o)}}function $T({segments:e,inputTokens:t,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,R)=>C+R.size,0),i=o??xT(s),c=t??a,d=kh(s,mT),m=bT(i,s,r),u=d??0,p=m.tokens===null?null:c+u,f=m.tokens===null?null:m.tokens-c,h=m.tokens===null?null:m.tokens-c-u,g=m.tokens===null||p===null?null:vT(p/m.tokens),b=jT(e,a),y=b[0]??null,w=e.filter(C=>C.role!=="tools").length,v=PT(e),j=LT(v),S=DT(b,a,w);j!==null&&S.unshift(j);const N=yT(g);return{model:i,contextWindow:m,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:p,remainingInputTokens:f,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:b,largestRole:y,diagnostics:S,duplicateGroups:v,health:zT({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:v})}}const eR={watch:jh,danger:Sh},Ud=new WeakMap;function FT(e){return e.map(t=>{const s=t.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${s}`}).join("|")}function BT(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function UT(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function qT(e,t){const s=BT(e.rawRequestBody);if(s===null)return null;const r=gf(ir(e)).anatomySegments(s);if(r===null)return null;const a=$T({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:t}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(UT);return{logId:e.id,model:i,timestamp:e.timestamp,contextWindow:a.contextWindow,estimatedInputTokens:a.estimatedInputTokens,windowUsedTokens:a.windowUsedTokens,usagePercent:a.usagePercent,riskLevel:a.riskLevel,health:a.health,diagnostics:a.diagnostics.map(d=>d.title),roleSegments:c,roleTotalTokens:c.reduce((d,m)=>d+m.size,0)}}function HT(e,t,s){const o=Ud.get(e);if(o!==void 0&&o.id===e.id&&o.rawRequestBody===e.rawRequestBody&&o.inputTokens===e.inputTokens&&o.model===e.model&&o.path===e.path&&o.apiFormat===e.apiFormat&&o.timestamp===e.timestamp&&o.providersSignature===s)return o.snapshot;const r=qT(e,t);return Ud.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:s,snapshot:r}),r}function VT(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function qd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function WT(e,t){const s=qd(t.latest.riskLevel)-qd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(t.peak.usagePercent??-1)-o;return a!==0?a:t.latest.logId-e.latest.logId}function GT(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function KT(e){for(let t=1;t<e.length;t++){const s=e[t-1],o=e[t];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function YT(e,t=[]){const s=KT(e),o=FT(t),r=new Map;for(const i of s){const c=HT(i,t,o);if(c===null)continue;const d=r.get(c.model);if(d===void 0){r.set(c.model,{model:c.model,requestCount:1,first:c,latest:c,peak:c});continue}r.set(c.model,{model:d.model,requestCount:d.requestCount+1,first:d.first,latest:c,peak:VT(c,d.peak)?c:d.peak})}return{models:[...r.values()].map(i=>({model:i.model,requestCount:i.requestCount,first:i.first,latest:i.latest,peak:i.peak,trendPercent:GT(i.first,i.latest)})).sort(WT)}}function An(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function JT(e){const t=new Map;for(const s of e)for(let o=0;o<s.logs.length;o+=1){const r=s.logs[o];r!==void 0&&t.set(r.id,o+1)}return t}function Hd(e,t){return t.get(e.id)??e.id}function Vd(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:t,totalOut:s}}function XT(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function ZT(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:jr(s.timestamp,o.timestamp,t)}function QT(e){switch(e){case"cool":return"text-status-cool";case"danger":return"text-status-danger";case"watch":return"text-status-watch";case"neutral":return"text-foreground"}}function eE(e){switch(e){case"rolling":return n.jsx(Ct,{className:"size-3 text-status-cool"});case"failed":return n.jsx(Xo,{className:"size-3 text-status-danger"});case"watch":return n.jsx(Ou,{className:"size-3 text-status-watch"});case"clear":return n.jsx(Pe,{className:"size-3 text-status-success"})}}function tE(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function nE(e){return e.pending>0?`${e.pending} pending / ${e.failures} failed`:e.lengthStops>0?`${e.lengthStops} output limit / ${e.failures} failed`:`${e.failures} failed / ${e.slow} slow`}function ts({label:e,value:t,detail:s,icon:o,tone:r="neutral"}){return n.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),n.jsx("div",{className:O("mt-2 font-mono text-sm font-semibold",QT(r)),children:t}),n.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function sE({stats:e}){return e.requests===0?null:n.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[n.jsx("div",{className:"px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[n.jsx(K0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),n.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),n.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[n.jsx(ts,{label:"Status",value:e.statusLabel,detail:nE(e),icon:eE(e.status),tone:tE(e.status)}),n.jsx(ts,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:n.jsx(Ng,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),n.jsx(ts,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:n.jsx(Xo,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),n.jsx(ts,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:n.jsx(Ou,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),n.jsx(ts,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:n.jsx(Ji,{className:"size-3 text-muted-foreground"})}),n.jsx(ts,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function zs(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function oE(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Mi(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function rE(e,t){if(t===null)return null;const s=Mi(e),o=Mi(t);return o<=0||Math.abs(o-s)<.5?null:o}function aE(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-cyan-300"}}function iE(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${su(t)}`}const lE=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function _h(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function Wa(e,t){if(e===null)return null;const s=e.metadata[t];return s===void 0?null:_h(s)}function cE(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function dE(e){const t=[];for(const s of lE){const o=e.metadata[s];if(o===void 0)continue;const r=_h(o);r!==null&&t.push({key:s,value:r})}return t}function Wd({memberships:e,defaultOpen:t=!1}){const[s,o]=l.useState(t);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=Wa(a,"score"),c=Wa(a,"decision"),d=Wa(a,"final_status"),m=[i===null?null:{label:`score ${i}`,value:i},c===null?null:{label:c,value:c},d===null?null:{label:d,value:d},a?.model===null||a?.model===void 0?null:{label:a.model,value:a.model}].filter(u=>u!==null&&u.label.length>0&&u.value.length>0);return n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[n.jsxs("button",{type:"button",onClick:()=>o(u=>!u),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":s,children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&n.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),n.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&n.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:m.slice(0,4).map(u=>n.jsx("span",{className:O("rounded border px-1.5 py-0.5 font-mono text-[10px]",cE(u.value)),children:u.label},u.label))})]}),s?n.jsx(Ki,{className:"size-4 shrink-0 text-muted-foreground"}):n.jsx(We,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&n.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const p=u.member,f=dE(p);return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),p.status!==null&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsx("span",{className:"font-mono",title:p.sessionId,children:An(p.sessionId)}),p.label!==null&&n.jsx("span",{children:p.label}),p.provider!==null&&n.jsx("span",{children:p.provider}),p.model!==null&&n.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&n.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",An(p.runId)]})]}),f.length>0&&n.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>n.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[n.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),n.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${p.id}`)})})]})}function Po({label:e,title:t,icon:s,disabled:o,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,disabled:o,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[s,n.jsx("span",{children:e})]})}function Gd({logs:e,pagination:t,embedded:s=!1}){if(t===void 0)return null;const o=t.isLoading;return n.jsxs("nav",{"aria-label":"Session log pagination",className:O("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",s?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[n.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[n.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[sk({logs:e,pagination:t}),t.isLoading&&e.length>0&&n.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&n.jsx(qo,{progress:t.loadProgress})]}),n.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[n.jsx(Po,{label:"Oldest",title:"Load the oldest logs in this session",icon:n.jsx(P0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOldest}),n.jsx(Po,{label:"Older",title:"Load older logs",icon:n.jsx(T0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOlder}),n.jsx(Po,{label:"Newer",title:"Load newer logs",icon:n.jsx(ft,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewer}),n.jsx(Po,{label:"Newest",title:"Load the newest logs in this session",icon:n.jsx(O0,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewest})]})]})}function uE(e){return`${e} ${e===1?"request":"requests"}`}function Kd(e){return`#${String(e)}`}function Yd(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-cyan-200"}}function mE(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-cyan-300/25 bg-cyan-400/8 text-cyan-100"}}function pE(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const fE=10,hE=80;function xE(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function gE(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:fh(hh())}),t.focus({preventScroll:!0}),xE(t),!0):!1}function Th(e){vs({logId:e,tab:"anatomy"});let t=0;const s=()=>{vs({logId:e,tab:"anatomy"}),!gE(e)&&(t+=1,t<fE&&window.setTimeout(s,hE))};window.setTimeout(s,0)}function bE({command:e}){const[t,s]=l.useState(!1),o=l.useCallback(()=>{Nt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return n.jsxs("div",{"data-command-example":"true",className:$C,children:[n.jsx("pre",{className:FC,children:e}),n.jsx("button",{type:"button",onClick:o,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:t?n.jsx(Pe,{className:"size-4"}):n.jsx(Et,{className:"size-4"})})]})}function Ga({label:e,children:t,className:s}){return n.jsxs("section",{className:O("rounded-[8px] border border-border/60 bg-card/55",s),children:[n.jsx("div",{className:"px-3 pt-3",children:n.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),n.jsx("div",{className:"p-3 pt-2",children:t})]})}function Lo({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[n.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:t}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function vE(){const{themeMode:e,setThemeMode:t}=yb();return n.jsxs("div",{className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-muted/70 p-0.5","aria-label":"Theme mode",role:"group",children:[n.jsx("button",{type:"button",onClick:()=>t("light"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:n.jsx(P1,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:n.jsx(Tu,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("dark"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:n.jsx(Kg,{className:"size-3.5"})})]})}function yE({visible:e,onToggle:t}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return n.jsx("button",{type:"button",onClick:t,className:O("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":s,"aria-pressed":e,title:s,children:n.jsx(ou,{className:O("size-4 transition-opacity",!e&&"opacity-45")})})}function wE({preference:e,resolvedScale:t,onChange:s}){const o=kb(t),r=e==="auto"?`Auto (${o})`:`${e}%`;return n.jsxs(Vs,{value:e,onValueChange:a=>s(el(a)),children:[n.jsxs(Ws,{size:"sm",className:"h-9 min-w-[4.5rem] justify-center gap-1 border-border/70 bg-muted/70 px-2 py-0 text-muted-foreground hover:bg-muted max-lg:h-11 [&>svg:last-child]:hidden","aria-label":`Interface size: ${r}`,children:[n.jsx(o0,{className:"size-3.5"}),n.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),n.jsxs(Gs,{align:"end",children:[n.jsx(ot,{value:"auto",children:"Auto"}),n.jsx(ot,{value:"100",children:"100%"}),n.jsx(ot,{value:"125",children:"125%"}),n.jsx(ot,{value:"150",children:"150%"})]})]})}const Eh="agent-inspector.detailsPanelCollapsed",Rh="agent-inspector.detailsPanelWidth",Mh="agent-inspector.pet.visible",as=360,jE=288,SE=520;function Ah(e){return Math.min(Math.max(e,jE),SE)}function NE(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Eh);return e===null||e==="1"}catch{return!0}}function CE(){if(typeof window>"u")return as;try{const e=window.localStorage.getItem(Rh);if(e===null)return as;const t=Number.parseInt(e,10);return Number.isFinite(t)?Ah(t):as}catch{return as}}function kE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Mh)!=="0"}catch{return!0}}function Jd({label:e,logId:t}){return n.jsxs("button",{type:"button",onClick:()=>Th(t),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${Kd(t)}`,children:[e," ",Kd(t)]})}function _E({latestPercent:e,peakPercent:t,risk:s,onOpenContext:o}){const r=Mi(e),a=rE(e,t),i=t===null?`Latest context window usage ${zs(e)}`:`Latest context window usage ${zs(e)}, peak ${zs(t)}`;return n.jsx("button",{type:"button",onClick:o,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${i}. Open latest Context details`,title:"Open latest Context details",children:n.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":i,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:[n.jsx("span",{className:O("block h-full rounded-full transition-[width]",aE(s)),style:{width:`${r}%`}}),a!==null&&n.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${a}% - 0.5px)`},"aria-hidden":"true"})]})})}function TE({summary:e}){const t=e.trendPercent,s=t===null||Math.abs(t)<.1?null:t>0?f0:l0,o=e.latest.diagnostics[0]??null,r=zs(e.latest.usagePercent),a=zs(e.peak.usagePercent),i=()=>{Th(e.latest.logId)};return n.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("button",{type:"button",onClick:i,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-text-link focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),n.jsx("span",{className:O("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",mE(e.latest.health.level)),children:pE(e.latest.health.level)})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsx("span",{children:uE(e.requestCount)}),n.jsx("span",{children:iE(e)})]})]}),n.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[n.jsx(_E,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),n.jsx("div",{className:O("mt-0.5 font-mono",Yd(e.latest.riskLevel)),children:r}),n.jsx(Jd,{label:"Log",logId:e.latest.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),n.jsx("div",{className:O("mt-0.5 font-mono",Yd(e.peak.riskLevel)),children:a}),n.jsx(Jd,{label:"Log",logId:e.peak.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&n.jsx(s,{className:O("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),oE(t)]}),n.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),n.jsxs("div",{className:"min-w-0 space-y-1.5",children:[n.jsx(nT,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&n.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.windowUsedTokens)," used"]}),o!==null&&n.jsx("span",{className:"truncate",children:o})]})]})]})}function EE({summary:e}){return e.models.length===0?null:n.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),n.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),n.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>n.jsx(TE,{summary:t},t.model))})]})}function RE(e){const t=e.models.filter(o=>o.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const s=e.models.filter(o=>o.latest.health.level==="optimizable").length;return s>0?`${s} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function ME({label:e,logs:t,totalIn:s,totalOut:o,timeDisplayFormat:r,contextSummary:a,showBackLink:i}){const[c,d]=l.useState(!1),[m,u]=l.useState(!1),p=l.useMemo(()=>ZT(t,r),[t,r]),f=l.useMemo(()=>XT(t),[t]),h=l.useMemo(()=>RE(a),[a]),g=l.useCallback(()=>{Nt(window.location.href).then(b=>{b&&(d(!0),setTimeout(()=>d(!1),2e3))})},[]);return n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i&&n.jsx("a",{href:Pi("/"),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:n.jsx(m0,{className:"size-3.5"})}),n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:An(e)}),f!==null&&n.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:f,children:f})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),p!==null&&n.jsx("span",{children:p}),(s>0||o>0)&&n.jsxs("span",{className:"font-mono",children:[Ee(s)," in / ",Ee(o)," out"]})]})]}),a.models.length>0&&n.jsxs("button",{type:"button",onClick:()=>u(b=>!b),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":m,title:m?"Hide context details":"Show context details",children:[n.jsx("span",{children:h}),m?n.jsx(Ki,{className:"size-3.5"}):n.jsx(We,{className:"size-3.5"})]}),n.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":c?"Copied session link":"Copy session link",title:c?"Copied session link":"Copy session link",children:c?n.jsx(Pe,{className:"size-3.5"}):n.jsx(Et,{className:"size-3.5"})})]}),m&&n.jsx(EE,{summary:a})]})}function AE({logs:e,sessions:t,selectedSession:s,selectedModel:o,onSessionChange:r,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:m,onImportLogs:u,viewMode:p,captureMode:f,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:b,isLoading:y=!1,liveConnection:w,onRetryLiveConnection:v,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:R=[],hideSessionFilter:P=!1,pinnedSessionId:L}){const{totalIn:M,totalOut:k}=l.useMemo(()=>Vd(e),[e]),{providers:A}=nl(),{uiScalePreference:D,resolvedUiScale:F,setUiScalePreference:Y}=Rb(),[X,$]=l.useState(null),[V,J]=l.useState(null),[U,K]=l.useState(!1),[ae,be]=l.useState(!1),[ve,ie]=l.useState(null),[z,Z]=l.useState(null),[we,Ne]=l.useState(!1),[pe,re]=l.useState(!1),[le,Re]=l.useState(!0),[he,ze]=l.useState(as),[rt,$e]=l.useState(!1),[Ge,Ke]=l.useState(!1),[Ue,Ye]=l.useState(!0),[Qe,et]=l.useState(!1),[H,te]=l.useState(null),[fe,me]=l.useState(null),je=l.useRef(null),Me=l.useRef(null),Ie=l.useRef(null),T=l.useRef(null),I=l.useRef(0),q=l.useRef(null);J_(je,Me,{pageWide:!0});const[ne,xe]=l.useState(null);l.useEffect(()=>Xi(xe),[]);const ce=l.useCallback(()=>{I.current+=1,T.current?.abort(),T.current=null,$(null),J(null)},[]);l.useEffect(()=>()=>{I.current+=1,T.current?.abort(),T.current=null},[]),l.useEffect(()=>{Re(NE()),ze(CE()),Ke(!0)},[]),l.useEffect(()=>{Ge&&window.localStorage.setItem(Eh,le?"1":"0")},[le,Ge]),l.useEffect(()=>{if(Ge)try{window.localStorage.setItem(Rh,String(he))}catch{}},[Ge,he]),l.useEffect(()=>{Ye(kE()),et(!0)},[]),l.useEffect(()=>{if(Qe)try{window.localStorage.setItem(Mh,Ue?"1":"0")}catch{}},[Qe,Ue]),l.useEffect(()=>{if(L===void 0){document.title="Agent Inspector";return}const Se=e.length===1?"1 req":`${e.length} req`;document.title=`${An(L)} - ${Se} - Agent Inspector`},[e.length,L]);const Q=l.useCallback(async Se=>{T.current?.abort();const Be=new AbortController;T.current=Be;const wt=I.current+1;I.current=wt,$(Se),J(null);try{const Kt=await hb(e,Se,{signal:Be.signal});if(I.current!==wt)return;if(!Kt.ok){if(Kt.canceled===!0)return;m!==void 0?m({message:Kt.message,tone:"error"}):J(Kt.message)}}finally{I.current===wt&&(T.current=null,$(null))}},[e,m]),se=l.useCallback(Se=>{if(qC(Se)){K(!0);return}Q(Se)},[Q]),Ae=l.useCallback(()=>{K(!1),Q("redacted")},[Q]),qe=l.useCallback(()=>{K(!1),Q("raw")},[Q]),Kr=l.useCallback(()=>{Ie.current?.click()},[]),io=l.useCallback(Se=>{const Be=Se.currentTarget.files?.[0];Se.currentTarget.value="",!(Be===void 0||u===void 0)&&(be(!0),Z(null),ie(null),u(Be).then(wt=>{const Kt=wt.skipped>0?`, skipped ${String(wt.skipped)}`:"",Yl=`Imported ${String(wt.imported)} logs as ${wt.sessionId}${Kt}.`;m!==void 0?m({message:Yl,tone:"success"}):ie(Yl)}).catch(wt=>{const Kt=wt instanceof Error?wt.message:"Failed to import logs";m!==void 0?m({message:Kt,tone:"error"}):Z(Kt)}).finally(()=>{be(!1)}))},[u,m]);l.useEffect(()=>{ce(),me(null),te(null)},[ce,s,o]);const Yr=l.useCallback(()=>{ce(),ie(null),Z(null),me(null),a()},[ce,a]),Jr=l.useCallback(()=>{Ne(!0)},[]),Mt=l.useCallback(()=>{ce(),ie(null),Z(null),me(null),i!==void 0&&(re(!0),i().then(()=>{Ne(!1)}).catch(Se=>{const Be=Se instanceof Error?Se.message:"Failed to delete stored logs";m!==void 0?m({message:Be,tone:"error"}):Z(Be)}).finally(()=>{re(!1)}))},[ce,i,m]),nn=l.useCallback(()=>{c!==void 0&&(ce(),ie(null),Z(null),me(null),c())},[ce,c]),Xr=l.useCallback(()=>{me(null)},[]),qn=l.useCallback(()=>{Re(Se=>!Se)},[]),Zr=l.useCallback(Se=>{q.current={startX:Se.clientX,startWidth:he,pointerId:Se.pointerId},Se.currentTarget.setPointerCapture(Se.pointerId),$e(!0)},[he]),_e=l.useCallback(Se=>{const Be=q.current;Be===null||Be.pointerId!==Se.pointerId||ze(Ah(Be.startWidth+Be.startX-Se.clientX))},[]),xt=l.useCallback(Se=>{const Be=q.current;Be===null||Be.pointerId!==Se.pointerId||(Se.currentTarget.hasPointerCapture(Se.pointerId)&&Se.currentTarget.releasePointerCapture(Se.pointerId),q.current=null,$e(!1))},[]),Je=l.useCallback(()=>{ze(as)},[]),Cs=l.useCallback(()=>{Ye(Se=>!Se)},[]),tt=l.useMemo(()=>H===null?null:new Set(H.logIds),[H]),yt=l.useMemo(()=>tt===null?e:e.filter(Se=>tt.has(Se.id)),[tt,e]),At=l.useMemo(()=>R5(yt),[yt]),ql=l.useMemo(()=>JT(At),[At]),Cn=l.useMemo(()=>nk({pinnedSessionId:L,selectedSession:s,sessions:t,logs:e}),[e,L,s,t]),Hn=Cn?.logs??[],ks=Cn!==null&&Hn.length>0,{totalIn:Hl,totalOut:Vl}=l.useMemo(()=>Vd(Hn),[Hn]),Ph=l.useMemo(()=>YT(Hn,A),[Hn,A]),Lh=l.useMemo(()=>w_(At),[At]),Qr=l.useMemo(()=>YN(At),[At]),Wl=HC(f,e.length),Oh=L!==void 0,Dh=e.length>0,zh=i!==void 0&&(e.length>0||s!=="__all__"),$h=s==="__all__"?"all sessions":"this session",Fh=s==="__all__"?"Deletes every stored log, streaming chunk, and session archive entry across all sessions.":"Deletes every stored log, streaming chunk, and session archive entry for this session, including history that is not currently loaded.",Bh=e.length===0?"Load":"Reload",ea=ks&&Cn!==null?An(Cn.label):s==="__all__"?"All sessions":An(s),Gl=T_(w),ta=E_(Gl),Uh=l.useMemo(()=>tk({logs:yt,conversationGroups:At,isLoading:y,timeDisplayFormat:b,slowResponseThresholdSeconds:g}),[yt,At,y,g,b]),qh=l.useCallback(Se=>{const Be=Qr.get(Se.id);Be!==void 0&&me([Be,Se])},[Qr]),Kl=L!==void 0?L:s==="__all__"?null:s;return n.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[n.jsx(C_,{liveConnection:w,alertsAction:n.jsx(Ak,{}),settingsAction:n.jsx(b4,{})}),n.jsxs("button",{type:"button",onClick:qn,className:O("group fixed top-1/2 right-3 z-50 inline-flex h-14 w-8 -translate-y-1/2 items-center justify-center rounded-l-md border border-border/70 bg-background/90 text-muted-foreground shadow-lg backdrop-blur transition-colors motion-reduce:transition-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"),"aria-label":le?"Show details panel":"Hide details panel",title:le?"Show details panel":"Hide details panel",children:[n.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),le?n.jsx(a1,{className:"size-3.5"}):n.jsx(o1,{className:"size-3.5"})]}),Qe&&Ue&&n.jsx(Vo,{feature:"Inspector Pet",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(SS,{logs:e})})}),n.jsxs("div",{className:O("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",rt&&"cursor-col-resize select-none"),children:[!le&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:qn,"aria-label":"Close details panel"}),n.jsxs("aside",{className:"inspector-scrollbar fixed inset-x-3 bottom-3 top-24 z-40 order-1 overflow-y-auto rounded-lg border border-border bg-background/98 shadow-2xl max-lg:!w-auto lg:relative lg:inset-auto lg:order-2 lg:h-full lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:shadow-none",style:{width:he},children:[n.jsx("button",{type:"button",className:"absolute bottom-0 left-0 top-0 z-30 hidden w-2 -translate-x-1/2 cursor-col-resize touch-none items-center justify-center lg:flex",onPointerDown:Zr,onPointerMove:_e,onPointerUp:xt,onPointerCancel:xt,onDoubleClick:Je,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:n.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),n.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[n.jsxs("div",{className:"sticky top-0 z-20 -mx-4 -mt-4 grid gap-2 border-b border-border/60 bg-background/95 px-4 pb-3 pt-4 backdrop-blur",children:[n.jsx(Ga,{label:"View",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx(vE,{}),n.jsx(wE,{preference:D,resolvedScale:F,onChange:Y})]})}),n.jsx(Ga,{label:"Workspace",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(Qk,{labelledTrigger:!0}),n.jsx(n_,{currentSessionId:Kl,logCount:e.length,labelledTrigger:!0})]})})]}),n.jsxs(Ga,{label:"Current scope",children:[n.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[n.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:ea,children:ea}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:Oh?"Pinned session":"Live Inspector data"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(Lo,{label:H===null?"Requests":"Results",value:yt.length}),n.jsx(Lo,{label:"Sessions",value:t.length}),n.jsx(Lo,{label:"Input",value:Ee(ks?Hl:M)}),n.jsx(Lo,{label:"Output",value:Ee(ks?Vl:k)})]}),N!==void 0&&n.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:n.jsx(qo,{progress:N})})]}),ks&&Cn!==null&&n.jsx(ME,{label:Cn.label,logs:Hn,totalIn:Hl,totalOut:Vl,timeDisplayFormat:b,contextSummary:Ph,showBackLink:Cn.showBackLink}),ks&&L!==void 0&&R.length>0&&n.jsx(Wd,{memberships:R}),n.jsx("div",{className:"flex-1"}),n.jsx(y_,{currentSessionId:Kl,logCount:e.length,onResultChange:te})]})]})]}),n.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[n.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),n.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:ea})]}),n.jsx(yE,{visible:Ue,onToggle:Cs}),u!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:Ie,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:io}),n.jsx("button",{type:"button",onClick:Kr,disabled:ae,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:ae?n.jsx("span",{children:"Importing..."}):n.jsxs(n.Fragment,{children:[n.jsx(Du,{className:"size-3.5"}),n.jsx("span",{children:"Import"})]})})]}),Wl.redacted&&n.jsx("button",{type:"button",onClick:()=>{se("redacted")},disabled:X!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:X==="redacted"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(Xs,{className:"size-3.5"}),n.jsx("span",{children:"Export"})]})}),Wl.raw&&n.jsx("button",{type:"button",onClick:()=>{se("raw")},disabled:X!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:X==="raw"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(fg,{className:"size-3.5"}),n.jsx("span",{children:"Raw"})]})}),c!==void 0&&n.jsxs("button",{type:"button",onClick:nn,disabled:y,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[n.jsx(Ct,{className:O("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),n.jsx("span",{children:Bh})]}),n.jsxs("button",{type:"button",onClick:Yr,disabled:!Dh,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[n.jsx(gn,{className:"size-3.5"}),n.jsx("span",{children:"Clear"})]}),i!==void 0&&n.jsxs("button",{type:"button",onClick:Jr,disabled:!zh||pe,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[n.jsx(gn,{className:"size-3.5"}),n.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&n.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:n.jsx(qo,{progress:N})}),C!==void 0&&n.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&n.jsxs("button",{type:"button",onClick:nn,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[n.jsx(Ct,{className:"size-3"}),"Retry"]})]}),H!==null&&n.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-md bg-cyan-400/[0.07] px-3 py-2 shadow-[inset_2px_0_0_rgba(103,232,249,0.35),inset_0_0_0_1px_rgba(103,232,249,0.08)]",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:H.question}),n.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(yt.length)," loaded logs from"," ",String(H.logIds.length)," linked results"]})]}),n.jsxs("button",{type:"button",onClick:()=>te(null),className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-black/20 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-black/30 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[n.jsx(Qs,{className:"size-3"}),"All logs"]})]}),H===null&&n.jsx(Gd,{logs:e,pagination:S,embedded:!0}),m===void 0&&V!==null&&n.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:V}),m===void 0&&z!==null&&n.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:z}),m===void 0&&ve!==null&&z===null&&n.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:ve}),w!==void 0&&w.status!=="live"&&v!==void 0&&j!==void 0&&n.jsx(S_,{state:w,hasLogs:e.length>0,onRetry:v,onStop:j})]}),n.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[n.jsx(sE,{stats:Uh}),H!==null&&yt.length===0?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.jsxs("div",{className:"mx-auto max-w-xl rounded-[8px] bg-white/[0.035] px-5 py-8 shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)]",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),n.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:"Assistant found evidence, but none of its linked log IDs are in the current loaded window. Open an evidence card in Assistant or restore the full log view."}),n.jsx("button",{type:"button",onClick:()=>te(null),className:"mt-4 inline-flex h-8 items-center rounded-md bg-cyan-400/10 px-3 text-xs text-cyan-100 transition-colors hover:bg-cyan-400/16",children:"Show all logs"})]})}):e.length===0?s!=="__all__"?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[n.jsx("p",{className:"text-sm font-medium",children:y?"Loading session data...":C===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),n.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:An(s)}),N!==void 0&&n.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:n.jsx(qo,{progress:N})}),R.length>0&&n.jsx("div",{className:"text-left",children:n.jsx(Wd,{memberships:R})}),!y&&n.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[n.jsx("p",{children:"Stored logs may still be available."}),n.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&n.jsxs("button",{type:"button",onClick:nn,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[n.jsx(Ct,{className:"size-3.5"}),n.jsx("span",{children:"Load session"})]}),P?n.jsx("a",{href:Pi("/"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):n.jsx("button",{type:"button",onClick:()=>r("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[n.jsx("p",{className:"text-sm font-medium",children:ta.title}),n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:ta.description}),Gl==="empty"&&t.length>0&&n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),ta.showConnectionCommands&&ne!==null&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col items-center gap-2",children:BC(ne).map(Se=>n.jsx(bE,{command:Se},Se))}),n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):n.jsxs("div",{ref:Me,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[n.jsx("div",{ref:je,children:n.jsx(F_,{groups:At,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:Lh,onCompareWithPrevious:qh,comparisonPredecessors:Qr,onClearGroup:d,defaultExpanded:At.length===1,timeDisplayFormat:b})}),H===null&&n.jsx("div",{className:"mt-3",children:n.jsx(Gd,{logs:e,pagination:S})})]})]})]})]}),n.jsx(Ft,{open:U,onOpenChange:K,children:n.jsx(Bt,{className:q_,children:n.jsx(V_,{onCancel:()=>K(!1),onExportRedacted:Ae,onConfirmRaw:qe})})}),n.jsx(Ft,{open:we,onOpenChange:Ne,children:n.jsxs(Bt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[n.jsxs(Wt,{children:[n.jsxs(Gt,{children:["Delete ",$h," history?"]}),n.jsx(oo,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),n.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[n.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),n.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:Fh})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:pe,onClick:()=>Ne(!1),children:"Cancel"}),n.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:pe,onClick:Mt,children:pe?"Deleting...":"Delete history"})]})]})}),fe!==null&&n.jsx(Vo,{feature:"Compare",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(jS,{left:fe[0],right:fe[1],leftDisplayNumber:Hd(fe[0],ql),rightDisplayNumber:Hd(fe[1],ql),onClose:Xr})})})]})}function IE(e,t,s){return t==="__all__"&&s==="__all__"?e:e.filter(o=>!(t!=="__all__"&&o.sessionId!==t||s!=="__all__"&&o.model!==s))}function PE(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of t)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Xd(e,t){return t.retainIds?.has(e.id)===!0||t.retainSessionId!==void 0&&e.sessionId===t.retainSessionId}function Zd(e,t){const s=e.reduce((a,i)=>a+(Xd(i,t)?0:1),0);if(s<=t.recentLimit)return e;let o=s-t.recentLimit;const r=[];for(const a of e){if(o>0&&!Xd(a,t)){o-=1;continue}r.push(a)}return r}function Mn(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s)}return t}function Ka(e,t,s,o){if(s.length===0){const m=Zd([...e],o);return{logs:m,index:Mn(m)}}const r=[...e];let a=r.length===0?Number.NEGATIVE_INFINITY:r.at(-1)?.id??0,i=!0;for(const m of s){const u=t.get(m.id);if(u!==void 0&&u>=0&&u<r.length){r[u]=m;continue}r.push(m),m.id<a&&(i=!1),a=Math.max(a,m.id)}const c=i?r:r.toSorted((m,u)=>m.id-u.id),d=Zd(c,o);return{logs:d,index:Mn(d)}}function En(e,t){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of t)o!==""&&s.add(o);return[...s].sort()}function LE(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const s=Xh();return s.ok?Zh(s.runtime,`/api/logs/stream?${t.toString()}`):null}function OE(e){const t=LE(e);return t===null?null:new EventSource(t)}const DE=Ut([_({type:oe("init"),logs:W(Fs)}),_({type:oe("update"),log:Fs})]),zE=_({logs:W(Fs),total:E().int().nonnegative(),limit:E().int().positive(),hasOlder:ke(),hasNewer:ke(),oldestLogId:E().int().positive().nullable(),newestLogId:E().int().positive().nullable()}),$E=W(x()),Qd=_({success:ke(),cleared:E().int().nonnegative(),logFilesRewritten:E().int().nonnegative().optional(),chunkFilesDeleted:E().int().nonnegative(),sessionArchiveLogsDeleted:E().int().nonnegative().optional()});function FE(e,t){const s=[];for(const o of e)for(const r of o.members)r.sessionId===t&&s.push({groupId:o.id,groupTitle:o.title,groupKind:o.kind,groupStatus:o.status,groupTask:o.task,groupProject:o.project,groupEvidence:o.evidence,member:r});return s}function Oo(e){const t=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&t.add(s.sessionId);return[...t]}function BE(e){const t=new Set;for(const s of e)s.model!==null&&s.model!==""&&t.add(s.model);return[...t]}const UE=100,qE=12,HE=1800,Ul=100,br=500,Ih=200,Ai=2e4,VE=1e4,WE=3e3,GE=1e4,KE=2e3;function YE(e,t,s=Ul){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(t.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(t.beforeLogId));break;case"newer":o.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${o.toString()}`}function $s(e,t,s=Ul){return Le(YE(e,t,s),zE,Ai)}async function JE(e,t){const s=new Set;let o=await $s(e,{kind:"oldest"},br);for(const a of o.logs)s.add(a.id);t(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<Ih;){o=await $s(e,{kind:"newer",afterLogId:o.newestLogId},br);for(const a of o.logs)s.add(a.id);r+=1,t(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function XE(){try{return{deleted:(await Ze("/api/groups",vu,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function tR({initialSessionId:e}={}){const[t,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:p}=Wf(),[f,h]=l.useState(__),[g,b]=l.useState(null),[y,w]=l.useState(e!==void 0),[v,j]=l.useState(null),[S,N]=l.useState(void 0),[C,R]=l.useState([]),[,P]=l.useTransition(),L=l.useRef(null),M=l.useRef(null),k=l.useRef(null),A=l.useRef(!0),D=l.useRef(null),F=l.useRef(0),Y=l.useRef(null),X=l.useRef(null),$=l.useRef(new Map),V=l.useRef([]),J=l.useRef(null),U=l.useCallback(()=>({recentLimit:KE,retainSessionId:e??(o==="__all__"?void 0:o)}),[e,o]),K=l.useCallback(T=>{u({message:T,tone:"error"})},[u]),ae=l.useCallback(()=>{X.current!==null&&(clearInterval(X.current),X.current=null),Y.current=null,N(void 0)},[]),be=l.useCallback((T,I,q=0,ne=0)=>{X.current!==null&&clearInterval(X.current);const xe=Date.now();Y.current=xe;const ce=()=>{F.current===I&&N({label:T,elapsedMs:Date.now()-xe,timeoutMs:Ai,loadedLogs:q,loadedPages:ne})};ce(),X.current=setInterval(ce,250)},[]),ve=l.useCallback((T,I,q,ne)=>{const xe=Y.current;xe===null||F.current!==I||N({label:T,elapsedMs:Date.now()-xe,timeoutMs:Ai,loadedLogs:q,loadedPages:ne})},[]),ie=l.useMemo(()=>IE(t,o,a),[t,o,a]),z=l.useMemo(()=>En(c,Oo(t)),[t,c]),Z=l.useMemo(()=>BE(t),[t]),we=l.useCallback(()=>{Ze("/api/sessions",$E).then(T=>{d(I=>En(I,T))}).catch(()=>{})},[]),Ne=l.useCallback(()=>{J.current=null;const T=V.current;V.current=[],T.length!==0&&P(()=>{s(I=>{const q=Ka(I,$.current,T,U());return $.current=q.index,q.logs})})},[U,P]),pe=l.useCallback(T=>{V.current.push(T),J.current===null&&(J.current=setTimeout(Ne,UE))},[Ne]),re=l.useCallback(()=>{L.current&&L.current.close(),M.current!==null&&(clearTimeout(M.current),M.current=null),h(I=>It(I,{type:"connect-requested"}));const T=OE(e);if(T===null){h(I=>It(I,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),K("Failed to resolve the live stream endpoint");return}L.current=T,T.onmessage=I=>{try{const q=String(I.data),ne=JSON.parse(q),xe=DE.safeParse(ne);if(!xe.success){h(Q=>It(Q,{type:"recoverable-error",message:"The live stream returned invalid data."})),K("Failed to parse SSE data");return}const ce=xe.data;ce.type==="init"?(J.current!==null&&(clearTimeout(J.current),J.current=null),V.current=[],s(Q=>{const se=Ka(Q,$.current,ce.logs,U());return $.current=se.index,se.logs}),d(Q=>En(Q,Oo(ce.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>It(Q,{type:"message-received",at:Date.now()})),p()):ce.type==="update"&&(d(Q=>ce.log.sessionId===null||ce.log.sessionId===""?Q:En(Q,[ce.log.sessionId])),pe(ce.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>It(Q,{type:"message-received",at:Date.now()})))}catch{h(q=>It(q,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),K("Failed to parse SSE data")}},T.onerror=()=>{const I=navigator.onLine;h(q=>It(q,{type:"connection-lost",online:I,message:"The live stream disconnected."})),T.close(),!(!I||!A.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(q=>It(q,{type:"stale-timeout"}))},GE)),M.current=setTimeout(re,WE))}},[p,e,pe,K]),le=l.useCallback(()=>{A.current=!0,M.current!==null&&(clearTimeout(M.current),M.current=null),re()},[re]),Re=l.useCallback(()=>{A.current=!1,L.current?.close(),L.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(T=>It(T,{type:"stop-retrying"}))},[]),he=l.useCallback(T=>{if(e===void 0)return;const I=F.current+1;F.current=I,w(!0),j(null),be("Loading session logs",I),p(),$s(e,T).then(q=>{if(F.current!==I)return;const ne=q.logs;$.current=Mn(ne),s(ne),b(q),r(e),w(!1),j(null),ae(),p()}).catch(q=>{if(F.current!==I)return;w(!1),ae();const ne=q instanceof Error?q.message:"Failed to load session logs";j(ne),K(ne)})},[p,e,K,be,ae]),ze=l.useCallback(T=>{const I=F.current+1;F.current=I,w(!0),j(null),be("Reloading full session",I),p(),(async()=>{const q=[];let ne=await $s(T,{kind:"oldest"},br);q.push(...ne.logs),ve("Reloading full session",I,q.length,1);let xe=1;for(;ne.hasNewer&&ne.newestLogId!==null&&xe<Ih;)ne=await $s(T,{kind:"newer",afterLogId:ne.newestLogId},br),q.push(...ne.logs),xe+=1,ve("Reloading full session",I,q.length,xe);F.current===I&&(s(ce=>{const Q=Ka(ce,$.current,q,U());return $.current=Q.index,Q.logs}),d(ce=>En(ce,[T])),w(!1),j(null),ae(),ne.hasNewer?u({message:`Loaded ${String(q.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(q=>{if(F.current!==I)return;w(!1),ae();const ne=q instanceof Error?q.message:"Failed to reload session logs";j(ne),K(ne)})},[p,K,u,be,ae,ve]);l.useEffect(()=>{if(e===void 0){R([]);return}let T=!1;return Le("/api/groups",ju,VE).then(I=>I.groups).then(I=>{T||I===null||R(FE(I,e))}).catch(()=>{T||R([])}),()=>{T=!0}},[e]),l.useEffect(()=>{we()},[we]),l.useEffect(()=>()=>{ae()},[ae]),l.useEffect(()=>{e!==void 0&&he({kind:"newest"})},[e,he]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&ze(o)},[e,ze,o]),l.useEffect(()=>{if(e!==void 0)return;re();const T=()=>{L.current?.close(),L.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(q=>It(q,{type:"browser-offline"}))},I=()=>{A.current&&re()};return window.addEventListener("offline",T),window.addEventListener("online",I),()=>{window.removeEventListener("offline",T),window.removeEventListener("online",I),L.current&&(L.current.close(),L.current=null),M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),J.current!==null&&(clearTimeout(J.current),J.current=null)}},[re,e]),l.useEffect(()=>{const T=window.location.hash;if(!T.startsWith("#log-")||D.current===T)return;const I=T.slice(1),q=Number(I.replace(/^log-/,""));Number.isInteger(q)&&q>0&&vs({logId:q,tab:"request"});let ne=!1,xe=0,ce=null,Q=null;const se=()=>{if(ne)return;const Ae=document.getElementById(I);if(Ae!==null){D.current=T,Ae.scrollIntoView({block:"center",behavior:fh(hh())}),Ae instanceof HTMLElement&&(ce=Ae,Ae.setAttribute("data-deep-link-highlight","true"),Q=window.setTimeout(()=>{Ae.removeAttribute("data-deep-link-highlight")},HE),Ae.focus({preventScroll:!0}),Ae.getAttribute("data-nav-action")==="expand"&&Ae.click());return}xe+=1,xe<qE&&window.setTimeout(se,100)};return se(),()=>{ne=!0,Q!==null&&window.clearTimeout(Q),ce!==null&&ce.removeAttribute("data-deep-link-highlight")}},[ie.length]);const rt=l.useCallback(()=>{const T=Oo(t);ae(),w(!1),$.current.clear(),s([]),b(null),d(I=>En(I,T)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,u,ae]),$e=l.useCallback(T=>{if(T.length===0)return;const I=new Set(T);s(q=>{const ne=q.filter(ce=>I.has(ce.id)),xe=q.filter(ce=>!I.has(ce.id));return d(ce=>En(ce,Oo(ne))),$.current=Mn(xe),xe}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),Ge=l.useCallback(async()=>{const T=F.current+1;F.current=T,w(!0),ae(),p();try{if(o==="__all__"){be("Deleting stored history",T);const Q=await Ze("/api/logs",Qd,{method:"DELETE"}),se=await XE();if(F.current!==T)return;s([]),$.current.clear(),b(null),d([]),R([]),w(!1),ae();const Ae=se.ok?` Cleared ${se.deleted.toString()} group${se.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${Q.cleared.toString()} stored log${Q.cleared===1?"":"s"} across all sessions.${Ae}`,tone:se.ok?"success":"error"});return}const I=o;be("Deleting session history",T);const q=await JE(I,(Q,se)=>{ve("Deleting session history",T,Q,se)}),ne=new Set(q.ids);for(const Q of t)Q.sessionId===I&&ne.add(Q.id);const xe=[...ne].filter(Q=>Number.isInteger(Q)&&Q>=0);if(xe.length===0){if(F.current!==T)return;s(Q=>{const se=Q.filter(Ae=>Ae.sessionId!==I);return $.current=Mn(se),se}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(se=>se.sessionId!==I)}),d(Q=>Q.filter(se=>se!==I)),w(!1),ae(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ce=await Ze("/api/logs",Qd,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:xe})});if(F.current!==T)return;s(Q=>{const se=Q.filter(Ae=>Ae.sessionId!==I);return $.current=Mn(se),se}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(se=>se.sessionId!==I)}),d(Q=>Q.filter(se=>se!==I)),w(!1),ae(),u({message:`Deleted ${ce.cleared.toString()} stored log${ce.cleared===1?"":"s"} for this session${q.truncated?". More history may remain.":"."}`,tone:q.truncated?"error":"success"})}finally{F.current===T&&(w(!1),ae())}},[t,p,o,u,be,ae,ve]),Ke=l.useCallback(()=>{if(e!==void 0){he({kind:"newest"});return}if(o==="__all__"){we();return}ze(o)},[e,he,we,ze,o]),Ue=l.useCallback(async T=>{const I=new FormData;I.set("file",T);const q=await Ze("/api/logs/import",Yx,{method:"POST",body:I});return s(ne=>{const xe=new Set(q.logs.map(Q=>Q.id)),ce=PE(ne.filter(Q=>!xe.has(Q.id)),q.logs);return $.current=Mn(ce),ce}),r(q.sessionId),i("__all__"),b(null),p(),q},[p]),{strip:Ye,captureMode:Qe,slowResponseThresholdSeconds:et,timeDisplayFormat:H}=Wi(),te=Qe,fe=l.useCallback(()=>{he({kind:"oldest"})},[he]),me=l.useCallback(()=>{he({kind:"newest"})},[he]),je=l.useCallback(()=>{const T=t[0],I=g?.oldestLogId??T?.id??null;I!==null&&he({kind:"older",beforeLogId:I})},[t,he,g]),Me=l.useCallback(()=>{const T=t[t.length-1],I=g?.newestLogId??T?.id??null;I!==null&&he({kind:"newer",afterLogId:I})},[t,he,g]),Ie=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??Ul,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:fe,onOlder:je,onNewer:Me,onNewest:me}},[e,me,Me,je,fe,g,S,y]);return n.jsxs(n.Fragment,{children:[n.jsx(Gf,{notice:m,onDismiss:p}),n.jsx(Z1,{}),n.jsx(AE,{logs:ie,sessions:z,models:Z,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:rt,onDeleteCurrentView:Ge,onReloadSession:e!==void 0||o!=="__all__"?Ke:void 0,onClearGroup:$e,onNotify:u,onImportLogs:e===void 0?Ue:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||y,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:le,onStopLiveConnection:Re,pagination:Ie,sessionLoadProgress:S,sessionLoadError:v??void 0,sessionMemberships:C,viewMode:te,captureMode:Qe,strip:Ye,slowResponseThresholdSeconds:et,timeDisplayFormat:H,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{fn as $,X_ as A,Ce as B,ng as C,Ft as D,eR as E,We as F,ge as G,cN as H,Pg as I,QE as J,Cu as K,TS as L,Au as M,dN as N,uN as O,tR as P,Fn as Q,h1 as R,nT as S,_f as T,vi as U,lr as V,m_ as W,Qs as X,V0 as Y,Bs as Z,G as _,E5 as a,Oe as a0,ru as a1,yS as a2,A0 as a3,Ql as b,B as c,Iu as d,ft as e,Pe as f,gf as g,Et as h,Bt as i,Wt as j,Gt as k,Lu as l,Tf as m,Yt as n,at as o,qg as p,Ns as q,ir as r,it as s,lt as t,nl as u,ct as v,vs as w,Fs as x,$T as y,Z_ as z};
60
+ args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{Nt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),n.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),s===null?n.jsx("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"The browser runtime does not provide a valid agent-facing MCP endpoint."}):n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(Bl,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function k4(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Wi(),[m,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useCallback(async w=>{u(null),f(!0);try{await a(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[a]),g=l.useCallback(async w=>{u(null),f(!0);try{await i(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[i]),b=l.useCallback(async w=>{u(null),f(!0);try{await c(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[c]),y=l.useCallback(async w=>{u(null),f(!0);try{await d(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[d]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",n.jsx("code",{children:"config.json"}),"."]})]}),n.jsxs("label",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",n.jsx("code",{children:"0"})," to disable it."]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Ya,step:1,value:t,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>Ya||g(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Ja,step:1,value:s,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>Ja||b(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),n.jsxs("select",{id:"time-display-format",value:o,disabled:r||p,onChange:w=>{const v=Su.safeParse(w.currentTarget.value);v.success&&y(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[n.jsx("option",{value:"time",children:"Time only"}),n.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&n.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const _4=ue(["installed","update-available","available","planned","unknown"]),T4=_({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:_4,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:ke()}),E4=_({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:W(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),R4=_({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:ke(),runnable:ke()}),M4=_({checkedAt:x(),packages:W(T4),runnerPresets:W(E4),recipes:W(R4)}),ah=ue(["install","upgrade","help","runner-presets","recipe"]),ih="RUN_LOCAL_COMMAND",A4=_({action:ah,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:E().int().positive(),scope:x()}),I4=_({nonce:x().uuid(),phrase:oe(ih),expiresAt:x().datetime(),plan:A4}),lh=_({confirmation:I4});wn("intent",[_({intent:oe("prepare")}),_({intent:oe("confirm"),nonce:x().uuid(),confirmation:oe(ih)})]);const P4=ue(["queued","running","succeeded","failed"]),ch=_({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:ah,status:P4,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:E().nullable(),error:x().nullable()}),dh=_({task:ch}),L4=_({tasks:W(ch)}),O4=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:a0},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Ct},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Gi},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:Zg}];async function D4(e){return Ze(e,M4,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function z4(e){return Ze(e,dh,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function $4(e){return Ze(e,L4,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function F4(e,t){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,o=await Ze(s,lh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},r=>`Failed to prepare ecosystem task: ${String(r.status)}`);return{endpoint:s,confirmation:o.confirmation}}async function B4(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ze(t,lh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:t,confirmation:s.confirmation}}async function U4(e){return(await Ze(e.endpoint,dh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},s=>`Failed to start ecosystem task: ${String(s.status)}`)).task}function q4(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function H4(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function V4(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function Ds(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets";case"recipe":return"Recipe"}}function W4(e){switch(e.status){case"queued":return"Queued";case"running":return`${Ds(e.action)} running`;case"succeeded":return`${Ds(e.action)} complete`;case"failed":return`${Ds(e.action)} failed`}}function uh(e){switch(e){case"queued":case"running":return"border-cyan-300/20 bg-cyan-300/8 text-cyan-100";case"succeeded":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-100";case"failed":return"border-red-400/20 bg-red-400/8 text-red-100"}}function G4(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function K4({pkg:e,activeTask:t,onStartTask:s}){const o=G4(e),r=t!==null&&t.packageId===e.id&&t.status==="running";return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(n1,{className:"size-4 shrink-0 text-white/55"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),n.jsx(Ce,{className:O("shrink-0",H4(e.state)),variant:"outline",children:q4(e.state)})]}),n.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:V4(e)}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&n.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Xs,{className:"size-3.5"}),Ds(o)]}),n.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[n.jsx(Fn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&n.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[n.jsx(Gi,{className:"size-3.5"}),"Presets"]})]})]})}function Y4({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return n.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?n.jsx(Oe,{className:"size-4 animate-spin text-cyan-200/75"}):n.jsx(Fn,{className:"size-4 text-white/55"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-semibold",children:W4(e)}),n.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),n.jsx(Ce,{variant:"outline",className:O("shrink-0",uh(e.status)),children:e.status})]}),n.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&n.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function J4({workflow:e}){const t=e.icon;return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),n.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),n.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function X4(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function Z4({preset:e}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Pu,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),n.jsxs(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[n.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function Q4({recipe:e,copied:t,running:s,onCopy:o,onRun:r}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Eu,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),n.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),n.jsx(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),n.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),n.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[t?n.jsx(Pe,{className:"size-3.5"}):n.jsx(Et,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&n.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Pu,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function e_({task:e,selected:t,onSelect:s}){const o=e.recipeId??Ds(e.action);return n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Mu,{className:"size-3.5 shrink-0 text-white/40"}),n.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),n.jsx(Ce,{variant:"outline",className:O("shrink-0",uh(e.status)),children:e.status})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[n.jsx("span",{children:e.packageId}),n.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&n.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),n.jsx(ee,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>s(e),children:t?"Open":"View"})]})}function t_({pending:e,busy:t,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return n.jsx(Ft,{open:e!==null,onOpenChange:s,children:n.jsxs(Bt,{className:"max-w-xl",children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Confirm local command"}),n.jsx(oo,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Source"}),n.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),n.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[n.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),n.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),n.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:r.command})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",n.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(ee,{type:"button",variant:"outline",disabled:t,onClick:()=>s(!1),children:"Cancel"}),n.jsxs(ee,{type:"button",variant:"secondary",disabled:t||r===null,onClick:o,children:[t?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(Fn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function n_({currentSessionId:e,logCount:t,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(!1),j=Ot("/api/ecosystem/packages",D4,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=Ot(p===null?null:`/api/ecosystem/tasks/${p}`,z4,{refreshInterval:U=>{const K=U?.task;return K!==void 0&&(K.status==="queued"||K.status==="running")?900:0},revalidateOnFocus:!1}),N=Ot(o?"/api/ecosystem/tasks":null,$4,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],R=j.data?.runnerPresets??[],P=j.data?.recipes??[],L=(N.data?.tasks??[]).slice(0,6),M=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=X4(e),A="npx @tonyclaw/eval-harness runner-presets",D=()=>{Nt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},F=()=>{Nt(A).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},Y=U=>{Nt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},X=U=>{g(null),B4(U.id).then(K=>{y(K)}).catch(K=>{g(K instanceof Error?K.message:"Failed to prepare ecosystem recipe")})},$=S.data?.task??null;l.useEffect(()=>{$!==null&&(N.mutate(),$.status==="succeeded"&&j.mutate())},[$,j,N]);const V=(U,K)=>{g(null),F4(U,K).then(ae=>{y(ae)}).catch(ae=>{g(ae instanceof Error?ae.message:"Failed to prepare ecosystem task")})},J=()=>{b!==null&&(g(null),v(!0),U4(b).then(U=>{f(U.id),y(null),S.mutate({task:U},{revalidate:!0}),N.mutate()}).catch(U=>{g(U instanceof Error?U.message:"Failed to start ecosystem task")}).finally(()=>{v(!1)}))};return n.jsxs(Ft,{open:o,onOpenChange:r,children:[n.jsx(so,{asChild:!0,children:n.jsxs(ee,{variant:"ghost",size:s?"default":"icon",className:O(ao,s&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[n.jsx(Eu,{className:"size-4"}),n.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),n.jsxs(Bt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Wt,{children:n.jsxs(Gt,{className:"flex items-center gap-2",children:[n.jsx(Za,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),n.jsxs("div",{className:"overflow-y-auto pr-2",children:[n.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),n.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),n.jsxs(Ce,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(M),"/",String(C.length)," packages"]})]}),n.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:O4.map(U=>n.jsx(J4,{workflow:U},U.id))})]}),n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),n.jsxs(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),n.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:k}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[n.jsxs(ee,{size:"sm",variant:"secondary",onClick:D,children:[a?n.jsx(Pe,{className:"size-3.5"}):n.jsx(Et,{className:"size-3.5"}),a?"Copied":"Copy"]}),n.jsxs(ee,{size:"sm",variant:"outline",onClick:F,children:[n.jsx(Gi,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(Za,{className:"size-3.5"}),"copy-ready workflows"]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[P.map(U=>n.jsx(Q4,{recipe:U,copied:m===U.id,running:$!==null&&$.recipeId===U.id&&($.status==="queued"||$.status==="running"),onCopy:Y,onRun:X},U.id)),j.isLoading&&P.length===0&&[0,1].map(U=>n.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(Fn,{className:"size-3.5"}),A]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[R.map(U=>n.jsx(Z4,{preset:U},U.id)),j.isLoading&&R.length===0&&[0,1,2,3].map(U=>n.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&n.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&n.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>n.jsx(K4,{pkg:U,activeTask:$,onStartTask:V},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>n.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),h!==null&&n.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:h}),L.length>0&&n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),n.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(L.length)]})]}),n.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:L.map(U=>n.jsx(e_,{task:U,selected:p===U.id,onSelect:K=>{f(K.id),S.mutate({task:K},{revalidate:!0})}},U.id))})]}),n.jsx(Y4,{task:$})]})]}),n.jsx(t_,{pending:b,busy:w,onOpenChange:U=>{!U&&!w&&y(null)},onConfirm:J})]})}function s_(e){return[...new Set(e.evidence.map(t=>t.logId).filter(t=>t!==null))]}const o_=[{id:"reliability",label:"Reliability",question:"Which requests failed, stalled, or look most likely to hang, and why?"},{id:"performance",label:"Performance",question:"Summarize latency and identify the slowest requests with supporting evidence."},{id:"tokens",label:"Token usage",question:"Where are tokens being spent, and which requests have unusually high usage?"},{id:"providers",label:"Providers",question:"Compare Provider and model reliability, latency, and token usage in this scope."},{id:"tools",label:"Tool activity",question:"Which tools were used most, and where did tool calls fail or produce warnings?"}],r_=4e3,Fa=12;function yd(){return{messages:[],question:"",error:null}}function a_(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,r_)}))}function st(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function dn(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function i_(e,t){const s=G(e,t);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function l_(e){const t=st(e,"source")??"log",s=st(e,"id")??"",o=dn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=dn(e,"inputTokens"),a=dn(e,"outputTokens"),i=dn(e,"totalTokens","tokenCount"),c=dn(e,"responseStatus","status"),d=st(e,"responseStatus","status");return{source:t,id:s!==""?s:String(o),logId:o,sessionId:st(e,"sessionId"),timestamp:st(e,"timestamp"),model:st(e,"model"),providerName:st(e,"providerName","provider"),path:st(e,"path"),status:c??d,elapsedMs:dn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:dn(e,"score","relevanceScore"),matchedFields:i_(e,"matchedFields"),excerpt:st(e,"excerpt","snippet")??"No excerpt available."}}function Ba(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function wd(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const t=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return t.length>0?t.join(", "):null}return null}function jd(e){return Object.getOwnPropertyNames(e).map(t=>[t,G(e,t)])}function Sd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[s,o]of jd(e)){const r=wd(o);if(r!==null){if(t.push({key:s,label:Ba(s),value:r}),t.length>=Fa)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of jd(o)){const c=wd(i);if(c===null)continue;const d=`${s}.${a}`;if(t.push({key:d,label:`${Ba(s)} ${Ba(a).toLowerCase()}`,value:c}),t.length>=Fa)break}if(t.length>=Fa)break}}return t}function c_(e){const t=st(e,"answer"),s=st(e,"providerId"),o=st(e,"providerName"),r=st(e,"model"),a=st(e,"protocol"),i=dn(e,"logCount");if(t===null||s===null||o===null||r===null||a===null||i===null)return null;const c=G(e,"evidence"),d=Array.isArray(c)?c.map(l_).filter(m=>m!==null).slice(0,12):[];return{answer:t,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:Sd(G(e,"summary")),queryMetrics:Sd(G(e,"queryStats"))}}const d_=l.lazy(()=>qt(()=>import("./index-CbQTPA5b.js"),__vite__mapDeps([10,1,2]),import.meta.url)),u_="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]",Ua=96*1024;function m_({text:e}){const[t,s]=l.useState(!1),o=e.length>Ua,r=o&&!t?e.slice(0,Ua):e;return l.useEffect(()=>{s(!1)},[e]),n.jsxs("div",{className:"space-y-2",children:[o&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Ua.toLocaleString()," characters for fast rendering. The full response is preserved."]}),n.jsx("div",{className:u_,children:n.jsx(l.Suspense,{fallback:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:n.jsx(d_,{children:r})})}),o&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(a=>!a),children:t?"Collapse fast preview":`Render full response (${e.length.toLocaleString()} chars)`})]})}const Nd="What looks abnormal, slow, or likely to hang?";function p_(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function f_(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function h_(e){return e.toSorted((t,s)=>{const o=t.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:t.name.localeCompare(s.name)})}function Cd(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Rn({label:e,value:t,tone:s="muted"}){return n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[n.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),t!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/55",children:":"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t})]})]})}function x_({metrics:e}){return e.length===0?null:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>n.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[n.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:t.label}),n.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:t.value})]},t.key))})}function g_({evidence:e}){const t=()=>{e.logId!==null&&vs({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return n.jsxs("button",{type:"button",onClick:t,disabled:e.logId===null,className:"w-full rounded-sm bg-black/25 px-2 py-2 text-left shadow-[inset_2px_0_0_rgba(103,232,249,0.22),inset_0_0_0_1px_rgba(255,255,255,0.045)] transition-colors hover:bg-black/35 disabled:cursor-default disabled:hover:bg-black/25",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&n.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&n.jsx("span",{children:e.providerName}),e.model!==null&&n.jsx("span",{children:e.model}),e.status!==null&&n.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&n.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),n.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function b_({response:e}){return n.jsxs("div",{className:"overflow-hidden rounded-md bg-[#050b12]/85 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.12),0_10px_24px_rgba(0,0,0,0.18)]",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-cyan-100/[0.08] bg-cyan-400/[0.045] px-3 py-2",children:[n.jsx(Rn,{label:"assistant@inspector",value:"output",tone:"cyan"}),n.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),n.jsxs("div",{className:"space-y-3 p-3",children:[n.jsx("div",{className:"rounded-sm bg-black/20 px-2.5 py-2 text-xs leading-5 shadow-[inset_2px_0_0_rgba(103,232,249,0.28)]",children:n.jsx(m_,{text:e.answer})}),n.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[n.jsx(Rn,{label:"provider",value:e.providerName}),n.jsx(Rn,{label:"model",value:e.model}),n.jsx(Rn,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Rn,{label:"metrics",tone:"cyan"}),n.jsx(x_,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Rn,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(t=>n.jsx(g_,{evidence:t},`${t.source}-${t.id}`))]})]})]})}function v_({message:e}){return e.role==="assistant"&&e.response!==null?n.jsx(b_,{response:e.response}):n.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:n.jsx(Rn,{label:"user@inspector",value:"query",tone:"cyan"})}),n.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[n.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function y_({currentSessionId:e,logCount:t,onResultChange:s}){const{providers:o}=nl(),r=l.useMemo(()=>h_(o.filter(p_)),[o]),[a,i]=l.useState(()=>({...yd(),question:Nd})),[c,d]=l.useState("__auto__"),[m,u]=l.useState("__auto__"),[p,f]=l.useState(!1),g=r.find(C=>C.id===c)?.models??[],b=a.question,y=b.trim()!==""&&r.length>0&&!p;if(r.length===0)return null;const w=C=>{i(R=>({...R,question:C.currentTarget.value}))},v=C=>{d(C),u("__auto__")},j=()=>{i({...yd(),question:Nd}),s(null)},S=C=>{i(R=>({...R,question:C,error:null}))},N=()=>{if(!y)return;const C=b.trim(),R=a_(a.messages),P={id:Cd("user"),role:"user",content:C,response:null};f(!0),i(M=>({...M,messages:[...M.messages,P],question:"",error:null}));const L={question:C,history:R,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};Jh("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(L)}).then(async M=>{const k=await M.text();if(!M.ok){i(F=>({...F,error:`Inspector Assistant failed: HTTP ${String(M.status)} ${k}`}));return}const A=JSON.parse(k),D=c_(A);if(D===null){i(F=>({...F,error:"Inspector Assistant returned an unexpected response."}));return}i(F=>({...F,messages:[...F.messages,{id:Cd("assistant"),role:"assistant",content:D.answer,response:D}]})),s({question:C,logIds:s_(D),reportedLogCount:D.logCount})}).catch(M=>{i(k=>({...k,error:M instanceof Error?M.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return n.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(S0,{className:"size-4 text-cyan-200"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),n.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),n.jsx("button",{type:"button",onClick:j,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:n.jsx(Lu,{className:"size-3.5"})})]}),a.messages.length===0&&n.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[n.jsxs(Vs,{value:c,onValueChange:v,children:[n.jsx(Ws,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(dr,{placeholder:"Provider"})}),n.jsxs(Gs,{children:[n.jsx(ot,{value:"__auto__",children:"Auto provider"}),r.map(C=>n.jsxs(ot,{value:C.id,children:[C.name," / ",f_(C)]},C.id))]})]}),n.jsxs(Vs,{value:m,onValueChange:u,children:[n.jsx(Ws,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(dr,{placeholder:"Model"})}),n.jsxs(Gs,{children:[n.jsx(ot,{value:"__auto__",children:"Auto model"}),g.map(C=>n.jsx(ot,{value:C,children:C},C))]})]})]}),a.messages.length===0&&n.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:o_.map(C=>n.jsxs("button",{type:"button",onClick:()=>{S(C.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[n.jsx(Za,{className:"size-3"}),n.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&n.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>n.jsx(v_,{message:C},C.id)),p&&n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx(Oe,{className:"size-3.5 animate-spin"}),n.jsx("span",{children:"Searching Inspector..."})]})]}),n.jsx("textarea",{value:b,onChange:w,className:"mt-3 min-h-20 w-full resize-y rounded-md bg-black/25 px-3 py-2 text-xs leading-5 text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring",placeholder:"Ask about this Inspector data..."}),n.jsxs("button",{type:"button",onClick:N,disabled:!y,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[p?n.jsx(Oe,{className:"size-3.5 animate-spin"}):n.jsx(S1,{className:"size-3.5"}),n.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),a.error!==null&&n.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),t===0&&n.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function w_(e){const t=new Map;for(const s of e){const o=s.logs;for(let r=1;r<o.length;r++){const a=o[r-1],i=o[r];a===void 0||i===void 0||t.set(i.id,{creation:kd(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:kd(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return t}function kd(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function mh(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function es(e,t,s){const o=mh(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${t}${i}${r}${a}`}function ph(e,t,s){switch(e){case"connecting":return{label:"Connecting",description:es(t,"Waiting for the first live update.",s),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:es(t,"Live updates are current.",s),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:es(t,"Live updates were interrupted.",s),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:es(t,"Live updates have not resumed.",s),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:es(t,t.errorMessage??"Live updates are paused.",s),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:es(t,t.errorMessage??"The live stream reported a recoverable error.",s),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function j_({state:e}){const t=ph(e.status,e,!1),s=mh(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return n.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:O("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[n.jsx("span",{className:O("size-1.5 shrink-0 rounded-full",t.dotClass)}),n.jsx("span",{className:"shrink-0",children:t.label}),o!==null&&n.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&n.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function S_({state:e,hasLogs:t,onRetry:s,onStop:o}){const r=ph(e.status,e,t);return n.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:O("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",r.toneClass),children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:O("size-2 shrink-0 rounded-full",r.dotClass)}),n.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),n.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&n.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[n.jsx(Ct,{className:"size-3"}),"Retry now"]}),r.canStop&&n.jsxs("button",{type:"button",onClick:o,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[n.jsx(V0,{className:"size-3"}),"Stop retrying"]})]})]})}function N_(){const[e,t]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{t(document.fullscreenElement!==null),o(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return i(),document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]);const r=l.useCallback(()=>{if(s){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{t(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{t(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return n.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ao,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?n.jsx(qg,{className:"size-4"}):n.jsx(Fg,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:a})]})}function C_({liveConnection:e,alertsAction:t,settingsAction:s}){return n.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:n.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[n.jsxs("a",{href:Pi("/"),"aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[n.jsx(ou,{className:"size-7 shrink-0 text-amber-500"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),n.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),n.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",zu.version]})]}),n.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?n.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[n.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):n.jsx(j_,{state:e})}),n.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[n.jsx(N_,{}),t,s]})]})})}function k_(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function qo({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(t*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=t>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${k_(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return n.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 truncate",children:e.label}),n.jsx("span",{className:O("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),n.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":i,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:n.jsx("div",{className:O("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",r?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${s.toString()}%`}})})]})}function fh(e){return e?"auto":"smooth"}function hh(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function __(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function It(e,t){switch(t.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:t.message}:{...e,status:"offline",retryCount:s,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:t.message}}}function T_(e){return e===void 0||e.status==="live"?"empty":e.status}function E_(e){switch(e){case"connecting":return{title:"Connecting to the live stream...",description:"Waiting for the first successful initialization before checking for logs.",showConnectionCommands:!1};case"empty":return{title:"No logs captured yet.",description:"Connect an AI coding tool to capture its first request.",showConnectionCommands:!0};case"reconnecting":return{title:"Reconnecting to live updates...",description:"The stream was interrupted. Agent Inspector is retrying automatically.",showConnectionCommands:!1};case"stale":return{title:"Live data is stale.",description:"No logs are hidden; retry the connection to resume live updates.",showConnectionCommands:!1};case"offline":return{title:"Live updates are offline.",description:"Check the browser and Inspector connection, then retry.",showConnectionCommands:!1};case"error":return{title:"Live updates could not initialize.",description:"The error is recoverable. Retry without reloading the page.",showConnectionCommands:!1}}}const _d="agent-inspector.hierarchy.collapsedClients",Td="agent-inspector.hierarchy.collapsedProcesses";function pr(e){return e.some(t=>t.responseStatus===null)}function xh(e){return e.filter(t=>t.responseStatus===null).length}function gh(e){for(const t of e){const s=t.userAgent;if(s!=null&&s!=="")return s}return null}function R_(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function bh(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function M_(e){return _l({userAgent:gh(e.logs),conversationId:e.conversationId,clientProjectFolder:bh(e.logs)})}function A_(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function I_(e,t){const s=qr(e);return s!==null?s:A_(t)}function fr(e){return e===null||e===""?"unknown":String(e)}function P_(e,t,s){return e!=="unknown"?e:`unknown:${fr(t)}:${fr(s)}`}function L_(e,t){return`${fr(e)}:${fr(t)}`}function Ed(e){return[...e].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}function Rd(e){let t="";for(const s of e)s.timestamp>t&&(t=s.timestamp);return t}function Md(e){return pr(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function qa(e){return[...e].sort((t,s)=>{const o=Md(t.logs)-Md(s.logs);if(o!==0)return o;const r=Rd(s.logs).localeCompare(Rd(t.logs));return r!==0?r:t.id.localeCompare(s.id)})}function O_(e){const t=new Map;for(const o of e){const r=gh(o.logs),a=bh(o.logs),i=M_(o),c=P_(i,r,a);let d=t.get(c);d===void 0&&(d={id:c,client:i,label:I_(i,r),userAgent:r,processes:new Map,logs:[]},t.set(c,d)),d.logs.push(...o.logs);const m=R_(o.logs),u=`${c}:${L_(m,a)}`;let p=d.processes.get(u);p===void 0&&(p={id:u,clientPid:m,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,p)),p.sessions.push(o),p.logs.push(...o.logs)}const s=[];for(const o of t.values()){const r=qa([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:qa(a.sessions),logs:Ed(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:Ed(o.logs)})}return qa(s)}function hr(e){return e<=0?"0":Ee(e)}function vh(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(t+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:t,outputTokens:s}}function D_(e){let t=0;for(const s of e)t+=s.sessions.length;return t}function Ad(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const s=JSON.parse(t);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function Id(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Pd(e,t){let s=!1;const o=new Set(e);for(const r of t)o.delete(r)&&(s=!0);return s?o:e}function z_(e){const t=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!pr(r.logs)&&t.add(r.id)}return t}function $_(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=t[t.length-1];if(s===void 0)return e;const o=t[t.length-2];return o===void 0?s:`${o}/${s}`}function xr({label:e,value:t,className:s}){return n.jsxs("span",{className:O("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),n.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function yh({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return n.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":t,title:t,children:[n.jsx(Oe,{className:"size-3 animate-spin"}),e>1&&n.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function F_({groups:e,...t}){const s=l.useMemo(()=>O_(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>z_(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const p=Ad(_d),f=Ad(Td);p!==null&&r(p),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(Id(_d,o),Id(Td,a))},[o,a,c]),l.useEffect(()=>{const p=new Set(s.filter(h=>pr(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>pr(g.logs)).map(g=>g.id)));r(h=>Pd(h,p)),i(h=>Pd(h,f))},[s]);const m=l.useCallback(p=>{r(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),u=l.useCallback(p=>{i(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]);return n.jsx("div",{className:"space-y-2",children:s.map(p=>n.jsx(B_,{group:p,collapsed:o.has(p.id),collapsedProcessIds:a,onToggleClient:()=>m(p.id),onToggleProcess:u,conversationProps:t},p.id))})}function B_({group:e,collapsed:t,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=vh(e.logs),c=D_(e.processes),d=e.logs.length,m=xh(e.logs),u=m>0;return n.jsxs("section",{className:O("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[n.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:o,"aria-expanded":!t,children:[e.client==="unknown"?n.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:n.jsx(Wg,{className:"size-4"})}):n.jsx(Hr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),n.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:Pj(e.client)}),u&&n.jsx(yh,{count:m})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),n.jsxs("span",{children:[c," session",c!==1?"s":""]}),n.jsxs("span",{children:[d," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(xr,{label:"IN",value:hr(i.inputTokens)}),n.jsx(xr,{label:"OUT",value:hr(i.outputTokens)})]}),n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:t?n.jsx(ft,{className:"size-4"}):n.jsx(We,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>n.jsx(U_,{group:p,collapsed:s.has(p.id),onToggle:()=>r(p.id),conversationProps:a},p.id))})]})}function U_({group:e,collapsed:t,onToggle:s,conversationProps:o}){const r=vh(e.logs),a=$_(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=xh(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return n.jsxs("section",{className:"relative pl-3",children:[n.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:s,"aria-expanded":!t,children:[n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:n.jsx(rg,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&n.jsx(yh,{count:d}),a!==null&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[n.jsx(_g,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",children:a})]})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[i," session",i!==1?"s":""]}),n.jsxs("span",{children:[c," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(xr,{label:"IN",value:hr(r.inputTokens)}),n.jsx(xr,{label:"OUT",value:hr(r.outputTokens)})]}),n.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:t?n.jsx(ft,{className:"size-4"}):n.jsx(We,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>n.jsx(zC,{group:p,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const q_="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",H_=[{label:"Headers",detail:"request and response headers, including authorization or cookie values"},{label:"Prompts",detail:"system instructions, user prompts, model responses, and conversation history"},{label:"Source content",detail:"source code, file contents, tool inputs, and tool output"},{label:"Secrets",detail:"API keys, access tokens, credentials, and other sensitive values"}];function V_({onCancel:e,onExportRedacted:t,onConfirmRaw:s}){return n.jsxs(n.Fragment,{children:[n.jsxs(Wt,{children:[n.jsx(Gt,{children:"Export unredacted logs?"}),n.jsx(oo,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),n.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[n.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),n.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:H_.map(o=>n.jsxs("li",{children:[n.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),n.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),n.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),n.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const gr="data-nav-id",W_="data-nav-action";function Ld(e){return Array.from(e.querySelectorAll(`[${gr}]`))}function Od(e){return e instanceof HTMLElement}function G_(e,t){let s=e;for(;s!==null&&s!==t;){if(s.hasAttribute(gr))return s;s=s.parentElement}return e.hasAttribute(gr)?e:null}function Ha(e){const t=e.getAttribute(W_);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function As(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Is(e,t){return e[t]??null}function wh(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function Dd(e){const t=e.tagName;return t==="BUTTON"||t==="A"||wh(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function K_(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function Y_(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Mo(e,t){return e.key===t&&e.shiftKey}function J_(e,t,s={}){const o=t??e,r=s.pageWide===!0,a=l.useCallback(i=>{const c=e.current,d=o.current;if(!c||!d)return;const m=i.target;if(!Od(m)||m!==d)return;const u=Ld(c),p=Is(u,0);p!==null&&As(p)},[e,o]);l.useEffect(()=>{const i=c=>{if(c.altKey||c.ctrlKey||c.metaKey)return;const d=e.current;if(!d)return;const m=c.target;if(!Od(m)||wh(m)||Y_())return;const u=d.contains(m);if(u&&Dd(m)&&!m.hasAttribute(gr)||!u&&(!r||Dd(m)||K_(m)))return;const p=Ld(d);if(p.length===0)return;const f=G_(m,d),h=f!==null?p.indexOf(f):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!Mo(c,"W"))break;c.preventDefault();const b=h>0?h-1:h===-1?p.length-1:-1;if(b!==-1){const y=Is(p,b);y!==null&&As(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!Mo(c,"S"))break;c.preventDefault();const b=h<p.length-1?h+1:h===-1?0:-1;if(b!==-1){const y=Is(p,b);y!==null&&As(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!Mo(c,"A")||f===null)break;if(c.preventDefault(),Ha(f)==="collapse")f.click();else if(h>0){const y=Is(p,h-1);y!==null&&As(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!Mo(c,"D")||f===null)break;if(c.preventDefault(),Ha(f)==="expand")f.click();else if(h<p.length-1){const y=Is(p,h+1);y!==null&&As(y)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Ha(f)!==null&&f.click(),g=!0;break}}g&&c.stopPropagation()};return document.addEventListener("keydown",i,{capture:!0}),()=>document.removeEventListener("keydown",i,{capture:!0})},[e,r,o]),l.useEffect(()=>(document.addEventListener("focusin",a),()=>document.removeEventListener("focusin",a)),[a])}const X_={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},Z_={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},Q_={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},Va=12,Ao=1,zd=80,$d=24;function eT(e){return e.length<=$d?e:`${e.slice(0,$d-3)}...`}function tT(e){const t=e.replace(/\s+/g," ").trim();return t.length<=zd?t:`${t.slice(0,zd)}...`}function Io(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const nT=l.memo(function({segments:t,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:t.reduce((y,w)=>y+w.size,0),[t,s]),i=t.slice(0,Va),c=t.slice(Va),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=Va,p=u+m-1,f=m>0,h=r!==void 0,g=l.useMemo(()=>i.reduce((y,w)=>y+w.size,0),[i]),b=l.useMemo(()=>`Request context: ~${Ee(a)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,a]);return t.length===0||a<=0?n.jsx("div",{role:"img","aria-label":b,className:"h-6"}):n.jsx(Ns,{delayDuration:150,children:n.jsxs("div",{role:"img","aria-label":b,className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Ao,v),S=O("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",Z_[y.role],h?Q_[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${Io(v)}, ~${Ee(y.size)} tokens`;return n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:h?n.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):n.jsx("span",{"aria-label":C,className:S,style:N})}),n.jsxs(ct,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[n.jsxs("div",{className:"font-semibold",children:[y.label," - ",Io(v)," - ~",Ee(y.size)," ","tokens"]}),n.jsx("div",{className:"text-muted-foreground",children:X_[y.role]}),n.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&n.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:tT(y.text)})]})]},`${y.path}-${w}`)}),f&&n.jsxs(it,{children:[n.jsx(lt,{asChild:!0,children:n.jsxs("div",{role:"img","aria-label":`${m} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(Ao,d/a*100)}%`},children:["... +",m]})}),n.jsxs(ct,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",p,")"]})]})]}),o&&n.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Ao,v);return n.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${Io(v)} - ~${Ee(y.size)} tokens`,children:[n.jsx("span",{className:"truncate font-mono text-foreground/80",children:eT(y.label)}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Io(v)," - ~",Ee(y.size)]})]},`label-${y.path}-${w}`)}),f&&n.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Ao,d/a*100)}%`},children:[n.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ee(d)]})]})]}),g<a*.1&&n.jsx("div",{className:"h-0"})]})})}),jh=.75,Sh=.9,Ti=8e3,sT=.35,Nh=40,Ch=160,oT=5,rT=8,aT=18,iT=6e4,lT=.7,Fd=3e3,cT=.3,Bd=160,dT=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),uT=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],mT=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],pT=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],fT={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function hT(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function kh(e,t){for(const s of t){const o=hT(G(e,s));if(o!==null)return o}return null}function xT(e){const t=G(e,"model");if(typeof t!="string")return null;const s=t.trim();return s===""?null:s}function gT(e,t){switch(t.mode){case"prefix":return t.patterns.some(s=>e.startsWith(s));case"includes":return t.patterns.some(s=>e.includes(s))}}function bT(e,t,s=[]){const o=kh(t,uT);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=g3(e,s);if(r!==null)return{tokens:r.tokens,label:`${r.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const a=e.trim().toLowerCase().replace(/\s+/g,"-");for(const i of pT)if(gT(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function vT(e){return e<0?0:e>1?1:e}function yT(e){return e===null?"unknown":e>=Sh?"danger":e>=jh?"watch":"ok"}function wT(e,t){return e.filter(s=>s.role===t).reduce((s,o)=>s+o.size,0)}function jT(e,t){return["system","user","assistant","tool","tools"].map(o=>{const r=wT(e,o);return{role:o,label:fT[o],tokens:r,percent:t>0?r/t:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function Ei(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function ST(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Bd?t:`${t.slice(0,Bd-3)}...`}function NT(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function CT(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function kT(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function _T(e){if(!kT(e))return null;try{return JSON.parse(e)}catch{return null}}function TT(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function ET(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function RT(e){const t=ET(e);return t===null?!1:dT.has(TT(t))}function MT(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function AT(e,t,s){const o=El(t);if(o<Ch)return null;const r=Tl(t);return r<Nh?null:{role:e.role,label:`${e.label} ${MT(s)}`,path:e.path,tokens:r,characters:o,text:t}}function Ri({value:e,segment:t,path:s,depth:o,candidates:r}){if(!(r.length>=rT)&&!(o>oT)){if(typeof e=="string"){if(!RT(s))return;const a=AT(t,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Ri({value:a,segment:t,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}Rl(e)&&Object.entries(e).forEach(([a,i])=>Ri({value:i,segment:t,path:[...s,a],depth:o+1,candidates:r}))}}function IT(e){const t=CT(e),s=_T(e.text);if(s===null)return[t];const o=[];Ri({value:s,segment:e,path:[],depth:0,candidates:o});const r=Ei(e.text),a=new Set([r]),i=o.filter(c=>{const d=Ei(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[t,...i]}function PT(e){const t=new Map;for(const o of e){const r=IT(o);for(const a of r){if(a.tokens<Nh||a.characters<Ch)continue;const i=Ei(a.text);if(i==="")continue;const c=t.get(i);if(c===void 0){t.set(i,{tokens:a.tokens,candidates:[a]});continue}t.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of t.values()){if(o.candidates.length<2)continue;const r=o.candidates[0]??null;if(r===null)continue;const a=o.tokens-r.tokens;s.push({key:`${r.path}:${r.label}:${String(o.candidates.length)}:${String(o.tokens)}`,count:o.candidates.length,totalTokens:o.tokens,repeatedTokens:a,preview:ST(r.text),firstLabel:r.label,segments:o.candidates.map(NT)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function LT(e){if(e.length===0)return null;const t=e.length,s=e.reduce((r,a)=>r+a.count,0),o=e.reduce((r,a)=>r+a.repeatedTokens,0);return{kind:"duplicate",severity:o>=Ti?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(o)} repeated tokens.`}}function OT(e){return e.reduce((t,s)=>t+s.repeatedTokens,0)}function DT(e,t,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=Ti||r.percent>=sT&&r.tokens>=Fd)&&o.push({kind:"tool-schema",severity:r.tokens>=Ti?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(r.percent*100)}% of request context.`});const a=e.find(d=>d.role==="system")??null;a!==null&&a.tokens>=Fd&&a.percent>=cT&&o.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(a.percent*100)}% of request context.`});const i=e.filter(d=>d.role==="user"||d.role==="assistant"||d.role==="tool").reduce((d,m)=>d+m.tokens,0),c=t>0?i/t:0;return s>=aT&&(i>=iT||c>=lT)&&o.push({kind:"history-bloat",severity:c>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(s)} message blocks take ${Math.round(c*100)}% of request context.`}),o}function zT({risk:e,contextWindow:t,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),t.source==="unknown"&&(a+=1);const i=s.some(d=>d.severity==="danger");return{level:e==="danger"||i?"risk":a>0?"optimizable":"ok",opportunityCount:a,reclaimableTokens:OT(o)}}function $T({segments:e,inputTokens:t,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,R)=>C+R.size,0),i=o??xT(s),c=t??a,d=kh(s,mT),m=bT(i,s,r),u=d??0,p=m.tokens===null?null:c+u,f=m.tokens===null?null:m.tokens-c,h=m.tokens===null?null:m.tokens-c-u,g=m.tokens===null||p===null?null:vT(p/m.tokens),b=jT(e,a),y=b[0]??null,w=e.filter(C=>C.role!=="tools").length,v=PT(e),j=LT(v),S=DT(b,a,w);j!==null&&S.unshift(j);const N=yT(g);return{model:i,contextWindow:m,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:p,remainingInputTokens:f,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:b,largestRole:y,diagnostics:S,duplicateGroups:v,health:zT({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:v})}}const eR={watch:jh,danger:Sh},Ud=new WeakMap;function FT(e){return e.map(t=>{const s=t.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${s}`}).join("|")}function BT(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function UT(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function qT(e,t){const s=BT(e.rawRequestBody);if(s===null)return null;const r=gf(ir(e)).anatomySegments(s);if(r===null)return null;const a=$T({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:t}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(UT);return{logId:e.id,model:i,timestamp:e.timestamp,contextWindow:a.contextWindow,estimatedInputTokens:a.estimatedInputTokens,windowUsedTokens:a.windowUsedTokens,usagePercent:a.usagePercent,riskLevel:a.riskLevel,health:a.health,diagnostics:a.diagnostics.map(d=>d.title),roleSegments:c,roleTotalTokens:c.reduce((d,m)=>d+m.size,0)}}function HT(e,t,s){const o=Ud.get(e);if(o!==void 0&&o.id===e.id&&o.rawRequestBody===e.rawRequestBody&&o.inputTokens===e.inputTokens&&o.model===e.model&&o.path===e.path&&o.apiFormat===e.apiFormat&&o.timestamp===e.timestamp&&o.providersSignature===s)return o.snapshot;const r=qT(e,t);return Ud.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:s,snapshot:r}),r}function VT(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function qd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function WT(e,t){const s=qd(t.latest.riskLevel)-qd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(t.peak.usagePercent??-1)-o;return a!==0?a:t.latest.logId-e.latest.logId}function GT(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function KT(e){for(let t=1;t<e.length;t++){const s=e[t-1],o=e[t];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function YT(e,t=[]){const s=KT(e),o=FT(t),r=new Map;for(const i of s){const c=HT(i,t,o);if(c===null)continue;const d=r.get(c.model);if(d===void 0){r.set(c.model,{model:c.model,requestCount:1,first:c,latest:c,peak:c});continue}r.set(c.model,{model:d.model,requestCount:d.requestCount+1,first:d.first,latest:c,peak:VT(c,d.peak)?c:d.peak})}return{models:[...r.values()].map(i=>({model:i.model,requestCount:i.requestCount,first:i.first,latest:i.latest,peak:i.peak,trendPercent:GT(i.first,i.latest)})).sort(WT)}}function An(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function JT(e){const t=new Map;for(const s of e)for(let o=0;o<s.logs.length;o+=1){const r=s.logs[o];r!==void 0&&t.set(r.id,o+1)}return t}function Hd(e,t){return t.get(e.id)??e.id}function Vd(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:t,totalOut:s}}function XT(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function ZT(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:jr(s.timestamp,o.timestamp,t)}function QT(e){switch(e){case"cool":return"text-status-cool";case"danger":return"text-status-danger";case"watch":return"text-status-watch";case"neutral":return"text-foreground"}}function eE(e){switch(e){case"rolling":return n.jsx(Ct,{className:"size-3 text-status-cool"});case"failed":return n.jsx(Xo,{className:"size-3 text-status-danger"});case"watch":return n.jsx(Ou,{className:"size-3 text-status-watch"});case"clear":return n.jsx(Pe,{className:"size-3 text-status-success"})}}function tE(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function nE(e){return e.pending>0?`${e.pending} pending / ${e.failures} failed`:e.lengthStops>0?`${e.lengthStops} output limit / ${e.failures} failed`:`${e.failures} failed / ${e.slow} slow`}function ts({label:e,value:t,detail:s,icon:o,tone:r="neutral"}){return n.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),n.jsx("div",{className:O("mt-2 font-mono text-sm font-semibold",QT(r)),children:t}),n.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function sE({stats:e}){return e.requests===0?null:n.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[n.jsx("div",{className:"px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[n.jsx(K0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),n.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),n.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[n.jsx(ts,{label:"Status",value:e.statusLabel,detail:nE(e),icon:eE(e.status),tone:tE(e.status)}),n.jsx(ts,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:n.jsx(Ng,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),n.jsx(ts,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:n.jsx(Xo,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),n.jsx(ts,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:n.jsx(Ou,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),n.jsx(ts,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:n.jsx(Ji,{className:"size-3 text-muted-foreground"})}),n.jsx(ts,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function zs(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function oE(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Mi(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function rE(e,t){if(t===null)return null;const s=Mi(e),o=Mi(t);return o<=0||Math.abs(o-s)<.5?null:o}function aE(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-cyan-300"}}function iE(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${su(t)}`}const lE=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function _h(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function Wa(e,t){if(e===null)return null;const s=e.metadata[t];return s===void 0?null:_h(s)}function cE(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function dE(e){const t=[];for(const s of lE){const o=e.metadata[s];if(o===void 0)continue;const r=_h(o);r!==null&&t.push({key:s,value:r})}return t}function Wd({memberships:e,defaultOpen:t=!1}){const[s,o]=l.useState(t);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=Wa(a,"score"),c=Wa(a,"decision"),d=Wa(a,"final_status"),m=[i===null?null:{label:`score ${i}`,value:i},c===null?null:{label:c,value:c},d===null?null:{label:d,value:d},a?.model===null||a?.model===void 0?null:{label:a.model,value:a.model}].filter(u=>u!==null&&u.label.length>0&&u.value.length>0);return n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[n.jsxs("button",{type:"button",onClick:()=>o(u=>!u),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":s,children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&n.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),n.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&n.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:m.slice(0,4).map(u=>n.jsx("span",{className:O("rounded border px-1.5 py-0.5 font-mono text-[10px]",cE(u.value)),children:u.label},u.label))})]}),s?n.jsx(Ki,{className:"size-4 shrink-0 text-muted-foreground"}):n.jsx(We,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&n.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const p=u.member,f=dE(p);return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),p.status!==null&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsx("span",{className:"font-mono",title:p.sessionId,children:An(p.sessionId)}),p.label!==null&&n.jsx("span",{children:p.label}),p.provider!==null&&n.jsx("span",{children:p.provider}),p.model!==null&&n.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&n.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",An(p.runId)]})]}),f.length>0&&n.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>n.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[n.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),n.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${p.id}`)})})]})}function Po({label:e,title:t,icon:s,disabled:o,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,disabled:o,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[s,n.jsx("span",{children:e})]})}function Gd({logs:e,pagination:t,embedded:s=!1}){if(t===void 0)return null;const o=t.isLoading;return n.jsxs("nav",{"aria-label":"Session log pagination",className:O("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",s?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[n.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[n.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[sk({logs:e,pagination:t}),t.isLoading&&e.length>0&&n.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&n.jsx(qo,{progress:t.loadProgress})]}),n.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[n.jsx(Po,{label:"Oldest",title:"Load the oldest logs in this session",icon:n.jsx(P0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOldest}),n.jsx(Po,{label:"Older",title:"Load older logs",icon:n.jsx(T0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOlder}),n.jsx(Po,{label:"Newer",title:"Load newer logs",icon:n.jsx(ft,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewer}),n.jsx(Po,{label:"Newest",title:"Load the newest logs in this session",icon:n.jsx(O0,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewest})]})]})}function uE(e){return`${e} ${e===1?"request":"requests"}`}function Kd(e){return`#${String(e)}`}function Yd(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-cyan-200"}}function mE(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-cyan-300/25 bg-cyan-400/8 text-cyan-100"}}function pE(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const fE=10,hE=80;function xE(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function gE(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:fh(hh())}),t.focus({preventScroll:!0}),xE(t),!0):!1}function Th(e){vs({logId:e,tab:"anatomy"});let t=0;const s=()=>{vs({logId:e,tab:"anatomy"}),!gE(e)&&(t+=1,t<fE&&window.setTimeout(s,hE))};window.setTimeout(s,0)}function bE({command:e}){const[t,s]=l.useState(!1),o=l.useCallback(()=>{Nt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return n.jsxs("div",{"data-command-example":"true",className:$C,children:[n.jsx("pre",{className:FC,children:e}),n.jsx("button",{type:"button",onClick:o,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:t?n.jsx(Pe,{className:"size-4"}):n.jsx(Et,{className:"size-4"})})]})}function Ga({label:e,children:t,className:s}){return n.jsxs("section",{className:O("rounded-[8px] border border-border/60 bg-card/55",s),children:[n.jsx("div",{className:"px-3 pt-3",children:n.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),n.jsx("div",{className:"p-3 pt-2",children:t})]})}function Lo({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[n.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:t}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function vE(){const{themeMode:e,setThemeMode:t}=yb();return n.jsxs("div",{className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-muted/70 p-0.5","aria-label":"Theme mode",role:"group",children:[n.jsx("button",{type:"button",onClick:()=>t("light"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:n.jsx(P1,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:n.jsx(Tu,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("dark"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:n.jsx(Kg,{className:"size-3.5"})})]})}function yE({visible:e,onToggle:t}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return n.jsx("button",{type:"button",onClick:t,className:O("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":s,"aria-pressed":e,title:s,children:n.jsx(ou,{className:O("size-4 transition-opacity",!e&&"opacity-45")})})}function wE({preference:e,resolvedScale:t,onChange:s}){const o=kb(t),r=e==="auto"?`Auto (${o})`:`${e}%`;return n.jsxs(Vs,{value:e,onValueChange:a=>s(el(a)),children:[n.jsxs(Ws,{size:"sm",className:"h-9 min-w-[4.5rem] justify-center gap-1 border-border/70 bg-muted/70 px-2 py-0 text-muted-foreground hover:bg-muted max-lg:h-11 [&>svg:last-child]:hidden","aria-label":`Interface size: ${r}`,children:[n.jsx(o0,{className:"size-3.5"}),n.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),n.jsxs(Gs,{align:"end",children:[n.jsx(ot,{value:"auto",children:"Auto"}),n.jsx(ot,{value:"100",children:"100%"}),n.jsx(ot,{value:"125",children:"125%"}),n.jsx(ot,{value:"150",children:"150%"})]})]})}const Eh="agent-inspector.detailsPanelCollapsed",Rh="agent-inspector.detailsPanelWidth",Mh="agent-inspector.pet.visible",as=360,jE=288,SE=520;function Ah(e){return Math.min(Math.max(e,jE),SE)}function NE(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Eh);return e===null||e==="1"}catch{return!0}}function CE(){if(typeof window>"u")return as;try{const e=window.localStorage.getItem(Rh);if(e===null)return as;const t=Number.parseInt(e,10);return Number.isFinite(t)?Ah(t):as}catch{return as}}function kE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Mh)!=="0"}catch{return!0}}function Jd({label:e,logId:t}){return n.jsxs("button",{type:"button",onClick:()=>Th(t),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${Kd(t)}`,children:[e," ",Kd(t)]})}function _E({latestPercent:e,peakPercent:t,risk:s,onOpenContext:o}){const r=Mi(e),a=rE(e,t),i=t===null?`Latest context window usage ${zs(e)}`:`Latest context window usage ${zs(e)}, peak ${zs(t)}`;return n.jsx("button",{type:"button",onClick:o,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${i}. Open latest Context details`,title:"Open latest Context details",children:n.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":i,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:[n.jsx("span",{className:O("block h-full rounded-full transition-[width]",aE(s)),style:{width:`${r}%`}}),a!==null&&n.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${a}% - 0.5px)`},"aria-hidden":"true"})]})})}function TE({summary:e}){const t=e.trendPercent,s=t===null||Math.abs(t)<.1?null:t>0?f0:l0,o=e.latest.diagnostics[0]??null,r=zs(e.latest.usagePercent),a=zs(e.peak.usagePercent),i=()=>{Th(e.latest.logId)};return n.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("button",{type:"button",onClick:i,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-text-link focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),n.jsx("span",{className:O("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",mE(e.latest.health.level)),children:pE(e.latest.health.level)})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsx("span",{children:uE(e.requestCount)}),n.jsx("span",{children:iE(e)})]})]}),n.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[n.jsx(_E,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),n.jsx("div",{className:O("mt-0.5 font-mono",Yd(e.latest.riskLevel)),children:r}),n.jsx(Jd,{label:"Log",logId:e.latest.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),n.jsx("div",{className:O("mt-0.5 font-mono",Yd(e.peak.riskLevel)),children:a}),n.jsx(Jd,{label:"Log",logId:e.peak.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&n.jsx(s,{className:O("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),oE(t)]}),n.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),n.jsxs("div",{className:"min-w-0 space-y-1.5",children:[n.jsx(nT,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&n.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.windowUsedTokens)," used"]}),o!==null&&n.jsx("span",{className:"truncate",children:o})]})]})]})}function EE({summary:e}){return e.models.length===0?null:n.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),n.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),n.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>n.jsx(TE,{summary:t},t.model))})]})}function RE(e){const t=e.models.filter(o=>o.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const s=e.models.filter(o=>o.latest.health.level==="optimizable").length;return s>0?`${s} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function ME({label:e,logs:t,totalIn:s,totalOut:o,timeDisplayFormat:r,contextSummary:a,showBackLink:i}){const[c,d]=l.useState(!1),[m,u]=l.useState(!1),p=l.useMemo(()=>ZT(t,r),[t,r]),f=l.useMemo(()=>XT(t),[t]),h=l.useMemo(()=>RE(a),[a]),g=l.useCallback(()=>{Nt(window.location.href).then(b=>{b&&(d(!0),setTimeout(()=>d(!1),2e3))})},[]);return n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i&&n.jsx("a",{href:Pi("/"),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:n.jsx(m0,{className:"size-3.5"})}),n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:An(e)}),f!==null&&n.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:f,children:f})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),p!==null&&n.jsx("span",{children:p}),(s>0||o>0)&&n.jsxs("span",{className:"font-mono",children:[Ee(s)," in / ",Ee(o)," out"]})]})]}),a.models.length>0&&n.jsxs("button",{type:"button",onClick:()=>u(b=>!b),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":m,title:m?"Hide context details":"Show context details",children:[n.jsx("span",{children:h}),m?n.jsx(Ki,{className:"size-3.5"}):n.jsx(We,{className:"size-3.5"})]}),n.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":c?"Copied session link":"Copy session link",title:c?"Copied session link":"Copy session link",children:c?n.jsx(Pe,{className:"size-3.5"}):n.jsx(Et,{className:"size-3.5"})})]}),m&&n.jsx(EE,{summary:a})]})}function AE({logs:e,sessions:t,selectedSession:s,selectedModel:o,onSessionChange:r,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:m,onImportLogs:u,viewMode:p,captureMode:f,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:b,isLoading:y=!1,liveConnection:w,onRetryLiveConnection:v,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:R=[],hideSessionFilter:P=!1,pinnedSessionId:L}){const{totalIn:M,totalOut:k}=l.useMemo(()=>Vd(e),[e]),{providers:A}=nl(),{uiScalePreference:D,resolvedUiScale:F,setUiScalePreference:Y}=Rb(),[X,$]=l.useState(null),[V,J]=l.useState(null),[U,K]=l.useState(!1),[ae,be]=l.useState(!1),[ve,ie]=l.useState(null),[z,Z]=l.useState(null),[we,Ne]=l.useState(!1),[pe,re]=l.useState(!1),[le,Re]=l.useState(!0),[he,ze]=l.useState(as),[rt,$e]=l.useState(!1),[Ge,Ke]=l.useState(!1),[Ue,Ye]=l.useState(!0),[Qe,et]=l.useState(!1),[H,te]=l.useState(null),[fe,me]=l.useState(null),je=l.useRef(null),Me=l.useRef(null),Ie=l.useRef(null),T=l.useRef(null),I=l.useRef(0),q=l.useRef(null);J_(je,Me,{pageWide:!0});const[ne,xe]=l.useState(null);l.useEffect(()=>Xi(xe),[]);const ce=l.useCallback(()=>{I.current+=1,T.current?.abort(),T.current=null,$(null),J(null)},[]);l.useEffect(()=>()=>{I.current+=1,T.current?.abort(),T.current=null},[]),l.useEffect(()=>{Re(NE()),ze(CE()),Ke(!0)},[]),l.useEffect(()=>{Ge&&window.localStorage.setItem(Eh,le?"1":"0")},[le,Ge]),l.useEffect(()=>{if(Ge)try{window.localStorage.setItem(Rh,String(he))}catch{}},[Ge,he]),l.useEffect(()=>{Ye(kE()),et(!0)},[]),l.useEffect(()=>{if(Qe)try{window.localStorage.setItem(Mh,Ue?"1":"0")}catch{}},[Qe,Ue]),l.useEffect(()=>{if(L===void 0){document.title="Agent Inspector";return}const Se=e.length===1?"1 req":`${e.length} req`;document.title=`${An(L)} - ${Se} - Agent Inspector`},[e.length,L]);const Q=l.useCallback(async Se=>{T.current?.abort();const Be=new AbortController;T.current=Be;const wt=I.current+1;I.current=wt,$(Se),J(null);try{const Kt=await hb(e,Se,{signal:Be.signal});if(I.current!==wt)return;if(!Kt.ok){if(Kt.canceled===!0)return;m!==void 0?m({message:Kt.message,tone:"error"}):J(Kt.message)}}finally{I.current===wt&&(T.current=null,$(null))}},[e,m]),se=l.useCallback(Se=>{if(qC(Se)){K(!0);return}Q(Se)},[Q]),Ae=l.useCallback(()=>{K(!1),Q("redacted")},[Q]),qe=l.useCallback(()=>{K(!1),Q("raw")},[Q]),Kr=l.useCallback(()=>{Ie.current?.click()},[]),io=l.useCallback(Se=>{const Be=Se.currentTarget.files?.[0];Se.currentTarget.value="",!(Be===void 0||u===void 0)&&(be(!0),Z(null),ie(null),u(Be).then(wt=>{const Kt=wt.skipped>0?`, skipped ${String(wt.skipped)}`:"",Yl=`Imported ${String(wt.imported)} logs as ${wt.sessionId}${Kt}.`;m!==void 0?m({message:Yl,tone:"success"}):ie(Yl)}).catch(wt=>{const Kt=wt instanceof Error?wt.message:"Failed to import logs";m!==void 0?m({message:Kt,tone:"error"}):Z(Kt)}).finally(()=>{be(!1)}))},[u,m]);l.useEffect(()=>{ce(),me(null),te(null)},[ce,s,o]);const Yr=l.useCallback(()=>{ce(),ie(null),Z(null),me(null),a()},[ce,a]),Jr=l.useCallback(()=>{Ne(!0)},[]),Mt=l.useCallback(()=>{ce(),ie(null),Z(null),me(null),i!==void 0&&(re(!0),i().then(()=>{Ne(!1)}).catch(Se=>{const Be=Se instanceof Error?Se.message:"Failed to delete stored logs";m!==void 0?m({message:Be,tone:"error"}):Z(Be)}).finally(()=>{re(!1)}))},[ce,i,m]),nn=l.useCallback(()=>{c!==void 0&&(ce(),ie(null),Z(null),me(null),c())},[ce,c]),Xr=l.useCallback(()=>{me(null)},[]),qn=l.useCallback(()=>{Re(Se=>!Se)},[]),Zr=l.useCallback(Se=>{q.current={startX:Se.clientX,startWidth:he,pointerId:Se.pointerId},Se.currentTarget.setPointerCapture(Se.pointerId),$e(!0)},[he]),_e=l.useCallback(Se=>{const Be=q.current;Be===null||Be.pointerId!==Se.pointerId||ze(Ah(Be.startWidth+Be.startX-Se.clientX))},[]),xt=l.useCallback(Se=>{const Be=q.current;Be===null||Be.pointerId!==Se.pointerId||(Se.currentTarget.hasPointerCapture(Se.pointerId)&&Se.currentTarget.releasePointerCapture(Se.pointerId),q.current=null,$e(!1))},[]),Je=l.useCallback(()=>{ze(as)},[]),Cs=l.useCallback(()=>{Ye(Se=>!Se)},[]),tt=l.useMemo(()=>H===null?null:new Set(H.logIds),[H]),yt=l.useMemo(()=>tt===null?e:e.filter(Se=>tt.has(Se.id)),[tt,e]),At=l.useMemo(()=>R5(yt),[yt]),ql=l.useMemo(()=>JT(At),[At]),Cn=l.useMemo(()=>nk({pinnedSessionId:L,selectedSession:s,sessions:t,logs:e}),[e,L,s,t]),Hn=Cn?.logs??[],ks=Cn!==null&&Hn.length>0,{totalIn:Hl,totalOut:Vl}=l.useMemo(()=>Vd(Hn),[Hn]),Ph=l.useMemo(()=>YT(Hn,A),[Hn,A]),Lh=l.useMemo(()=>w_(At),[At]),Qr=l.useMemo(()=>YN(At),[At]),Wl=HC(f,e.length),Oh=L!==void 0,Dh=e.length>0,zh=i!==void 0&&(e.length>0||s!=="__all__"),$h=s==="__all__"?"all sessions":"this session",Fh=s==="__all__"?"Deletes every stored log, streaming chunk, and session archive entry across all sessions.":"Deletes every stored log, streaming chunk, and session archive entry for this session, including history that is not currently loaded.",Bh=e.length===0?"Load":"Reload",ea=ks&&Cn!==null?An(Cn.label):s==="__all__"?"All sessions":An(s),Gl=T_(w),ta=E_(Gl),Uh=l.useMemo(()=>tk({logs:yt,conversationGroups:At,isLoading:y,timeDisplayFormat:b,slowResponseThresholdSeconds:g}),[yt,At,y,g,b]),qh=l.useCallback(Se=>{const Be=Qr.get(Se.id);Be!==void 0&&me([Be,Se])},[Qr]),Kl=L!==void 0?L:s==="__all__"?null:s;return n.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[n.jsx(C_,{liveConnection:w,alertsAction:n.jsx(Ak,{}),settingsAction:n.jsx(b4,{})}),n.jsxs("button",{type:"button",onClick:qn,className:O("group fixed top-1/2 right-3 z-50 inline-flex h-14 w-8 -translate-y-1/2 items-center justify-center rounded-l-md border border-border/70 bg-background/90 text-muted-foreground shadow-lg backdrop-blur transition-colors motion-reduce:transition-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"),"aria-label":le?"Show details panel":"Hide details panel",title:le?"Show details panel":"Hide details panel",children:[n.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),le?n.jsx(a1,{className:"size-3.5"}):n.jsx(o1,{className:"size-3.5"})]}),Qe&&Ue&&n.jsx(Vo,{feature:"Inspector Pet",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(SS,{logs:e})})}),n.jsxs("div",{className:O("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",rt&&"cursor-col-resize select-none"),children:[!le&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:qn,"aria-label":"Close details panel"}),n.jsxs("aside",{className:"inspector-scrollbar fixed inset-x-3 bottom-3 top-24 z-40 order-1 overflow-y-auto rounded-lg border border-border bg-background/98 shadow-2xl max-lg:!w-auto lg:relative lg:inset-auto lg:order-2 lg:h-full lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:shadow-none",style:{width:he},children:[n.jsx("button",{type:"button",className:"absolute bottom-0 left-0 top-0 z-30 hidden w-2 -translate-x-1/2 cursor-col-resize touch-none items-center justify-center lg:flex",onPointerDown:Zr,onPointerMove:_e,onPointerUp:xt,onPointerCancel:xt,onDoubleClick:Je,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:n.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),n.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[n.jsxs("div",{className:"sticky top-0 z-20 -mx-4 -mt-4 grid gap-2 border-b border-border/60 bg-background/95 px-4 pb-3 pt-4 backdrop-blur",children:[n.jsx(Ga,{label:"View",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx(vE,{}),n.jsx(wE,{preference:D,resolvedScale:F,onChange:Y})]})}),n.jsx(Ga,{label:"Workspace",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(Qk,{labelledTrigger:!0}),n.jsx(n_,{currentSessionId:Kl,logCount:e.length,labelledTrigger:!0})]})})]}),n.jsxs(Ga,{label:"Current scope",children:[n.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[n.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:ea,children:ea}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:Oh?"Pinned session":"Live Inspector data"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(Lo,{label:H===null?"Requests":"Results",value:yt.length}),n.jsx(Lo,{label:"Sessions",value:t.length}),n.jsx(Lo,{label:"Input",value:Ee(ks?Hl:M)}),n.jsx(Lo,{label:"Output",value:Ee(ks?Vl:k)})]}),N!==void 0&&n.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:n.jsx(qo,{progress:N})})]}),ks&&Cn!==null&&n.jsx(ME,{label:Cn.label,logs:Hn,totalIn:Hl,totalOut:Vl,timeDisplayFormat:b,contextSummary:Ph,showBackLink:Cn.showBackLink}),ks&&L!==void 0&&R.length>0&&n.jsx(Wd,{memberships:R}),n.jsx("div",{className:"flex-1"}),n.jsx(y_,{currentSessionId:Kl,logCount:e.length,onResultChange:te})]})]})]}),n.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[n.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),n.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:ea})]}),n.jsx(yE,{visible:Ue,onToggle:Cs}),u!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:Ie,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:io}),n.jsx("button",{type:"button",onClick:Kr,disabled:ae,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:ae?n.jsx("span",{children:"Importing..."}):n.jsxs(n.Fragment,{children:[n.jsx(Du,{className:"size-3.5"}),n.jsx("span",{children:"Import"})]})})]}),Wl.redacted&&n.jsx("button",{type:"button",onClick:()=>{se("redacted")},disabled:X!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:X==="redacted"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(Xs,{className:"size-3.5"}),n.jsx("span",{children:"Export"})]})}),Wl.raw&&n.jsx("button",{type:"button",onClick:()=>{se("raw")},disabled:X!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:X==="raw"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(fg,{className:"size-3.5"}),n.jsx("span",{children:"Raw"})]})}),c!==void 0&&n.jsxs("button",{type:"button",onClick:nn,disabled:y,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[n.jsx(Ct,{className:O("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),n.jsx("span",{children:Bh})]}),n.jsxs("button",{type:"button",onClick:Yr,disabled:!Dh,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[n.jsx(gn,{className:"size-3.5"}),n.jsx("span",{children:"Clear"})]}),i!==void 0&&n.jsxs("button",{type:"button",onClick:Jr,disabled:!zh||pe,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[n.jsx(gn,{className:"size-3.5"}),n.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&n.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:n.jsx(qo,{progress:N})}),C!==void 0&&n.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&n.jsxs("button",{type:"button",onClick:nn,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[n.jsx(Ct,{className:"size-3"}),"Retry"]})]}),H!==null&&n.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-md bg-cyan-400/[0.07] px-3 py-2 shadow-[inset_2px_0_0_rgba(103,232,249,0.35),inset_0_0_0_1px_rgba(103,232,249,0.08)]",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:H.question}),n.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(yt.length)," loaded logs from"," ",String(H.logIds.length)," linked results"]})]}),n.jsxs("button",{type:"button",onClick:()=>te(null),className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-black/20 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-black/30 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[n.jsx(Qs,{className:"size-3"}),"All logs"]})]}),H===null&&n.jsx(Gd,{logs:e,pagination:S,embedded:!0}),m===void 0&&V!==null&&n.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:V}),m===void 0&&z!==null&&n.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:z}),m===void 0&&ve!==null&&z===null&&n.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:ve}),w!==void 0&&w.status!=="live"&&v!==void 0&&j!==void 0&&n.jsx(S_,{state:w,hasLogs:e.length>0,onRetry:v,onStop:j})]}),n.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[n.jsx(sE,{stats:Uh}),H!==null&&yt.length===0?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.jsxs("div",{className:"mx-auto max-w-xl rounded-[8px] bg-white/[0.035] px-5 py-8 shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)]",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),n.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:"Assistant found evidence, but none of its linked log IDs are in the current loaded window. Open an evidence card in Assistant or restore the full log view."}),n.jsx("button",{type:"button",onClick:()=>te(null),className:"mt-4 inline-flex h-8 items-center rounded-md bg-cyan-400/10 px-3 text-xs text-cyan-100 transition-colors hover:bg-cyan-400/16",children:"Show all logs"})]})}):e.length===0?s!=="__all__"?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[n.jsx("p",{className:"text-sm font-medium",children:y?"Loading session data...":C===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),n.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:An(s)}),N!==void 0&&n.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:n.jsx(qo,{progress:N})}),R.length>0&&n.jsx("div",{className:"text-left",children:n.jsx(Wd,{memberships:R})}),!y&&n.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[n.jsx("p",{children:"Stored logs may still be available."}),n.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&n.jsxs("button",{type:"button",onClick:nn,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[n.jsx(Ct,{className:"size-3.5"}),n.jsx("span",{children:"Load session"})]}),P?n.jsx("a",{href:Pi("/"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):n.jsx("button",{type:"button",onClick:()=>r("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[n.jsx("p",{className:"text-sm font-medium",children:ta.title}),n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:ta.description}),Gl==="empty"&&t.length>0&&n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),ta.showConnectionCommands&&ne!==null&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col items-center gap-2",children:BC(ne).map(Se=>n.jsx(bE,{command:Se},Se))}),n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):n.jsxs("div",{ref:Me,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[n.jsx("div",{ref:je,children:n.jsx(F_,{groups:At,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:Lh,onCompareWithPrevious:qh,comparisonPredecessors:Qr,onClearGroup:d,defaultExpanded:At.length===1,timeDisplayFormat:b})}),H===null&&n.jsx("div",{className:"mt-3",children:n.jsx(Gd,{logs:e,pagination:S})})]})]})]})]}),n.jsx(Ft,{open:U,onOpenChange:K,children:n.jsx(Bt,{className:q_,children:n.jsx(V_,{onCancel:()=>K(!1),onExportRedacted:Ae,onConfirmRaw:qe})})}),n.jsx(Ft,{open:we,onOpenChange:Ne,children:n.jsxs(Bt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[n.jsxs(Wt,{children:[n.jsxs(Gt,{children:["Delete ",$h," history?"]}),n.jsx(oo,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),n.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[n.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),n.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:Fh})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:pe,onClick:()=>Ne(!1),children:"Cancel"}),n.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:pe,onClick:Mt,children:pe?"Deleting...":"Delete history"})]})]})}),fe!==null&&n.jsx(Vo,{feature:"Compare",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(jS,{left:fe[0],right:fe[1],leftDisplayNumber:Hd(fe[0],ql),rightDisplayNumber:Hd(fe[1],ql),onClose:Xr})})})]})}function IE(e,t,s){return t==="__all__"&&s==="__all__"?e:e.filter(o=>!(t!=="__all__"&&o.sessionId!==t||s!=="__all__"&&o.model!==s))}function PE(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of t)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Xd(e,t){return t.retainIds?.has(e.id)===!0||t.retainSessionId!==void 0&&e.sessionId===t.retainSessionId}function Zd(e,t){const s=e.reduce((a,i)=>a+(Xd(i,t)?0:1),0);if(s<=t.recentLimit)return e;let o=s-t.recentLimit;const r=[];for(const a of e){if(o>0&&!Xd(a,t)){o-=1;continue}r.push(a)}return r}function Mn(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s)}return t}function Ka(e,t,s,o){if(s.length===0){const m=Zd([...e],o);return{logs:m,index:Mn(m)}}const r=[...e];let a=r.length===0?Number.NEGATIVE_INFINITY:r.at(-1)?.id??0,i=!0;for(const m of s){const u=t.get(m.id);if(u!==void 0&&u>=0&&u<r.length){r[u]=m;continue}r.push(m),m.id<a&&(i=!1),a=Math.max(a,m.id)}const c=i?r:r.toSorted((m,u)=>m.id-u.id),d=Zd(c,o);return{logs:d,index:Mn(d)}}function En(e,t){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of t)o!==""&&s.add(o);return[...s].sort()}function LE(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const s=Xh();return s.ok?Zh(s.runtime,`/api/logs/stream?${t.toString()}`):null}function OE(e){const t=LE(e);return t===null?null:new EventSource(t)}const DE=Ut([_({type:oe("init"),logs:W(Fs)}),_({type:oe("update"),log:Fs})]),zE=_({logs:W(Fs),total:E().int().nonnegative(),limit:E().int().positive(),hasOlder:ke(),hasNewer:ke(),oldestLogId:E().int().positive().nullable(),newestLogId:E().int().positive().nullable()}),$E=W(x()),Qd=_({success:ke(),cleared:E().int().nonnegative(),logFilesRewritten:E().int().nonnegative().optional(),chunkFilesDeleted:E().int().nonnegative(),sessionArchiveLogsDeleted:E().int().nonnegative().optional()});function FE(e,t){const s=[];for(const o of e)for(const r of o.members)r.sessionId===t&&s.push({groupId:o.id,groupTitle:o.title,groupKind:o.kind,groupStatus:o.status,groupTask:o.task,groupProject:o.project,groupEvidence:o.evidence,member:r});return s}function Oo(e){const t=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&t.add(s.sessionId);return[...t]}function BE(e){const t=new Set;for(const s of e)s.model!==null&&s.model!==""&&t.add(s.model);return[...t]}const UE=100,qE=12,HE=1800,Ul=100,br=500,Ih=200,Ai=2e4,VE=1e4,WE=3e3,GE=1e4,KE=2e3;function YE(e,t,s=Ul){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(t.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(t.beforeLogId));break;case"newer":o.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${o.toString()}`}function $s(e,t,s=Ul){return Le(YE(e,t,s),zE,Ai)}async function JE(e,t){const s=new Set;let o=await $s(e,{kind:"oldest"},br);for(const a of o.logs)s.add(a.id);t(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<Ih;){o=await $s(e,{kind:"newer",afterLogId:o.newestLogId},br);for(const a of o.logs)s.add(a.id);r+=1,t(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function XE(){try{return{deleted:(await Ze("/api/groups",vu,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function tR({initialSessionId:e}={}){const[t,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:p}=Wf(),[f,h]=l.useState(__),[g,b]=l.useState(null),[y,w]=l.useState(e!==void 0),[v,j]=l.useState(null),[S,N]=l.useState(void 0),[C,R]=l.useState([]),[,P]=l.useTransition(),L=l.useRef(null),M=l.useRef(null),k=l.useRef(null),A=l.useRef(!0),D=l.useRef(null),F=l.useRef(0),Y=l.useRef(null),X=l.useRef(null),$=l.useRef(new Map),V=l.useRef([]),J=l.useRef(null),U=l.useCallback(()=>({recentLimit:KE,retainSessionId:e??(o==="__all__"?void 0:o)}),[e,o]),K=l.useCallback(T=>{u({message:T,tone:"error"})},[u]),ae=l.useCallback(()=>{X.current!==null&&(clearInterval(X.current),X.current=null),Y.current=null,N(void 0)},[]),be=l.useCallback((T,I,q=0,ne=0)=>{X.current!==null&&clearInterval(X.current);const xe=Date.now();Y.current=xe;const ce=()=>{F.current===I&&N({label:T,elapsedMs:Date.now()-xe,timeoutMs:Ai,loadedLogs:q,loadedPages:ne})};ce(),X.current=setInterval(ce,250)},[]),ve=l.useCallback((T,I,q,ne)=>{const xe=Y.current;xe===null||F.current!==I||N({label:T,elapsedMs:Date.now()-xe,timeoutMs:Ai,loadedLogs:q,loadedPages:ne})},[]),ie=l.useMemo(()=>IE(t,o,a),[t,o,a]),z=l.useMemo(()=>En(c,Oo(t)),[t,c]),Z=l.useMemo(()=>BE(t),[t]),we=l.useCallback(()=>{Ze("/api/sessions",$E).then(T=>{d(I=>En(I,T))}).catch(()=>{})},[]),Ne=l.useCallback(()=>{J.current=null;const T=V.current;V.current=[],T.length!==0&&P(()=>{s(I=>{const q=Ka(I,$.current,T,U());return $.current=q.index,q.logs})})},[U,P]),pe=l.useCallback(T=>{V.current.push(T),J.current===null&&(J.current=setTimeout(Ne,UE))},[Ne]),re=l.useCallback(()=>{L.current&&L.current.close(),M.current!==null&&(clearTimeout(M.current),M.current=null),h(I=>It(I,{type:"connect-requested"}));const T=OE(e);if(T===null){h(I=>It(I,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),K("Failed to resolve the live stream endpoint");return}L.current=T,T.onmessage=I=>{try{const q=String(I.data),ne=JSON.parse(q),xe=DE.safeParse(ne);if(!xe.success){h(Q=>It(Q,{type:"recoverable-error",message:"The live stream returned invalid data."})),K("Failed to parse SSE data");return}const ce=xe.data;ce.type==="init"?(J.current!==null&&(clearTimeout(J.current),J.current=null),V.current=[],s(Q=>{const se=Ka(Q,$.current,ce.logs,U());return $.current=se.index,se.logs}),d(Q=>En(Q,Oo(ce.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>It(Q,{type:"message-received",at:Date.now()})),p()):ce.type==="update"&&(d(Q=>ce.log.sessionId===null||ce.log.sessionId===""?Q:En(Q,[ce.log.sessionId])),pe(ce.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>It(Q,{type:"message-received",at:Date.now()})))}catch{h(q=>It(q,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),K("Failed to parse SSE data")}},T.onerror=()=>{const I=navigator.onLine;h(q=>It(q,{type:"connection-lost",online:I,message:"The live stream disconnected."})),T.close(),!(!I||!A.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(q=>It(q,{type:"stale-timeout"}))},GE)),M.current=setTimeout(re,WE))}},[p,e,pe,K]),le=l.useCallback(()=>{A.current=!0,M.current!==null&&(clearTimeout(M.current),M.current=null),re()},[re]),Re=l.useCallback(()=>{A.current=!1,L.current?.close(),L.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(T=>It(T,{type:"stop-retrying"}))},[]),he=l.useCallback(T=>{if(e===void 0)return;const I=F.current+1;F.current=I,w(!0),j(null),be("Loading session logs",I),p(),$s(e,T).then(q=>{if(F.current!==I)return;const ne=q.logs;$.current=Mn(ne),s(ne),b(q),r(e),w(!1),j(null),ae(),p()}).catch(q=>{if(F.current!==I)return;w(!1),ae();const ne=q instanceof Error?q.message:"Failed to load session logs";j(ne),K(ne)})},[p,e,K,be,ae]),ze=l.useCallback(T=>{const I=F.current+1;F.current=I,w(!0),j(null),be("Reloading full session",I),p(),(async()=>{const q=[];let ne=await $s(T,{kind:"oldest"},br);q.push(...ne.logs),ve("Reloading full session",I,q.length,1);let xe=1;for(;ne.hasNewer&&ne.newestLogId!==null&&xe<Ih;)ne=await $s(T,{kind:"newer",afterLogId:ne.newestLogId},br),q.push(...ne.logs),xe+=1,ve("Reloading full session",I,q.length,xe);F.current===I&&(s(ce=>{const Q=Ka(ce,$.current,q,U());return $.current=Q.index,Q.logs}),d(ce=>En(ce,[T])),w(!1),j(null),ae(),ne.hasNewer?u({message:`Loaded ${String(q.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(q=>{if(F.current!==I)return;w(!1),ae();const ne=q instanceof Error?q.message:"Failed to reload session logs";j(ne),K(ne)})},[p,K,u,be,ae,ve]);l.useEffect(()=>{if(e===void 0){R([]);return}let T=!1;return Le("/api/groups",ju,VE).then(I=>I.groups).then(I=>{T||I===null||R(FE(I,e))}).catch(()=>{T||R([])}),()=>{T=!0}},[e]),l.useEffect(()=>{we()},[we]),l.useEffect(()=>()=>{ae()},[ae]),l.useEffect(()=>{e!==void 0&&he({kind:"newest"})},[e,he]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&ze(o)},[e,ze,o]),l.useEffect(()=>{if(e!==void 0)return;re();const T=()=>{L.current?.close(),L.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(q=>It(q,{type:"browser-offline"}))},I=()=>{A.current&&re()};return window.addEventListener("offline",T),window.addEventListener("online",I),()=>{window.removeEventListener("offline",T),window.removeEventListener("online",I),L.current&&(L.current.close(),L.current=null),M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),J.current!==null&&(clearTimeout(J.current),J.current=null)}},[re,e]),l.useEffect(()=>{const T=window.location.hash;if(!T.startsWith("#log-")||D.current===T)return;const I=T.slice(1),q=Number(I.replace(/^log-/,""));Number.isInteger(q)&&q>0&&vs({logId:q,tab:"request"});let ne=!1,xe=0,ce=null,Q=null;const se=()=>{if(ne)return;const Ae=document.getElementById(I);if(Ae!==null){D.current=T,Ae.scrollIntoView({block:"center",behavior:fh(hh())}),Ae instanceof HTMLElement&&(ce=Ae,Ae.setAttribute("data-deep-link-highlight","true"),Q=window.setTimeout(()=>{Ae.removeAttribute("data-deep-link-highlight")},HE),Ae.focus({preventScroll:!0}),Ae.getAttribute("data-nav-action")==="expand"&&Ae.click());return}xe+=1,xe<qE&&window.setTimeout(se,100)};return se(),()=>{ne=!0,Q!==null&&window.clearTimeout(Q),ce!==null&&ce.removeAttribute("data-deep-link-highlight")}},[ie.length]);const rt=l.useCallback(()=>{const T=Oo(t);ae(),w(!1),$.current.clear(),s([]),b(null),d(I=>En(I,T)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,u,ae]),$e=l.useCallback(T=>{if(T.length===0)return;const I=new Set(T);s(q=>{const ne=q.filter(ce=>I.has(ce.id)),xe=q.filter(ce=>!I.has(ce.id));return d(ce=>En(ce,Oo(ne))),$.current=Mn(xe),xe}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),Ge=l.useCallback(async()=>{const T=F.current+1;F.current=T,w(!0),ae(),p();try{if(o==="__all__"){be("Deleting stored history",T);const Q=await Ze("/api/logs",Qd,{method:"DELETE"}),se=await XE();if(F.current!==T)return;s([]),$.current.clear(),b(null),d([]),R([]),w(!1),ae();const Ae=se.ok?` Cleared ${se.deleted.toString()} group${se.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${Q.cleared.toString()} stored log${Q.cleared===1?"":"s"} across all sessions.${Ae}`,tone:se.ok?"success":"error"});return}const I=o;be("Deleting session history",T);const q=await JE(I,(Q,se)=>{ve("Deleting session history",T,Q,se)}),ne=new Set(q.ids);for(const Q of t)Q.sessionId===I&&ne.add(Q.id);const xe=[...ne].filter(Q=>Number.isInteger(Q)&&Q>=0);if(xe.length===0){if(F.current!==T)return;s(Q=>{const se=Q.filter(Ae=>Ae.sessionId!==I);return $.current=Mn(se),se}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(se=>se.sessionId!==I)}),d(Q=>Q.filter(se=>se!==I)),w(!1),ae(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ce=await Ze("/api/logs",Qd,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:xe})});if(F.current!==T)return;s(Q=>{const se=Q.filter(Ae=>Ae.sessionId!==I);return $.current=Mn(se),se}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(se=>se.sessionId!==I)}),d(Q=>Q.filter(se=>se!==I)),w(!1),ae(),u({message:`Deleted ${ce.cleared.toString()} stored log${ce.cleared===1?"":"s"} for this session${q.truncated?". More history may remain.":"."}`,tone:q.truncated?"error":"success"})}finally{F.current===T&&(w(!1),ae())}},[t,p,o,u,be,ae,ve]),Ke=l.useCallback(()=>{if(e!==void 0){he({kind:"newest"});return}if(o==="__all__"){we();return}ze(o)},[e,he,we,ze,o]),Ue=l.useCallback(async T=>{const I=new FormData;I.set("file",T);const q=await Ze("/api/logs/import",Yx,{method:"POST",body:I});return s(ne=>{const xe=new Set(q.logs.map(Q=>Q.id)),ce=PE(ne.filter(Q=>!xe.has(Q.id)),q.logs);return $.current=Mn(ce),ce}),r(q.sessionId),i("__all__"),b(null),p(),q},[p]),{strip:Ye,captureMode:Qe,slowResponseThresholdSeconds:et,timeDisplayFormat:H}=Wi(),te=Qe,fe=l.useCallback(()=>{he({kind:"oldest"})},[he]),me=l.useCallback(()=>{he({kind:"newest"})},[he]),je=l.useCallback(()=>{const T=t[0],I=g?.oldestLogId??T?.id??null;I!==null&&he({kind:"older",beforeLogId:I})},[t,he,g]),Me=l.useCallback(()=>{const T=t[t.length-1],I=g?.newestLogId??T?.id??null;I!==null&&he({kind:"newer",afterLogId:I})},[t,he,g]),Ie=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??Ul,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:fe,onOlder:je,onNewer:Me,onNewest:me}},[e,me,Me,je,fe,g,S,y]);return n.jsxs(n.Fragment,{children:[n.jsx(Gf,{notice:m,onDismiss:p}),n.jsx(Z1,{}),n.jsx(AE,{logs:ie,sessions:z,models:Z,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:rt,onDeleteCurrentView:Ge,onReloadSession:e!==void 0||o!=="__all__"?Ke:void 0,onClearGroup:$e,onNotify:u,onImportLogs:e===void 0?Ue:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||y,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:le,onStopLiveConnection:Re,pagination:Ie,sessionLoadProgress:S,sessionLoadError:v??void 0,sessionMemberships:C,viewMode:te,captureMode:Qe,strip:Ye,slowResponseThresholdSeconds:et,timeDisplayFormat:H,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{fn as $,X_ as A,Ce as B,ng as C,Ft as D,eR as E,We as F,ge as G,cN as H,Pg as I,QE as J,Cu as K,TS as L,Au as M,dN as N,uN as O,tR as P,Fn as Q,h1 as R,nT as S,_f as T,vi as U,lr as V,m_ as W,Qs as X,V0 as Y,Bs as Z,G as _,E5 as a,Oe as a0,ru as a1,yS as a2,A0 as a3,Ql as b,B as c,Iu as d,ft as e,Pe as f,gf as g,Et as h,Bt as i,Wt as j,Gt as k,Lu as l,Tf as m,Yt as n,at as o,qg as p,Ns as q,ir as r,it as s,lt as t,nl as u,ct as v,vs as w,Fs as x,$T as y,Z_ as z};