@tonyclaw/agent-inspector 4.0.21 → 4.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/backend/nitro.json +1 -1
- package/.output/cli.js +1 -1
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-HTKEFlBr.mjs → router-B5uygwx6.mjs} +52 -52
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-CGtGLpRr.js → CompareDrawer-2xeE_Q1P.js} +1 -1
- package/.output/ui/assets/{InspectorPet-C7EyBke0.js → InspectorPet-AvhMmdDB.js} +1 -1
- package/.output/ui/assets/ProxyViewerContainer-D_Dp0lk0.js +60 -0
- package/.output/ui/assets/{ReplayDialog-D-HJ-GY-.js → ReplayDialog-7bUrau-W.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-CS3IEG8L.js → RequestAnatomy-CB2DHVi8.js} +1 -1
- package/.output/ui/assets/{ResponseView-BU2uDaMH.js → ResponseView-Ce4vSp-V.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DT7vuTnV.js → StreamingChunkSequence-B4NyOyI1.js} +1 -1
- package/.output/ui/assets/{_sessionId-LpWM6fUR.js → _sessionId-BW0J28Z5.js} +1 -1
- package/.output/ui/assets/{_sessionId-DVNVVqtQ.js → _sessionId-JP_5y9rG.js} +1 -1
- package/.output/ui/assets/{index-BX9hEtiY.js → index-8NhILpoH.js} +1 -1
- package/.output/ui/assets/{index-D0laIdpr.js → index-CHkBy24f.js} +2 -2
- package/.output/ui/assets/index-CcLX9JKu.css +1 -0
- package/.output/ui/assets/{index-qkfRlMvL.js → index-CsQEn5un.js} +1 -1
- package/.output/ui/assets/{index-CHGXicPQ.js → index-d2B_ndVR.js} +1 -1
- package/.output/ui/assets/{json-viewer-Be1ybyLo.js → json-viewer-D29qxkd8.js} +1 -1
- package/.output/ui/assets/{jszip.min-CNa5iyer.js → jszip.min-CjWc6qJe.js} +1 -1
- package/.output/ui/index.html +2 -2
- package/README.md +6 -0
- package/package.json +4 -4
- package/.output/ui/assets/ProxyViewerContainer-DyEPnEkM.js +0 -60
- package/.output/ui/assets/index-CIvE7pNX.css +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-CjWc6qJe.js","./index-CHkBy24f.js","./index-CcLX9JKu.css","./CompareDrawer-2xeE_Q1P.js","./InspectorPet-AvhMmdDB.js","./ReplayDialog-7bUrau-W.js","./ResponseView-Ce4vSp-V.js","./RequestAnatomy-CB2DHVi8.js","./StreamingChunkSequence-B4NyOyI1.js","./json-viewer-D29qxkd8.js","./index-d2B_ndVR.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as ox,u as Gt,s as x,n as _,b as Ce,_ as Qr,a as V,c as qe,o as T,d as pe,e as ae,f as Tn,g as Gs,h as qt,i as hu,k as Ke,r as l,j as t,m as Kt,p as vn,A as cc,q as ax,t as pa,v as Mo,w as Es,x as L,B as J,y as Un,z as xu,C as Ie,D as gu,E as bt,F as Ao,G as ix,H as Be,L as eo,I as bu,J as lx,K as to,M as vu,N as cx,O as Vi,P as dx,Q as Wi,T as ux,U as px}from"./index-CHkBy24f.js";const Xe=ox(()=>Gt([x(),_(),Ce(),Qr(),V(Xe),qe(x(),Xe)])),Lt=_().int().nonnegative().max(Number.MAX_SAFE_INTEGER),mx=pe(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),yu=T({index:_(),timestamp:_(),type:x(),data:Xe}),fx=T({id:x(),logId:Lt,index:_().int().nonnegative(),provider:pe(["anthropic","openai"]),name:x(),argumentsText:x().nullable(),argumentsPreview:x().nullable()}),hx=pe(["end_turn","tool_use","stop","length"]),xx=hx.nullable(),gx=T({chunks:V(yu),truncated:Ce().optional().default(!1)}),bx=pe(["request","response"]),wu=T({logId:Lt,part:bx,text:x(),offset:_().int().nonnegative(),limit:_().int().positive(),totalBytes:_().int().nonnegative(),textBytes:_().int().nonnegative(),nextOffset:_().int().nonnegative().nullable(),hasMore:Ce(),contentMode:pe(["empty","partial","full"])}),Xs=T({id:Lt,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:_().nullable(),responseText:x().nullable(),inputTokens:_().nullable(),outputTokens:_().nullable(),cacheCreationInputTokens:_().nullable(),cacheReadInputTokens:_().nullable(),elapsedMs:_().nullable(),firstChunkMs:_().nullable().optional(),totalStreamMs:_().nullable().optional(),tokensPerSecond:_().nullable().optional(),streaming:Ce(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:qe(x(),x()).optional(),headers:qe(x(),x()).optional(),apiFormat:pe(["anthropic","openai","unknown"]).default("unknown"),isTest:Ce().optional().default(!1),replayOfLogId:Lt.nullable().optional(),providerName:x().nullable().optional(),clientPort:_().nullable().optional(),clientPid:_().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:gx.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:_().int().nonnegative().nullable().optional(),responseTextBytes:_().int().nonnegative().nullable().optional(),bodyContentMode:pe(["full","compact","truncated"]).optional(),captureIncomplete:Ce().optional(),droppedChunks:_().int().nonnegative().optional(),droppedBytes:_().int().nonnegative().optional(),captureIncompleteReason:mx.nullable().optional(),warnings:V(x()).optional(),toolTraceEvents:V(fx).optional(),stopReason:xx.optional(),error:x().nullable().optional()}),Gi=T({type:x(),ttl:x().optional(),scope:x().optional()}),Ki=T({type:ae("text"),text:x(),cache_control:Gi.optional()}),ju=T({type:ae("thinking"),thinking:x(),signature:x().optional()}),vx=T({type:ae("think"),thinking:x(),signature:x().optional()}),yx=T({type:ae("base64"),media_type:x(),data:x()}),Su=T({type:ae("image"),source:yx}),Nu=T({type:ae("tool_use"),id:x(),name:x(),input:qe(x(),Xe)}),wx=Tn("type",[Ki,Su]),jx=T({type:ae("tool_result"),tool_use_id:x().optional(),content:Gt([x(),V(wx)]),is_error:Ce().optional()}),Sx=Tn("type",[Ki,ju,Su,Nu,jx]),Nx=Gt([x(),V(Sx)]),Cx=T({role:pe(["user","assistant"]),content:Nx}),kx=T({type:ae("text"),text:x(),cache_control:Gi.optional()}),Tx=T({type:x(),properties:qe(x(),qe(x(),Xe)).optional(),required:V(x()).optional(),additionalProperties:Ce().optional(),$schema:x().optional()}),_x=T({name:x(),description:x().optional(),input_schema:Tx.optional(),cache_control:Gi.optional()}),Ex=Tn("type",[T({type:ae("enabled"),budget_tokens:_()}),T({type:ae("disabled")}),T({type:ae("adaptive")})]),Rx=T({model:x(),messages:V(Cx),system:V(kx).optional(),tools:V(_x).optional(),max_tokens:_().optional(),temperature:_().optional(),stream:Ce().optional(),thinking:Ex.optional(),metadata:T({user_id:x().optional()}).optional()}),Yi=Tn("type",[Ki,ju,vx,Nu]),Mx=T({input_tokens:_().nullable().optional(),output_tokens:_().nullable().optional(),cache_creation_input_tokens:_().nullable().optional(),cache_read_input_tokens:_().nullable().optional()}).passthrough(),Ax=T({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V(Yi),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:Mx}).passthrough(),Ix=T({type:ae("message_start"),message:T({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V(Yi),stop_reason:Qr(),stop_sequence:Qr(),usage:T({input_tokens:_(),cache_creation_input_tokens:_().optional(),cache_read_input_tokens:_().optional()}).passthrough()})}),Px=T({type:ae("content_block_start"),index:_(),content_block:Yi}),Lx=Tn("type",[T({type:ae("text_delta"),text:x()}),T({type:ae("input_json_delta"),partial_json:x()}),T({type:ae("thinking_delta"),thinking:x()}),T({type:ae("signature_delta"),signature:x()})]),Ox=T({type:ae("content_block_delta"),index:_(),delta:Lx}),zx=T({type:ae("content_block_stop"),index:_()}),Dx=T({type:ae("message_delta"),delta:T({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:T({output_tokens:_(),input_tokens:_().optional(),cache_creation_input_tokens:_().optional(),cache_read_input_tokens:_().optional()}).passthrough()}),$x=T({type:ae("message_stop")}),Fx=T({type:ae("ping")}),Bx=T({type:ae("error"),error:T({type:x(),message:x()})});Tn("type",[Ix,Px,Ox,zx,Dx,$x,Fx,Bx]);const Ux=Gt([x(),V(Tn("type",[T({type:ae("text"),text:x()}),T({type:ae("image_url"),image_url:T({url:x(),detail:x().optional()})})]))]),Cu=T({role:pe(["system","user","assistant","tool"]),content:Ux,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),qx=T({name:x(),arguments:x()}),ku=T({index:_().optional(),id:x().optional(),type:ae("function").optional(),function:T({name:x().optional(),arguments:x().optional()})});Cu.extend({content:Gt([x(),V(T({type:ae("text"),text:x()}))]).optional(),function_call:qx.optional(),tool_calls:V(ku).optional()});const Hx=T({type:ae("function"),function:T({name:x(),description:x().optional(),parameters:qe(x(),Xe)})}),Vx=T({model:x(),messages:V(Cu),temperature:_().optional(),max_tokens:_().optional(),stream:Ce().optional(),tools:V(Hx).optional(),tool_choice:Gt([pe(["auto","none","required"]),T({type:ae("auto")}),T({type:ae("none")}),T({type:ae("function"),function:T({name:x()})})]).optional(),user:x().optional()}),Wx=T({type:x(),name:x().optional(),description:x().optional(),parameters:Xe.optional(),function:T({name:x().optional(),description:x().optional(),parameters:Xe.optional()}).optional()}).passthrough(),Gx=T({model:x(),input:Gs().optional(),instructions:Gt([x(),Qr()]).optional(),stream:Ce().optional(),tools:V(Wx).optional(),tool_choice:Gs().optional(),max_output_tokens:_().optional(),temperature:_().optional(),user:x().optional(),metadata:qe(x(),Gs()).optional()}).passthrough(),Tu=T({role:pe(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:T({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:V(T({index:_(),id:x().optional(),type:ae("function").optional(),function:T({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),Kx=T({index:_(),message:T({role:pe(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:T({name:x(),arguments:x()}).nullable().optional(),tool_calls:V(ku).optional()}).optional(),delta:Tu.optional(),finish_reason:x().nullable()}),Yx=T({id:x(),object:ae("chat.completion"),created:_(),model:x(),choices:V(Kx),usage:T({prompt_tokens:_().nullable().optional(),completion_tokens:_().nullable().optional(),total_tokens:_().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();T({id:x(),object:ae("chat.completion.chunk"),created:_(),model:x(),choices:V(T({index:_(),delta:Tu,finish_reason:x().nullable().optional()})),usage:T({prompt_tokens:_().nullable().optional(),completion_tokens:_().nullable().optional(),total_tokens:_().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const Jx=T({input_tokens:_().nullable().optional(),output_tokens:_().nullable().optional(),total_tokens:_().nullable().optional(),input_tokens_details:T({cached_tokens:_().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:T({reasoning_tokens:_().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Xx=T({type:x()}).passthrough(),Zx=T({id:x(),object:ae("response").optional(),created_at:_().optional(),status:x().nullable().optional(),model:x().optional(),output:V(Xx).optional(),output_text:x().optional(),usage:Jx.nullable().optional(),error:Gs().optional()}).passthrough();T({type:x()}).passthrough();function Qx(e){try{const n=JSON.parse(e),s=Yx.safeParse(n);return s.success?s.data:null}catch{return null}}function eg(e){try{const n=JSON.parse(e),s=Zx.safeParse(n);return s.success?s.data:null}catch{return null}}const _u=T({input:_().int().nonnegative(),output:_().int().nonnegative(),cacheCreate:_().int().nonnegative(),cacheRead:_().int().nonnegative(),total:_().int().nonnegative()}),tg=T({id:Lt,sessionLogNumber:_().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:pe(["anthropic","openai","unknown"]),method:x(),path:x(),status:_().nullable(),isStreaming:Ce(),hasError:Ce(),error:x().nullable(),latencyMs:_().nullable(),firstChunkMs:_().nullable().optional(),totalStreamMs:_().nullable().optional(),tokensPerSecond:_().nullable().optional(),tokens:T({input:_().nullable(),output:_().nullable(),cacheCreate:_().nullable(),cacheRead:_().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:_().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Eu=T({id:x(),status:pe(["active","failed","completed","empty"]),logCoverage:pe(["recent","history"]),source:pe(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:pe(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:_().int().nonnegative(),activeRequests:_().int().nonnegative(),completedRequests:_().int().nonnegative(),failedRequests:_().int().nonnegative(),queuedTasks:_().int().nonnegative(),runningTasks:_().int().nonnegative(),lastTaskError:x().nullable(),logCount:_().int().nonnegative(),errorCount:_().int().nonnegative(),models:V(x()),providers:V(x()),tokenUsage:_u,lastLogId:Lt.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:_().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:_().int().positive(),latestLogs:V(tg)}),ar=pe(["created","running","completed","failed","cancelled"]),Ji=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),ng=pe(["run-created","session-started","request","session-finished","evidence-exported"]),sg=pe(["info","success","warning","error"]),rg=T({timestamp:x(),kind:ng,severity:sg,title:x(),details:x(),logId:Lt.nullable(),status:_().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:_().nullable(),isStreaming:Ce().nullable()}),og=pe(["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"]),Ru=T({outcome:pe(["success","failure","active","unknown"]),severity:pe(["none","low","medium","high"]),category:og,summary:x(),evidenceLogIds:V(Lt),hints:V(x())}),Xi=T({status:pe(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),Mu=Xi,Zi=T({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:ar,tags:V(x()),metadata:qe(x(),Xe),evidence:Ji.nullable(),createdAt:x(),updatedAt:x()});T({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:ar.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()}).optional();T({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:ar.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()});T({includeHistory:Ce().optional(),latestLogLimit:_().int().positive().max(50).optional()}).optional();T({run:Zi,evidence:Ji,session:Eu.nullable(),timeline:V(rg),classification:Ru,jenkinsReport:Xi});const ag=T({run:Zi,classification:Ru,evidence:Ji.nullable(),jenkinsReport:Xi.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});T({failures:V(ag),total:_().int().nonnegative(),limit:_().int().positive()});const Qi=pe(["created","running","completed","failed","cancelled"]),el=pe(["evaluation","batch","manual"]),tl=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Au=T({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:ar.nullable(),metadata:qe(x(),Xe),addedAt:x(),updatedAt:x()}),nl=T({id:x(),title:x(),kind:el,task:x().nullable(),project:x().nullable(),status:Qi,tags:V(x()),metadata:qe(x(),Xe),evidence:tl.nullable(),members:V(Au),createdAt:x(),updatedAt:x()});T({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:el.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Qi.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()}).optional();T({title:x().min(1).optional(),kind:el.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Qi.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()});T({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:ar.nullable().optional(),metadata:qe(x(),Xe).optional()});T({includeHistory:Ce().optional(),latestLogLimit:_().int().positive().max(50).optional()}).optional();T({deleteEvidence:Ce().optional()});const Iu=T({groupId:x(),deleted:Ce(),evidenceDeleted:Ce(),evidencePath:x().nullable()}),Pu=T({deleted:_().int().nonnegative(),groups:V(Iu)}),Lu=T({member:Au,run:Zi.nullable(),session:Eu.nullable()}),Ou=T({memberCount:_().int().nonnegative(),sessionsWithData:_().int().nonnegative(),missingSessions:_().int().nonnegative(),requestCount:_().int().nonnegative(),errorCount:_().int().nonnegative(),tokenUsage:_u,models:V(x()),providers:V(x()),completedMembers:_().int().nonnegative(),failedMembers:_().int().nonnegative(),runningMembers:_().int().nonnegative()}),ig=T({group:nl,evidence:tl,members:V(Lu).nullable(),markdown:x(),summary:Ou.nullable(),report:Mu.nullable()}),lg=T({group:nl,evidence:tl,members:V(Lu),summary:Ou,jenkinsReport:Mu}),zu=T({groups:V(nl)}),cg=T({sessionId:x(),imported:_().int().nonnegative(),skipped:_().int().nonnegative(),warnings:V(x()),logs:V(Xs)}),no=10,ai=600,so=60,ii=600,ro="time",sl="simple",Du=pe(["time","full"]),dg=pe(["simple","full"]),Io=T({stripClaudeCodeBillingHeader:Ce(),hasSeenOnboarding:Ce().default(!1),slowResponseThresholdSeconds:_().int().min(0).max(ai).default(no),providerTestTimeoutSeconds:_().int().min(1).max(ii).default(so),timeDisplayFormat:Du.default(ro),captureMode:dg.default(sl)}),cs="/api/config";async function ug(e){return Ke(e,Io,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function hr(e){return Ke(cs,Io,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function rl(){const e=qt(cs,ug,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=hu(),s=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??sl,o=e.data?.slowResponseThresholdSeconds??no,a=e.data?.providerTestTimeoutSeconds??so,i=e.data?.timeDisplayFormat??ro,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??no,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??so,timeDisplayFormat:e.data?.timeDisplayFormat??ro,captureMode:r,...f}),d=async f=>{await n(cs,hr({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await n(cs,hr({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await n(cs,hr({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await n(cs,hr({providerTestTimeoutSeconds:f}),{optimisticData:c({providerTestTimeoutSeconds:f}),rollbackOnError:!0,revalidate:!1})};return{strip:s,captureMode:r,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:a,timeDisplayFormat:i,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:d,setSlowResponseThresholdSeconds:p,setProviderTestTimeoutSeconds:m,setTimeDisplayFormat:u}}const $u=(...e)=>e.filter((n,s,r)=>!!n&&n.trim()!==""&&r.indexOf(n)===s).join(" ").trim();const pg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const mg=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,s,r)=>r?r.toUpperCase():s.toLowerCase());const dc=e=>{const n=mg(e);return n.charAt(0).toUpperCase()+n.slice(1)};var fg={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 hg=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const xg=l.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...fg,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:$u("lucide",o),...!a&&!hg(c)&&{"aria-hidden":"true"},...c},[...i.map(([p,u])=>l.createElement(p,u)),...Array.isArray(a)?a:[a]]));const B=(e,n)=>{const s=l.forwardRef(({className:r,...o},a)=>l.createElement(xg,{ref:a,iconNode:n,className:$u(`lucide-${pg(dc(e))}`,`lucide-${e}`,r),...o}));return s.displayName=dc(e),s};const gg=[["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"}]],bg=B("a-large-small",gg);const vg=[["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"}]],yg=B("activity",vg);const wg=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],jg=B("arrow-down-right",wg);const Sg=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ng=B("arrow-down",Sg);const Cg=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],kg=B("arrow-left",Cg);const Tg=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],_g=B("arrow-up-right",Tg);const Eg=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Rg=B("arrow-up",Eg);const Mg=[["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"}]],ol=B("beaker",Mg);const Ag=[["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"}]],Ig=B("bell",Ag);const Pg=[["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"}]],Lg=B("blocks",Pg);const Og=[["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"}]],zg=B("brain-circuit",Og);const Dg=[["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"}]],Fu=B("brain",Dg);const $g=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],De=B("check",$g);const Fg=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ze=B("chevron-down",Fg);const Bg=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bu=B("chevron-left",Bg);const Ug=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ct=B("chevron-right",Ug);const qg=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],al=B("chevron-up",qg);const Hg=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Vg=B("chevrons-down",Hg);const Wg=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Gg=B("chevrons-left",Wg);const Kg=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Yg=B("chevrons-right",Kg);const Jg=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Xg=B("chevrons-up",Jg);const Zg=[["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"}]],tn=B("circle-alert",Zg);const Qg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],e0=B("circle-arrow-up",Qg);const t0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ir=B("circle-check-big",t0);const n0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ys=B("circle-check",n0);const s0=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],li=B("circle-play",s0);const r0=[["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"}]],o0=B("circle-question-mark",r0);const a0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],i0=B("circle-stop",a0);const l0=[["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"}]],Uu=B("circle-x",l0);const c0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],d0=B("circle",c0);const u0=[["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"}]],p0=B("clapperboard",u0);const m0=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],f0=B("clipboard-check",m0);const h0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],x0=B("clock-3",h0);const g0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],en=B("clock",g0);const b0=[["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"}]],v0=B("cloud-upload",b0);const y0=[["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"}]],qu=B("code-xml",y0);const w0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],j0=B("columns-2",w0);const S0=[["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"}]],yt=B("copy",S0);const N0=[["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"}]],C0=B("cpu",N0);const k0=[["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"}]],Rs=B("download",k0);const T0=[["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"}]],_0=B("ellipsis",T0);const E0=[["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"}]],lr=B("external-link",E0);const R0=[["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"}]],M0=B("eye-off",R0);const A0=[["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"}]],Hu=B("eye",A0);const I0=[["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"}]],P0=B("file-braces",I0);const L0=[["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"}]],O0=B("file-diff",L0);const z0=[["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"}]],D0=B("file-search",z0);const $0=[["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"}]],F0=B("file-terminal",$0);const B0=[["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"}]],U0=B("file-text",B0);const q0=[["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"}]],H0=B("flag",q0);const V0=[["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"}]],Vu=B("flask-conical",V0);const W0=[["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"}]],G0=B("folder-open",W0);const K0=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],il=B("gauge",K0);const Y0=[["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"}]],J0=B("git-compare-arrows",Y0);const X0=[["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"}]],Wu=B("globe",X0);const Z0=[["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"}]],Gu=B("history",Z0);const Q0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ku=B("info",Q0);const e1=[["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"}]],uc=B("layers",e1);const t1=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=B("loader-circle",t1);const n1=[["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"}]],s1=B("lock",n1);const r1=[["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"}]],o1=B("maximize-2",r1);const a1=[["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"}]],Po=B("message-square",a1);const i1=[["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"}]],l1=B("minimize-2",i1);const c1=[["path",{d:"M5 12h14",key:"1ays0h"}]],Yu=B("minus",c1);const d1=[["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"}]],u1=B("monitor",d1);const p1=[["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"}]],m1=B("moon",p1);const f1=[["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"}]],h1=B("mouse-pointer-click",f1);const x1=[["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"}]],g1=B("network",x1);const b1=[["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"}]],v1=B("octagon-alert",b1);const y1=[["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"}]],w1=B("package-check",y1);const j1=[["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"}]],S1=B("panel-right-close",j1);const N1=[["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"}]],C1=B("panel-right-open",N1);const k1=[["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"}]],Ju=B("pencil",k1);const T1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pc=B("plus",T1);const _1=[["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"}]],ci=B("radio",_1);const E1=[["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"}]],lt=B("refresh-cw",E1);const R1=[["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"}]],Xu=B("rocket",R1);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"}]],Zu=B("rotate-ccw",M1);const A1=[["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"}]],oo=B("rotate-cw",A1);const I1=[["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"}]],P1=B("rows-3",I1);const L1=[["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"}]],O1=B("save",L1);const z1=[["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"}]],D1=B("scan",z1);const $1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],F1=B("search",$1);const B1=[["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"}]],U1=B("send",B1);const q1=[["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"}]],Qu=B("server",q1);const H1=[["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"}]],V1=B("settings",H1);const W1=[["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"}]],G1=B("shield-alert",W1);const K1=[["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"}]],mc=B("shield-check",K1);const Y1=[["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"}]],ao=B("siren",Y1);const J1=[["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"}]],di=B("sparkles",J1);const X1=[["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"}]],Z1=B("sun",X1);const Q1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],qn=B("terminal",Q1);const eb=[["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"}]],ep=B("timer",eb);const tb=[["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"}]],Sn=B("trash-2",tb);const nb=[["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"}]],yn=B("triangle-alert",nb);const sb=[["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"}]],tp=B("upload",sb);const rb=[["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"}]],ob=B("wifi-off",rb);const ab=[["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"}]],ib=B("wifi",ab);const lb=[["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"}]],cr=B("wrench",lb);const cb=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],dr=B("x",cb);const db=[["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"}]],Zs=B("zap",db),ui="/api/config";async function ub(e){return Ke(e,Io,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function pb(e){return Ke(ui,Io,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function mb(){const e=qt(ui,ub,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=hu(),s=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??sl,o=async()=>{await n(ui,pb({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??no,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??so,timeDisplayFormat:e.data?.timeDisplayFormat??ro,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:r,isLoading:e.isLoading,markSeen:o}}function fb({isLoading:e,hasSeenOnboarding:n,dismissedInView:s}){return!e&&!n&&!s}function hb({expanded:e,onToggle:n,onDismiss:s}){const r=e?"grid":"hidden sm:grid";return t.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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Ku,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),t.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),t.jsxs("div",{className:`${r} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Network"}),": replace ",t.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),t.jsx("button",{type:"button",onClick:n,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:t.jsx(Ze,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),t.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:[t.jsx(De,{className:"size-3.5"}),"Got it"]}),t.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:t.jsx(dr,{className:"size-3.5"})})]})})}function xb(){const{hasSeenOnboarding:e,isLoading:n,markSeen:s}=mb(),[r,o]=l.useState(!1),[a,i]=l.useState(!1);return fb({isLoading:n,hasSeenOnboarding:e,dismissedInView:a})?t.jsx(hb,{expanded:r,onToggle:()=>o(c=>!c),onDismiss:()=>{i(!0),s().catch(()=>{})}}):null}const gb="@tonyclaw/agent-inspector",bb="4.0.23",vb="module",yb="Agent observability and knowledge capture layer for AI coding tools.",wb="MIT",jb={node:">=22.0.0"},Sb="TonyClaw",Nb={type:"git",url:"git+https://gitcode.com/TonyClaw/OpenInspector.git"},Cb="https://gitcode.com/TonyClaw/OpenInspector#readme",kb=["packages/*"],Tb={url:"https://gitcode.com/TonyClaw/OpenInspector/issues"},_b={access:"public",registry:"https://registry.npmjs.org/"},Eb=["claude","anthropic","openai","proxy","api-inspector","agent-observability","agent-memory","debugging","llm","ai-coding-tools"],Rb={"agent-inspector":"bin/agent-inspector.js"},Mb=["bin","src/assets/agent-inspector.ico","scripts/setup-windows-runtime.mjs","scripts/setup-agent-skills.mjs","scripts/generate-theme-scales.mjs","docs/instance-control.openapi.yaml","styles",".output","!.output/*.exe"],Ab={dev:"node scripts/dev-decoupled.mjs","dev:ui":"vite dev --config vite.ui.config.ts","dev:backend":"node scripts/dev-backend.mjs","test:smoke":"node scripts/run-local-bun.mjs scripts/run-test-suite.mjs smoke","test:fast":"node scripts/run-local-bun.mjs scripts/run-test-suite.mjs smoke","test:unit":"node scripts/run-local-bun.mjs scripts/run-test-suite.mjs unit","test:integration":"node scripts/run-local-bun.mjs scripts/run-test-suite.mjs integration","test:changed":"node scripts/run-local-bun.mjs scripts/run-test-suite.mjs changed","test:all":"node scripts/run-local-bun.mjs scripts/run-test-suite.mjs all","test:hostile-inputs":"bun test src/proxy/identityProxy.test.ts src/proxy/handler.cancellationCompatibility.test.ts src/proxy/logImporter.test.ts src/backend/routes/api/-logs.stream.test.ts src/proxy/handler.admission.test.ts src/proxy/runtimeHealth.test.ts src/proxy/storageLifecycle.test.ts","test:compatibility-tooling":"node scripts/run-compatibility-tests.mjs ultra","test:compatibility-tooling:extended":"node scripts/run-compatibility-tests.mjs extended","test:compatibility-conformance":"node scripts/run-compatibility-tests.mjs conformance",start:"node .output/cli.js","start:backend":"node .output/cli.js --backend-only --no-open","preview:ui":"vite preview --config vite.ui.config.ts","clean:output":"node scripts/clean-output.mjs",build:"bun clean:output && bun build:backend && bun build:ui && bun smoke:ui-preview && bun build:workers && bun build:cli && bun build:mcp && bun check:bundle && bun check:boundaries","build:backend":"vite build --config vite.backend.config.ts","build:ui":"vite build --config vite.ui.config.ts","build:workers":"npx esbuild src/proxy/logFinalizer.worker.ts src/proxy/sessionWorkerEntry.ts --bundle --minify --legal-comments=none --platform=node --target=node22 --format=esm --outdir=.output/workers --external:better-sqlite3","smoke:workers":"node scripts/smoke-production-workers.mjs","smoke:packed-workers":"node scripts/smoke-packed-workers.mjs","smoke:instances":"node scripts/smoke-windows-instances.mjs","smoke:coding-agent-instances":"node scripts/smoke-coding-agent-instances.mjs","smoke:ui-preview":"node scripts/smoke-decoupled-ui-preview.mjs","check:bundle":"node scripts/check-client-bundle.mjs","check:boundaries":"node scripts/check-runtime-boundaries.mjs","check:commercial-performance":"node scripts/check-commercial-performance-budgets.mjs","check:hostile-inputs":"node scripts/check-hostile-input-coverage.mjs","check:supply-chain":"node scripts/check-commercial-supply-chain.mjs","compatibility:bdd":"node scripts/lint-bdd-catalog.mjs","compatibility:compare":"node scripts/compatibility/cli.mjs compare","compatibility:drift":"node scripts/check-backend-compatibility.mjs","compatibility:fixtures":"bun scripts/validate-compatibility-fixtures.ts","compatibility:freeze":"node scripts/freeze-backend-baseline.mjs","compatibility:run":"node scripts/compatibility/cli.mjs run","compatibility:performance":"node scripts/compatibility/performance-cli.mjs","compatibility:performance:verify":"node scripts/compatibility/performance-cli.mjs verify","build:cli":"npx esbuild src/cli.ts --bundle --minify --legal-comments=none --platform=node --target=node22 --format=esm --outfile=.output/cli.js","build:mcp":"npx esbuild packages/agent-inspector-mcp/src/cli.ts --bundle --minify --legal-comments=none --platform=node --target=node22 --format=esm --outfile=packages/agent-inspector-mcp/dist/cli.js","rust:build-package":"node scripts/rust/build-platform.mjs","rust:stage-package":"node scripts/rust/stage-platform.mjs","rust:verify-package":"node scripts/rust/verify-platform.mjs","rust:pack-package":"node scripts/rust/pack-platform.mjs","rust:native-artifact":"node scripts/rust/create-native-artifact.mjs","rust:native:aggregate":"node scripts/rust/aggregate-native-artifacts.mjs","rust:release-gate:preflight":"node scripts/rust/release-gate-preflight.mjs","rust:release-evidence:plan":"node scripts/rust/release-evidence-plan.mjs","commercial:release-gate:preflight":"node scripts/commercial-release-preflight.mjs","test:commercial-release-gate":"bun test scripts/commercialReleasePreflight.test.ts","test:rust-packaging":"bun test scripts/rust/npmPackaging.test.ts scripts/rust/nativeReleaseContract.test.ts scripts/rust/nativeStartupSmoke.test.ts scripts/rust/releaseGatePreflight.test.ts scripts/releaseCore.test.ts","rust:packages:check":"node scripts/rust/sync-package-versions.mjs","rust:packages:sync":"node scripts/rust/sync-package-versions.mjs --write","themes:generate":"node scripts/generate-theme-scales.mjs",postinstall:"node scripts/setup-windows-runtime.mjs && node scripts/setup-agent-skills.mjs",prepublishOnly:"node scripts/rust/require-release-orchestrator.mjs",typecheck:"tsc --noEmit --incremental --tsBuildInfoFile .cache/tsconfig.tsbuildinfo",lint:"eslint . --cache --cache-location .cache/eslintcache",format:"biome format --write .","format:check":"biome format .","verify:ultra":"node scripts/compatibility/ultra-gate.mjs","verify:ultra:fresh":"node scripts/compatibility/ultra-gate.mjs --no-cache","verify:ultra:smoke":"npm run verify:ultra && npm run test:smoke","verify:fast":"bun scripts/run-static-checks.mjs --format && bun test:changed","extension:zip":"node scripts/pack-chrome-extension.mjs","extension:release":"node scripts/release-chrome-extension.mjs",release:"node scripts/release.mjs",knip:"knip",check:"bun scripts/run-static-checks.mjs --format && bun check:boundaries && bun check:commercial-performance && bun check:hostile-inputs && bun compatibility:bdd && bun rust:packages:check",prepare:"husky",ladle:"ladle serve","ladle:build":"ladle build"},Ib={"@mariozechner/pi-agent-core":"^0.73.1","@mariozechner/pi-ai":"^0.73.1","@modelcontextprotocol/server":"^2.0.0-beta.4","@tailwindcss/typography":"^0.5.20","@tanstack/react-router":"^1.170.18","@tanstack/react-start":"^1.168.28","@tanstack/react-virtual":"^3.14.6","class-variance-authority":"^0.7.1",clsx:"^2.1.1",conf:"^15.1.0",diff:"^9.0.0",jszip:"^3.10.1","lucide-react":"^0.563.0","radix-ui":"1.6.2",react:"^19.2.7","react-dom":"^19.2.7","react-markdown":"^10.1.0",swr:"^2.4.2","tailwind-merge":"^3.6.0",three:"0.185.1","tw-animate-css":"^1.4.0",zod:"^4.4.3"},Pb={"@tonyclaw/agent-inspector-backend-darwin-arm64":"4.0.23","@tonyclaw/agent-inspector-backend-linux-x64-gnu":"4.0.23","@tonyclaw/agent-inspector-backend-win32-x64-msvc":"4.0.23","better-sqlite3":"^12.11.1",rcedit:"4.0.1"},Lb={"@biomejs/biome":"^2.5.3","@eslint/js":"^10.0.1","@ladle/react":"^5.1.1","@radix-ui/colors":"^3.0.0","@tailwindcss/vite":"^4.3.2","@tanstack/router-plugin":"^1.168.20","@types/bun":"^1.3.14","@types/react":"^19.2.17","@types/react-dom":"^19.2.3","@types/three":"0.185.1","@typescript-eslint/eslint-plugin":"^8.64.0","@typescript-eslint/parser":"^8.64.0","@vitejs/plugin-react":"^5.2.0",ajv:"8.20.0","ajv-formats":"3.0.1","colorjs.io":"^0.7.0",esbuild:"^0.28.1",eslint:"^9.39.5","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-functional":"^9.0.5","eslint-plugin-unicorn":"^63.0.0",husky:"^9.1.7",knip:"^5.88.1",nitro:"^3.0.260610-beta",playwright:"^1.61.1",tailwindcss:"^4.3.2",typescript:"^5.9.3",vite:"^7.3.6","vite-tsconfig-paths":"^6.1.1"},Ob={undici:">=7.24.0 <8.0.0",rollup:">=4.59.0 <5.0.0",postcss:">=8.5.10 <9.0.0","js-yaml":">=4.1.2 <5.0.0",flatted:">=3.4.0 <4.0.0","smol-toml":">=1.6.1 <2.0.0",koa:">=2.16.4 <3.0.0","@babel/core":">=7.29.1 <8.0.0","@typescript-eslint/typescript-estree":"^8.63.0",vite:"^7.3.6"},io={name:gb,version:bb,type:vb,description:yb,license:wb,engines:jb,author:Sb,repository:Nb,homepage:Cb,workspaces:kb,bugs:Tb,publishConfig:_b,keywords:Eb,bin:Rb,files:Mb,scripts:Ab,dependencies:Ib,optionalDependencies:Pb,devDependencies:Lb,overrides:Ob};function ds(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const np="[REDACTED]",zb=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,Db=[/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],fc=200,$b=25e6,sp=50,Fb=1e4,Bb=1024*1024,Ub=64,qb=1e4;function Hb(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function Vb(e){let n=0;for(const s of e)n+=s.rawRequestBody?.length??s.rawRequestBodyBytes??0,n+=s.responseText?.length??s.responseTextBytes??0;return n}function Wb(e){if(e.length>fc)return`Export is limited to ${fc} logs at once. Narrow the filter and try again.`;const n=Vb(e);return n>$b?`Export is too large (${Hb(n)} of text). Narrow the filter and try again.`:null}function xr(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function Gb(e,n){try{const s=await vn(`/api/logs/${e}/chunks`,Fb,{signal:n});if(!s.ok)return null;const r=await s.json();return JSON.stringify(r,null,2)}catch{return null}}function Kb(e,n){switch(n){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function hc(e,n,s){const r=Kb(e,n);if(r!==null)return r;let o=0,a="";for(let i=0;i<Ub;i+=1){const c=new URLSearchParams({part:n,offset:String(o),limit:String(Bb)});try{const d=await vn(`/api/logs/${String(e.id)}/body?${c.toString()}`,qb,{signal:s});if(!d.ok)return a.length>0?a:null;const p=await d.json(),u=wu.safeParse(p);if(!u.success||(a=`${a}${u.data.text}`,!u.data.hasMore||u.data.nextOffset===null))return a.length>0?a:null;o=u.data.nextOffset}catch{return a.length>0?a:null}}return a.length>0?a:null}function pi(e){if(Array.isArray(e))return e.map(s=>pi(s));if(!ds(e))return e;const n={};for(const[s,r]of Object.entries(e))n[s]=zb.test(s)?np:pi(r);return n}function Yb(e){const n=s=>{let r=s;for(const o of Db)r=r.replace(o,np);return r};try{const s=JSON.parse(e);return n(JSON.stringify(pi(s),null,2))}catch{return n(e)}}function ma(e,n){return n==="redacted"?Yb(e):e}function Jb(e,n){return{...e,rawRequestBody:null,responseText:null,rawHeaders:n==="raw"?e.rawHeaders:void 0,headers:n==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function Xb(e,n,s,r=new Date().toISOString()){return{version:io.version,exportedAt:r,mode:n,redacted:n==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:sp,streamingChunkLogIds:s.map(o=>o.id)}}async function Zb(e,n="redacted",s={}){const r=xr(s.signal);if(r!==null)return r;const o=Wb(e);if(o!==null)return{ok:!1,message:o};const{default:a}=await Kt(async()=>{const{default:h}=await import("./jszip.min-CjWc6qJe.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=n==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,sp);i.file("manifest.json",JSON.stringify(Xb(e,n,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>Jb(h,n)),null,2));for(const h of e){const g=xr(s.signal);if(g!==null)return g;const v=await hc(h,"request",s.signal);v!==null&&i.file(`#${h.id}.Request.json`,ma(v,n));const w=await hc(h,"response",s.signal);w!==null&&i.file(`#${h.id}.Response.json`,ma(w,n))}for(const h of d){const g=xr(s.signal);if(g!==null)return g;const v=await Gb(h.id,s.signal);v!==null&&i.file(`#${h.id}.SSE.Response.json`,ma(v,n))}const p=await i.generateAsync({type:"blob"}),u=xr(s.signal);if(u!==null)return u;const m=URL.createObjectURL(p),f=document.createElement("a");return f.href=m,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(m),{ok:!0}}function Qb(e){const n=pa(e,"/proxy"),s=pa(e,"/proxy/v1"),r=pa(e,"/api/mcp");return n===null||s===null||r===null?null:{proxy:n,openAiV1:s,mcp:r}}function ev(){const e=ax();return e.ok?Qb(e.runtime):null}function ll(e){const n=()=>e(ev());return n(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(cc,n),()=>globalThis.removeEventListener(cc,n))}function mi(e,n){switch(n){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Lo(e,n,s){return`${mi(e,s)} - ${mi(n,s)}`}const cl="agent-inspector.theme";function rp(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 fa(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function tv(){if(typeof window>"u")return"dark";try{return rp(window.localStorage.getItem(cl))}catch{return"dark"}}function nv(e){if(!(typeof window>"u"))try{window.localStorage.setItem(cl,e)}catch{}}function sv(){const[e,n]=l.useState(tv),s=l.useCallback(r=>{n(r),fa(r),nv(r)},[]);return l.useEffect(()=>{fa(e)},[e]),l.useEffect(()=>{function r(o){if(o.key!==cl)return;const a=rp(o.newValue);n(a),fa(a)}return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{themeMode:e,setThemeMode:s}}const dl="agent-inspector.uiScale",rv=1.25,ov=2200,av=3e3,iv=12;function ha(e,n){return Number.isFinite(e)&&e>0?e:n}function ul(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 lv(e,n){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=ha(n.viewportWidth,1280),r=ha(n.screenWidth,s),o=ha(n.devicePixelRatio,1),a=Math.min(s,r);return o>rv?1:a>=av?1.25:a>=ov?1.125:1}}}function cv(e){return`${Math.round(e*100)}%`}function xa(e,n){return Math.max(iv,e*n)}function dv(){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 ga(e){const n=lv(e,dv());if(typeof document>"u")return n;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(n*100)),s.style.setProperty("--inspector-ui-scale",String(n)),s.style.setProperty("--inspector-root-font-size",`${String(16*n)}px`),s.style.setProperty("--inspector-font-9",`${String(xa(9,n))}px`),s.style.setProperty("--inspector-font-10",`${String(xa(10,n))}px`),s.style.setProperty("--inspector-font-11",`${String(xa(11,n))}px`),s.style.setProperty("--inspector-font-13",`${String(13*n)}px`),n}function uv(){if(typeof window>"u")return"auto";try{return ul(window.localStorage.getItem(dl))}catch{return"auto"}}function pv(e){if(!(typeof window>"u"))try{window.localStorage.setItem(dl,e)}catch{}}function mv(){const[e,n]=l.useState(uv),[s,r]=l.useState(1),o=l.useCallback(a=>{n(a),pv(a),r(ga(a))},[]);return l.useEffect(()=>{const a=()=>{r(ga(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==dl)return;const c=ul(i.newValue);n(c),r(ga(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:o}}const fv=200,hv=512,xv=256,wn=64,fi=256,op=64,gv=32,bv=2,vv=4,xc=16,ve=_().int().positive(),yv=T({proxy:T({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),control:T({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),upstream:T({fetchResponseBytes:ve,fetchDeadlineMs:ve,replayResponseBytes:ve,replayDeadlineMs:ve,metadataResponseBytes:ve,metadataDeadlineMs:ve,connectTimeoutMs:ve,idleTimeoutMs:ve}),pagination:T({restPageSize:ve,searchQueryChars:ve,searchProjectChars:ve}),sse:T({clients:ve,initLogs:ve,heartbeatMs:ve}),imports:T({archiveBytes:ve,entries:ve,entryBytes:ve,uncompressedBytes:ve,expansionRatio:ve}),fanOut:T({providerModels:ve,providerModelMetadata:ve,providerTestConcurrency:ve,activeProviderTests:ve}),queues:T({proxyRequests:ve,finalizerJobs:ve,rawStreamMessages:ve,rawStreamBytes:ve,backgroundWorkers:ve})}).superRefine((e,n)=>{e.control.requestBytes>e.proxy.requestBytes&&n.addIssue({code:"custom",path:["control","requestBytes"],message:"control request budget must not exceed proxy request budget"}),e.control.responseBytes>e.proxy.responseBytes&&n.addIssue({code:"custom",path:["control","responseBytes"],message:"control response budget must not exceed proxy response budget"}),e.control.activeRequests>e.proxy.activeRequests&&n.addIssue({code:"custom",path:["control","activeRequests"],message:"control active request budget must not exceed proxy active request budget"}),e.upstream.fetchResponseBytes>e.proxy.responseBytes&&n.addIssue({code:"custom",path:["upstream","fetchResponseBytes"],message:"upstream fetch response budget must not exceed proxy response budget"}),e.upstream.replayResponseBytes>e.proxy.responseBytes&&n.addIssue({code:"custom",path:["upstream","replayResponseBytes"],message:"upstream replay response budget must not exceed proxy response budget"}),e.upstream.metadataResponseBytes>e.control.responseBytes&&n.addIssue({code:"custom",path:["upstream","metadataResponseBytes"],message:"upstream metadata response budget must not exceed control response budget"}),e.upstream.metadataDeadlineMs>e.control.deadlineMs&&n.addIssue({code:"custom",path:["upstream","metadataDeadlineMs"],message:"upstream metadata deadline must not exceed control deadline"}),e.queues.proxyRequests<e.proxy.activeRequests&&n.addIssue({code:"custom",path:["queues","proxyRequests"],message:"proxy request queue budget must cover active proxy requests"})});yv.parse({proxy:{requestBytes:64*1024*1024,responseBytes:256*1024*1024,headerBytes:64*1024,deadlineMs:12e4,idleTimeoutMs:3e4,activeRequests:xc},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:fv,searchQueryChars:hv,searchProjectChars:xv},sse:{clients:gv,initLogs:500,heartbeatMs:15e3},imports:{archiveBytes:64*1024*1024,entries:5e3,entryBytes:32*1024*1024,uncompressedBytes:256*1024*1024,expansionRatio:20},fanOut:{providerModels:wn,providerModelMetadata:op,providerTestConcurrency:vv,activeProviderTests:bv},queues:{proxyRequests:xc,finalizerJobs:1e3,rawStreamMessages:16384,rawStreamBytes:64*1024*1024,backgroundWorkers:4}});const wv=pe(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),jv=Gt([ae(400),ae(413),ae(429),ae(503)]);T({error:x().min(1).max(300),code:wv,status:jv,resource:x().min(1).max(80),limit:_().int().positive(),retryable:Ce()});function gr(){return x().refine(e=>{if(e.length===0)return!0;try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const pl=x().max(fi),Sv=V(pl).max(wn),Nv=T({model:pl.min(1),contextWindow:_().int().positive().optional(),outputLimit:_().int().positive().optional(),source:pe(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),Cv=V(Nv).max(op),kv=T({id:x(),name:x(),apiKey:x(),model:pl.optional(),models:Sv.optional().default([]),format:pe(["anthropic","openai"]).optional(),baseUrl:gr().optional(),anthropicBaseUrl:gr().optional(),openaiBaseUrl:gr().optional(),openaiResponsesBaseUrl:gr().optional(),authHeader:pe(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:Cv.optional(),source:pe(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),Tv="configured",lo=kv.extend({apiKey:ae(Tv)});async function _v(e){return Ke(e,lo.array(),void 0,n=>`Failed to fetch ${e}: ${n.status}`)}function ml(){const e=qt("/api/providers",_v,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function gc(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Ev(...e){return n=>{let s=!1;const r=e.map(o=>{const a=gc(o,n);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():gc(e[o],null)}}}}function Ae(...e){return l.useCallback(Ev(...e),e)}function ws(e){const n=l.forwardRef((s,r)=>{let{children:o,...a}=s,i=null,c=!1;const d=[];bc(o)&&typeof br=="function"&&(o=br(o._payload)),l.Children.forEach(o,f=>{if(Lv(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;bc(g)&&typeof br=="function"&&(g=br(g._payload)),i=Av(h,g),d.push(i?.props?.children)}else d.push(f)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(o)===1&&l.isValidElement(o)&&(i=o);const p=i?Pv(i):void 0,u=Ae(r,p);if(!i){if(o||o===0)throw new Error(c?$v(e):Dv(e));return o}const m=Iv(a,i.props??{});return i.type!==l.Fragment&&(m.ref=r?u:p),l.cloneElement(i,m)});return n.displayName=`${e}.Slot`,n}var Rv=ws("Slot"),ap=Symbol.for("radix.slottable");function Mv(e){const n=s=>"child"in s?s.children(s.child):s.children;return n.displayName=`${e}.Slottable`,n.__radixId=ap,n}var Av=(e,n)=>{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(n)?n:null};function Iv(e,n){const s={...n};for(const r in n){const o=e[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?s[r]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(s[r]=o):r==="style"?s[r]={...o,...a}:r==="className"&&(s[r]=[o,a].filter(Boolean).join(" "))}return{...e,...s}}function Pv(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function Lv(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ap}var Ov=Symbol.for("react.lazy");function bc(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ov&&"_payload"in e&&zv(e._payload)}function zv(e){return typeof e=="object"&&e!==null&&"then"in e}var Dv=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,$v=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,br=Mo[" use ".trim().toString()],Fv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=Fv.reduce((e,n)=>{const s=ws(`Primitive.${n}`),r=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return r.displayName=`Primitive.${n}`,{...e,[n]:r}},{});function Bv(e,n){e&&Es.flushSync(()=>e.dispatchEvent(n))}var ip=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"}),Uv="VisuallyHidden",lp=l.forwardRef((e,n)=>t.jsx(be.span,{...e,ref:n,style:{...ip,...e.style}}));lp.displayName=Uv;var qv=lp;function on(e,n=[]){let s=[];function r(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const p=m=>{const{scope:f,children:h,...g}=m,v=f?.[e]?.[d]||c,w=l.useMemo(()=>g,Object.values(g));return t.jsx(v.Provider,{value:w,children:h})};p.displayName=a+"Provider";function u(m,f,h={}){const{optional:g=!1}=h,v=f?.[e]?.[d]||c,w=l.useContext(v);if(w)return w;if(i!==void 0)return i;if(!g)throw new Error(`\`${m}\` must be used within \`${a}\``)}return[p,u]}const o=()=>{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 o.scopeName=e,[r,Hv(o,...n)]}function Hv(...e){const n=e[0];if(e.length===1)return n;const s=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((c,{useScope:d,scopeName:p})=>{const m=d(a)[`__scope${p}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return s.scopeName=n.scopeName,s}function cp(e){const n=e+"CollectionProvider",[s,r]=on(n),[o,a]=s(n,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:w,children:y}=v,b=l.useRef(null),j=l.useRef(new Map).current;return t.jsx(o,{scope:w,itemMap:j,collectionRef:b,children:y})};i.displayName=n;const c=e+"CollectionSlot",d=ws(c),p=l.forwardRef((v,w)=>{const{scope:y,children:b}=v,j=a(c,y),S=Ae(w,j.collectionRef);return t.jsx(d,{ref:S,children:b})});p.displayName=c;const u=e+"CollectionItemSlot",m="data-radix-collection-item",f=ws(u),h=l.forwardRef((v,w)=>{const{scope:y,children:b,...j}=v,S=l.useRef(null),N=Ae(w,S),C=a(u,y);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),t.jsx(f,{[m]:"",ref:N,children:b})});h.displayName=u;function g(v){const w=a(e+"CollectionConsumer",v);return l.useCallback(()=>{const b=w.collectionRef.current;if(!b)return[];const j=Array.from(b.querySelectorAll(`[${m}]`));return Array.from(w.itemMap.values()).sort((C,E)=>j.indexOf(C.ref.current)-j.indexOf(E.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:p,ItemSlot:h},g,r]}function ue(e,n,{checkForDefaultPrevented:s=!0}={}){return function(o){if(e?.(o),s===!1||!o||!o.defaultPrevented)return n?.(o)}}var Ve=globalThis?.document?l.useLayoutEffect:()=>{},Vv=Mo[" useInsertionEffect ".trim().toString()]||Ve;function $n({prop:e,defaultProp:n,onChange:s=()=>{},caller:r}){const[o,a,i]=Wv({defaultProp:n,onChange:s}),c=e!==void 0,d=c?e:o;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const m=u.current;m!==c&&console.warn(`${r} is changing from ${m?"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,r])}const p=l.useCallback(u=>{if(c){const m=Gv(u)?u(e):u;m!==e&&i.current?.(m)}else a(u)},[c,e,a,i]);return[d,p]}function Wv({defaultProp:e,onChange:n}){const[s,r]=l.useState(e),o=l.useRef(s),a=l.useRef(n);return Vv(()=>{a.current=n},[n]),l.useEffect(()=>{o.current!==s&&(a.current?.(s),o.current=s)},[s,o]),[s,r,a]}function Gv(e){return typeof e=="function"}function Kv(e,n){return l.useReducer((s,r)=>n[s][r]??s,e)}var wt=e=>{const{present:n,children:s}=e,r=Yv(n),o=typeof s=="function"?s({present:r.isPresent}):l.Children.only(s),a=Jv(r.ref,Xv(o));return typeof s=="function"||r.isPresent?l.cloneElement(o,{ref:a}):null};wt.displayName="Presence";function Yv(e){const[n,s]=l.useState(),r=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),i=l.useRef(void 0),c=e?"mounted":"unmounted",[d,p]=Kv(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??zs(r.current),i.current=void 0):a.current="none"},[d]),Ve(()=>{const u=r.current,m=o.current;if(m!==e){const h=a.current,g=zs(u);e?(i.current=g,p("MOUNT")):g==="none"||u?.display==="none"?p("UNMOUNT"):p(m&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,p]),Ve(()=>{if(n){let u;const m=n.ownerDocument.defaultView??window,f=g=>{const w=zs(r.current).includes(CSS.escape(g.animationName));if(g.target===n&&w&&(p("ANIMATION_END"),!o.current)){const y=n.style.animationFillMode;n.style.animationFillMode="forwards",u=m.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=y)})}},h=g=>{g.target===n&&(a.current=zs(r.current))};return n.addEventListener("animationstart",h),n.addEventListener("animationcancel",f),n.addEventListener("animationend",f),()=>{m.clearTimeout(u),n.removeEventListener("animationstart",h),n.removeEventListener("animationcancel",f),n.removeEventListener("animationend",f)}}else p("ANIMATION_END")},[n,p]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const m=getComputedStyle(u);r.current=m,i.current=zs(m)}else r.current=null;s(u)},[])}}function vc(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Jv(...e){const n=l.useRef(e);return n.current=e,l.useCallback(s=>{const r=n.current;let o=!1;const a=r.map(i=>{const c=vc(i,s);return!o&&typeof c=="function"&&(o=!0),c});if(o)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():vc(r[i],null)}}},[])}function zs(e){return e?.animationName||"none"}function Xv(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Zv=Mo[" useId ".trim().toString()]||(()=>{}),Qv=0;function Ht(e){const[n,s]=l.useState(Zv());return Ve(()=>{s(r=>r??String(Qv++))},[e]),e||(n?`radix-${n}`:"")}var Oo="Collapsible",[e2]=on(Oo),[t2,fl]=e2(Oo),dp=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,open:r,defaultOpen:o,disabled:a,onOpenChange:i,...c}=e,[d,p]=$n({prop:r,defaultProp:o??!1,onChange:i,caller:Oo});return t.jsx(t2,{scope:s,disabled:a,contentId:Ht(),open:d,onOpenToggle:l.useCallback(()=>p(u=>!u),[p]),children:t.jsx(be.div,{"data-state":xl(d),"data-disabled":a?"":void 0,...c,ref:n})})});dp.displayName=Oo;var up="CollapsibleTrigger",pp=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,...r}=e,o=fl(up,s);return t.jsx(be.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":xl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:n,onClick:ue(e.onClick,o.onOpenToggle)})});pp.displayName=up;var hl="CollapsibleContent",mp=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=fl(hl,e.__scopeCollapsible);return t.jsx(wt,{present:s||o.open,children:({present:a})=>t.jsx(n2,{...r,ref:n,present:a})})});mp.displayName=hl;var n2=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,present:r,children:o,...a}=e,i=fl(hl,s),[c,d]=l.useState(r),p=l.useRef(null),u=Ae(n,p),m=l.useRef(0),f=m.current,h=l.useRef(0),g=h.current,v=i.open||c,w=l.useRef(v),y=l.useRef(void 0);return l.useEffect(()=>{const b=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(b)},[]),Ve(()=>{const b=p.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const j=b.getBoundingClientRect();m.current=j.height,h.current=j.width,w.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),d(r)}},[i.open,r]),t.jsx(be.div,{"data-state":xl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...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:v&&o})});function xl(e){return e?"open":"closed"}var s2=dp,r2=l.createContext(void 0);function zo(e){const n=l.useContext(r2);return e||n||"ltr"}function Je(e){const n=l.useRef(e);return l.useEffect(()=>{n.current=e}),l.useMemo(()=>((...s)=>n.current?.(...s)),[])}var o2="DismissableLayer",hi="dismissableLayer.update",a2="dismissableLayer.pointerDownOutside",i2="dismissableLayer.focusOutside",yc,gl=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Do=l.forwardRef((e,n)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...p}=e,u=l.useContext(gl),[m,f]=l.useState(null),h=m?.ownerDocument??globalThis?.document,[,g]=l.useState({}),v=Ae(n,f),w=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?w.indexOf(y):-1,j=m?w.indexOf(m):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=b,C=l.useRef(!1),E=p2(k=>{a?.(k),c?.(k),k.defaultPrevented||d?.()},{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:l.useCallback(k=>{if(!(k instanceof Node))return!1;const R=[...u.branches].some(O=>O.contains(k));return N&&!R},[u.branches,N])}),A=m2(k=>{if(r&&C.current)return;const R=k.target;[...u.branches].some($=>$.contains(R))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),I=m?j===w.length-1:!1,M=Je(k=>{k.key==="Escape"&&(o?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(I)return h.addEventListener("keydown",M,{capture:!0}),()=>h.removeEventListener("keydown",M,{capture:!0})},[h,I,M]),l.useEffect(()=>{if(m)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(yc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(m)),u.layers.add(m),wc(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(m),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=yc))}},[m,h,s,u]),l.useEffect(()=>()=>{m&&(u.layers.delete(m),u.layersWithOutsidePointerEventsDisabled.delete(m),wc())},[m,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(hi,k),()=>document.removeEventListener(hi,k)},[]),t.jsx(be.div,{...p,ref:v,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:ue(e.onFocusCapture,A.onFocusCapture),onBlurCapture:ue(e.onBlurCapture,A.onBlurCapture),onPointerDownCapture:ue(e.onPointerDownCapture,E.onPointerDownCapture)})});Do.displayName=o2;var l2="DismissableLayerBranch",c2=l.forwardRef((e,n)=>{const s=l.useContext(gl),r=l.useRef(null),o=Ae(n,r);return l.useEffect(()=>{const a=r.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),t.jsx(be.div,{...e,ref:o})});c2.displayName=l2;function d2(){const e=l.useContext(gl),[n,s]=l.useState(null);return l.useEffect(()=>{if(n)return e.dismissableSurfaces.add(n),()=>{e.dismissableSurfaces.delete(n)}},[n,e.dismissableSurfaces]),s}var u2=()=>!0;function p2(e,n){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=u2}=n,c=Je(e),d=l.useRef(!1),p=l.useRef(!1),u=l.useRef(new Map),m=l.useRef(()=>{});return l.useEffect(()=>{function f(){p.current=!1,o.current=!1,u.current.clear()}function h(){return Array.from(u.current.values()).some(Boolean)}function g(j){if(!p.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(()=>{p.current&&m.current()},0)}function v(j){p.current&&u.current.set(j.type,!1)}const w=j=>{if(j.target&&!d.current){let S=function(){s.removeEventListener("click",m.current);const C=h();f(),C||fp(a2,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",m.current),f(),d.current=!1;return}const N={originalEvent:j};p.current=!0,o.current=r&&j.button===0,u.current.clear(),!r||j.button!==0?S():(s.removeEventListener("click",m.current),m.current=S,s.addEventListener("click",m.current,{once:!0}))}else s.removeEventListener("click",m.current),f();d.current=!1},y=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of y)s.addEventListener(j,g,!0),s.addEventListener(j,v);const b=window.setTimeout(()=>{s.addEventListener("pointerdown",w)},0);return()=>{window.clearTimeout(b),s.removeEventListener("pointerdown",w),s.removeEventListener("click",m.current);for(const j of y)s.removeEventListener(j,g,!0),s.removeEventListener(j,v)}},[s,c,r,o,a,i]),{onPointerDownCapture:()=>d.current=!0}}function m2(e,n=globalThis?.document){const s=Je(e),r=l.useRef(!1);return l.useEffect(()=>{const o=a=>{a.target&&!r.current&&fp(i2,s,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,s]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function wc(){const e=new CustomEvent(hi);document.dispatchEvent(e)}function fp(e,n,s,{discrete:r}){const o=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});n&&o.addEventListener(e,n,{once:!0}),r?Bv(o,a):o.dispatchEvent(a)}var ba="focusScope.autoFocusOnMount",va="focusScope.autoFocusOnUnmount",jc={bubbles:!1,cancelable:!0},f2="FocusScope",bl=l.forwardRef((e,n)=>{const{loop:s=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),p=Je(o),u=Je(a),m=l.useRef(null),f=Ae(n,d),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let v=function(j){if(h.paused||!c)return;const S=j.target;c.contains(S)?m.current=S:fn(m.current,{select:!0})},w=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||fn(m.current,{select:!0}))},y=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&fn(c)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const b=new MutationObserver(y);return c&&b.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),b.disconnect()}}},[r,c,h.paused]),l.useEffect(()=>{if(c){Nc.add(h);const v=document.activeElement;if(!c.contains(v)){const y=new CustomEvent(ba,jc);c.addEventListener(ba,p),c.dispatchEvent(y),y.defaultPrevented||(h2(y2(hp(c)),{select:!0}),document.activeElement===v&&fn(c))}return()=>{c.removeEventListener(ba,p),setTimeout(()=>{const y=new CustomEvent(va,jc);c.addEventListener(va,u),c.dispatchEvent(y),y.defaultPrevented||fn(v??document.body,{select:!0}),c.removeEventListener(va,u),Nc.remove(h)},0)}}},[c,p,u,h]);const g=l.useCallback(v=>{if(!s&&!r||h.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,y=document.activeElement;if(w&&y){const b=v.currentTarget,[j,S]=x2(b);j&&S?!v.shiftKey&&y===S?(v.preventDefault(),s&&fn(j,{select:!0})):v.shiftKey&&y===j&&(v.preventDefault(),s&&fn(S,{select:!0})):y===b&&v.preventDefault()}},[s,r,h.paused]);return t.jsx(be.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});bl.displayName=f2;function h2(e,{select:n=!1}={}){const s=document.activeElement;for(const r of e)if(fn(r,{select:n}),document.activeElement!==s)return}function x2(e){const n=hp(e),s=Sc(n,e),r=Sc(n.reverse(),e);return[s,r]}function hp(e){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n}function Sc(e,n){const s=typeof n.checkVisibility=="function"&&n.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):g2(r,{upTo:n})))return r}function g2(e,{upTo:n}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n!==void 0&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function b2(e){return e instanceof HTMLInputElement&&"select"in e}function fn(e,{select:n=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&b2(e)&&n&&e.select()}}var Nc=v2();function v2(){let e=[];return{add(n){const s=e[0];n!==s&&s?.pause(),e=Cc(e,n),e.unshift(n)},remove(n){e=Cc(e,n),e[0]?.resume()}}}function Cc(e,n){const s=[...e],r=s.indexOf(n);return r!==-1&&s.splice(r,1),s}function y2(e){return e.filter(n=>n.tagName!=="A")}var w2="Portal",$o=l.forwardRef((e,n)=>{const{container:s,...r}=e,[o,a]=l.useState(!1);Ve(()=>a(!0),[]);const i=s||o&&globalThis?.document?.body;return i?Es.createPortal(t.jsx(be.div,{...r,ref:n}),i):null});$o.displayName=w2;var vr=0,Xn=null;function xp(){l.useEffect(()=>{Xn||(Xn={start:kc(),end:kc()});const{start:e,end:n}=Xn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==n&&document.body.insertAdjacentElement("beforeend",n),vr++,()=>{vr===1&&(Xn?.start.remove(),Xn?.end.remove(),Xn=null),vr=Math.max(0,vr-1)}},[])}function kc(){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 Bt=function(){return Bt=Object.assign||function(n){for(var s,r=1,o=arguments.length;r<o;r++){s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=s[a])}return n},Bt.apply(this,arguments)};function gp(e,n){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(s[r[o]]=e[r[o]]);return s}function j2(e,n,s){if(s||arguments.length===2)for(var r=0,o=n.length,a;r<o;r++)(a||!(r in n))&&(a||(a=Array.prototype.slice.call(n,0,r)),a[r]=n[r]);return e.concat(a||Array.prototype.slice.call(n))}var Wr="right-scroll-bar-position",Gr="width-before-scroll-bar",S2="with-scroll-bars-hidden",N2="--removed-body-scroll-bar-size";function ya(e,n){return typeof e=="function"?e(n):e&&(e.current=n),e}function C2(e,n){var s=l.useState(function(){return{value:e,callback:n,facade:{get current(){return s.value},set current(r){var o=s.value;o!==r&&(s.value=r,s.callback(r,o))}}}})[0];return s.callback=n,s.facade}var k2=typeof window<"u"?l.useLayoutEffect:l.useEffect,Tc=new WeakMap;function T2(e,n){var s=C2(null,function(r){return e.forEach(function(o){return ya(o,r)})});return k2(function(){var r=Tc.get(s);if(r){var o=new Set(r),a=new Set(e),i=s.current;o.forEach(function(c){a.has(c)||ya(c,null)}),a.forEach(function(c){o.has(c)||ya(c,i)})}Tc.set(s,e)},[e]),s}function _2(e){return e}function E2(e,n){n===void 0&&(n=_2);var s=[],r=!1,o={read:function(){if(r)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=n(a,r);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(r=!0;s.length;){var i=s;s=[],i.forEach(a)}s={push:function(c){return a(c)},filter:function(){return s}}},assignMedium:function(a){r=!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)},p=function(){return Promise.resolve().then(d)};p(),s={push:function(u){i.push(u),p()},filter:function(u){return i=i.filter(u),s}}}};return o}function R2(e){e===void 0&&(e={});var n=E2(null);return n.options=Bt({async:!0,ssr:!1},e),n}var bp=function(e){var n=e.sideCar,s=gp(e,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=n.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,Bt({},s))};bp.isSideCarExport=!0;function M2(e,n){return e.useMedium(n),bp}var vp=R2(),wa=function(){},Fo=l.forwardRef(function(e,n){var s=l.useRef(null),r=l.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),o=r[0],a=r[1],i=e.forwardProps,c=e.children,d=e.className,p=e.removeScrollBar,u=e.enabled,m=e.shards,f=e.sideCar,h=e.noRelative,g=e.noIsolation,v=e.inert,w=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,j=e.gapMode,S=gp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=T2([s,n]),E=Bt(Bt({},S),o);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:vp,removeScrollBar:p,shards:m,noRelative:h,noIsolation:g,inert:v,setCallbacks:a,allowPinchZoom:!!w,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),Bt(Bt({},E),{ref:C})):l.createElement(b,Bt({},E,{className:d,ref:C}),c))});Fo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Fo.classNames={fullWidth:Gr,zeroRight:Wr};var A2=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function I2(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var n=A2();return n&&e.setAttribute("nonce",n),e}function P2(e,n){e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n))}function L2(e){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(e)}var O2=function(){var e=0,n=null;return{add:function(s){e==0&&(n=I2())&&(P2(n,s),L2(n)),e++},remove:function(){e--,!e&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},z2=function(){var e=O2();return function(n,s){l.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&s])}},yp=function(){var e=z2(),n=function(s){var r=s.styles,o=s.dynamic;return e(r,o),null};return n},D2={left:0,top:0,right:0,gap:0},ja=function(e){return parseInt(e||"",10)||0},$2=function(e){var n=window.getComputedStyle(document.body),s=n[e==="padding"?"paddingLeft":"marginLeft"],r=n[e==="padding"?"paddingTop":"marginTop"],o=n[e==="padding"?"paddingRight":"marginRight"];return[ja(s),ja(r),ja(o)]},F2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return D2;var n=$2(e),s=document.documentElement.clientWidth,r=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,r-s+n[2]-n[0])}},B2=yp(),fs="data-scroll-locked",U2=function(e,n,s,r){var o=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
|
|
3
|
+
.`.concat(S2,` {
|
|
4
|
+
overflow: hidden `).concat(r,`;
|
|
5
|
+
padding-right: `).concat(c,"px ").concat(r,`;
|
|
6
|
+
}
|
|
7
|
+
body[`).concat(fs,`] {
|
|
8
|
+
overflow: hidden `).concat(r,`;
|
|
9
|
+
overscroll-behavior: contain;
|
|
10
|
+
`).concat([n&&"position: relative ".concat(r,";"),s==="margin"&&`
|
|
11
|
+
padding-left: `.concat(o,`px;
|
|
12
|
+
padding-top: `).concat(a,`px;
|
|
13
|
+
padding-right: `).concat(i,`px;
|
|
14
|
+
margin-left:0;
|
|
15
|
+
margin-top:0;
|
|
16
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
17
|
+
`),s==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.`).concat(Wr,` {
|
|
21
|
+
right: `).concat(c,"px ").concat(r,`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.`).concat(Gr,` {
|
|
25
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.`).concat(Wr," .").concat(Wr,` {
|
|
29
|
+
right: 0 `).concat(r,`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.`).concat(Gr," .").concat(Gr,` {
|
|
33
|
+
margin-right: 0 `).concat(r,`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body[`).concat(fs,`] {
|
|
37
|
+
`).concat(N2,": ").concat(c,`px;
|
|
38
|
+
}
|
|
39
|
+
`)},_c=function(){var e=parseInt(document.body.getAttribute(fs)||"0",10);return isFinite(e)?e:0},q2=function(){l.useEffect(function(){return document.body.setAttribute(fs,(_c()+1).toString()),function(){var e=_c()-1;e<=0?document.body.removeAttribute(fs):document.body.setAttribute(fs,e.toString())}},[])},H2=function(e){var n=e.noRelative,s=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;q2();var a=l.useMemo(function(){return F2(o)},[o]);return l.createElement(B2,{styles:U2(a,!n,o,s?"":"!important")})},xi=!1;if(typeof window<"u")try{var yr=Object.defineProperty({},"passive",{get:function(){return xi=!0,!0}});window.addEventListener("test",yr,yr),window.removeEventListener("test",yr,yr)}catch{xi=!1}var Zn=xi?{passive:!1}:!1,V2=function(e){return e.tagName==="TEXTAREA"},wp=function(e,n){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[n]!=="hidden"&&!(s.overflowY===s.overflowX&&!V2(e)&&s[n]==="visible")},W2=function(e){return wp(e,"overflowY")},G2=function(e){return wp(e,"overflowX")},Ec=function(e,n){var s=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=jp(e,r);if(o){var a=Sp(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},K2=function(e){var n=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[n,s,r]},Y2=function(e){var n=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[n,s,r]},jp=function(e,n){return e==="v"?W2(n):G2(n)},Sp=function(e,n){return e==="v"?K2(n):Y2(n)},J2=function(e,n){return e==="h"&&n==="rtl"?-1:1},X2=function(e,n,s,r,o){var a=J2(e,window.getComputedStyle(n).direction),i=a*r,c=s.target,d=n.contains(c),p=!1,u=i>0,m=0,f=0;do{if(!c)break;var h=Sp(e,c),g=h[0],v=h[1],w=h[2],y=v-w-a*g;(g||y)&&jp(e,c)&&(m+=y,f+=g);var b=c.parentNode;c=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!d&&c!==document.body||d&&(n.contains(c)||n===c));return(u&&Math.abs(m)<1||!u&&Math.abs(f)<1)&&(p=!0),p},wr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Rc=function(e){return[e.deltaX,e.deltaY]},Mc=function(e){return e&&"current"in e?e.current:e},Z2=function(e,n){return e[0]===n[0]&&e[1]===n[1]},Q2=function(e){return`
|
|
40
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
41
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
42
|
+
`)},ey=0,Qn=[];function ty(e){var n=l.useRef([]),s=l.useRef([0,0]),r=l.useRef(),o=l.useState(ey++)[0],a=l.useState(yp)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=j2([e.lockRef.current],(e.shards||[]).map(Mc),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var y=wr(v),b=s.current,j="deltaX"in v?v.deltaX:b[0]-y[0],S="deltaY"in v?v.deltaY:b[1]-y[1],N,C=v.target,E=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in v&&E==="h"&&C.type==="range")return!1;var A=window.getSelection(),I=A&&A.anchorNode,M=I?I===C||I.contains(C):!1;if(M)return!1;var k=Ec(E,C);if(!k)return!0;if(k?N=E:(N=E==="v"?"h":"v",k=Ec(E,C)),!k)return!1;if(!r.current&&"changedTouches"in v&&(j||S)&&(r.current=N),!N)return!0;var R=r.current||N;return X2(R,w,v,R==="h"?j:S)},[]),d=l.useCallback(function(v){var w=v;if(!(!Qn.length||Qn[Qn.length-1]!==a)){var y="deltaY"in w?Rc(w):wr(w),b=n.current.filter(function(N){return N.name===w.type&&(N.target===w.target||w.target===N.shadowParent)&&Z2(N.delta,y)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var j=(i.current.shards||[]).map(Mc).filter(Boolean).filter(function(N){return N.contains(w.target)}),S=j.length>0?c(w,j[0]):!i.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),p=l.useCallback(function(v,w,y,b){var j={name:v,delta:w,target:y,should:b,shadowParent:ny(y)};n.current.push(j),setTimeout(function(){n.current=n.current.filter(function(S){return S!==j})},1)},[]),u=l.useCallback(function(v){s.current=wr(v),r.current=void 0},[]),m=l.useCallback(function(v){p(v.type,Rc(v),v.target,c(v,e.lockRef.current))},[]),f=l.useCallback(function(v){p(v.type,wr(v),v.target,c(v,e.lockRef.current))},[]);l.useEffect(function(){return Qn.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:f}),document.addEventListener("wheel",d,Zn),document.addEventListener("touchmove",d,Zn),document.addEventListener("touchstart",u,Zn),function(){Qn=Qn.filter(function(v){return v!==a}),document.removeEventListener("wheel",d,Zn),document.removeEventListener("touchmove",d,Zn),document.removeEventListener("touchstart",u,Zn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:Q2(o)}):null,h?l.createElement(H2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ny(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const sy=M2(vp,ty);var vl=l.forwardRef(function(e,n){return l.createElement(Fo,Bt({},e,{ref:n,sideCar:sy}))});vl.classNames=Fo.classNames;var ry=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},es=new WeakMap,jr=new WeakMap,Sr={},Sa=0,Np=function(e){return e&&(e.host||Np(e.parentNode))},oy=function(e,n){return n.map(function(s){if(e.contains(s))return s;var r=Np(s);return r&&e.contains(r)?r:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},ay=function(e,n,s,r){var o=oy(n,Array.isArray(e)?e:[e]);Sr[s]||(Sr[s]=new WeakMap);var a=Sr[s],i=[],c=new Set,d=new Set(o),p=function(m){!m||c.has(m)||(c.add(m),p(m.parentNode))};o.forEach(p);var u=function(m){!m||d.has(m)||Array.prototype.forEach.call(m.children,function(f){if(c.has(f))u(f);else try{var h=f.getAttribute(r),g=h!==null&&h!=="false",v=(es.get(f)||0)+1,w=(a.get(f)||0)+1;es.set(f,v),a.set(f,w),i.push(f),v===1&&g&&jr.set(f,!0),w===1&&f.setAttribute(s,"true"),g||f.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return u(n),c.clear(),Sa++,function(){i.forEach(function(m){var f=es.get(m)-1,h=a.get(m)-1;es.set(m,f),a.set(m,h),f||(jr.has(m)||m.removeAttribute(r),jr.delete(m)),h||m.removeAttribute(s)}),Sa--,Sa||(es=new WeakMap,es=new WeakMap,jr=new WeakMap,Sr={})}},Cp=function(e,n,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=ry(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),ay(r,o,s,"aria-hidden")):function(){return null}},Bo="Dialog",[kp]=on(Bo),[iy,Dt]=kp(Bo),Tp=e=>{const{__scopeDialog:n,children:s,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[p,u]=$n({prop:r,defaultProp:o??!1,onChange:a,caller:Bo});return t.jsx(iy,{scope:n,triggerRef:c,contentRef:d,contentId:Ht(),titleId:Ht(),descriptionId:Ht(),open:p,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(m=>!m),[u]),modal:i,children:s})};Tp.displayName=Bo;var _p="DialogTrigger",Ep=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Dt(_p,s),a=Ae(n,o.triggerRef);return t.jsx(be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":wl(o.open),...r,ref:a,onClick:ue(e.onClick,o.onOpenToggle)})});Ep.displayName=_p;var yl="DialogPortal",[ly,Rp]=kp(yl,{forceMount:void 0}),Mp=e=>{const{__scopeDialog:n,forceMount:s,children:r,container:o}=e,a=Dt(yl,n);return t.jsx(ly,{scope:n,forceMount:s,children:l.Children.map(r,i=>t.jsx(wt,{present:s||a.open,children:t.jsx($o,{asChild:!0,container:o,children:i})}))})};Mp.displayName=yl;var co="DialogOverlay",Ap=l.forwardRef((e,n)=>{const s=Rp(co,e.__scopeDialog),{forceMount:r=s.forceMount,...o}=e,a=Dt(co,e.__scopeDialog);return a.modal?t.jsx(wt,{present:r||a.open,children:t.jsx(dy,{...o,ref:n})}):null});Ap.displayName=co;var cy=ws("DialogOverlay.RemoveScroll"),dy=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Dt(co,s),a=d2(),i=Ae(n,a);return t.jsx(vl,{as:cy,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(be.div,{"data-state":wl(o.open),...r,ref:i,style:{pointerEvents:"auto",...r.style}})})}),js="DialogContent",Ip=l.forwardRef((e,n)=>{const s=Rp(js,e.__scopeDialog),{forceMount:r=s.forceMount,...o}=e,a=Dt(js,e.__scopeDialog);return t.jsx(wt,{present:r||a.open,children:a.modal?t.jsx(uy,{...o,ref:n}):t.jsx(py,{...o,ref:n})})});Ip.displayName=js;var uy=l.forwardRef((e,n)=>{const s=Dt(js,e.__scopeDialog),r=l.useRef(null),o=Ae(n,s.contentRef,r);return l.useEffect(()=>{const a=r.current;if(a)return Cp(a)},[]),t.jsx(Pp,{...e,ref:o,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:ue(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:ue(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:ue(e.onFocusOutside,a=>a.preventDefault())})}),py=l.forwardRef((e,n)=>{const s=Dt(js,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return t.jsx(Pp,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||s.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;s.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Pp=l.forwardRef((e,n)=>{const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Dt(js,s);return xp(),t.jsx(t.Fragment,{children:t.jsx(bl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:t.jsx(Do,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":wl(c.open),...i,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),Lp="DialogTitle",Op=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Dt(Lp,s);return t.jsx(be.h2,{id:o.titleId,...r,ref:n})});Op.displayName=Lp;var zp="DialogDescription",Dp=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Dt(zp,s);return t.jsx(be.p,{id:o.descriptionId,...r,ref:n})});Dp.displayName=zp;var $p="DialogClose",Fp=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Dt($p,s);return t.jsx(be.button,{type:"button",...r,ref:n,onClick:ue(e.onClick,()=>o.onOpenChange(!1))})});Fp.displayName=$p;function wl(e){return e?"open":"closed"}function my(e){const n=l.useRef({value:e,previous:e});return l.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}function fy(e){const[n,s]=l.useState(void 0);return Ve(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,c;if("borderBoxSize"in a){const d=a.borderBoxSize,p=Array.isArray(d)?d[0]:d;i=p.inlineSize,c=p.blockSize}else i=e.offsetWidth,c=e.offsetHeight;s({width:i,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else s(void 0)},[e]),n}const hy=["top","right","bottom","left"],Nn=Math.min,ht=Math.max,uo=Math.round,Nr=Math.floor,Vt=e=>({x:e,y:e}),xy={left:"right",right:"left",bottom:"top",top:"bottom"},gy={start:"end",end:"start"};function gi(e,n,s){return ht(e,Nn(n,s))}function nn(e,n){return typeof e=="function"?e(n):e}function sn(e){return e.split("-")[0]}function Ms(e){return e.split("-")[1]}function jl(e){return e==="x"?"y":"x"}function Sl(e){return e==="y"?"height":"width"}const by=new Set(["top","bottom"]);function Ut(e){return by.has(sn(e))?"y":"x"}function Nl(e){return jl(Ut(e))}function vy(e,n,s){s===void 0&&(s=!1);const r=Ms(e),o=Nl(e),a=Sl(o);let i=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[a]>n.floating[a]&&(i=po(i)),[i,po(i)]}function yy(e){const n=po(e);return[bi(e),n,bi(n)]}function bi(e){return e.replace(/start|end/g,n=>gy[n])}const Ac=["left","right"],Ic=["right","left"],wy=["top","bottom"],jy=["bottom","top"];function Sy(e,n,s){switch(e){case"top":case"bottom":return s?n?Ic:Ac:n?Ac:Ic;case"left":case"right":return n?wy:jy;default:return[]}}function Ny(e,n,s,r){const o=Ms(e);let a=Sy(sn(e),s==="start",r);return o&&(a=a.map(i=>i+"-"+o),n&&(a=a.concat(a.map(bi)))),a}function po(e){return e.replace(/left|right|bottom|top/g,n=>xy[n])}function Cy(e){return{top:0,right:0,bottom:0,left:0,...e}}function Bp(e){return typeof e!="number"?Cy(e):{top:e,right:e,bottom:e,left:e}}function mo(e){const{x:n,y:s,width:r,height:o}=e;return{width:r,height:o,top:s,left:n,right:n+r,bottom:s+o,x:n,y:s}}function Pc(e,n,s){let{reference:r,floating:o}=e;const a=Ut(n),i=Nl(n),c=Sl(i),d=sn(n),p=a==="y",u=r.x+r.width/2-o.width/2,m=r.y+r.height/2-o.height/2,f=r[c]/2-o[c]/2;let h;switch(d){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:m};break;case"left":h={x:r.x-o.width,y:m};break;default:h={x:r.x,y:r.y}}switch(Ms(n)){case"start":h[i]-=f*(s&&p?-1:1);break;case"end":h[i]+=f*(s&&p?-1:1);break}return h}async function ky(e,n){var s;n===void 0&&(n={});const{x:r,y:o,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:p="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:f=!1,padding:h=0}=nn(n,e),g=Bp(h),w=c[f?m==="floating"?"reference":"floating":m],y=mo(await a.getClippingRect({element:(s=await(a.isElement==null?void 0:a.isElement(w)))==null||s?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:p,rootBoundary:u,strategy:d})),b=m==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),S=await(a.isElement==null?void 0:a.isElement(j))?await(a.getScale==null?void 0:a.getScale(j))||{x:1,y:1}:{x:1,y:1},N=mo(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:j,strategy:d}):b);return{top:(y.top-N.top+g.top)/S.y,bottom:(N.bottom-y.bottom+g.bottom)/S.y,left:(y.left-N.left+g.left)/S.x,right:(N.right-y.right+g.right)/S.x}}const Ty=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=s,c=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(n));let p=await i.getElementRects({reference:e,floating:n,strategy:o}),{x:u,y:m}=Pc(p,r,d),f=r,h={},g=0;for(let w=0;w<c.length;w++){var v;const{name:y,fn:b}=c[w],{x:j,y:S,data:N,reset:C}=await b({x:u,y:m,initialPlacement:r,placement:f,strategy:o,middlewareData:h,rects:p,platform:{...i,detectOverflow:(v=i.detectOverflow)!=null?v:ky},elements:{reference:e,floating:n}});u=j??u,m=S??m,h={...h,[y]:{...h[y],...N}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(p=C.rects===!0?await i.getElementRects({reference:e,floating:n,strategy:o}):C.rects),{x:u,y:m}=Pc(p,f,d)),w=-1)}return{x:u,y:m,placement:f,strategy:o,middlewareData:h}},_y=e=>({name:"arrow",options:e,async fn(n){const{x:s,y:r,placement:o,rects:a,platform:i,elements:c,middlewareData:d}=n,{element:p,padding:u=0}=nn(e,n)||{};if(p==null)return{};const m=Bp(u),f={x:s,y:r},h=Nl(o),g=Sl(h),v=await i.getDimensions(p),w=h==="y",y=w?"top":"left",b=w?"bottom":"right",j=w?"clientHeight":"clientWidth",S=a.reference[g]+a.reference[h]-f[h]-a.floating[g],N=f[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(p));let E=C?C[j]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=c.floating[j]||a.floating[g]);const A=S/2-N/2,I=E/2-v[g]/2-1,M=Nn(m[y],I),k=Nn(m[b],I),R=M,O=E-v[g]-k,$=E/2-v[g]/2+A,K=gi(R,$,O),ee=!d.arrow&&Ms(o)!=null&&$!==K&&a.reference[g]/2-($<R?M:k)-v[g]/2<0,D=ee?$<R?$-R:$-O:0;return{[h]:f[h]+D,data:{[h]:K,centerOffset:$-K-D,...ee&&{alignmentOffset:D}},reset:ee}}}),Ey=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:p}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...w}=nn(e,n);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const y=sn(o),b=Ut(c),j=sn(c)===c,S=await(d.isRTL==null?void 0:d.isRTL(p.floating)),N=f||(j||!v?[po(c)]:yy(c)),C=g!=="none";!f&&C&&N.push(...Ny(c,v,g,S));const E=[c,...N],A=await d.detectOverflow(n,w),I=[];let M=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&I.push(A[y]),m){const $=vy(o,i,S);I.push(A[$[0]],A[$[1]])}if(M=[...M,{placement:o,overflows:I}],!I.every($=>$<=0)){var k,R;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,K=E[$];if(K&&(!(m==="alignment"?b!==Ut(K):!1)||M.every(H=>Ut(H.placement)===b?H.overflows[0]>0:!0)))return{data:{index:$,overflows:M},reset:{placement:K}};let ee=(R=M.filter(D=>D.overflows[0]<=0).sort((D,H)=>D.overflows[1]-H.overflows[1])[0])==null?void 0:R.placement;if(!ee)switch(h){case"bestFit":{var O;const D=(O=M.filter(H=>{if(C){const te=Ut(H.placement);return te===b||te==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(te=>te>0).reduce((te,U)=>te+U,0)]).sort((H,te)=>H[1]-te[1])[0])==null?void 0:O[0];D&&(ee=D);break}case"initialPlacement":ee=c;break}if(o!==ee)return{reset:{placement:ee}}}return{}}}};function Lc(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function Oc(e){return hy.some(n=>e[n]>=0)}const Ry=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:s,platform:r}=n,{strategy:o="referenceHidden",...a}=nn(e,n);switch(o){case"referenceHidden":{const i=await r.detectOverflow(n,{...a,elementContext:"reference"}),c=Lc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Oc(c)}}}case"escaped":{const i=await r.detectOverflow(n,{...a,altBoundary:!0}),c=Lc(i,s.floating);return{data:{escapedOffsets:c,escaped:Oc(c)}}}default:return{}}}}},Up=new Set(["left","top"]);async function My(e,n){const{placement:s,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=sn(s),c=Ms(s),d=Ut(s)==="y",p=Up.has(i)?-1:1,u=a&&d?-1:1,m=nn(n,e);let{mainAxis:f,crossAxis:h,alignmentAxis:g}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),d?{x:h*u,y:f*p}:{x:f*p,y:h*u}}const Ay=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:o,y:a,placement:i,middlewareData:c}=n,d=await My(n,e);return i===((s=c.offset)==null?void 0:s.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:a+d.y,data:{...d,placement:i}}}}},Iy=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:r,placement:o,platform:a}=n,{mainAxis:i=!0,crossAxis:c=!1,limiter:d={fn:y=>{let{x:b,y:j}=y;return{x:b,y:j}}},...p}=nn(e,n),u={x:s,y:r},m=await a.detectOverflow(n,p),f=Ut(sn(o)),h=jl(f);let g=u[h],v=u[f];if(i){const y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",j=g+m[y],S=g-m[b];g=gi(j,g,S)}if(c){const y=f==="y"?"top":"left",b=f==="y"?"bottom":"right",j=v+m[y],S=v-m[b];v=gi(j,v,S)}const w=d.fn({...n,[h]:g,[f]:v});return{...w,data:{x:w.x-s,y:w.y-r,enabled:{[h]:i,[f]:c}}}}}},Py=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:s,y:r,placement:o,rects:a,middlewareData:i}=n,{offset:c=0,mainAxis:d=!0,crossAxis:p=!0}=nn(e,n),u={x:s,y:r},m=Ut(o),f=jl(m);let h=u[f],g=u[m];const v=nn(c,n),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(d){const j=f==="y"?"height":"width",S=a.reference[f]-a.floating[j]+w.mainAxis,N=a.reference[f]+a.reference[j]-w.mainAxis;h<S?h=S:h>N&&(h=N)}if(p){var y,b;const j=f==="y"?"width":"height",S=Up.has(sn(o)),N=a.reference[m]-a.floating[j]+(S&&((y=i.offset)==null?void 0:y[m])||0)+(S?0:w.crossAxis),C=a.reference[m]+a.reference[j]+(S?0:((b=i.offset)==null?void 0:b[m])||0)-(S?w.crossAxis:0);g<N?g=N:g>C&&(g=C)}return{[f]:h,[m]:g}}}},Ly=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var s,r;const{placement:o,rects:a,platform:i,elements:c}=n,{apply:d=()=>{},...p}=nn(e,n),u=await i.detectOverflow(n,p),m=sn(o),f=Ms(o),h=Ut(o)==="y",{width:g,height:v}=a.floating;let w,y;m==="top"||m==="bottom"?(w=m,y=f===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(y=m,w=f==="end"?"top":"bottom");const b=v-u.top-u.bottom,j=g-u.left-u.right,S=Nn(v-u[w],b),N=Nn(g-u[y],j),C=!n.middlewareData.shift;let E=S,A=N;if((s=n.middlewareData.shift)!=null&&s.enabled.x&&(A=j),(r=n.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!f){const M=ht(u.left,0),k=ht(u.right,0),R=ht(u.top,0),O=ht(u.bottom,0);h?A=g-2*(M!==0||k!==0?M+k:ht(u.left,u.right)):E=v-2*(R!==0||O!==0?R+O:ht(u.top,u.bottom))}await d({...n,availableWidth:A,availableHeight:E});const I=await i.getDimensions(c.floating);return g!==I.width||v!==I.height?{reset:{rects:!0}}:{}}}};function Uo(){return typeof window<"u"}function As(e){return qp(e)?(e.nodeName||"").toLowerCase():"#document"}function vt(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function Yt(e){var n;return(n=(qp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function qp(e){return Uo()?e instanceof Node||e instanceof vt(e).Node:!1}function Ot(e){return Uo()?e instanceof Element||e instanceof vt(e).Element:!1}function Wt(e){return Uo()?e instanceof HTMLElement||e instanceof vt(e).HTMLElement:!1}function zc(e){return!Uo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vt(e).ShadowRoot}const Oy=new Set(["inline","contents"]);function ur(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=zt(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&!Oy.has(o)}const zy=new Set(["table","td","th"]);function Dy(e){return zy.has(As(e))}const $y=[":popover-open",":modal"];function qo(e){return $y.some(n=>{try{return e.matches(n)}catch{return!1}})}const Fy=["transform","translate","scale","rotate","perspective"],By=["transform","translate","scale","rotate","perspective","filter"],Uy=["paint","layout","strict","content"];function Cl(e){const n=kl(),s=Ot(e)?zt(e):e;return Fy.some(r=>s[r]?s[r]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!n&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!n&&(s.filter?s.filter!=="none":!1)||By.some(r=>(s.willChange||"").includes(r))||Uy.some(r=>(s.contain||"").includes(r))}function qy(e){let n=Cn(e);for(;Wt(n)&&!Ss(n);){if(Cl(n))return n;if(qo(n))return null;n=Cn(n)}return null}function kl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Hy=new Set(["html","body","#document"]);function Ss(e){return Hy.has(As(e))}function zt(e){return vt(e).getComputedStyle(e)}function Ho(e){return Ot(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Cn(e){if(As(e)==="html")return e;const n=e.assignedSlot||e.parentNode||zc(e)&&e.host||Yt(e);return zc(n)?n.host:n}function Hp(e){const n=Cn(e);return Ss(n)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(n)&&ur(n)?n:Hp(n)}function Qs(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=Hp(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=vt(o);if(a){const c=vi(i);return n.concat(i,i.visualViewport||[],ur(o)?o:[],c&&s?Qs(c):[])}return n.concat(o,Qs(o,[],s))}function vi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Vp(e){const n=zt(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=Wt(e),a=o?e.offsetWidth:s,i=o?e.offsetHeight:r,c=uo(s)!==a||uo(r)!==i;return c&&(s=a,r=i),{width:s,height:r,$:c}}function Tl(e){return Ot(e)?e:e.contextElement}function hs(e){const n=Tl(e);if(!Wt(n))return Vt(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:a}=Vp(n);let i=(a?uo(s.width):s.width)/r,c=(a?uo(s.height):s.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Vy=Vt(0);function Wp(e){const n=vt(e);return!kl()||!n.visualViewport?Vy:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function Wy(e,n,s){return n===void 0&&(n=!1),!s||n&&s!==vt(e)?!1:n}function Fn(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),a=Tl(e);let i=Vt(1);n&&(r?Ot(r)&&(i=hs(r)):i=hs(e));const c=Wy(a,s,r)?Wp(a):Vt(0);let d=(o.left+c.x)/i.x,p=(o.top+c.y)/i.y,u=o.width/i.x,m=o.height/i.y;if(a){const f=vt(a),h=r&&Ot(r)?vt(r):r;let g=f,v=vi(g);for(;v&&r&&h!==g;){const w=hs(v),y=v.getBoundingClientRect(),b=zt(v),j=y.left+(v.clientLeft+parseFloat(b.paddingLeft))*w.x,S=y.top+(v.clientTop+parseFloat(b.paddingTop))*w.y;d*=w.x,p*=w.y,u*=w.x,m*=w.y,d+=j,p+=S,g=vt(v),v=vi(g)}}return mo({width:u,height:m,x:d,y:p})}function Vo(e,n){const s=Ho(e).scrollLeft;return n?n.left+s:Fn(Yt(e)).left+s}function Gp(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-Vo(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function Gy(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Yt(r),c=n?qo(n.floating):!1;if(r===i||c&&a)return s;let d={scrollLeft:0,scrollTop:0},p=Vt(1);const u=Vt(0),m=Wt(r);if((m||!m&&!a)&&((As(r)!=="body"||ur(i))&&(d=Ho(r)),Wt(r))){const h=Fn(r);p=hs(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=i&&!m&&!a?Gp(i,d):Vt(0);return{width:s.width*p.x,height:s.height*p.y,x:s.x*p.x-d.scrollLeft*p.x+u.x+f.x,y:s.y*p.y-d.scrollTop*p.y+u.y+f.y}}function Ky(e){return Array.from(e.getClientRects())}function Yy(e){const n=Yt(e),s=Ho(e),r=e.ownerDocument.body,o=ht(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),a=ht(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let i=-s.scrollLeft+Vo(e);const c=-s.scrollTop;return zt(r).direction==="rtl"&&(i+=ht(n.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:c}}const Dc=25;function Jy(e,n){const s=vt(e),r=Yt(e),o=s.visualViewport;let a=r.clientWidth,i=r.clientHeight,c=0,d=0;if(o){a=o.width,i=o.height;const u=kl();(!u||u&&n==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const p=Vo(r);if(p<=0){const u=r.ownerDocument,m=u.body,f=getComputedStyle(m),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(r.clientWidth-m.clientWidth-h);g<=Dc&&(a-=g)}else p<=Dc&&(a+=p);return{width:a,height:i,x:c,y:d}}const Xy=new Set(["absolute","fixed"]);function Zy(e,n){const s=Fn(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,a=Wt(e)?hs(e):Vt(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,d=o*a.x,p=r*a.y;return{width:i,height:c,x:d,y:p}}function $c(e,n,s){let r;if(n==="viewport")r=Jy(e,s);else if(n==="document")r=Yy(Yt(e));else if(Ot(n))r=Zy(n,s);else{const o=Wp(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return mo(r)}function Kp(e,n){const s=Cn(e);return s===n||!Ot(s)||Ss(s)?!1:zt(s).position==="fixed"||Kp(s,n)}function Qy(e,n){const s=n.get(e);if(s)return s;let r=Qs(e,[],!1).filter(c=>Ot(c)&&As(c)!=="body"),o=null;const a=zt(e).position==="fixed";let i=a?Cn(e):e;for(;Ot(i)&&!Ss(i);){const c=zt(i),d=Cl(i);!d&&c.position==="fixed"&&(o=null),(a?!d&&!o:!d&&c.position==="static"&&!!o&&Xy.has(o.position)||ur(i)&&!d&&Kp(e,i))?r=r.filter(u=>u!==i):o=c,i=Cn(i)}return n.set(e,r),r}function ew(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const i=[...s==="clippingAncestors"?qo(n)?[]:Qy(n,this._c):[].concat(s),r],c=i[0],d=i.reduce((p,u)=>{const m=$c(n,u,o);return p.top=ht(m.top,p.top),p.right=Nn(m.right,p.right),p.bottom=Nn(m.bottom,p.bottom),p.left=ht(m.left,p.left),p},$c(n,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function tw(e){const{width:n,height:s}=Vp(e);return{width:n,height:s}}function nw(e,n,s){const r=Wt(n),o=Yt(n),a=s==="fixed",i=Fn(e,!0,a,n);let c={scrollLeft:0,scrollTop:0};const d=Vt(0);function p(){d.x=Vo(o)}if(r||!r&&!a)if((As(n)!=="body"||ur(o))&&(c=Ho(n)),r){const h=Fn(n,!0,a,n);d.x=h.x+n.clientLeft,d.y=h.y+n.clientTop}else o&&p();a&&!r&&o&&p();const u=o&&!r&&!a?Gp(o,c):Vt(0),m=i.left+c.scrollLeft-d.x-u.x,f=i.top+c.scrollTop-d.y-u.y;return{x:m,y:f,width:i.width,height:i.height}}function Na(e){return zt(e).position==="static"}function Fc(e,n){if(!Wt(e)||zt(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return Yt(e)===s&&(s=s.ownerDocument.body),s}function Yp(e,n){const s=vt(e);if(qo(e))return s;if(!Wt(e)){let o=Cn(e);for(;o&&!Ss(o);){if(Ot(o)&&!Na(o))return o;o=Cn(o)}return s}let r=Fc(e,n);for(;r&&Dy(r)&&Na(r);)r=Fc(r,n);return r&&Ss(r)&&Na(r)&&!Cl(r)?s:r||qy(e)||s}const sw=async function(e){const n=this.getOffsetParent||Yp,s=this.getDimensions,r=await s(e.floating);return{reference:nw(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function rw(e){return zt(e).direction==="rtl"}const ow={convertOffsetParentRelativeRectToViewportRelativeRect:Gy,getDocumentElement:Yt,getClippingRect:ew,getOffsetParent:Yp,getElementRects:sw,getClientRects:Ky,getDimensions:tw,getScale:hs,isElement:Ot,isRTL:rw};function Jp(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function aw(e,n){let s=null,r;const o=Yt(e);function a(){var c;clearTimeout(r),(c=s)==null||c.disconnect(),s=null}function i(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),a();const p=e.getBoundingClientRect(),{left:u,top:m,width:f,height:h}=p;if(c||n(),!f||!h)return;const g=Nr(m),v=Nr(o.clientWidth-(u+f)),w=Nr(o.clientHeight-(m+h)),y=Nr(u),j={rootMargin:-g+"px "+-v+"px "+-w+"px "+-y+"px",threshold:ht(0,Nn(1,d))||1};let S=!0;function N(C){const E=C[0].intersectionRatio;if(E!==d){if(!S)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Jp(p,e.getBoundingClientRect())&&i(),S=!1}try{s=new IntersectionObserver(N,{...j,root:o.ownerDocument})}catch{s=new IntersectionObserver(N,j)}s.observe(e)}return i(!0),a}function iw(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,p=Tl(e),u=o||a?[...p?Qs(p):[],...Qs(n)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",s,{passive:!0}),a&&y.addEventListener("resize",s)});const m=p&&c?aw(p,s):null;let f=-1,h=null;i&&(h=new ResizeObserver(y=>{let[b]=y;b&&b.target===p&&h&&(h.unobserve(n),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(n)})),s()}),p&&!d&&h.observe(p),h.observe(n));let g,v=d?Fn(e):null;d&&w();function w(){const y=Fn(e);v&&!Jp(v,y)&&s(),v=y,g=requestAnimationFrame(w)}return s(),()=>{var y;u.forEach(b=>{o&&b.removeEventListener("scroll",s),a&&b.removeEventListener("resize",s)}),m?.(),(y=h)==null||y.disconnect(),h=null,d&&cancelAnimationFrame(g)}}const lw=Ay,cw=Iy,dw=Ey,uw=Ly,pw=Ry,Bc=_y,mw=Py,fw=(e,n,s)=>{const r=new Map,o={platform:ow,...s},a={...o.platform,_c:r};return Ty(e,n,{...o,platform:a})};var hw=typeof document<"u",xw=function(){},Kr=hw?l.useLayoutEffect:xw;function fo(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,r,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(r=s;r--!==0;)if(!fo(e[r],n[r]))return!1;return!0}if(o=Object.keys(e),s=o.length,s!==Object.keys(n).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(n,o[r]))return!1;for(r=s;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!fo(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}function Xp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Uc(e,n){const s=Xp(e);return Math.round(n*s)/s}function Ca(e){const n=l.useRef(e);return Kr(()=>{n.current=e}),n}function gw(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:d,open:p}=e,[u,m]=l.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[f,h]=l.useState(r);fo(f,r)||h(r);const[g,v]=l.useState(null),[w,y]=l.useState(null),b=l.useCallback(H=>{H!==C.current&&(C.current=H,v(H))},[]),j=l.useCallback(H=>{H!==E.current&&(E.current=H,y(H))},[]),S=a||g,N=i||w,C=l.useRef(null),E=l.useRef(null),A=l.useRef(u),I=d!=null,M=Ca(d),k=Ca(o),R=Ca(p),O=l.useCallback(()=>{if(!C.current||!E.current)return;const H={placement:n,strategy:s,middleware:f};k.current&&(H.platform=k.current),fw(C.current,E.current,H).then(te=>{const U={...te,isPositioned:R.current!==!1};$.current&&!fo(A.current,U)&&(A.current=U,Es.flushSync(()=>{m(U)}))})},[f,n,s,k,R]);Kr(()=>{p===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,m(H=>({...H,isPositioned:!1})))},[p]);const $=l.useRef(!1);Kr(()=>($.current=!0,()=>{$.current=!1}),[]),Kr(()=>{if(S&&(C.current=S),N&&(E.current=N),S&&N){if(M.current)return M.current(S,N,O);O()}},[S,N,O,M,I]);const K=l.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:j}),[b,j]),ee=l.useMemo(()=>({reference:S,floating:N}),[S,N]),D=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!ee.floating)return H;const te=Uc(ee.floating,u.x),U=Uc(ee.floating,u.y);return c?{...H,transform:"translate("+te+"px, "+U+"px)",...Xp(ee.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:te,top:U}},[s,c,ee.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:O,refs:K,elements:ee,floatingStyles:D}),[u,O,K,ee,D])}const bw=e=>{function n(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:r,padding:o}=typeof e=="function"?e(s):e;return r&&n(r)?r.current!=null?Bc({element:r.current,padding:o}).fn(s):{}:r?Bc({element:r,padding:o}).fn(s):{}}}},vw=(e,n)=>({...lw(e),options:[e,n]}),yw=(e,n)=>({...cw(e),options:[e,n]}),ww=(e,n)=>({...mw(e),options:[e,n]}),jw=(e,n)=>({...dw(e),options:[e,n]}),Sw=(e,n)=>({...uw(e),options:[e,n]}),Nw=(e,n)=>({...pw(e),options:[e,n]}),Cw=(e,n)=>({...bw(e),options:[e,n]});var kw="Arrow",Zp=l.forwardRef((e,n)=>{const{children:s,width:r=10,height:o=5,...a}=e;return t.jsx(be.svg,{...a,ref:n,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Zp.displayName=kw;var Tw=Zp,_l="Popper",[Qp,Wo]=on(_l),[_w,em]=Qp(_l),tm=e=>{const{__scopePopper:n,children:s}=e,[r,o]=l.useState(null),[a,i]=l.useState(void 0);return t.jsx(_w,{scope:n,anchor:r,onAnchorChange:o,placementState:a,setPlacementState:i,children:s})};tm.displayName=_l;var nm="PopperAnchor",sm=l.forwardRef((e,n)=>{const{__scopePopper:s,virtualRef:r,...o}=e,a=em(nm,s),i=l.useRef(null),c=a.onAnchorChange,d=l.useCallback(g=>{i.current=g,g&&c(g)},[c]),p=Ae(n,d),u=l.useRef(null);l.useEffect(()=>{if(!r)return;const g=u.current;u.current=r.current,g!==u.current&&c(u.current)});const m=a.placementState&&Rl(a.placementState),f=m?.[0],h=m?.[1];return r?null:t.jsx(be.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...o,ref:p})});sm.displayName=nm;var El="PopperContent",[Ew,Rw]=Qp(El),rm=l.forwardRef((e,n)=>{const{__scopePopper:s,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:p=[],collisionPadding:u=0,sticky:m="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:g,...v}=e,w=em(El,s),[y,b]=l.useState(null),j=Ae(n,b),[S,N]=l.useState(null),C=fy(S),E=C?.width??0,A=C?.height??0,I=r+(a!=="center"?"-"+a:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(p)?p:[p],R=k.length>0,O={padding:M,boundary:k.filter(Aw),altBoundary:R},{refs:$,floatingStyles:K,placement:ee,isPositioned:D,middlewareData:H}=gw({strategy:"fixed",placement:I,whileElementsMounted:(...Se)=>iw(...Se,{animationFrame:h==="always"}),elements:{reference:w.anchor},middleware:[vw({mainAxis:o+A,alignmentAxis:i}),d&&yw({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?ww():void 0,...O}),d&&jw({...O}),Sw({...O,apply:({elements:Se,rects:_e,availableWidth:ge,availableHeight:le})=>{const{width:ce,height:Pe}=_e.reference,Re=Se.floating.style;Re.setProperty("--radix-popper-available-width",`${ge}px`),Re.setProperty("--radix-popper-available-height",`${le}px`),Re.setProperty("--radix-popper-anchor-width",`${ce}px`),Re.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),S&&Cw({element:S,padding:c}),Iw({arrowWidth:E,arrowHeight:A}),f&&Nw({strategy:"referenceHidden",...O,boundary:R?O.boundary:void 0})]}),te=w.setPlacementState;Ve(()=>(te(ee),()=>{te(void 0)}),[ee,te]);const[U,Q]=Rl(ee),fe=Je(g);Ve(()=>{D&&fe?.()},[D,fe]);const je=H.arrow?.x,he=H.arrow?.y,re=H.arrow?.centerOffset!==0,[P,X]=l.useState();return Ve(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:D?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:P,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Ew,{scope:s,placedSide:U,placedAlign:Q,onArrowChange:N,arrowX:je,arrowY:he,shouldHideArrow:re,children:t.jsx(be.div,{"data-side":U,"data-align":Q,...v,ref:j,style:{...v.style,animation:D?void 0:"none"}})})})});rm.displayName=El;var om="PopperArrow",Mw={top:"bottom",right:"left",bottom:"top",left:"right"},am=l.forwardRef(function(n,s){const{__scopePopper:r,...o}=n,a=Rw(om,r),i=Mw[a.placedSide];return t.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:t.jsx(Tw,{...o,ref:s,style:{...o.style,display:"block"}})})});am.displayName=om;function Aw(e){return e!==null}var Iw=e=>({name:"transformOrigin",options:e,fn(n){const{placement:s,rects:r,middlewareData:o}=n,i=o.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[p,u]=Rl(s),m={start:"0%",center:"50%",end:"100%"}[u],f=(o.arrow?.x??0)+c/2,h=(o.arrow?.y??0)+d/2;let g="",v="";return p==="bottom"?(g=i?m:`${f}px`,v=`${-d}px`):p==="top"?(g=i?m:`${f}px`,v=`${r.floating.height+d}px`):p==="right"?(g=`${-d}px`,v=i?m:`${h}px`):p==="left"&&(g=`${r.floating.width+d}px`,v=i?m:`${h}px`),{data:{x:g,y:v}}}});function Rl(e){const[n,s="center"]=e.split("-");return[n,s]}var im=tm,lm=sm,cm=rm,dm=am,ka=!1;function Pw(){const[e,n]=l.useState(ka);return l.useEffect(()=>{ka||(ka=!0,n(!0))},[]),e}var um=Mo[" useSyncExternalStore ".trim().toString()];function Lw(){return()=>{}}function Ow(){return um(Lw,()=>!0,()=>!1)}var zw=typeof um=="function"?Ow:Pw,Ta="rovingFocusGroup.onEntryFocus",Dw={bubbles:!1,cancelable:!0},pr="RovingFocusGroup",[yi,pm,$w]=cp(pr),[Fw,mm]=on(pr,[$w]),[Bw,Uw]=Fw(pr),fm=l.forwardRef((e,n)=>t.jsx(yi.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(yi.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(qw,{...e,ref:n})})}));fm.displayName=pr;var qw=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:p,preventScrollOnEntryFocus:u=!1,...m}=e,f=l.useRef(null),h=Ae(n,f),g=zo(a),[v,w]=$n({prop:i,defaultProp:c??null,onChange:d,caller:pr}),[y,b]=l.useState(!1),j=Je(p),S=pm(s),N=l.useRef(!1),[C,E]=l.useState(0);return l.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Ta,j),()=>A.removeEventListener(Ta,j)},[j]),t.jsx(Bw,{scope:s,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:l.useCallback(A=>w(A),[w]),onItemShiftTab:l.useCallback(()=>b(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:l.useCallback(()=>E(A=>A-1),[]),children:t.jsx(be.div,{tabIndex:y||C===0?-1:0,"data-orientation":r,...m,ref:h,style:{outline:"none",...e.style},onMouseDown:ue(e.onMouseDown,()=>{N.current=!0}),onFocus:ue(e.onFocus,A=>{const I=!N.current;if(A.target===A.currentTarget&&I&&!y){const M=new CustomEvent(Ta,Dw);if(A.currentTarget.dispatchEvent(M),!M.defaultPrevented){const k=S().filter(ee=>ee.focusable),R=k.find(ee=>ee.active),O=k.find(ee=>ee.id===v),K=[R,O,...k].filter(Boolean).map(ee=>ee.ref.current);gm(K,u)}}N.current=!1}),onBlur:ue(e.onBlur,()=>b(!1))})})}),hm="RovingFocusGroupItem",xm=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...c}=e,d=Ht(),p=a||d,u=Uw(hm,s),m=u.currentTabStopId===p,f=pm(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:v}=u,w=zw();return Ve(()=>{if(!(!w||!r))return h(),()=>g()},[w,r,h,g]),l.useEffect(()=>{if(!(w||!r))return h(),()=>g()},[w,r,h,g]),t.jsx(yi.ItemSlot,{scope:s,id:p,focusable:r,active:o,children:t.jsx(be.span,{tabIndex:m?0:-1,"data-orientation":u.orientation,...c,ref:n,onMouseDown:ue(e.onMouseDown,y=>{r?u.onItemFocus(p):y.preventDefault()}),onFocus:ue(e.onFocus,()=>u.onItemFocus(p)),onKeyDown:ue(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const b=Ww(y,u.orientation,u.dir);if(b!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let S=f().filter(N=>N.focusable).map(N=>N.ref.current);if(b==="last")S.reverse();else if(b==="prev"||b==="next"){b==="prev"&&S.reverse();const N=S.indexOf(y.currentTarget);S=u.loop?Gw(S,N+1):S.slice(N+1)}setTimeout(()=>gm(S))}}),children:typeof i=="function"?i({isCurrentTabStop:m,hasTabStop:v!=null}):i})})});xm.displayName=hm;var Hw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Vw(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ww(e,n,s){const r=Vw(e.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Hw[r]}function gm(e,n=!1){const s=document.activeElement;for(const r of e)if(r===s||(r.focus({preventScroll:n}),document.activeElement!==s))return}function Gw(e,n){return e.map((s,r)=>e[(n+r)%e.length])}var Kw=fm,Yw=xm;function wi(e,[n,s]){return Math.min(s,Math.max(n,e))}function Jw(e,n){return l.useReducer((s,r)=>n[s][r]??s,e)}var Ml="ScrollArea",[bm]=on(Ml),[Xw,kt]=bm(Ml),vm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,type:r="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[p,u]=l.useState(null),[m,f]=l.useState(null),[h,g]=l.useState(null),[v,w]=l.useState(null),[y,b]=l.useState(0),[j,S]=l.useState(0),[N,C]=l.useState(!1),[E,A]=l.useState(!1),I=Ae(n,d),M=zo(o);return t.jsx(Xw,{scope:s,type:r,dir:M,scrollHideDelay:a,scrollArea:c,viewport:p,onViewportChange:u,content:m,onContentChange:f,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:N,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:w,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:S,children:t.jsx(be.div,{dir:M,...i,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});vm.displayName=Ml;var ym="ScrollAreaViewport",wm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,children:r,nonce:o,...a}=e,i=kt(ym,s),c=l.useRef(null),d=Ae(n,c,i.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx(Zw,{nonce:o}),t.jsx(be.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});wm.displayName=ym;var Zw=l.memo(({nonce:e})=>t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,n)=>e.nonce===n.nonce),Jt="ScrollAreaScrollbar",jm=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=kt(Jt,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),o.type==="hover"?t.jsx(Qw,{...r,ref:n,forceMount:s}):o.type==="scroll"?t.jsx(ej,{...r,ref:n,forceMount:s}):o.type==="auto"?t.jsx(Sm,{...r,ref:n,forceMount:s}):o.type==="always"?t.jsx(Al,{...r,ref:n,"data-state":"visible"}):null});jm.displayName=Jt;var Qw=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=kt(Jt,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const p=()=>{window.clearTimeout(d),i(!0)},u=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",p),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",p),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),t.jsx(wt,{present:s||a,children:t.jsx(Sm,{"data-state":a?"visible":"hidden",...r,ref:n})})}),ej=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=kt(Jt,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Ko(()=>d("SCROLL_END"),100),[c,d]=Jw("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const p=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(p)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const p=o.viewport,u=a?"scrollLeft":"scrollTop";if(p){let m=p[u];const f=()=>{const h=p[u];m!==h&&(d("SCROLL"),i()),m=h};return p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[o.viewport,a,d,i]),t.jsx(wt,{present:s||c!=="hidden",children:t.jsx(Al,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:n,onPointerEnter:ue(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:ue(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Sm=l.forwardRef((e,n)=>{const s=kt(Jt,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Ko(()=>{if(s.viewport){const p=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?p:u)}},10);return Ns(s.viewport,d),Ns(s.content,d),t.jsx(wt,{present:r||a,children:t.jsx(Al,{"data-state":a?"visible":"hidden",...o,ref:n})})}),Al=l.forwardRef((e,n)=>{const{orientation:s="vertical",...r}=e,o=kt(Jt,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),p=_m(c.viewport,c.content),u={...r,sizes:c,onSizesChange:d,hasThumb:p>0&&p<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function m(f,h){return aj(f,i.current,c,h)}return s==="horizontal"?t.jsx(tj,{...u,ref:n,onThumbPositionChange:()=>{if(o.viewport&&a.current){const f=o.viewport.scrollLeft,h=qc(f,c,o.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{o.viewport&&(o.viewport.scrollLeft=f)},onDragScroll:f=>{o.viewport&&(o.viewport.scrollLeft=m(f,o.dir))}}):s==="vertical"?t.jsx(nj,{...u,ref:n,onThumbPositionChange:()=>{if(o.viewport&&a.current){const f=o.viewport.scrollTop,h=qc(f,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{o.viewport&&(o.viewport.scrollTop=f)},onDragScroll:f=>{o.viewport&&(o.viewport.scrollTop=m(f))}}):null}),tj=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:r,...o}=e,a=kt(Jt,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),p=Ae(n,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Cm,{"data-orientation":"horizontal",...o,ref:p,sizes:s,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Go(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,m)=>{if(a.viewport){const f=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(f),Rm(f,m)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:xo(i.paddingLeft),paddingEnd:xo(i.paddingRight)}})}})}),nj=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:r,...o}=e,a=kt(Jt,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),p=Ae(n,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Cm,{"data-orientation":"vertical",...o,ref:p,sizes:s,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Go(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,m)=>{if(a.viewport){const f=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(f),Rm(f,m)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:xo(i.paddingTop),paddingEnd:xo(i.paddingBottom)}})}})}),[sj,Nm]=bm(Jt),Cm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:p,onWheelScroll:u,onResize:m,...f}=e,h=kt(Jt,s),[g,v]=l.useState(null),w=Ae(n,v),y=l.useRef(null),b=l.useRef(""),j=h.viewport,S=r.content-r.viewport,N=Je(u),C=Je(d),E=Ko(m,10);function A(I){if(y.current){const M=I.clientX-y.current.left,k=I.clientY-y.current.top;p({x:M,y:k})}}return l.useEffect(()=>{const I=M=>{const k=M.target;g?.contains(k)&&N(M,S)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[j,g,S,N]),l.useEffect(C,[r,C]),Ns(g,E),Ns(h.content,E),t.jsx(sj,{scope:s,scrollbar:g,hasThumb:o,onThumbChange:Je(a),onThumbPointerUp:Je(i),onThumbPositionChange:C,onThumbPointerDown:Je(c),children:t.jsx(be.div,{...f,ref:w,style:{position:"absolute",...f.style},onPointerDown:ue(e.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),y.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),A(I))}),onPointerMove:ue(e.onPointerMove,A),onPointerUp:ue(e.onPointerUp,I=>{const M=I.target;M.hasPointerCapture(I.pointerId)&&M.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),ho="ScrollAreaThumb",km=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=Nm(ho,e.__scopeScrollArea);return t.jsx(wt,{present:s||o.hasThumb,children:t.jsx(rj,{ref:n,...r})})}),rj=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,style:r,...o}=e,a=kt(ho,s),i=Nm(ho,s),{onThumbPositionChange:c}=i,d=Ae(n,i.onThumbChange),p=l.useRef(void 0),u=Ko(()=>{p.current&&(p.current(),p.current=void 0)},100);return l.useEffect(()=>{const m=a.viewport;if(m){const f=()=>{if(u(),!p.current){const h=ij(m,c);p.current=h,c()}};return c(),m.addEventListener("scroll",f),()=>m.removeEventListener("scroll",f)}},[a.viewport,u,c]),t.jsx(be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ue(e.onPointerDownCapture,m=>{const h=m.target.getBoundingClientRect(),g=m.clientX-h.left,v=m.clientY-h.top;i.onThumbPointerDown({x:g,y:v})}),onPointerUp:ue(e.onPointerUp,i.onThumbPointerUp)})});km.displayName=ho;var Il="ScrollAreaCorner",Tm=l.forwardRef((e,n)=>{const s=kt(Il,e.__scopeScrollArea),r=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&r?t.jsx(oj,{...e,ref:n}):null});Tm.displayName=Il;var oj=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,...r}=e,o=kt(Il,s),[a,i]=l.useState(0),[c,d]=l.useState(0),p=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:m}=o;return Ns(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),d(f)}),Ns(o.scrollbarY,()=>{const f=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(f),i(f)}),l.useEffect(()=>()=>{u(0),m(0)},[u,m]),p?t.jsx(be.div,{...r,ref:n,style:{width:a,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function xo(e){return e?parseInt(e,10):0}function _m(e,n){const s=e/n;return isNaN(s)?0:s}function Go(e){const n=_m(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-s)*n;return Math.max(r,18)}function aj(e,n,s,r="ltr"){const o=Go(s),a=o/2,i=n||a,c=o-i,d=s.scrollbar.paddingStart+i,p=s.scrollbar.size-s.scrollbar.paddingEnd-c,u=s.content-s.viewport,m=r==="ltr"?[0,u]:[u*-1,0];return Em([d,p],m)(e)}function qc(e,n,s="ltr"){const r=Go(n),o=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,a=n.scrollbar.size-o,i=n.content-n.viewport,c=a-r,d=s==="ltr"?[0,i]:[i*-1,0],p=wi(e,d);return Em([0,i],[0,c])(p)}function Em(e,n){return s=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const r=(n[1]-n[0])/(e[1]-e[0]);return n[0]+r*(s-e[0])}}function Rm(e,n){return e>0&&e<n}var ij=(e,n=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},r=0;return(function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=s.left!==a.left,c=s.top!==a.top;(i||c)&&n(),s=a,r=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(r)};function Ko(e,n){const s=Je(e),r=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),l.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(s,n)},[s,n])}function Ns(e,n){const s=Je(n);Ve(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(s)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,s])}var lj=vm,cj=wm,dj=Tm,uj=[" ","Enter","ArrowUp","ArrowDown"],pj=[" ","Enter"],Bn="Select",[Yo,Jo,mj]=cp(Bn),[Hn]=on(Bn,[mj,Wo]),Xo=Wo(),[fj,_n]=Hn(Bn),[hj,xj]=Hn(Bn),gj="SelectProvider";function Mm(e){const{__scopeSelect:n,children:s,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:d,dir:p,name:u,autoComplete:m,disabled:f,required:h,form:g,internal_do_not_use_render:v}=e,w=Xo(n),[y,b]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),E=zo(p),[A,I]=$n({prop:r,defaultProp:o??!1,onChange:a,caller:Bn}),[M,k]=$n({prop:i,defaultProp:c,onChange:d,caller:Bn}),R=l.useRef(null),O=l.useRef(M);l.useEffect(()=>{const fe=g?y?.ownerDocument.getElementById(g):y?.form;if(fe instanceof HTMLFormElement){const je=()=>k(O.current);return fe.addEventListener("reset",je),()=>fe.removeEventListener("reset",je)}},[g,y,k]);const $=y?!!g||!!y.closest("form"):!0,[K,ee]=l.useState(new Set),D=Ht(),H=Array.from(K).map(fe=>fe.props.value).join(";"),te=l.useCallback(fe=>{ee(je=>new Set(je).add(fe))},[]),U=l.useCallback(fe=>{ee(je=>{const he=new Set(je);return he.delete(fe),he})},[]),Q={required:h,trigger:y,onTriggerChange:b,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:D,value:M,onValueChange:k,open:A,onOpenChange:I,dir:E,triggerPointerDownPosRef:R,disabled:f,name:u,autoComplete:m,form:g,nativeOptions:K,nativeSelectKey:H,isFormControl:$};return t.jsx(im,{...w,children:t.jsx(fj,{scope:n,...Q,children:t.jsx(Yo.Provider,{scope:n,children:t.jsx(hj,{scope:n,onNativeOptionAdd:te,onNativeOptionRemove:U,children:Pj(v)?v(Q):s})})})})}Mm.displayName=gj;var Am=e=>{const{__scopeSelect:n,children:s,...r}=e;return t.jsx(Mm,{__scopeSelect:n,...r,internal_do_not_use_render:({isFormControl:o})=>t.jsxs(t.Fragment,{children:[s,o?t.jsx(rf,{__scopeSelect:n}):null]})})};Am.displayName=Bn;var Im="SelectTrigger",Pm=l.forwardRef((e,n)=>{const{__scopeSelect:s,disabled:r=!1,...o}=e,a=Xo(s),i=_n(Im,s),c=i.disabled||r,d=Ae(n,i.onTriggerChange),p=Jo(s),u=l.useRef("touch"),[m,f,h]=of(v=>{const w=p().filter(j=>!j.disabled),y=w.find(j=>j.value===i.value),b=af(w,v,y);b!==void 0&&i.onValueChange(b.value)}),g=v=>{c||(i.onOpenChange(!0),h()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return t.jsx(lm,{asChild:!0,...a,children:t.jsx(be.button,{type:"button",role:"combobox","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Zo(i.value)?"":void 0,...o,ref:d,onClick:ue(o.onClick,v=>{v.currentTarget.focus(),u.current!=="mouse"&&g(v)}),onPointerDown:ue(o.onPointerDown,v=>{u.current=v.pointerType;const w=v.target;w.hasPointerCapture(v.pointerId)&&w.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(g(v),v.preventDefault())}),onKeyDown:ue(o.onKeyDown,v=>{const w=m.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(w&&v.key===" ")&&uj.includes(v.key)&&(g(),v.preventDefault())})})})});Pm.displayName=Im;var Lm="SelectValue",Om=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:r,style:o,children:a,placeholder:i="",...c}=e,d=_n(Lm,s),{onValueNodeHasChildrenChange:p}=d,u=a!==void 0,m=Ae(n,d.onValueNodeChange);Ve(()=>{p(u)},[p,u]);const f=Zo(d.value);return t.jsx(be.span,{...c,asChild:f?!1:c.asChild,ref:m,style:{pointerEvents:"none"},children:t.jsx(l.Fragment,{children:f?i:a},f?"placeholder":"value")})});Om.displayName=Lm;var bj="SelectIcon",zm=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:r,...o}=e;return t.jsx(be.span,{"aria-hidden":!0,...o,ref:n,children:r||"▼"})});zm.displayName=bj;var Dm="SelectPortal",[vj,yj]=Hn(Dm,{forceMount:void 0}),$m=e=>{const{__scopeSelect:n,forceMount:s,...r}=e;return t.jsx(vj,{scope:e.__scopeSelect,forceMount:s,children:t.jsx($o,{asChild:!0,...r})})};$m.displayName=Dm;var kn="SelectContent",Fm=l.forwardRef((e,n)=>{const s=yj(kn,e.__scopeSelect),{forceMount:r=s.forceMount,...o}=e,a=_n(kn,e.__scopeSelect),[i,c]=l.useState();return Ve(()=>{c(new DocumentFragment)},[]),t.jsx(wt,{present:r||a.open,children:({present:d})=>d?t.jsx(qm,{...o,ref:n}):t.jsx(Bm,{...o,fragment:i})})});Fm.displayName=kn;var Bm=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:r,fragment:o}=e;return o?Es.createPortal(t.jsx(Um,{scope:s,children:t.jsx(Yo.Slot,{scope:s,children:t.jsx("div",{ref:n,children:r})})}),o):null});Bm.displayName="SelectContentFragment";var Pt=10,[Um,En]=Hn(kn),wj="SelectContentImpl",jj=ws("SelectContent.RemoveScroll"),qm=l.forwardRef((e,n)=>{const{__scopeSelect:s}=e,{position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:m,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:w,...y}=e,b=_n(kn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),E=Ae(n,S),[A,I]=l.useState(null),[M,k]=l.useState(null),R=Jo(s),[O,$]=l.useState(!1),K=l.useRef(!1);l.useEffect(()=>{if(j)return Cp(j)},[j]),xp();const ee=l.useCallback(X=>{const[Se,..._e]=R().map(ce=>ce.ref.current),[ge]=_e.slice(-1),le=document.activeElement;for(const ce of X)if(ce===le||(ce?.scrollIntoView({block:"nearest"}),ce===Se&&N&&(N.scrollTop=0),ce===ge&&N&&(N.scrollTop=N.scrollHeight),ce?.focus(),document.activeElement!==le))return},[R,N]),D=l.useCallback(()=>ee([A,j]),[ee,A,j]);l.useEffect(()=>{O&&D()},[O,D]);const{onOpenChange:H,triggerPointerDownPosRef:te}=b;l.useEffect(()=>{if(j){let X={x:0,y:0};const Se=ge=>{X={x:Math.abs(Math.round(ge.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(ge.pageY)-(te.current?.y??0))}},_e=ge=>{X.x<=10&&X.y<=10?ge.preventDefault():ge.composedPath().includes(j)||H(!1),document.removeEventListener("pointermove",Se),te.current=null};return te.current!==null&&(document.addEventListener("pointermove",Se),document.addEventListener("pointerup",_e,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Se),document.removeEventListener("pointerup",_e,{capture:!0})}}},[j,H,te]),l.useEffect(()=>{const X=()=>H(!1);return window.addEventListener("blur",X),window.addEventListener("resize",X),()=>{window.removeEventListener("blur",X),window.removeEventListener("resize",X)}},[H]);const[U,Q]=of(X=>{const Se=R().filter(le=>!le.disabled),_e=Se.find(le=>le.ref.current===document.activeElement),ge=af(Se,X,_e);ge&&setTimeout(()=>ge.ref.current?.focus())}),fe=l.useCallback((X,Se,_e)=>{const ge=!K.current&&!_e;(b.value!==void 0&&b.value===Se||ge)&&(I(X),ge&&(K.current=!0))},[b.value]),je=l.useCallback(()=>j?.focus(),[j]),he=l.useCallback((X,Se,_e)=>{const ge=!K.current&&!_e;(b.value!==void 0&&b.value===Se||ge)&&k(X)},[b.value]),re=r==="popper"?ji:Hm,P=re===ji?{side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:m,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:w}:{};return t.jsx(Um,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:fe,selectedItem:A,onItemLeave:je,itemTextRefCallback:he,focusSelectedItem:D,selectedItemText:M,position:r,isPositioned:O,searchRef:U,children:t.jsx(vl,{as:jj,allowPinchZoom:!0,children:t.jsx(bl,{asChild:!0,trapped:b.open,onMountAutoFocus:X=>{X.preventDefault()},onUnmountAutoFocus:ue(o,X=>{b.trigger?.focus({preventScroll:!0}),X.preventDefault()}),children:t.jsx(Do,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:X=>X.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:t.jsx(re,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:X=>X.preventDefault(),...y,...P,onPlaced:()=>$(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ue(y.onKeyDown,X=>{const Se=X.ctrlKey||X.altKey||X.metaKey;if(X.key==="Tab"&&X.preventDefault(),!Se&&X.key.length===1&&Q(X.key),["ArrowUp","ArrowDown","Home","End"].includes(X.key)){let ge=R().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(X.key)&&(ge=ge.slice().reverse()),["ArrowUp","ArrowDown"].includes(X.key)){const le=X.target,ce=ge.indexOf(le);ge=ge.slice(ce+1)}setTimeout(()=>ee(ge)),X.preventDefault()}})})})})})})});qm.displayName=wj;var Sj="SelectItemAlignedPosition",Hm=l.forwardRef((e,n)=>{const{__scopeSelect:s,onPlaced:r,...o}=e,a=_n(kn,s),i=En(kn,s),[c,d]=l.useState(null),[p,u]=l.useState(null),m=Ae(n,u),f=Jo(s),h=l.useRef(!1),g=l.useRef(!0),{viewport:v,selectedItem:w,selectedItemText:y,focusSelectedItem:b}=i,j=l.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&p&&v&&w&&y){const E=a.trigger.getBoundingClientRect(),A=p.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(a.dir!=="rtl"){const le=M.left-A.left,ce=I.left-le,Pe=E.left-ce,Re=E.width+Pe,Fe=Math.max(Re,A.width),dt=window.innerWidth-Pt,He=wi(ce,[Pt,Math.max(Pt,dt-Fe)]);c.style.minWidth=Re+"px",c.style.left=He+"px"}else{const le=A.right-M.right,ce=window.innerWidth-I.right-le,Pe=window.innerWidth-E.right-ce,Re=E.width+Pe,Fe=Math.max(Re,A.width),dt=window.innerWidth-Pt,He=wi(ce,[Pt,Math.max(Pt,dt-Fe)]);c.style.minWidth=Re+"px",c.style.right=He+"px"}const k=f(),R=window.innerHeight-Pt*2,O=v.scrollHeight,$=window.getComputedStyle(p),K=parseInt($.borderTopWidth,10),ee=parseInt($.paddingTop,10),D=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),te=K+ee+O+H+D,U=Math.min(w.offsetHeight*5,te),Q=window.getComputedStyle(v),fe=parseInt(Q.paddingTop,10),je=parseInt(Q.paddingBottom,10),he=E.top+E.height/2-Pt,re=R-he,P=w.offsetHeight/2,X=w.offsetTop+P,Se=K+ee+X,_e=te-Se;if(Se<=he){const le=k.length>0&&w===k[k.length-1].ref.current;c.style.bottom="0px";const ce=p.clientHeight-v.offsetTop-v.offsetHeight,Pe=Math.max(re,P+(le?je:0)+ce+D),Re=Se+Pe;c.style.height=Re+"px"}else{const le=k.length>0&&w===k[0].ref.current;c.style.top="0px";const Pe=Math.max(he,K+v.offsetTop+(le?fe:0)+P)+_e;c.style.height=Pe+"px",v.scrollTop=Se-he+v.offsetTop}c.style.margin=`${Pt}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=R+"px",r?.(),requestAnimationFrame(()=>h.current=!0)}},[f,a.trigger,a.valueNode,c,p,v,w,y,a.dir,r]);Ve(()=>j(),[j]);const[S,N]=l.useState();Ve(()=>{p&&N(window.getComputedStyle(p).zIndex)},[p]);const C=l.useCallback(E=>{E&&g.current===!0&&(j(),b?.(),g.current=!1)},[j,b]);return t.jsx(Cj,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:t.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:t.jsx(be.div,{...o,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Hm.displayName=Sj;var Nj="SelectPopperPosition",ji=l.forwardRef((e,n)=>{const{__scopeSelect:s,align:r="start",collisionPadding:o=Pt,...a}=e,i=Xo(s);return t.jsx(cm,{...i,...a,ref:n,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ji.displayName=Nj;var[Cj,Pl]=Hn(kn,{}),Si="SelectViewport",Vm=l.forwardRef((e,n)=>{const{__scopeSelect:s,nonce:r,...o}=e,a=En(Si,s),i=Pl(Si,s),c=Ae(n,a.onViewportChange),d=l.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),t.jsx(Yo.Slot,{scope:s,children:t.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ue(o.onScroll,p=>{const u=p.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:f}=i;if(f?.current&&m){const h=Math.abs(d.current-u.scrollTop);if(h>0){const g=window.innerHeight-Pt*2,v=parseFloat(m.style.minHeight),w=parseFloat(m.style.height),y=Math.max(v,w);if(y<g){const b=y+h,j=Math.min(g,b),S=b-j;m.style.height=j+"px",m.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,m.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Vm.displayName=Si;var Wm="SelectGroup",[kj,Tj]=Hn(Wm),_j=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e,o=Ht();return t.jsx(kj,{scope:s,id:o,children:t.jsx(be.div,{role:"group","aria-labelledby":o,...r,ref:n})})});_j.displayName=Wm;var Gm="SelectLabel",Ej=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e,o=Tj(Gm,s);return t.jsx(be.div,{id:o.id,...r,ref:n})});Ej.displayName=Gm;var go="SelectItem",[Rj,Km]=Hn(go),Ym=l.forwardRef((e,n)=>{const{__scopeSelect:s,value:r,disabled:o=!1,textValue:a,...i}=e,c=_n(go,s),d=En(go,s),p=c.value===r,[u,m]=l.useState(a??""),[f,h]=l.useState(!1),g=Je(j=>d.itemRefCallback?.(j,r,o)),v=Ae(n,g),w=Ht(),y=l.useRef("touch"),b=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};return t.jsx(Rj,{scope:s,value:r,disabled:o,textId:w,isSelected:p,onItemTextChange:l.useCallback(j=>{m(S=>S||(j?.textContent??"").trim())},[]),children:t.jsx(Yo.ItemSlot,{scope:s,value:r,disabled:o,textValue:u,children:t.jsx(be.div,{role:"option","aria-labelledby":w,"data-highlighted":f?"":void 0,"aria-selected":p&&f,"data-state":p?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ue(i.onFocus,()=>h(!0)),onBlur:ue(i.onBlur,()=>h(!1)),onClick:ue(i.onClick,()=>{y.current!=="mouse"&&b()}),onPointerUp:ue(i.onPointerUp,()=>{y.current==="mouse"&&b()}),onPointerDown:ue(i.onPointerDown,j=>{y.current=j.pointerType}),onPointerMove:ue(i.onPointerMove,j=>{y.current=j.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ue(i.onPointerLeave,j=>{j.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:ue(i.onKeyDown,j=>{o||j.target!==j.currentTarget||d.searchRef?.current!==""&&j.key===" "||(pj.includes(j.key)&&b(),j.key===" "&&j.preventDefault())})})})})});Ym.displayName=go;var Vs="SelectItemText",Jm=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:r,style:o,...a}=e,i=_n(Vs,s),c=En(Vs,s),d=Km(Vs,s),p=xj(Vs,s),[u,m]=l.useState(null),f=Je(b=>c.itemTextRefCallback?.(b,d.value,d.disabled)),h=Ae(n,m,d.onItemTextChange,f),g=u?.textContent,v=l.useMemo(()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:w,onNativeOptionRemove:y}=p;return Ve(()=>(w(v),()=>y(v)),[w,y,v]),t.jsxs(t.Fragment,{children:[t.jsx(be.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Zo(i.value)?Es.createPortal(a.children,i.valueNode):null]})});Jm.displayName=Vs;var Xm="SelectItemIndicator",Zm=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e;return Km(Xm,s).isSelected?t.jsx(be.span,{"aria-hidden":!0,...r,ref:n}):null});Zm.displayName=Xm;var Ni="SelectScrollUpButton",Qm=l.forwardRef((e,n)=>{const s=En(Ni,e.__scopeSelect),r=Pl(Ni,e.__scopeSelect),[o,a]=l.useState(!1),i=Ae(n,r.onScrollButtonChange);return Ve(()=>{if(s.viewport&&s.isPositioned){let c=function(){const p=d.scrollTop>0;a(p)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),o?t.jsx(tf,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Qm.displayName=Ni;var Ci="SelectScrollDownButton",ef=l.forwardRef((e,n)=>{const s=En(Ci,e.__scopeSelect),r=Pl(Ci,e.__scopeSelect),[o,a]=l.useState(!1),i=Ae(n,r.onScrollButtonChange);return Ve(()=>{if(s.viewport&&s.isPositioned){let c=function(){const p=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<p;a(u)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),o?t.jsx(tf,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});ef.displayName=Ci;var tf=l.forwardRef((e,n)=>{const{__scopeSelect:s,onAutoScroll:r,...o}=e,a=En("SelectScrollButton",s),i=l.useRef(null),c=Jo(s),d=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ve(()=>{c().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(be.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:ue(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ue(o.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ue(o.onPointerLeave,()=>{d()})})}),Mj="SelectSeparator",Aj=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e;return t.jsx(be.div,{"aria-hidden":!0,...r,ref:n})});Aj.displayName=Mj;var nf="SelectArrow",Ij=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e,o=Xo(s);return En(nf,s).position==="popper"?t.jsx(dm,{...o,...r,ref:n}):null});Ij.displayName=nf;var sf="SelectBubbleInput",rf=l.forwardRef(({__scopeSelect:e,...n},s)=>{const r=_n(sf,e),{value:o,onValueChange:a,required:i,disabled:c,name:d,autoComplete:p,form:u}=r,{nativeOptions:m,nativeSelectKey:f}=r,h=l.useRef(null),g=Ae(s,h),v=o??"",w=my(v),y=Array.from(m).some(b=>(b.props.value??"")==="");return l.useEffect(()=>{const b=h.current;if(!b)return;const j=window.HTMLSelectElement.prototype,N=Object.getOwnPropertyDescriptor(j,"value").set;if(w!==v&&N){const C=new Event("change",{bubbles:!0});N.call(b,v),b.dispatchEvent(C)}},[w,v]),t.jsxs(be.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:p,disabled:c,form:u,onChange:b=>a(b.target.value),...n,style:{...ip,...n.style},ref:g,defaultValue:v,children:[Zo(o)&&!y?t.jsx("option",{value:""}):null,Array.from(m)]},f)});rf.displayName=sf;function Pj(e){return typeof e=="function"}function Zo(e){return e===""||e===void 0}function of(e){const n=Je(e),s=l.useRef(""),r=l.useRef(0),o=l.useCallback(i=>{const c=s.current+i;n(c),(function d(p){s.current=p,window.clearTimeout(r.current),p!==""&&(r.current=window.setTimeout(()=>d(""),1e3))})(c)},[n]),a=l.useCallback(()=>{s.current="",window.clearTimeout(r.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),[s,o,a]}function af(e,n,s){const o=n.length>1&&Array.from(n).every(p=>p===n[0])?n[0]:n,a=s?e.indexOf(s):-1;let i=Lj(e,Math.max(a,0));o.length===1&&(i=i.filter(p=>p!==s));const d=i.find(p=>p.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==s?d:void 0}function Lj(e,n){return e.map((s,r)=>e[(n+r)%e.length])}var Qo="Tabs",[Oj]=on(Qo,[mm]),lf=mm(),[zj,Ll]=Oj(Qo),cf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...p}=e,u=zo(c),[m,f]=$n({prop:r,onChange:o,defaultProp:a??"",caller:Qo});return t.jsx(zj,{scope:s,baseId:Ht(),value:m,onValueChange:f,orientation:i,dir:u,activationMode:d,children:t.jsx(be.div,{dir:u,"data-orientation":i,...p,ref:n})})});cf.displayName=Qo;var df="TabsList",uf=l.forwardRef((e,n)=>{const{__scopeTabs:s,loop:r=!0,...o}=e,a=Ll(df,s),i=lf(s);return t.jsx(Kw,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:t.jsx(be.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:n})})});uf.displayName=df;var pf="TabsTrigger",mf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:r,disabled:o=!1,...a}=e,i=Ll(pf,s),c=lf(s),d=xf(i.baseId,r),p=gf(i.baseId,r),u=r===i.value;return t.jsx(Yw,{asChild:!0,...c,focusable:!o,active:u,children:t.jsx(be.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":p,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:n,onMouseDown:ue(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?i.onValueChange(r):m.preventDefault()}),onKeyDown:ue(e.onKeyDown,m=>{o||m.target!==m.currentTarget||[" ","Enter"].includes(m.key)&&i.onValueChange(r)}),onFocus:ue(e.onFocus,()=>{const m=i.activationMode!=="manual";!u&&!o&&m&&i.onValueChange(r)})})})});mf.displayName=pf;var ff="TabsContent",hf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:r,forceMount:o,children:a,...i}=e,c=Ll(ff,s),d=xf(c.baseId,r),p=gf(c.baseId,r),u=r===c.value,m=l.useRef(u);return l.useEffect(()=>{const f=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(f)},[]),t.jsx(wt,{present:o||u,children:({present:f})=>t.jsx(be.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:p,tabIndex:0,...i,ref:n,style:{...e.style,animationDuration:m.current?"0s":void 0},children:f&&a})})});hf.displayName=ff;function xf(e,n){return`${e}-trigger-${n}`}function gf(e,n){return`${e}-content-${n}`}var Dj=cf,$j=uf,Fj=mf,Bj=hf,[ea]=on("Tooltip",[Wo]),ta=Wo(),bf="TooltipProvider",Uj=700,ki="tooltip.open",[qj,Ol]=ea(bf),vf=e=>{const{__scopeTooltip:n,delayDuration:s=Uj,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,i=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const p=d.current;return()=>window.clearTimeout(p)},[]),t.jsx(qj,{scope:n,isOpenDelayedRef:i,delayDuration:s,onOpen:l.useCallback(()=>{r<=0||(window.clearTimeout(d.current),i.current=!1)},[r]),onClose:l.useCallback(()=>{r<=0||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,r))},[r]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(p=>{c.current=p},[]),disableHoverableContent:o,children:a})};vf.displayName=bf;var er="Tooltip",[Hj,mr]=ea(er),yf=e=>{const{__scopeTooltip:n,children:s,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=Ol(er,e.__scopeTooltip),p=ta(n),[u,m]=l.useState(null),f=Ht(),h=l.useRef(0),g=i??d.disableHoverableContent,v=c??d.delayDuration,w=l.useRef(!1),[y,b]=$n({prop:r,defaultProp:o??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(ki))):d.onClose(),a?.(E)},caller:er}),j=l.useMemo(()=>y?w.current?"delayed-open":"instant-open":"closed",[y]),S=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w.current=!1,b(!0)},[b]),N=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),C=l.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{w.current=!0,b(!0),h.current=0},v)},[v,b]);return l.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),t.jsx(im,{...p,children:t.jsx(Hj,{scope:n,contentId:f,open:y,stateAttribute:j,trigger:u,onTriggerChange:m,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?C():S()},[d.isOpenDelayedRef,C,S]),onTriggerLeave:l.useCallback(()=>{g?N():(window.clearTimeout(h.current),h.current=0)},[N,g]),onOpen:S,onClose:N,disableHoverableContent:g,children:s})})};yf.displayName=er;var Ti="TooltipTrigger",wf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...r}=e,o=mr(Ti,s),a=Ol(Ti,s),i=ta(s),c=l.useRef(null),d=Ae(n,c,o.onTriggerChange),p=l.useRef(!1),u=l.useRef(!1),m=l.useCallback(()=>p.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),t.jsx(lm,{asChild:!0,...i,children:t.jsx(be.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:ue(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:ue(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:ue(e.onPointerDown,()=>{o.open&&o.onClose(),p.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:ue(e.onFocus,()=>{p.current||o.onOpen()}),onBlur:ue(e.onBlur,o.onClose),onClick:ue(e.onClick,o.onClose)})})});wf.displayName=Ti;var zl="TooltipPortal",[Vj,Wj]=ea(zl,{forceMount:void 0}),jf=e=>{const{__scopeTooltip:n,forceMount:s,children:r,container:o}=e,a=mr(zl,n);return t.jsx(Vj,{scope:n,forceMount:s,children:t.jsx(wt,{present:s||a.open,children:t.jsx($o,{asChild:!0,container:o,children:r})})})};jf.displayName=zl;var Cs="TooltipContent",Sf=l.forwardRef((e,n)=>{const s=Wj(Cs,e.__scopeTooltip),{forceMount:r=s.forceMount,side:o="top",...a}=e,i=mr(Cs,e.__scopeTooltip);return t.jsx(wt,{present:r||i.open,children:i.disableHoverableContent?t.jsx(Nf,{side:o,...a,ref:n}):t.jsx(Gj,{side:o,...a,ref:n})})}),Gj=l.forwardRef((e,n)=>{const s=mr(Cs,e.__scopeTooltip),r=Ol(Cs,e.__scopeTooltip),o=l.useRef(null),a=Ae(n,o),[i,c]=l.useState(null),{trigger:d,onClose:p}=s,u=o.current,{onPointerInTransitChange:m}=r,f=l.useCallback(()=>{c(null),m(!1)},[m]),h=l.useCallback((g,v)=>{const w=g.currentTarget,y={x:g.clientX,y:g.clientY},b=Xj(y,w.getBoundingClientRect()),j=Zj(y,b),S=Qj(v.getBoundingClientRect()),N=t5([...j,...S]);c(N),m(!0)},[m]);return l.useEffect(()=>()=>f(),[f]),l.useEffect(()=>{if(d&&u){const g=w=>h(w,u),v=w=>h(w,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",v),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",v)}}},[d,u,h,f]),l.useEffect(()=>{if(i){const g=v=>{const w=v.target,y={x:v.clientX,y:v.clientY},b=d?.contains(w)||u?.contains(w),j=!e5(y,i);b?f():j&&(f(),p())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,p,f]),t.jsx(Nf,{...e,ref:a})}),[Kj,Yj]=ea(er,{isInside:!1}),Jj=Mv("TooltipContent"),Nf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=mr(Cs,s),p=ta(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(ki,u),()=>document.removeEventListener(ki,u)),[u]),l.useEffect(()=>{if(d.trigger){const m=f=>{f.target instanceof Node&&f.target.contains(d.trigger)&&u()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[d.trigger,u]),t.jsx(Do,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:m=>m.preventDefault(),onDismiss:u,children:t.jsxs(cm,{"data-state":d.stateAttribute,...p,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(Jj,{children:r}),t.jsx(Kj,{scope:s,isInside:!0,children:t.jsx(qv,{id:d.contentId,role:"tooltip",children:o||r})})]})})});Sf.displayName=Cs;var Cf="TooltipArrow",kf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...r}=e,o=ta(s);return Yj(Cf,s).isInside?null:t.jsx(dm,{...o,...r,ref:n})});kf.displayName=Cf;function Xj(e,n){const s=Math.abs(n.top-e.y),r=Math.abs(n.bottom-e.y),o=Math.abs(n.right-e.x),a=Math.abs(n.left-e.x);switch(Math.min(s,r,o,a)){case a:return"left";case o:return"right";case s:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Zj(e,n,s=5){const r=[];switch(n){case"top":r.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":r.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":r.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":r.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return r}function Qj(e){const{top:n,right:s,bottom:r,left:o}=e;return[{x:o,y:n},{x:s,y:n},{x:s,y:r},{x:o,y:r}]}function e5(e,n){const{x:s,y:r}=e;let o=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){const c=n[a],d=n[i],p=c.x,u=c.y,m=d.x,f=d.y;u>r!=f>r&&s<(m-p)*(r-u)/(f-u)+p&&(o=!o)}return o}function t5(e){const n=e.slice();return n.sort((s,r)=>s.x<r.x?-1:s.x>r.x?1:s.y<r.y?-1:s.y>r.y?1:0),n5(n)}function n5(e){if(e.length<=1)return e.slice();const n=[];for(let r=0;r<e.length;r++){const o=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}n.pop();const s=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;s.length>=2;){const a=s[s.length-1],i=s[s.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))s.pop();else break}s.push(o)}return s.pop(),n.length===1&&s.length===1&&n[0].x===s[0].x&&n[0].y===s[0].y?n:n.concat(s)}var s5=vf,r5=yf,o5=wf,a5=jf,i5=Sf,l5=kf;function Nt({...e}){return t.jsx(Tp,{"data-slot":"dialog",...e})}function Vn({...e}){return t.jsx(Ep,{"data-slot":"dialog-trigger",...e})}function c5({...e}){return t.jsx(Mp,{"data-slot":"dialog-portal",...e})}function d5({className:e,...n}){return t.jsx(Ap,{"data-slot":"dialog-overlay",className:L("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...n})}function Ct({className:e,children:n,...s}){return t.jsxs(c5,{children:[t.jsx(d5,{}),t.jsxs(Ip,{"data-slot":"dialog-content",className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...s,children:[n,t.jsxs(Fp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(dr,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Tt({className:e,...n}){return t.jsx("div",{"data-slot":"dialog-header",className:L("flex flex-col space-y-1.5 text-center sm:text-left",e),...n})}function _t({className:e,...n}){return t.jsx(Op,{"data-slot":"dialog-title",className:L("text-lg font-semibold leading-none tracking-tight",e),...n})}function Is({className:e,...n}){return t.jsx(Dp,{"data-slot":"dialog-description",className:L("text-sm text-muted-foreground",e),...n})}function Dl({open:e,onOpenChange:n,title:s,description:r,confirmLabel:o="Confirm",variant:a="default",onConfirm:i}){return t.jsx(Nt,{open:e,onOpenChange:n,children:t.jsxs(Ct,{children:[t.jsx(Tt,{children:t.jsx(_t,{children:s})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:r}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(J,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),t.jsx(J,{variant:a,size:"sm",onClick:()=>{i(),n(!1)},children:o})]})]})})}const u5="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",p5="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'%3e%3c/path%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23lobe-icons-codex-_R_0_)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-codex-_R_0_'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'%3e%3c/stop%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%233941FF'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",m5="data:image/svg+xml,%3csvg%20fill='%237dd3fc'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenCode%3c/title%3e%3cpath%20d='M16%206H8v12h8V6zm4%2016H4V2h16v20z'%3e%3c/path%3e%3c/svg%3e",f5="data:image/svg+xml,%3csvg%20fill='%23ff6900'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMiMo%20Code%3c/title%3e%3cpath%20d='M.958%2015.936a.459.459%200%2001.459.44v2.729a.46.46%200%2001-.918%200v-2.729a.459.459%200%2001.459-.44zm4.814-2.035a.46.46%200%2001.553.45v4.754a.458.458%200%2011-.918%200V15.48L3.74%2017.202a.462.462%200%2001-.655.016.462.462%200%2001-.065-.082L.628%2014.67a.459.459%200%2001.658-.637l2.124%202.187%202.127-2.188a.46.46%200%2001.235-.13zm2.068.004a.46.46%200%2001.458.445v4.755a.46.46%200%2001-.458.458.459.459%200%2001-.458-.458V14.35a.459.459%200%2001.458-.445zm1.973%202.014a.46.46%200%2001.46.457v2.729a.46.46%200%2001-.784.324.46.46%200%2001-.134-.324v-2.729a.46.46%200%2001.458-.458zm.002-2.045a.458.458%200%2001.328.157l2.127%202.19%202.125-2.19a.459.459%200%2001.784.318v4.756a.46.46%200%2001-.455.458.46.46%200%2001-.458-.458V15.48l-1.667%201.723a.46.46%200%2001-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46%200%2001-.008-.667.461.461%200%2001.338-.128zm6.797%201.206a.46.46%200%2001.53.651A1.966%201.966%200%200019.81%2018.4a.462.462%200%2001.623.18.46.46%200%2001-.181.624%202.863%202.863%200%2001-1.38.353l-.142-.004a2.88%202.88%200%2001-2.393-4.263.461.461%200%2001.274-.21zm.864-.931a2.884%202.884%200%20013.915%203.914.46.46%200%2001-.402.24l-.057-.004a.458.458%200%2001-.164-.055.46.46%200%2001-.182-.622%201.967%201.967%200%2000-2.669-2.67.459.459%200%2011-.441-.803zM9.59%206.368c1.481%200%201.696%201.202%201.696%201.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133%200-1.289-.03-1.384-1.136-.082-.932.675-1.61%202.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379%201.012-.567%201.764-.567zm4.427.1c1.263%200%202.082.97%202.083%202.15%200%201.181-.824%202.154-2.083%202.154-1.26%200-2.084-.972-2.084-2.152%200-1.18.82-2.153%202.084-2.153zm6.801.015c.68%200%201.202.465%201.197%201.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628%200-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22%201.22%200%2001.947-.516c.398%200%20.76.193.982.686a1.321%201.321%200%20011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311%208.07l2.14%202.602H4.24L2.725%208.796%201.21%2010.672H0L2.138%208.07.13%205.583h1.138l1.458%201.772zm4.149%203.317h-.916V6.644h.916v4.028zm16.99%200h-.916V6.644h.916v4.028zM9.925%208.71c-1.055%200-1.359.412-1.326.742.032.329.324.537.757.537a1.013%201.013%200%20001.014-.968l.002-.31h-.447zM14.018%207.3c-.663%200-1.184.487-1.184%201.32%200%20.832.52%201.32%201.184%201.32.662%200%201.182-.49%201.182-1.32%200-.832-.52-1.32-1.182-1.32zM6.417%205.001a.568.568%200%2001.587.582.588.588%200%2001-1.175%200A.57.57%200%20016.417%205zm16.991%200a.57.57%200%2001.592.582.588.588%200%2001-1.174%200%20.57.57%200%2001.357-.542.572.572%200%2001.225-.04z'%3e%3c/path%3e%3c/svg%3e",h5=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,x5={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function Cr(e){return e?.toLowerCase()??""}function ts(e,n){for(const s of n)if(e.includes(s))return!0;return!1}function $l(e){const n=[Cr(e.userAgent),Cr(e.conversationId),Cr(e.clientProjectFolder)].join(" ");return ts(n,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":ts(n,["mimocode","mimo-code","mimo code"])?"mimo-code":ts(n,["opencode","open-code","open code"])?"opencode":ts(n,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":ts(n,["codex desktop","codex-cli","openai-codex","codex"])?"codex":ts(Cr(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function na(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return x5[e];case"unknown":return null}}function g5(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return"IDE";case"agent-inspector":case"ai-sdk":case"unknown":return"CLIENT"}}const b5={"agent-inspector":h5,codex:p5,opencode:m5,"mimo-code":f5,"claude-code":u5},v5={"agent-inspector":"border-orange-700/15 bg-orange-500/[0.08] dark:border-orange-200/25 dark:bg-orange-300/[0.12]",codex:"border-cyan-700/15 bg-cyan-500/[0.08] dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",opencode:"border-sky-700/15 bg-sky-500/[0.09] dark:border-sky-200/25 dark:bg-sky-300/[0.12]","mimo-code":"border-orange-700/15 bg-orange-500/[0.09] dark:border-orange-200/25 dark:bg-orange-400/[0.12]","claude-code":"border-amber-700/15 bg-amber-500/[0.08] dark:border-amber-100/20 dark:bg-amber-300/[0.09]"},y5={"agent-inspector":"p-0.5 drop-shadow-[0_0_8px_rgba(251,146,60,0.35)]",codex:"p-0.5",opencode:"p-1 drop-shadow-[0_0_8px_rgba(125,211,252,0.35)]","mimo-code":"p-0.5 drop-shadow-[0_0_8px_rgba(255,105,0,0.35)]","claude-code":"p-0.5"};function sa({client:e,className:n,decorative:s=!1}){if(e==="unknown")return null;const r=na(e);if(r===null)return null;if(e==="ai-sdk")return t.jsx("span",{className:L("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-cyan-700/15 bg-cyan-500/[0.08] text-[var(--inspector-status-cool)] shadow-sm dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",n),"aria-label":s?void 0:r,"aria-hidden":s?!0:void 0,title:r,children:t.jsx(qu,{className:"size-1/2","aria-hidden":"true"})});const o=b5[e];return t.jsx("span",{className:L("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",v5[e],n),"aria-label":s?void 0:r,"aria-hidden":s?!0:void 0,title:r,children:t.jsx("img",{src:o,alt:"",className:L("size-full object-contain",y5[e]),"aria-hidden":"true"})})}const w5="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='0%206.603%201192.672%201193.397'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m233.96%20800.215%20234.684-131.678%203.947-11.436-3.947-6.363h-11.436l-39.221-2.416-134.094-3.624-116.296-4.832-112.67-6.04-28.35-6.04-26.577-35.035%202.738-17.477%2023.84-16.027%2034.147%202.98%2075.463%205.155%20113.235%207.812%2082.147%204.832%20121.692%2012.644h19.329l2.738-7.812-6.604-4.832-5.154-4.832-117.182-79.41-126.845-83.92-66.443-48.321-35.92-24.484-18.12-22.953-7.813-50.093%2032.618-35.92%2043.812%202.98%2011.195%202.98%2044.375%2034.147%2094.792%2073.37%20123.786%2091.167%2018.12%2015.06%207.249-5.154.886-3.624-8.135-13.61-67.329-121.692-71.838-123.785-31.974-51.302-8.456-30.765c-2.98-12.645-5.154-23.275-5.154-36.242l37.127-50.416%2020.537-6.604%2049.53%206.604%2020.86%2018.121%2030.765%2070.39%2049.852%20110.818%2077.315%20150.684%2022.631%2044.698%2012.08%2041.396%204.51%2012.645h7.813v-7.248l6.362-84.886%2011.759-104.215%2011.436-134.094%203.946-37.772%2018.685-45.262%2037.127-24.482%2028.994%2013.852%2023.839%2034.148-3.303%2022.067-14.174%2092.134-27.785%20144.323-18.121%2096.644h10.55l12.08-12.08%2048.887-64.913%2082.147-102.685%2036.242-40.752%2042.282-45.02%2027.14-21.423h51.303l37.772%2056.135-16.913%2057.986-52.832%2067.007-43.812%2056.779-62.82%2084.563-39.22%2067.651%203.623%205.396%209.343-.886%20141.906-30.201%2076.671-13.852%2091.49-15.705%2041.396%2019.329%204.51%2019.65-16.269%2040.189-97.852%2024.16-114.764%2022.954-170.9%2040.43-2.093%201.53%202.416%202.98%2076.993%207.248%2032.94%201.771h80.617l150.12%2011.195%2039.222%2025.933%2023.517%2031.732-3.946%2024.16-60.403%2030.766-81.503-19.33-190.228-45.26-65.235-16.27h-9.02v5.397l54.362%2053.154%2099.624%2089.96%20124.752%20115.973%206.362%2028.671-16.027%2022.63-16.912-2.415-109.611-82.47-42.282-37.127-95.758-80.618h-6.363v8.456l22.067%2032.296%20116.537%20175.167%206.04%2053.719-8.456%2017.476-30.201%2010.55-33.181-6.04-68.215-95.758-70.39-107.84-56.778-96.644-6.926%203.947-33.503%20360.886-15.705%2018.443-36.243%2013.852-30.201-22.953-16.027-37.127%2016.027-73.37%2019.329-95.758%2015.704-76.107%2014.175-94.55%208.456-31.41-.563-2.094-6.927.886-71.275%2097.852-108.402%20146.497-85.772%2091.812-20.537%208.134-35.597-18.443%203.301-32.94%2019.893-29.315%20118.712-151.007%2071.597-93.583%2046.228-54.04-.322-7.813h-2.738l-315.302%20204.725-56.135%207.248-24.16-22.63%202.98-37.128%2011.435-12.08%2094.792-65.236-.322.323z'%20fill='%23d97757'/%3e%3c/svg%3e",j5="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='-1%20-.1%20949.1%20959.8'%20width='2474'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m925.8%20456.3c10.4%2023.2%2017%2048%2019.7%2073.3%202.6%2025.3%201.3%2050.9-4.1%2075.8-5.3%2024.9-14.5%2048.8-27.3%2070.8-8.4%2014.7-18.3%2028.5-29.7%2041.2-11.3%2012.6-23.9%2024-37.6%2034-13.8%2010-28.5%2018.4-44.1%2025.3-15.5%206.8-31.7%2012-48.3%2015.4-7.8%2024.2-19.4%2047.1-34.4%2067.7-14.9%2020.6-33%2038.7-53.6%2053.6-20.6%2015-43.4%2026.6-67.6%2034.4-24.2%207.9-49.5%2011.8-75%2011.8-16.9.1-33.9-1.7-50.5-5.1-16.5-3.5-32.7-8.8-48.2-15.7s-30.2-15.5-43.9-25.5c-13.6-10-26.2-21.5-37.4-34.2-25%205.4-50.6%206.7-75.9%204.1-25.3-2.7-50.1-9.3-73.4-19.7-23.2-10.3-44.7-24.3-63.6-41.4s-35-37.1-47.7-59.1c-8.5-14.7-15.5-30.2-20.8-46.3s-8.8-32.7-10.6-49.6c-1.8-16.8-1.7-33.8.1-50.7%201.8-16.8%205.5-33.4%2010.8-49.5-17-18.9-31-40.4-41.4-63.6-10.3-23.3-17-48-19.6-73.3-2.7-25.3-1.3-50.9%204-75.8s14.5-48.8%2027.3-70.8c8.4-14.7%2018.3-28.6%2029.6-41.2s24-24%2037.7-34%2028.5-18.5%2044-25.3c15.6-6.9%2031.8-12%2048.4-15.4%207.8-24.3%2019.4-47.1%2034.3-67.7%2015-20.6%2033.1-38.7%2053.7-53.7%2020.6-14.9%2043.4-26.5%2067.6-34.4%2024.2-7.8%2049.5-11.8%2075-11.7%2016.9-.1%2033.9%201.6%2050.5%205.1s32.8%208.7%2048.3%2015.6c15.5%207%2030.2%2015.5%2043.9%2025.5%2013.7%2010.1%2026.3%2021.5%2037.5%2034.2%2024.9-5.3%2050.5-6.6%2075.8-4s50%209.3%2073.3%2019.6c23.2%2010.4%2044.7%2024.3%2063.6%2041.4%2018.9%2017%2035%2036.9%2047.7%2059%208.5%2014.6%2015.5%2030.1%2020.8%2046.3%205.3%2016.1%208.9%2032.7%2010.6%2049.6%201.8%2016.9%201.8%2033.9-.1%2050.8-1.8%2016.9-5.5%2033.5-10.8%2049.6%2017.1%2018.9%2031%2040.3%2041.4%2063.6zm-333.2%20426.9c21.8-9%2041.6-22.3%2058.3-39s30-36.5%2039-58.4c9-21.8%2013.7-45.2%2013.7-68.8v-223q-.1-.3-.2-.7-.1-.3-.3-.6-.2-.3-.5-.5-.3-.3-.6-.4l-80.7-46.6v269.4c0%202.7-.4%205.5-1.1%208.1-.7%202.7-1.7%205.2-3.1%207.6s-3%204.6-5%206.5a32.1%2032.1%200%200%201%20-6.5%205l-191.1%20110.3c-1.6%201-4.3%202.4-5.7%203.2%207.9%206.7%2016.5%2012.6%2025.5%2017.8%209.1%205.2%2018.5%209.6%2028.3%2013.2%209.8%203.5%2019.9%206.2%2030.1%208%2010.3%201.8%2020.7%202.7%2031.1%202.7%2023.6%200%2047-4.7%2068.8-13.8zm-455.1-151.4c11.9%2020.5%2027.6%2038.3%2046.3%2052.7%2018.8%2014.4%2040.1%2024.9%2062.9%2031s46.6%207.7%2070%204.6%2045.9-10.7%2066.4-22.5l193.2-111.5.5-.5q.2-.2.3-.6.2-.3.3-.6v-94l-233.2%20134.9c-2.4%201.4-4.9%202.4-7.5%203.2-2.7.7-5.4%201-8.2%201-2.7%200-5.4-.3-8.1-1-2.6-.8-5.2-1.8-7.6-3.2l-191.1-110.4c-1.7-1-4.2-2.5-5.6-3.4-1.8%2010.3-2.7%2020.7-2.7%2031.1s1%2020.8%202.8%2031.1c1.8%2010.2%204.6%2020.3%208.1%2030.1%203.6%209.8%208%2019.2%2013.2%2028.2zm-50.2-417c-11.8%2020.5-19.4%2043.1-22.5%2066.5s-1.5%2047.1%204.6%2070c6.1%2022.8%2016.6%2044.1%2031%2062.9%2014.4%2018.7%2032.3%2034.4%2052.7%2046.2l193.1%20111.6q.3.1.7.2h.7q.4%200%20.7-.2.3-.1.6-.3l81-46.8-233.2-134.6c-2.3-1.4-4.5-3.1-6.5-5a32.1%2032.1%200%200%201%20-5-6.5c-1.3-2.4-2.4-4.9-3.1-7.6-.7-2.6-1.1-5.3-1-8.1v-227.1c-9.8%203.6-19.3%208-28.3%2013.2-9%205.3-17.5%2011.3-25.5%2018-7.9%206.7-15.3%2014.1-22%2022.1-6.7%207.9-12.6%2016.5-17.8%2025.5zm663.3%20154.4c2.4%201.4%204.6%203%206.6%205%201.9%201.9%203.6%204.1%205%206.5%201.3%202.4%202.4%205%203.1%207.6.6%202.7%201%205.4.9%208.2v227.1c32.1-11.8%2060.1-32.5%2080.8-59.7%2020.8-27.2%2033.3-59.7%2036.2-93.7s-3.9-68.2-19.7-98.5-39.9-55.5-69.5-72.5l-193.1-111.6q-.3-.1-.7-.2h-.7q-.3.1-.7.2-.3.1-.6.3l-80.6%2046.6%20233.2%20134.7zm80.5-121h-.1v.1zm-.1-.1c5.8-33.6%201.9-68.2-11.3-99.7-13.1-31.5-35-58.6-63-78.2-28-19.5-61-30.7-95.1-32.2-34.2-1.4-68%206.9-97.6%2023.9l-193.1%20111.5q-.3.2-.5.5l-.4.6q-.1.3-.2.7-.1.3-.1.7v93.2l233.2-134.7c2.4-1.4%205-2.4%207.6-3.2%202.7-.7%205.4-1%208.1-1%202.8%200%205.5.3%208.2%201%202.6.8%205.1%201.8%207.5%203.2l191.1%20110.4c1.7%201%204.2%202.4%205.6%203.3zm-505.3-103.2c0-2.7.4-5.4%201.1-8.1.7-2.6%201.7-5.2%203.1-7.6%201.4-2.3%203-4.5%205-6.5%201.9-1.9%204.1-3.6%206.5-4.9l191.1-110.3c1.8-1.1%204.3-2.5%205.7-3.2-26.2-21.9-58.2-35.9-92.1-40.2-33.9-4.4-68.3%201-99.2%2015.5-31%2014.5-57.2%2037.6-75.5%2066.4-18.3%2028.9-28%2062.3-28%2096.5v223q.1.4.2.7.1.3.3.6.2.3.5.6.2.2.6.4l80.7%2046.6zm43.8%20294.7%20103.9%2060%20103.9-60v-119.9l-103.8-60-103.9%2060z'/%3e%3c/svg%3e",S5="data:image/svg+xml,%3csvg%20fill='none'%20height='1320'%20viewBox='3.771%206.973%2023.993%2017.652'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m27.501%208.469c-.252-.123-.36.111-.508.23-.05.04-.093.09-.135.135-.368.395-.797.652-1.358.621-.821-.045-1.521.213-2.14.842-.132-.776-.57-1.238-1.235-1.535-.349-.155-.701-.309-.944-.645-.171-.238-.217-.504-.303-.765-.054-.159-.108-.32-.29-.348-.197-.031-.274.135-.352.273-.31.567-.43%201.192-.419%201.825.028%201.421.628%202.554%201.82%203.36.136.093.17.186.128.321-.081.278-.178.547-.264.824-.054.178-.135.217-.324.14a5.448%205.448%200%200%201%20-1.719-1.169c-.848-.82-1.614-1.726-2.57-2.435-.225-.166-.449-.32-.681-.467-.976-.95.128-1.729.383-1.82.267-.096.093-.428-.77-.424s-1.653.293-2.659.677a2.782%202.782%200%200%201%20-.46.135%209.554%209.554%200%200%200%20-2.853-.1c-1.866.21-3.356%201.092-4.452%202.6-1.315%201.81-1.625%203.87-1.246%206.018.399%202.261%201.552%204.136%203.326%205.601%201.837%201.518%203.955%202.262%206.37%202.12%201.466-.085%203.1-.282%204.942-1.842.465.23.952.322%201.762.392.623.059%201.223-.031%201.687-.127.728-.154.677-.828.414-.953-2.132-.994-1.665-.59-2.09-.916%201.084-1.285%202.717-2.619%203.356-6.94.05-.343.007-.558%200-.837-.004-.168.034-.235.228-.254a4.084%204.084%200%200%200%201.529-.47c1.382-.757%201.938-1.997%202.07-3.485.02-.227-.004-.463-.243-.582zm-12.041%2013.391c-2.067-1.627-3.07-2.162-3.483-2.138-.387.021-.318.465-.233.754.089.285.205.482.368.732.113.166.19.414-.112.598-.666.414-1.823-.139-1.878-.166-1.347-.793-2.473-1.842-3.267-3.276-.765-1.38-1.21-2.861-1.284-4.441-.02-.383.093-.518.472-.586a4.692%204.692%200%200%201%201.514-.04c2.109.31%203.905%201.255%205.41%202.749.86.853%201.51%201.871%202.18%202.865.711%201.057%201.478%202.063%202.454%202.887.343.289.619.51.881.672-.792.088-2.117.107-3.022-.61zm.99-6.38a.304.304%200%201%201%20.609%200c0%20.17-.136.304-.306.304a.3.3%200%200%201%20-.303-.305zm3.077%201.581c-.197.08-.394.15-.584.159a1.246%201.246%200%200%201%20-.79-.252c-.27-.227-.463-.354-.546-.752a1.752%201.752%200%200%201%20.016-.582c.07-.324-.008-.531-.235-.72-.187-.155-.422-.196-.682-.196a.551.551%200%200%201%20-.252-.078c-.108-.055-.197-.19-.112-.356.027-.053.159-.183.19-.207.352-.201.758-.135%201.134.016.349.142.611.404.99.773.388.448.457.573.678.906.174.264.333.534.441.842.066.192-.02.35-.248.448z'%20fill='%234d6bfe'/%3e%3c/svg%3e",N5=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,C5=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,k5=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,T5=""+new URL("zhipuai-BPNAnxo-.svg",import.meta.url).href,_5={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function E5(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function R5(e){if(e===null)return"unknown";const n=e.toLowerCase();if(E5(n))return"zhipuai";for(const[s,r]of Object.entries(_5))if(n.startsWith(s.toLowerCase()))return r;return"unknown"}const Wn={width:24,height:24,objectFit:"contain"},M5=Un.memo(({className:e})=>t.jsx("img",{src:w5,alt:"Anthropic",className:e,style:Wn})),A5=Un.memo(({className:e})=>t.jsx("img",{src:j5,alt:"OpenAI",className:e,style:{...Wn,background:"white",borderRadius:"4px"}})),I5=Un.memo(({className:e})=>t.jsx("img",{src:S5,alt:"DeepSeek",className:e,style:Wn})),P5=Un.memo(({className:e})=>t.jsx("img",{src:N5,alt:"MiniMax",className:e,style:Wn})),L5=Un.memo(({className:e})=>t.jsx("img",{src:C5,alt:"Alibaba",className:e,style:Wn})),O5=Un.memo(({className:e})=>t.jsx("img",{src:k5,alt:"Qwen",className:e,style:Wn})),z5=Un.memo(({className:e})=>t.jsx("img",{src:T5,alt:"ZhipuAI",className:e,style:Wn}));function D5({provider:e,className:n}){switch(e){case"anthropic":return t.jsx(M5,{className:n});case"openai":return t.jsx(A5,{className:n});case"deepseek":return t.jsx(I5,{className:n});case"minimax":return t.jsx(P5,{className:n});case"alibaba":return t.jsx(L5,{className:n});case"qwen":return t.jsx(O5,{className:n});case"zhipuai":return t.jsx(z5,{className:n});case"unknown":return null}}function Ps({delayDuration:e=600,...n}){return t.jsx(s5,{"data-slot":"tooltip-provider",delayDuration:e,...n})}function pt({...e}){return t.jsx(r5,{"data-slot":"tooltip",...e})}function mt({...e}){return t.jsx(o5,{"data-slot":"tooltip-trigger",...e})}function ft({className:e,sideOffset:n=0,children:s,...r}){return t.jsx(a5,{children:t.jsxs(i5,{"data-slot":"tooltip-content",sideOffset:n,className:L("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[s,t.jsx(l5,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const $5=3;function F5({items:e,ariaLabel:n,className:s}){if(e.length===0)return t.jsx("span",{className:L("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const r=e.slice(0,$5),o=e.length-r.length;return t.jsx(Ps,{delayDuration:150,children:t.jsxs("span",{className:L("flex h-8 w-12 shrink-0 items-center",s),"aria-label":n,children:[r.map((a,i)=>t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx("span",{className:L("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",i>0&&"-ml-2"),children:t.jsx(D5,{provider:a.provider,className:"size-4"})})}),t.jsx(ft,{children:a.tooltip})]},`${a.provider}-${String(i)}`)),o>0&&t.jsxs("span",{className:"border border-border bg-muted/40 -ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md px-1 font-mono text-[10px] text-muted-foreground",children:["+",o]})]})})}const B5=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function Tf(e){const n=e.split("?")[0]??"";for(const[s,r]of B5)if(n===s)return r;return"unknown"}function _f(e,n){for(const s of Array.from(e))n(s)}const U5=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Fl(e){if(e.length===0)return 0;let n=0,s=0;return _f(e,r=>{U5.test(r)?n+=1:s+=1}),Math.ceil(n*1)+Math.ceil(s/4)}function Bl(e){if(e.length===0)return 0;let n=0;return _f(e,()=>{n+=1}),n}function Ul(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e,n){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,n)?.value}const q5=["file","shell","browser","web","mcp","code","other"];function _i(e){const n=e.replace(/\s+/g," ").trim();return n.length<=120?n:`${n.slice(0,119)}...`}function Ef(e){if(e===null)return null;const n=e.replace(/\s+/g," ").trim();if(n.length===0)return null;const s=n.search(/[.!?。!?]/);return s>=24?_i(n.slice(0,s+1)):_i(n)}function H5(e,n){return`${e} ${n??""}`.toLowerCase()}function ns(e,n){return n.some(s=>e.includes(s))}function Rf(e,n){const s=H5(e,n);return e.startsWith("mcp__")||e.startsWith("inspector_")||ns(s,[" mcp","model context protocol"])?"mcp":ns(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":ns(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":ns(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":ns(s,["web","search","http","url","fetch"])?"web":ns(s,["code","typescript","javascript","python","repl"])?"code":"other"}function Mf(e){const n=G(e,"properties");return n===null||typeof n!="object"||Array.isArray(n)?[]:Object.keys(n).sort((s,r)=>s.localeCompare(r))}function Af(e){const n=G(e,"required");if(!Array.isArray(n))return[];const s=[];for(const r of n)typeof r=="string"&&r.length>0&&s.push(r);return s.sort((r,o)=>r.localeCompare(o))}function V5(e){const n=G(e,"name");if(typeof n!="string"||n.length===0)return null;const s=G(e,"description"),r=G(e,"input_schema")??null,o=typeof s=="string"?s:null;return{name:n,description:o,descriptionPreview:Ef(o),category:Rf(n,o),parameterCount:Mf(r).length,requiredParameters:Af(r),schema:r}}function W5(e){const n=G(e,"function"),s=G(e,"type");if(n===void 0&&typeof s!="string")return null;const r=G(n,"name")??G(e,"name")??(typeof s=="string"?s:void 0);if(typeof r!="string"||r.length===0)return null;const o=G(n,"description")??G(e,"description"),a=G(n,"parameters")??G(e,"parameters")??null,i=typeof o=="string"?o:null;return{name:r,description:i,descriptionPreview:Ef(i),category:Rf(r,i),parameterCount:Mf(a).length,requiredParameters:Af(a),schema:a}}function G5(e){const n=W5(e);return n!==null?n:V5(e)}function K5(e){if(e==null)return null;if(typeof e=="string")return e;const n=G(e,"type"),s=G(e,"name"),r=G(G(e,"function"),"name");if(typeof n=="string"&&typeof r=="string"&&r.length>0)return`${n}: ${r}`;if(typeof n=="string"&&typeof s=="string"&&s.length>0)return`${n}: ${s}`;if(typeof n=="string")return n;const o=JSON.stringify(e);return o===void 0?null:_i(o)}function Y5(e){const n=new Map;for(const s of e)n.set(s.category,(n.get(s.category)??0)+1);return q5.flatMap(s=>{const r=n.get(s)??0;return r>0?[{category:s,count:r}]:[]})}function ql(e){const n=G(e,"tools");if(!Array.isArray(n)||n.length===0)return null;const s=[];for(const r of n){const o=G5(r);o!==null&&s.push(o)}return s.length===0?null:{tools:s,toolChoiceLabel:K5(G(e,"tool_choice")),categories:Y5(s)}}function Dn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const xs={parsed:null,toolNames:null};function J5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const r=s;switch(r.type){case"text":typeof r.text=="string"&&n.push(r.text);break;case"thinking":case"think":typeof r.thinking=="string"&&n.push(r.thinking);break;case"tool_use":{const a=typeof r.name=="string"?r.name:"",i=r.input!==void 0?JSON.stringify(r.input):"";n.push(`${a} ${i}`.trim());break}case"tool_result":{const a=r.content;if(typeof a=="string")n.push(a);else if(Array.isArray(a)){for(const i of a)if(i!==null&&typeof i=="object"){const c=i.text;typeof c=="string"&&n.push(c)}}break}case"image":n.push("[image]");break}}return n.join(`
|
|
43
|
+
`)}function X5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e)if(s!==null&&typeof s=="object"){const r=s.text;s.type==="text"&&typeof r=="string"&&n.push(r)}return n.join(`
|
|
44
|
+
`)}function Z5(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const r=s;typeof r.name=="string"&&n.push(r.name),typeof r.description=="string"&&n.push(r.description),r.input_schema!==void 0&&n.push(JSON.stringify(r.input_schema))}return n.join(`
|
|
45
|
+
`)}function _a(e,n,s,r){return{role:e,label:n,text:s,size:Fl(s),characters:Bl(s),path:r}}const Q5={format:"anthropic",analyzeRequest(e){if(e===null)return Dn(e);try{const n=JSON.parse(e),s=ql(n)?.tools.length??null,r=Rx.safeParse(n);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:s}:Dn(e)}catch{return Dn(e)}},analyzeResponse(e){if(e===null)return xs;try{let n=JSON.parse(e);typeof n=="string"&&(n=JSON.parse(n));const s=Ax.safeParse(n);if(!s.success)return xs;const r=s.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:s.data,toolNames:r.length>0?r:null}}catch{return xs}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(n.system!==void 0){const r=X5(n.system);r.length>0&&s.push(_a("system","system",r,"/system"))}if(Array.isArray(n.messages)&&n.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const a=r,i=a.role==="user"||a.role==="assistant"?a.role:"user",c=J5(a.content);s.push(_a(i,`[${o}] ${i}`,c,`/messages/${o}`))}),Array.isArray(n.tools)&&n.tools.length>0){const r=Z5(n.tools);s.push(_a("tools","tools",r,"/tools"))}return s.length>0?s:null}};function Ei(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const r=s,o=r.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof r.text=="string"?n.push(r.text):(o==="image_url"||o==="input_image")&&n.push("[image]")}return n.join(`
|
|
46
|
+
`)}function eS(e){const n=[],s=Ei(e.content);s.length>0&&n.push(s);const r=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";r.length>0&&n.push(r);const o=e.tool_calls;if(Array.isArray(o))for(const a of o){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:"";n.push(`${c} ${d}`.trim())}return n.join(`
|
|
47
|
+
`)}function tS(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const r=G(s,"function"),o=G(r,"name")??G(s,"name"),a=G(r,"description")??G(s,"description"),i=G(r,"parameters")??G(s,"parameters");typeof o=="string"&&n.push(o),typeof a=="string"&&n.push(a),i!==void 0&&n.push(JSON.stringify(i))}return n.join(`
|
|
48
|
+
`)}function nS(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function sS(e){if(typeof e=="string")return e;const n=G(e,"text");if(typeof n=="string")return n;const s=Ei(G(e,"content"));if(s.length>0)return s;const r=Ei(G(e,"output"));if(r.length>0)return r;const o=G(e,"arguments");return typeof o=="string"?o:""}function rS(e){const n=G(e,"role");if(n==="system"||n==="user"||n==="assistant"||n==="tool")return n;const s=G(e,"type");return s==="function_call_output"?"tool":"user"}function oS(e){const n=G(e,"output");if(!Array.isArray(n))return[];const s=[];for(const r of n){if(G(r,"type")!=="function_call")continue;const o=G(r,"name");typeof o=="string"&&o.length>0&&s.push(o)}return s}function Ds(e,n,s,r){return{role:e,label:n,text:s,size:Fl(s),characters:Bl(s),path:r}}const aS={format:"openai",analyzeRequest(e){if(e===null)return Dn(e);try{const n=JSON.parse(e),s=ql(n)?.tools.length??null,r=Vx.safeParse(n);if(!r.success){const o=Gx.safeParse(n);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:nS(o.data.input),toolCount:s}:Dn(e)}return{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:s}}catch{return Dn(e)}},analyzeResponse(e){if(e===null)return xs;const n=Qx(e);if(n===null){const r=eg(e);if(r===null)return xs;const o=oS(r);return{parsed:r,toolNames:o.length>0?o:null}}const s=n.choices[0]?.message?.tool_calls?.map(r=>r.function?.name??"").filter(r=>r!=="")??[];return{parsed:n,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(typeof n.instructions=="string"&&n.instructions.length>0&&s.push(Ds("system","instructions",n.instructions,"/instructions")),Array.isArray(n.messages)&&n.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const a=r,i=a.role==="user"||a.role==="assistant"||a.role==="system"||a.role==="tool"?a.role:"user",c=eS(a);s.push(Ds(i,`[${o}] ${i}`,c,`/messages/${o}`))}),Array.isArray(n.messages)||(typeof n.input=="string"&&n.input.length>0?s.push(Ds("user","input",n.input,"/input")):Array.isArray(n.input)&&n.input.forEach((r,o)=>{const a=rS(r),i=sS(r);s.push(Ds(a,`[${o}] ${a}`,i,`/input/${o}`))})),Array.isArray(n.tools)&&n.tools.length>0){const r=tS(n.tools);s.push(Ds("tools","tools",r,"/tools"))}return s.length>0?s:null}},iS={format:"unknown",analyzeRequest(e){return Dn(e)},analyzeResponse(){return xs},anatomySegments(){return null}},lS={anthropic:Q5,openai:aS,unknown:iS};function If(e){return lS[e]}function bo(e){const n=Tf(e.path);return n==="unknown"?e.apiFormat:n}const Hc="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 Pf(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function cS(e){return Pf(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function Ea({icon:e,children:n,title:s,className:r}){return t.jsxs("span",{className:L("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",r),title:s,children:[e,t.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:n})]})}function dS(){return t.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:[t.jsx(Ue,{className:"size-3 animate-spin"}),"Turn open"]})}function uS({conversationId:e,startTime:n,endTime:s,totalCalls:r,totalInputTokens:o,totalOutputTokens:a,expanded:i,onToggle:c,providers:d,isLoading:p=!1,userAgent:u,clientPid:m,clientProjectFolder:f,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:v,onClear:w}){const[y,b]=l.useState(!1),j=K=>{K.stopPropagation(),w!==void 0&&b(!0)},S=l.useCallback(K=>{K.stopPropagation(),window.open(xu(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:K,models:ee})=>({provider:K,tooltip:ee.length===1?ee[0]??K:ee.join(", ")}))??[],C=$l({userAgent:u,conversationId:e,clientProjectFolder:f}),E=na(C),A=u!=null&&u!=="",I=E??u??null,M=E!==null&&A?`${E} - ${u}`:null,k=Pf(e),R=cS(e),O=Lo(n,s,v),$=`${r} call${r!==1?"s":""}`;return t.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:L("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:K=>{K.target===K.currentTarget&&(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),c())},children:[t.jsx(F5,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.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?m!=null?t.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${m}`,children:["PID ",m]}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:R}),!k&&g&&m!==null&&m!==void 0&&t.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 ${m}`,children:["PID ",m]}),k&&g&&f!==null&&f!==void 0&&f!==""&&t.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:f,children:f}),h&&I!==null&&I!==""&&t.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??I,children:[t.jsx(sa,{client:C,className:"size-4 shrink-0",decorative:!0}),t.jsx("span",{className:"font-mono leading-snug tabular-nums",children:I})]}),p&&t.jsx(dS,{})]}),t.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx(Ea,{icon:t.jsx(en,{className:"size-3 shrink-0"}),title:O,children:O}),t.jsx(Ea,{icon:t.jsx(Po,{className:"size-3 shrink-0"}),children:$}),t.jsxs(Ea,{icon:t.jsx(Zs,{className:"size-3 shrink-0"}),className:"max-w-full",children:[t.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ie(o)})," / ",t.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ie(a)})]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[t.jsx("button",{type:"button",onClick:S,onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&S(K)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Hc,children:t.jsx(lr,{className:"size-3.5"})}),w!==void 0&&t.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${r} request${r!==1?"s":""})`,title:"Clear this group from the current view",className:Hc,children:t.jsx(Sn,{className:"size-3.5"})}),t.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?t.jsx(Ze,{className:"size-4 shrink-0"}):p?t.jsx(Ue,{className:"size-4 shrink-0 animate-spin"}):t.jsx(ct,{className:"size-4 shrink-0"})})]}),p&&t.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:t.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),t.jsx(Dl,{open:y,onOpenChange:b,title:"Clear this group from the current view?",description:`This will hide ${r} request${r!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{w?.()}})]})}function pS(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const n=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!n&&!s)return"default";const r=n?`PID:${e.clientPid}`:"unknown",o=s?e.clientProjectFolder:"no-folder";return`${r}|${o}`}function mS(e){const n=new Map;for(const r of e){const o=pS(r),a=n.get(o);a!==void 0?a.push(r):n.set(o,[r])}const s=[];for(const[r,o]of n){const a=[...o].sort((i,c)=>i.timestamp.localeCompare(c.timestamp));s.push({id:r,conversationId:r,logs:a})}return s.sort((r,o)=>(r.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),s}function fS(e,n,s){const r=new Array(e);return new Proxy(r,{get(o,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 p=o[d];if(!p){const u=n[d*2];p=o[d]={index:d,key:s(d),start:u,size:n[d*2+1],end:u+n[d*2+1],lane:0}}return p}}if(a==="length")return e}return Reflect.get(o,a,i)}})}function ss(e,n,s){let r=s.initialDeps??[],o,a=!0;function i(){const c=e();return(c.length!==r.length||c.some((p,u)=>r[u]!==p))&&(r=c,o=n(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(o),a=!1),o}return i.updateDeps=c=>{r=c},i}function Vc(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const hS=(e,n)=>Math.abs(e-n)<1.01,xS=(e,n,s)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>n.apply(this,o),s)}};let $s;const Ra=()=>{if($s!==void 0)return $s;if(typeof navigator>"u")return $s=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return $s=!0;const e=navigator.maxTouchPoints;return $s=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Wc=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},gS=e=>e,bS=e=>{const n=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(r);for(let a=0;a<r;a++)o[a]=n+a;return o},vS=(e,n)=>{const s=e.scrollElement;if(!s)return;const r=e.targetWindow;if(!r)return;const o=i=>{const{width:c,height:d}=i;n({width:Math.round(c),height:Math.round(d)})};if(o(Wc(s)),!r.ResizeObserver)return()=>{};const a=new r.ResizeObserver(i=>{const c=()=>{const d=i[0];if(d?.borderBoxSize){const p=d.borderBoxSize[0];if(p){o({width:p.inlineSize,height:p.blockSize});return}}o(Wc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},tr={passive:!0},yS=(e,n)=>{const s=e.scrollElement;if(!s)return;const r=()=>{n({width:s.innerWidth,height:s.innerHeight})};return r(),s.addEventListener("resize",r,tr),()=>{s.removeEventListener("resize",r)}},wS=typeof window>"u"?!0:"onscrollend"in window,Lf=(e,n,s)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const a=e.options.useScrollendEvent&&wS;let i=0;const c=a?null:xS(o,()=>n(i,!1),e.options.isScrollingResetDelay),d=m=>()=>{i=s(r),c?.(),n(i,m)},p=d(!0),u=d(!1);return r.addEventListener("scroll",p,tr),a&&r.addEventListener("scrollend",u,tr),()=>{r.removeEventListener("scroll",p),a&&r.removeEventListener("scrollend",u)}},jS=(e,n)=>Lf(e,n,s=>{const{horizontal:r,isRtl:o}=e.options;return r?s.scrollLeft*(o&&-1||1):s.scrollTop}),SS=(e,n)=>Lf(e,n,s=>e.options.horizontal?s.scrollX:s.scrollY),NS=(e,n,s)=>{if(s.options.useCachedMeasurements){const r=s.indexFromElement(e),o=s.options.getItemKey(r);return s.itemSizeCache.get(o)??s.options.estimateSize(r)}if(n?.borderBoxSize){const r=n.borderBoxSize[0];if(r)return Math.round(r[s.options.horizontal?"inlineSize":"blockSize"])}if(!n){const r=s.indexFromElement(e),o=s.options.getItemKey(r),a=s.itemSizeCache.get(o);if(a!==void 0)return a}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},Of=(e,{adjustments:n=0,behavior:s},r)=>{var o,a;(a=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||a.call(o,{[r.options.horizontal?"left":"top"]:e+n,behavior:s})},CS=Of,kS=Of;class TS{constructor(n){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,r,o;return((o=(r=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:r.now)==null?void 0:o.call(r))??Date.now()},this.observer=(()=>{let s=null;const r=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(o=>{o.forEach(a=>{const i=()=>{const c=a.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[p,u]of this.elementsCache)if(u===c){this.elementsCache.delete(p);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),s=null},observe:o=>{var a;return(a=r())==null?void 0:a.observe(o,{box:"border-box"})},unobserve:o=>{var a;return(a=r())==null?void 0:a.unobserve(o)}}})(),this.range=null,this.setOptions=s=>{var r,o;const a={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:gS,rangeExtractor:bS,onChange:()=>{},measureElement:NS,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,p=!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(),v=f>0?((r=g[0])==null?void 0:r.key)??i.getItemKey(0):null,w=f>0?((o=g[f-1])==null?void 0:o.key)??i.getItemKey(f-1):null;if(h!==f||f>0&&h>0&&(a.getItemKey(0)!==v||a.getItemKey(h-1)!==w)){p=!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)!==w)&&(d=S)}}this.options=a,p&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,m=0;if(c&&this.scrollOffset!==null){const[f,h]=c,g=this.getMeasurements(),{count:v,getItemKey:w}=this.options;let y=0;for(;y<v&&w(y)!==f;)y++;if(y<v){const b=g[y];if(b){const j=b.start+h;j!==this.scrollOffset&&(m=j-this.scrollOffset,this.scrollOffset=j,u=!0)}}}(u||d)&&(this.pendingScrollAnchor=[u?c[0]:null,u?c[1]:0,d,m])},this.notify=s=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,s)},this.maybeNotify=ss(()=>(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 r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,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,!(!Ra()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,tr),a.addEventListener("touchend",c,tr),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 o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[a,i,c,d]=o;a!==null&&!c&&(Ra()&&(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(),r=this.getMaxScrollOffset();if(s<0||s>r)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=o,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=ss(()=>[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,r,o,a,i,c,d,p)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:s,paddingStart:r,scrollMargin:o,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:p}),{key:!1}),this.getMeasurements=ss(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:r,scrollMargin:o,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:p},u)=>{const m=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const y of this.laneAssignments.keys())y>=s&&this.laneAssignments.delete(y);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(y=>{this.itemSizeCache.set(y.key,y.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 y=s*2;let b=this._flatMeasurements;if(!b||b.length<y){const N=new Float64Array(y);b&&f>0&&N.set(b.subarray(0,f*2)),b=N,this._flatMeasurements=b}let j;if(f===0)j=r+o;else{const N=f-1;j=b[N*2]+b[N*2+1]+p}for(let N=f;N<s;N++){const C=a(N),E=m.get(C),A=typeof E=="number"?E:this.options.estimateSize(N);b[N*2]=j,b[N*2+1]=A,j+=A+p}const S=fS(s,b,a);return this.measurementsCache=S,S}const h=this.measurementsCache.slice(0,f),g=new Array(c).fill(void 0),v=new Float64Array(c);let w=0;for(let y=0;y<f;y++){const b=h[y];b&&(g[b.lane]===void 0&&w++,g[b.lane]=y,v[b.lane]=b.end)}for(let y=f;y<s;y++){const b=a(y),j=this.laneAssignments.get(y);let S,N;const C=d==="estimate"||m.has(b);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+p:r+o}else if(w===c){let M=0,k=v[0],R=g[0];for(let O=1;O<c;O++){const $=v[O];($<k||$===k&&g[O]<R)&&(M=O,k=$,R=g[O])}S=M,N=k+p,C&&this.laneAssignments.set(y,S)}else S=y%this.options.lanes,N=r+o,C&&this.laneAssignments.set(y,S);const E=m.get(b),A=typeof E=="number"?E:this.options.estimateSize(y),I=N+A;h[y]={index:y,start:N,size:A,end:I,key:b,lane:S},g[S]===void 0&&w++,g[S]=y,v[S]=I}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ss(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,r,o,a)=>s.length===0||r===0?(this.range=null,null):(this.range=ES(s,r,o,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ss(()=>{let s=null,r=null;const o=this.calculateRange();return o&&(s=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,r]},(s,r,o,a,i)=>a===null||i===null?[]:s({startIndex:a,endIndex:i,overscan:r,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const r=this.options.indexAttribute,o=s.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(o!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,o-a),c=Math.min(this.options.count-1,o+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 r=this.indexFromElement(s),o=this.options.getItemKey(r),a=this.elementsCache.get(o);a!==s&&(a&&this.observer.unobserve(a),this.observer.observe(s),this.elementsCache.set(o,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,r)=>{var o,a;if(s<0||s>=this.options.count)return;let i,c,d;const p=this._flatMeasurements;if(this.options.lanes===1&&p!==null)d=this.options.getItemKey(s),c=p[s*2],i=p[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,m=r-u;if(m!==0){const f=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.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},m,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,r),this.itemSizeCacheVersion++,f?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(m),this.notify(!1)}},this.getVirtualItems=ss(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,r)=>{const o=[];for(let a=0,i=s.length;a<i;a++){const c=s[a],d=r[c];o.push(d)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const r=this.getMeasurements();if(r.length===0)return;const o=this._flatMeasurements,a=this.options.lanes===1&&o!=null,i=zf(0,r.length-1,a?c=>o[c*2]:c=>Vc(r[c]).start,s);return Vc(r[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,r,o=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=s>=i+a?"end":"start"),r==="center"?s+=(o-a)/2:r==="end"&&(s-=a);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,r="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const o=this.getSize(),a=this.getScrollOffset(),i=this.measurementsCache[s];if(!i)return;if(r==="auto")if(i.end>=a+o-this.options.scrollPaddingEnd)r="end";else if(i.start<=a+this.options.scrollPaddingStart)r="start";else return[a,r];if(r==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),r];const c=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,r,i.size),r]},this.scrollToOffset=(s,{align:r="start",behavior:o="auto"}={})=>{const a=this.getOffsetForAlignment(s,r),i=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:r="auto",behavior:o="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getOffsetForIndex(s,r);if(!a)return;const[i,c]=a,d=this.now();this.scrollState={index:s,align:c,behavior:o,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:r="auto"}={})=>{const o=this.getScrollOffset()+s,a=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:a,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),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 r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const a=r.length-1,i=this._flatMeasurements;i!=null?o=i[a*2]+i[a*2+1]:o=((s=r[a])==null?void 0:s.end)??0}else{const a=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&a.some(c=>c===null);){const c=r[i];a[c.lane]===null&&(a[c.lane]=c.end),i--}o=Math.max(...a.filter(c=>c!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const r=this.getMeasurements();for(const o of r)o&&this.itemSizeCache.has(o.key)&&s.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return s},this._scrollToOffset=(s,{adjustments:r,behavior:o})=>{this._intendedScrollOffset=s+(r??0),this.options.scrollToFn(s,{behavior:o,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,s){n!==0&&(Ra()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,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 r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=r?r[0]:this.scrollState.lastTargetOffset,a=1,i=o!==this.scrollState.lastTargetOffset;if(!i&&hS(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const c=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),p=this.scrollState.behavior==="smooth"&&d>c;this.scrollState.lastTargetOffset=o,p||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:p?"smooth":"auto"})}this.scheduleScrollReconcile()}}const zf=(e,n,s,r)=>{for(;e<=n;){const o=(e+n)/2|0,a=s(o);if(a<r)e=o+1;else if(a>r)n=o-1;else return o}return e>0?e-1:0};function _S(e,n,s){let r=0;for(;r<=n;){const o=(r+n)/2|0,a=e[o*2];if(a<s)r=o+1;else if(a>s)n=o-1;else return o}return r>0?r-1:0}function ES(e,n,s,r,o){const a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&o!==null){const p=_S(o,a,s);let u=p;const m=s+n;for(;u<a&&o[u*2]+o[u*2+1]<m;)u++;return{startIndex:p,endIndex:u}}let c=zf(0,a,p=>e[p].start,s),d=c;if(r===1)for(;d<a&&e[d].end<s+n;)d++;else if(r>1){const p=Array(r).fill(0);for(;d<a&&p.some(m=>m<s+n);){const m=e[d];p[m.lane]=m.end,d++}const u=Array(r).fill(s+n);for(;c>=0&&u.some(m=>m>=s);){const m=e[c];u[m.lane]=m.start,c--}c=Math.max(0,c-c%r),d=Math.min(a,d+(r-1-d%r))}return{startIndex:c,endIndex:d}}const Ma=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Df({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:s="transform",...r}){const o=l.useReducer(p=>p+1,0)[1],a=l.useRef({enabled:n,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=n,a.current.mode=s;const i=p=>{const u=a.current;if(!u.enabled||!u.container)return;const m=p.getTotalSize();if(m!==u.lastSize){u.lastSize=m;const y=p.options.horizontal?"width":"height";u.container.style[y]=`${m}px`}const f=!!p.options.horizontal,h=u.mode==="transform",g=f?"left":"top",v=p.options.scrollMargin,w=p.getVirtualItems();for(const y of w){const b=y.start-v,j=p.elementsCache.get(y.key);j&&u.lastPositions.get(j)!==b&&(u.lastPositions.set(j,b),h?j.style.transform=f?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:j.style[g]=`${b}px`)}},c={...r,onChange:(p,u)=>{var m;const f=a.current;let h=!0;if(f.enabled){i(p);const g=p.range,v=f.prevRange;h=!v||v.isScrolling!==p.isScrolling||v.startIndex!==g?.startIndex||v.endIndex!==g?.endIndex,h&&(f.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:p.isScrolling}:null)}h&&(e&&u?Es.flushSync(o):o()),(m=r.onChange)==null||m.call(r,p,u)}},[d]=l.useState(()=>{const p=new TS(c);return Object.assign(p,{containerRef:u=>{const m=a.current;if(m.container=u,m.lastSize=null,u&&m.enabled){const f=p.getTotalSize();m.lastSize=f;const h=p.options.horizontal?"width":"height";u.style[h]=`${f}px`}}})});return d.setOptions(c),Ma(()=>d._didMount(),[]),Ma(()=>d._willUpdate()),Ma(()=>{i(d)}),d}function RS(e){return Df({observeElementRect:vS,observeElementOffset:jS,scrollToFn:kS,...e})}function MS(e){return Df({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:yS,observeElementOffset:SS,scrollToFn:CS,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const rn="agent-inspector:focus-log";function ks(e){window.dispatchEvent(new CustomEvent(rn,{detail:e}))}function ra(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const n=e.detail,s=G(n,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const r=G(n,"tab");switch(r){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const o=G(n,"source"),a=G(n,"toolCallIndex"),i=typeof a=="number"&&Number.isInteger(a)&&a>=0?{logId:s,tab:r??"request",toolCallIndex:a}:{logId:s,tab:r??"request"};switch(o){case"virtualizer":return{...i,source:o};case void 0:return i;default:return null}}function Gc(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function $f(e){if(!ds(e))return null;if(typeof e.stop_reason=="string")return Gc(e.stop_reason);if(ds(e.delta)&&typeof e.delta.stop_reason=="string")return Gc(e.delta.stop_reason);if(Array.isArray(e.choices))for(const n of e.choices){if(!ds(n)||typeof n.finish_reason!="string")continue;const s=IS(n.finish_reason);if(s!==null)return s}if(Array.isArray(e.output)){for(const n of e.output)if(ds(n)&&n.type==="function_call")return"tool_use";if(e.status==="completed")return"stop"}if(e.status==="incomplete"&&ds(e.incomplete_details)){const n=e.incomplete_details.reason;if(typeof n=="string"&&PS(n))return"length"}return null}function AS(e){let n=null;for(const s of e.split(`
|
|
49
|
+
`)){const r=s.trim();if(!r.startsWith("data: "))continue;const o=r.slice(6).trim();if(o==="[DONE]")break;try{const a=$f(JSON.parse(o));a!==null&&(n=a)}catch{}}return n}function IS(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function PS(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Ff(e){if(e.stopReason!==void 0)return e.stopReason;if(e.responseText===null)return null;try{let n=JSON.parse(e.responseText);return typeof n=="string"&&(n=JSON.parse(n)),$f(n)}catch{return AS(e.responseText)}}function Hl(e){return e==="end_turn"||e==="stop"||e==="length"}function Et({className:e,style:n,d:s,eyeStalks:r,eyes:o,legs:a,extras:i}){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:n,className:L("inline-block size-5",e),children:[t.jsx("path",{d:s}),r,o,a,i]})}const Rn=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),t.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),t.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),t.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),Bf=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),t.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),t.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),t.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function Uf({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.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 LS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),t.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:Bf,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),t.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function OS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),t.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),t.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function zS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),t.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),t.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),t.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),t.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),t.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function DS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.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 $S({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.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 FS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),t.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),t.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:Bf,extras:t.jsxs(t.Fragment,{children:[t.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"}),t.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 BS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),t.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function US({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function qS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),t.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),t.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),t.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),t.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),t.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function HS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),t.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),t.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:Rn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function VS({className:e}){return t.jsx(Et,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),t.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),t.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),t.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),t.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),t.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 Ri=[Uf,LS,OS,zS,DS,$S,FS,BS,US,qS,HS,VS];function Vl(e){return Ri[Math.abs(e)%Ri.length]??Uf}function WS(e){const n=Ri.length-2;return n<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%n+n)%n}function GS(e){return Vl(WS(e))}const KS="x-anthropic-billing-header:";function YS(e){return e.trimStart().toLowerCase().startsWith(KS)}function JS(e){return Ul(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function XS(e){if(!Ul(e))return!1;const n=G(e,"type"),s=G(e,"text");return typeof n!="string"||n!=="text"||typeof s!="string"?!1:YS(s)}function ZS(e){let n;try{n=JSON.parse(e)}catch{return{body:e,removed:0}}if(!JS(n))return{body:e,removed:0};const s=n.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const r=[];let o=0;for(const a of s){if(XS(a)){o+=1;continue}r.push(a)}return o===0?{body:e,removed:0}:(r.length===0?delete n.system:n.system=r,{body:JSON.stringify(n),removed:o})}const QS=400,Kc=2e3;function eN(e){return Array.isArray(e)}function tN(e,n){const s=[e];let r=0;for(;s.length>0;){const o=s.pop();if(o!==void 0){if(r+=1,r>n)return r;if(!(o===null||typeof o!="object")){if(eN(o)){for(const a of o)s.push(a);continue}for(const a of Object.keys(o)){const i=o[a];i!==void 0&&s.push(i)}}}}return r}function nN(e){const n=tN(e,Kc+1);return n<=QS?{depth:Number.POSITIVE_INFINITY}:n<=Kc?{depth:3}:{depth:2}}function sN(e){try{const n=JSON.parse(e);return{kind:"json",data:vo(n)}}catch{return{kind:"text"}}}function Aa(e){const n=l.useMemo(()=>e===null?null:sN(e),[e]),s=n?.kind==="json"?n.data:null,r=l.useMemo(()=>s===null?null:nN(s),[s]),[o,a]=l.useState(!1),[i,c]=l.useState(0),[d,p]=l.useState(0),[u,m]=l.useTransition(),f=l.useCallback(()=>{const h=!o,g=h&&r!==null?r.depth:0;m(()=>{a(h),c(g),p(v=>v+1)})},[o,r]);return{parsedData:s,policy:r,isExpanded:o,toggle:f,isPending:u,bulkDepth:i,bulkRevision:d}}function vo(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=>vo(s));const n={};for(const s of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,s);n[s]=vo(r?.value)}return n}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function qf({className:e,orientation:n="horizontal",...s}){return t.jsx(Dj,{"data-slot":"tabs","data-orientation":n,orientation:n,className:L("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const rN=gu("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 Hf({className:e,variant:n="default",...s}){return t.jsx($j,{"data-slot":"tabs-list","data-variant":n,className:L(rN({variant:n}),e),...s})}function Zt({className:e,...n}){return t.jsx(Fj,{"data-slot":"tabs-trigger",className:L("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),...n})}function ut({className:e,...n}){return t.jsx(Bj,{"data-slot":"tabs-content",className:L("flex-1 outline-none",e),...n})}function xn(e){const[n,s]=l.useState(!1),r=l.useRef(null);l.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=l.useCallback(a=>{a.stopPropagation(),e!==null&&bt(e).then(i=>{i&&(s(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:n,copy:o}}const oN=l.lazy(()=>Kt(()=>import("./CompareDrawer-2xeE_Q1P.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),aN=l.lazy(()=>Kt(()=>import("./InspectorPet-AvhMmdDB.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),iN=l.lazy(()=>Kt(()=>import("./ReplayDialog-7bUrau-W.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),lN=l.lazy(()=>Kt(()=>import("./RequestAnatomy-CB2DHVi8.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),cN=l.lazy(()=>Kt(()=>import("./ResponseView-Ce4vSp-V.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),dN=l.lazy(()=>Kt(()=>import("./StreamingChunkSequence-B4NyOyI1.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),Mi=l.lazy(()=>Kt(()=>import("./json-viewer-D29qxkd8.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),uN=l.lazy(()=>Kt(()=>import("./json-viewer-D29qxkd8.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),pN=1200,mN=12;function fN(e){const{containerRef:n,setExpandToPath:s,ensureTabActive:r,highlightMs:o}=e,a=l.useRef(null);return l.useCallback(i=>{r?.(),s(i.path);const c=m=>{m.scrollIntoView({behavior:"smooth",block:"center"}),m.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(()=>{m.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},o??pN)},p=`[data-anatomy-path="${(m=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(m):m.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=m=>{const f=n.current;if(f!==null){const h=f.querySelector(p);if(h!==null){c(h);return}}m>0?window.requestAnimationFrame(()=>u(m-1)):s(null)};window.requestAnimationFrame(()=>u(mN))},[n,r,o,s])}var hN={};const Yc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.",Jc=64,Qt=new Map,Yr=new Map;function us(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 xN(e,n){const s=[];return e!=null&&s.push(`Request ${us(e)}`),n!=null&&s.push(`Response ${us(n)}`),s.length===0?null:s.join(" · ")}function gN(e){if(e instanceof Ao)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 n=e.message.trim();return{title:"Full bodies could not be loaded",detail:n===""?Yc:n}}return{title:"Full bodies could not be loaded",detail:Yc}}function bN(){const e=hN.AGENT_INSPECTOR_UI_DETAIL_CACHE_LIMIT;if(e===void 0||e==="")return Jc;const n=Number(e);return!Number.isSafeInteger(n)||n<1||n>1e3?Jc:n}function vN(e){for(Qt.delete(e.id),Qt.set(e.id,e);Qt.size>bN();){const n=Qt.keys().next().value;if(typeof n!="number")break;Qt.delete(n)}return e}function Vf(e){const n=Qt.get(e);return n===void 0?null:(Qt.delete(e),Qt.set(e,n),n)}function yN(e){Qt.delete(e),Yr.delete(e)}async function wN(e,n){const s=Vf(e);if(s!==null)return s;const r=Yr.get(e);if(r!==void 0)return await r;const o=n().then(vN).finally(()=>{Yr.delete(e)});return Yr.set(e,o),await o}class Wf{diff(n,s,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const a=this.castInput(n,r),i=this.castInput(s,r),c=this.removeEmpty(this.tokenize(a,r)),d=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(c,d,r,o)}diffWithOptionsObj(n,s,r,o){var a;const i=b=>{if(b=this.postProcess(b,r),o){setTimeout(function(){o(b)},0);return}else return b},c=s.length,d=n.length;let p=1,u=c+d;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));const m=(a=r.timeout)!==null&&a!==void 0?a:1/0,f=Date.now()+m,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,n,0,r);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,n));let v=-1/0,w=1/0;const y=()=>{for(let b=Math.max(v,-p);b<=Math.min(w,p);b+=2){let j;const S=h[b-1],N=h[b+1];S&&(h[b-1]=void 0);let C=!1;if(N){const A=N.oldPos-b;C=N&&0<=A&&A<c}const E=S&&S.oldPos+1<d;if(!C&&!E){h[b]=void 0;continue}if(!E||C&&S.oldPos<N.oldPos?j=this.addToPath(N,!0,!1,0,r):j=this.addToPath(S,!1,!0,1,r),g=this.extractCommon(j,s,n,b,r),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,n))||!0;h[b]=j,j.oldPos+1>=d&&(w=Math.min(w,b-1)),g+1>=c&&(v=Math.max(v,b+1))}p++};if(o)(function b(){setTimeout(function(){if(p>u||Date.now()>f)return o(void 0);y()||b()},0)})();else for(;p<=u&&Date.now()<=f;){const b=y();if(b)return b}}addToPath(n,s,r,o,a){const i=n.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===r?{oldPos:n.oldPos+o,lastComponent:{count:i.count+1,added:s,removed:r,previousComponent:i.previousComponent}}:{oldPos:n.oldPos+o,lastComponent:{count:1,added:s,removed:r,previousComponent:i}}}extractCommon(n,s,r,o,a){const i=s.length,c=r.length;let d=n.oldPos,p=d-o,u=0;for(;p+1<i&&d+1<c&&this.equals(r[d+1],s[p+1],a);)p++,d++,u++,a.oneChangePerToken&&(n.lastComponent={count:1,previousComponent:n.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(n.lastComponent={count:u,previousComponent:n.lastComponent,added:!1,removed:!1}),n.oldPos=d,p}equals(n,s,r){return r.comparator?r.comparator(n,s):n===s||!!r.ignoreCase&&n.toLowerCase()===s.toLowerCase()}removeEmpty(n){const s=[];for(let r=0;r<n.length;r++)n[r]&&s.push(n[r]);return s}castInput(n,s){return n}tokenize(n,s){return Array.from(n)}join(n){return n.join("")}postProcess(n,s){return n}get useLongestToken(){return!1}buildValues(n,s,r){const o=[];let a;for(;n;)o.push(n),a=n.previousComponent,delete n.previousComponent,n=a;o.reverse();const i=o.length;let c=0,d=0,p=0;for(;c<i;c++){const u=o[c];if(u.removed)u.value=this.join(r.slice(p,p+u.count)),p+=u.count;else{if(!u.added&&this.useLongestToken){let m=s.slice(d,d+u.count);m=m.map(function(f,h){const g=r[p+h];return g.length>f.length?g:f}),u.value=this.join(m)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(p+=u.count)}}return o}}class jN extends Wf{constructor(){super(...arguments),this.tokenize=Kf}equals(n,s,r){return r.ignoreWhitespace?((!r.newlineIsToken||!n.includes(`
|
|
50
|
+
`))&&(n=n.trim()),(!r.newlineIsToken||!s.includes(`
|
|
51
|
+
`))&&(s=s.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(n.endsWith(`
|
|
52
|
+
`)&&(n=n.slice(0,-1)),s.endsWith(`
|
|
53
|
+
`)&&(s=s.slice(0,-1))),super.equals(n,s,r)}}const SN=new jN;function Gf(e,n,s){return SN.diff(e,n,s)}function Kf(e,n){n.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
54
|
+
`));const s=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const a=r[o];o%2&&!n.newlineIsToken?s[s.length-1]+=a:s.push(a)}return s}class NN extends Wf{constructor(){super(...arguments),this.tokenize=Kf}get useLongestToken(){return!0}castInput(n,s){const{undefinedReplacement:r,stringifyReplacer:o=(a,i)=>typeof i>"u"?r:i}=s;return typeof n=="string"?n:JSON.stringify(Ai(n,null,null,o),null," ")}equals(n,s,r){return super.equals(n.replace(/,([\r\n])/g,"$1"),s.replace(/,([\r\n])/g,"$1"),r)}}const CN=new NN;function kN(e,n,s){return CN.diff(e,n,s)}function Ai(e,n,s,r,o){n=n||[],s=s||[],r&&(e=r(o===void 0?"":o,e));let a;for(a=0;a<n.length;a+=1)if(n[a]===e)return s[a];let i;if(Object.prototype.toString.call(e)==="[object Array]"){for(n.push(e),i=new Array(e.length),s.push(i),a=0;a<e.length;a+=1)i[a]=Ai(e[a],n,s,r,String(a));return n.pop(),s.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){n.push(e),i={},s.push(i);const c=[];let d;for(d in e)Object.prototype.hasOwnProperty.call(e,d)&&c.push(d);for(c.sort(),a=0;a<c.length;a+=1)d=c[a],i[d]=Ai(e[d],n,s,r,d);n.pop(),s.pop()}else i=e;return i}function Xc(e){return e===void 0?[]:Object.entries(e).map(n=>[n[0].toLowerCase(),n[1]]).sort(([n],[s])=>n.localeCompare(s))}function Zc([e,n]){return`${e}: ${n}`}function Ii(e){const n=[];let s=0,r=0;for(const o of e){const a=o.value.split(`
|
|
55
|
+
`);a.length>0&&a[a.length-1]===""&&a.pop();for(const i of a)o.added?(r+=1,n.push({kind:"added",text:i,oldLineNumber:null,newLineNumber:r})):o.removed?(s+=1,n.push({kind:"removed",text:i,oldLineNumber:s,newLineNumber:null})):(s+=1,r+=1,n.push({kind:"context",text:i,oldLineNumber:s,newLineNumber:r}))}return n}function TN(e,n){const s=Xc(e).map(Zc).join(`
|
|
56
|
+
`),r=Xc(n).map(Zc).join(`
|
|
57
|
+
`);if(s===r)return{lines:[],isEmpty:!0};const o=Gf(s,r);return{lines:Ii(o),isEmpty:!1}}function Qc(e){try{const n=JSON.parse(e);return n===null||typeof n=="string"||typeof n=="object"?n:null}catch{return null}}function _N(e,n){const s=e??"",r=n??"";if(s===r)return{lines:[],isEmpty:!0};const o=Qc(s),a=Qc(r);if(o!==null&&a!==null){const c=kN(o,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:Ii(c),isEmpty:!1}}const i=Gf(s,r);return{lines:Ii(i),isEmpty:!1}}const EN=22,Ia=1e4;function RN(e){return e==="added"?"+":e==="removed"?"-":" "}function MN(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 AN=function({result:n,emptyLabel:s}){const[r,o]=l.useState("unified"),a=l.useRef(null),i=RS({count:n.lines.length,getScrollElement:()=>a.current,estimateSize:()=>EN,overscan:10});if(n.isEmpty)return t.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=n.lines.length,d=c>Ia,p=d?n.lines.slice(0,Ia):n.lines;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${Ia.toLocaleString()})`]}),t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:L("flex items-center gap-1 px-2 py-1 transition-colors",r==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[t.jsx(P1,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:L("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",r==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[t.jsx(j0,{className:"size-3"}),"Split"]})]})]}),t.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:r==="unified"?t.jsx(IN,{virtualizer:i,lines:p}):t.jsx(ON,{lines:p})})]})};function IN({virtualizer:e,lines:n}){return t.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const r=n[s.index];return r===void 0?null:t.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:L("flex items-start gap-3 px-2",MN(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),t.jsx("span",{className:L("select-none w-3 text-right font-bold",r.kind==="added"&&"text-green-600 dark:text-green-400",r.kind==="removed"&&"text-red-600 dark:text-red-400"),children:RN(r.kind)}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},s.key)})})}function PN(e){const n=[];let s=0;for(;s<e.length;){const r=e[s];if(r===void 0)break;if(r.kind==="context"){n.push({left:{text:r.text,lineNumber:r.oldLineNumber},right:{text:r.text,lineNumber:r.newLineNumber},kind:"equal"}),s+=1;continue}const o=[],a=[];for(;s<e.length&&e[s]?.kind==="removed";){const c=e[s];c!==void 0&&o.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(o.length,a.length);for(let c=0;c<i;c+=1){const d=o[c],p=a[c];d!==void 0&&p!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:p.text,lineNumber:p.newLineNumber},kind:"changed"}):d!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):p!==void 0&&n.push({left:null,right:{text:p.text,lineNumber:p.newLineNumber},kind:"added"})}}return n}function LN(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 ON({lines:e}){const n=PN(e);return t.jsx("div",{"data-testid":"diff-split",children:n.map((s,r)=>t.jsxs("div",{className:L("grid grid-cols-2 font-mono text-xs",LN(s.kind)),children:[t.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),t.jsx("span",{className:L("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?"-":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),t.jsxs("div",{className:"flex items-start gap-2 px-2",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),t.jsx("span",{className:L("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?"+":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},r))})}const Yf=l.memo(AN),zN=gu("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 Te({className:e,variant:n="default",asChild:s=!1,...r}){const o=s?Rv:"span";return t.jsx(o,{"data-slot":"badge","data-variant":n,className:L(zN({variant:n}),e),...r})}const DN=3;function $N({event:e}){const n=s=>{s.stopPropagation(),ks({logId:e.logId,tab:"response",toolCallIndex:e.index})};return t.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:n,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:t.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function FN({events:e}){if(e.length===0)return null;const n=e.slice(0,DN),s=Math.max(0,e.length-n.length);return t.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:r=>r.stopPropagation(),onKeyDown:r=>r.stopPropagation(),children:[t.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:[t.jsx(cr,{className:"size-3"}),"Call ",e.length]}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[n.map(r=>t.jsx($N,{event:r},r.id)),s>0&&t.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 BN={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"},UN={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"}},Fs="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",At="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Bs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function qN(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function HN(e,n){switch(e){case"success":return n===null?"OK":String(n);case"client_error":return n===null?"WARN":String(n);case"server_error":return n===null?"FAIL":String(n);case"pending":return"ROLL"}}function ed({trend:e}){if(e===null)return null;const n=e.direction==="up",s=n?Rg:Ng,r=n?"+":"-";return t.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[t.jsx(s,{className:n?"size-3 text-cyan-300":"size-3 text-rose-400"}),t.jsxs("span",{className:"font-mono",children:[r,Ie(e.delta)]})]})}const VN=l.memo(function({log:e,displayNumber:n,messageCount:s=null,toolCount:r=null,toolEvents:o=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:p,onReplay:u,slowResponseThresholdSeconds:m=0,showClientMetadata:f=!0,timeDisplayFormat:h}){const g=ix(e.responseStatus),v=e.elapsedMs!==null&&m>0&&e.elapsedMs>m*1e3,w=e.inputTokens!==null||e.outputTokens!==null,y=e.firstChunkMs??null,b=e.tokensPerSecond??null,j=y===null?null:Bs(y),S=b===null||b<=0?null:qN(b),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,E=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const A=UN[g],I=HN(g,e.responseStatus),M=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return t.jsx(Ps,{children:t.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:L("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:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),i())},children:[t.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:L("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",A.frame),children:t.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",n]})}),t.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:[t.jsx(en,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:mi(e.timestamp,h)})]}),M&&t.jsxs(Te,{variant:"outline",className:L("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)]",BN[g]),children:[g==="success"?t.jsx(De,{className:"size-3","aria-label":"Success"}):g==="server_error"?t.jsx(v1,{className:"size-3","aria-label":"Server error"}):g==="client_error"?t.jsx(yn,{className:"size-3","aria-label":"Client error"}):t.jsx(Ue,{className:"size-3 animate-spin","aria-label":"Pending"}),I]}),N>0&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsxs(Te,{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:[t.jsx(yn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),t.jsx(ft,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(v?t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsxs("span",{className:L(At,"shrink-0 border-amber-300/25 text-amber-200"),children:[t.jsx(en,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:Bs(e.elapsedMs)}),t.jsx(yn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsxs(ft,{children:["Slow response: ",Bs(e.elapsedMs)," exceeds"," ",Bs(m*1e3)]})]}):t.jsxs("span",{className:L(At,"shrink-0 text-muted-foreground"),children:[t.jsx(en,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:Bs(e.elapsedMs)})]})),e.streaming&&j!==null&&t.jsxs("span",{className:L(At,"shrink-0 text-cyan-300"),children:[t.jsx(ci,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&t.jsxs("span",{className:L(At,"shrink-0 text-cyan-300"),children:[t.jsx(il,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:S})]}),w&&t.jsxs("span",{className:L(At,"min-w-0 sm:shrink-0"),children:[t.jsx(Zs,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[t.jsxs("span",{className:L("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ie(e.inputTokens):"n/a"]}),t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsxs("span",{className:L("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ie(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:L(At,"shrink-0"),children:[t.jsx(ed,{trend:c?.creation??null}),t.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ie(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:L(At,"shrink-0"),children:[t.jsx(ed,{trend:c?.read??null}),t.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ie(e.cacheReadInputTokens)]})]}),s!==null&&t.jsxs("span",{className:L(At,"shrink-0 text-muted-foreground"),children:[t.jsx(Po,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:s})]}),r!==null&&t.jsxs("span",{className:L(At,"shrink-0 text-muted-foreground"),children:[t.jsx(cr,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:r})]}),t.jsx(FN,{events:o}),e.origin!==null&&t.jsxs("span",{className:L(At,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[t.jsx(Wu,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(C||E)&&t.jsxs("span",{className:L(At,"hidden shrink-0 text-purple-300 xl:flex"),children:[t.jsx(F0,{className:"size-3"}),E?t.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):t.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&t.jsx(ci,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:R=>R.stopPropagation(),onKeyDown:R=>R.stopPropagation(),children:[p!==void 0&&d!==void 0&&(()=>{const R=p[d];return R===void 0?null:t.jsxs(t.Fragment,{children:[R.expansion!==null&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx(J,{variant:"outline",size:"icon",className:Fs,onClick:R.expansion.onToggle,disabled:R.expansion.isPending,"aria-pressed":R.expansion.isExpanded,"aria-label":R.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:R.expansion.isExpanded?t.jsx(Xg,{className:"size-3.5"}):t.jsx(Vg,{className:"size-3.5"})})}),t.jsx(ft,{children:R.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),R.diffWithRaw!==void 0&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx(J,{variant:"outline",size:"icon",className:L(Fs,R.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:R.diffWithRaw.onToggle,"aria-pressed":R.diffWithRaw.active,"aria-label":R.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:t.jsx(O0,{className:"size-3.5"})})}),t.jsx(ft,{children:R.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),R.diffWithPrevious!==void 0&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx(J,{variant:"outline",size:"icon",className:Fs,onClick:R.diffWithPrevious,"aria-label":"Diff with previous",children:t.jsx(Gu,{className:"size-3.5"})})}),t.jsx(ft,{children:"Compare this request with the immediately preceding one"})]}),R.copyText!==null&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx(J,{variant:"outline",size:"icon",className:Fs,onClick:R.onCopy,"aria-label":R.copyCopied?"Copied":R.copyLabel,children:R.copyCopied?t.jsx(De,{className:"size-3.5 text-cyan-300"}):t.jsx(yt,{className:"size-3.5"})})}),t.jsx(ft,{children:R.copyCopied?"Copied to clipboard":R.copyLabel})]})]})})(),u!==void 0&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx(J,{variant:"outline",size:"icon",className:Fs,onClick:u,"aria-label":"Replay request",children:t.jsx(Zu,{className:"size-3.5"})})}),t.jsx(ft,{children:"Re-send this request to the provider"})]})]}),t.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?t.jsx(Ze,{className:"size-4 shrink-0"}):t.jsx(ct,{className:"size-4 shrink-0"})})]})]})})});function WN({...e}){return t.jsx(s2,{"data-slot":"collapsible",...e})}function YR({...e}){return t.jsx(pp,{"data-slot":"collapsible-trigger",...e})}function GN({...e}){return t.jsx(mp,{"data-slot":"collapsible-content",...e})}function KN({className:e,children:n,...s}){return t.jsxs(lj,{"data-slot":"scroll-area",className:L("relative overflow-hidden",e),...s,children:[t.jsx(cj,{"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:n}),t.jsx(YN,{}),t.jsx(dj,{})]})}function YN({className:e,orientation:n="vertical",...s}){return t.jsx(jm,{"data-slot":"scroll-area-scrollbar",orientation:n,className:L("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:t.jsx(km,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Jf={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},JN={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 XN({category:e}){switch(e){case"file":return t.jsx(U0,{className:"size-3.5"});case"shell":return t.jsx(qn,{className:"size-3.5"});case"browser":return t.jsx(h1,{className:"size-3.5"});case"web":return t.jsx(Wu,{className:"size-3.5"});case"mcp":return t.jsx(Lg,{className:"size-3.5"});case"code":return t.jsx(qu,{className:"size-3.5"});case"other":return t.jsx(_0,{className:"size-3.5"})}}function ZN({names:e}){return e.length===0?null:t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(n=>t.jsx(Te,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:n},n)),e.length>4&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function QN({tool:e,called:n}){const[s,r]=l.useState(!1),o=xn(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return t.jsx(WN,{open:s,onOpenChange:r,children:t.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[t.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:()=>r(i=>!i),"aria-expanded":s,disabled:!a,children:[t.jsx(XN,{category:e.category}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),n&&t.jsx(Te,{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"}),t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),t.jsx("span",{className:"flex-1"}),a&&(s?t.jsx(Ze,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(ct,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),t.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:o.copy,"aria-label":o.copied?"Copied tool name":"Copy tool name",children:o.copied?t.jsx(De,{className:"size-3.5 text-emerald-400"}):t.jsx(yt,{className:"size-3.5"})})]}),t.jsx(GN,{children:s&&t.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),t.jsx(ZN,{names:e.requiredParameters}),e.schema!==null&&t.jsx(KN,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:t.jsx(l.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(Mi,{data:vo(e.schema),defaultExpandDepth:0})})})]})})]})})}function eC(e,n){return n.length===0?!0:`${e.name} ${e.description??""} ${Jf[e.category]}`.toLowerCase().trim().includes(n)}const tC=l.memo(function({summary:n,calledToolNames:s}){const[r,o]=l.useState(!1),[a,i]=l.useState(""),c=l.useMemo(()=>new Set(s),[s]),d=a.trim().toLowerCase(),p=l.useMemo(()=>n===null?[]:n.tools.filter(f=>eC(f,d)),[d,n]);if(n===null)return null;const u=n.tools.slice(0,6),m=n.tools.length-u.length;return t.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx(cr,{className:"size-4 shrink-0 text-sky-300/80"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),t.jsx(Te,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:n.tools.length}),n.toolChoiceLabel!==null&&t.jsxs(Te,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",n.toolChoiceLabel]})]}),t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:n.categories.map(f=>t.jsxs(Te,{variant:"outline",className:L("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",JN[f.category]),children:[f.count," ",Jf[f.category]]},f.category))})]})]}),t.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(f=>!f),"aria-expanded":r,children:[r?t.jsx(Ze,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"}),r?"Hide":"Show"]})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(f=>t.jsx(Te,{variant:"outline",className:L("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)),m>0&&t.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",m]})]}),r&&t.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[t.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:[t.jsx(F1,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.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"})]}),t.jsx("div",{className:"grid gap-1.5",children:p.length>0?p.map(f=>t.jsx(QN,{tool:f,called:c.has(f.name)},f.name)):t.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function td(e,n,s){return e==="anthropic"&&n==="full"&&s}function nC(e,n){return e==="full"&&n}function Pa(e,n){return e==="full"&&n}function La(e,n){return e==="full"&&n}function sC(e,n){return e==="full"&&n===!0}function rC(e,n,s,r){return e==="anthropic"&&n==="full"&&s&&r}const oC=new Set(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","shutdown"]);function aC({responseStatus:e,captureIncompleteReason:n,error:s}){const r=s==null||s===""?null:s;return n==="upstream-stream-error"?{title:"Upstream stream interrupted",summary:"The provider connection ended before the streaming response completed. Inspector preserved the response prefix it had already received.",detail:r,action:"Retry the request. If it repeats, check the provider status, network path, proxy, and timeout settings.",source:"upstream"}:n!=null&&oC.has(n)?{title:"Inspector capture failed",summary:"Inspector encountered an internal capture or persistence problem. The coding tool may still have received the model response.",detail:r??`Capture stage: ${n}`,action:"Check Inspector health and runtime logs, then retry. Report the capture stage shown here if the problem repeats.",source:"inspector"}:e===502&&r!==null?{title:"Inspector could not complete the upstream request",summary:"Inspector generated this 502 before it could obtain a complete response from the provider.",detail:r,action:"Check the provider URL, DNS, TLS, network access, and timeout settings, then retry.",source:"inspector"}:e===502?{title:"Upstream returned HTTP 502",summary:"The provider or an upstream gateway returned this response. Inspector forwarded it unchanged.",detail:null,action:"Retry the request or check the provider and gateway status.",source:"upstream"}:r!==null?{title:"Streaming response error",summary:"The response stream did not complete normally.",detail:r,action:"Retry the request and inspect the detail below if the problem repeats.",source:"upstream"}:null}function rs(){return t.jsx("div",{className:"h-1","aria-hidden":"true"})}function iC(e,n){switch(e){case"anatomy":return n===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const lC=15e3,cC=15e3,dC=256*1024,gn=1024*1024,nd=256*1024,Oa=512*1024,cn="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 kr(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function yo(e){return e??0}function ps(e,n){return n??e?.length??0}function Wl(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Xf(e){return Wl(e)?yo(e.rawRequestBodyBytes)>gn||yo(e.responseTextBytes)>gn:!1}function uC(e){return Wl(e)&&!Xf(e)}function pC(e,n){return Wl(e)?!1:n?ps(e.rawRequestBody,e.rawRequestBodyBytes)<=gn&&ps(e.responseText,e.responseTextBytes)<=gn:ps(e.rawRequestBody,e.rawRequestBodyBytes)<=nd&&ps(e.responseText,e.responseTextBytes)<=nd}function mC(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 fC(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 hC(e){return e instanceof Ao?"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 Tr({status:e,error:n,footprint:s,onRetry:r}){switch(e){case"idle":return null;case"loading":return t.jsx(Ts,{tone:"loading",title:"Loading full bodies",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ue,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),t.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&t.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 t.jsx(Ts,{tone:"warning",title:n?.title??"Full bodies could not be loaded",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{children:n?.detail??"Compact metadata is still available."}),t.jsxs(J,{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:r,children:[t.jsx(lt,{className:"size-3"}),"Retry"]})]})})}}function sd(e,n){return e?n.text!==""?n.text:n.status==="success"?"":null:null}function dn({children:e,className:n}){return t.jsx("div",{className:L("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",n),children:e})}function Jr({children:e}){return t.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function _r({children:e}){const[n,s]=l.useState(!1),r=typeof e=="string"?e:null,o=r!==null&&r.length>Oa,a=r!==null&&o&&!n?r.slice(0,Oa):e;return l.useEffect(()=>{s(!1)},[r]),t.jsxs("div",{className:"space-y-2",children:[o&&!n&&t.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 ",Oa.toLocaleString()," characters for fast rendering. The full body is preserved and can still be copied from the tab action."]}),t.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}),o&&t.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:n?"Collapse fast preview":`Render full body (${r.length.toLocaleString()} chars)`})]})}const xC={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 Ts({tone:e,title:n,children:s}){return t.jsxs("div",{className:L("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",xC[e]),children:[n!==void 0&&t.jsx("div",{className:"mb-1 font-semibold",children:n}),t.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function Er({label:e,state:n,expectedBytes:s,onLoadMore:r}){const o=n.totalBytes??s,a=o===null?us(n.offset):`${us(n.offset)} / ${us(o)}`,i=n.status!=="loading"&&n.hasMore,c=n.status==="failed"?"Retry":"Load more";return t.jsx(Ts,{tone:n.status==="failed"?"warning":"loading",title:`${e} body preview`,children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{children:[n.status==="idle"&&o!==null?`${e} body is ${us(o)}. Loading the first preview chunk.`:`Loaded ${a}.`,n.status==="failed"&&n.error!==null&&` ${n.error}`]}),i&&t.jsx(J,{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:r,children:c})]})})}function za({responseStatus:e,captureIncompleteReason:n,error:s,onOpenSse:r}){const o=aC({responseStatus:e,captureIncompleteReason:n,error:s});return o===null?null:t.jsx(Ts,{tone:"danger",title:o.title,children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{children:o.summary}),o.detail!==null&&t.jsx("div",{className:"rounded border border-destructive/30 bg-background/40 px-2 py-1.5 font-mono text-foreground",children:o.detail}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-muted-foreground",children:[t.jsxs("span",{children:["Source: ",o.source==="inspector"?"Agent Inspector":"Upstream provider","."," ",o.action]}),r!==void 0&&t.jsx(J,{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:r,children:"View SSE"})]})]})})}function gC({onOpenSse:e}){return t.jsx(Ts,{tone:"loading",title:"SSE chunks",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{children:"Streaming chunks are available in the SSE tab."}),t.jsx(J,{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 rd({headers:e,emptyLabel:n}){const s=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return s.length===0?t.jsx(Jr,{children:n}):t.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([r,o])=>t.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:[t.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:r}),t.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},r))})}function bC({active:e,onClick:n}){return t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsxs(J,{variant:e?"default":"outline",size:"sm",className:L("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:n,"aria-pressed":e,children:[t.jsx(J0,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),t.jsx(ft,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const vC=l.memo(function({rawBody:e,displayedBody:n,emptyLabel:s}){const r=l.useMemo(()=>_N(e,n),[e,n]);return t.jsx(Yf,{result:r,emptyLabel:s})}),yC=l.memo(function({rawHeaders:e,headers:n,emptyLabel:s}){const r=l.useMemo(()=>TN(e,n),[e,n]);return t.jsx(Yf,{result:r,emptyLabel:s})}),wC=l.memo(function({log:e,displayNumber:n,viewMode:s="simple",strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:p=[]}){const[u,m]=l.useState(!1),[f,h]=l.useState(!1),[g,v]=l.useState(!1),[w,y]=l.useState(!1),[b,j]=l.useState("request"),[S,N]=l.useState(null),[C,E]=l.useState(0),[A,I]=l.useState(null),[M,k]=l.useState(null),[R,O]=l.useState("idle"),[$,K]=l.useState(null),[ee,D]=l.useState(0),[H,te]=l.useState(()=>kr(e.rawRequestBodyBytes??null)),[U,Q]=l.useState(()=>kr(e.responseTextBytes??null)),fe=l.useRef(null),je=l.useRef(e.id),he=l.useRef(!1),re=l.useRef(!1),P=M??e,X=M===null&&Xf(e),Se=l.useMemo(()=>xN(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),_e=sd(X,H),ge=sd(X,U),le=P.rawRequestBody??_e,ce=P.responseText??ge,Pe=P.rawRequestBody===null&&_e!==null,Re=P.responseText===null&&ge!==null,Fe=ps(le,e.rawRequestBodyBytes)<=gn,dt=ps(ce,e.responseTextBytes)<=gn,He=Fe&&(!Pe||H.hasMore===!1&&yo(H.totalBytes)<=gn),Le=dt&&(!Re||U.hasMore===!1&&yo(U.totalBytes)<=gn),We=bo(P),Ye=If(We),Qe=pC(P,u),ot=l.useMemo(()=>Ye.analyzeRequest(Qe?P.rawRequestBody:null),[Ye,Qe,P.rawRequestBody]),nt=l.useMemo(()=>Ye.analyzeResponse(Qe?P.responseText:null),[Ye,Qe,P.responseText]),se=l.useMemo(()=>!r||We!=="anthropic"||P.rawRequestBody===null?null:ZS(P.rawRequestBody).body,[P.rawRequestBody,We,r])??le,xe=Aa(u&&fC(b)&&He?se:null),me=Aa(b==="raw-request"&&He?le:null),we=Aa(b==="raw"&&Le?ce:null),Oe=sC(s,P.streaming),$e=xe.parsedData??ot.parsed,z=l.useMemo(()=>{const Me=nt.toolNames;return Me!==null?Me:p.map(jt=>jt.name)},[nt.toolNames,p]),Y=l.useMemo(()=>P.headers&&Object.keys(P.headers).length>0?JSON.stringify(P.headers,null,2):null,[P.headers]),de=l.useMemo(()=>P.rawHeaders&&Object.keys(P.rawHeaders).length>0?JSON.stringify(P.rawHeaders,null,2):null,[P.rawHeaders]),Ne=xn(se),F=xn(le),W=xn(Y),Z=xn(de),ne=xn(ce),Ee=l.useMemo(()=>({request:{copyLabel:Pe?"Copy loaded request preview":"Copy request body",copyText:se,copyCopied:Ne.copied,onCopy:Ne.copy,expansion:He?{isExpanded:xe.isExpanded,isPending:xe.isPending,onToggle:xe.toggle}:null,diffWithRaw:rC(We,s,r,P.rawRequestBody!==null)?{active:w,onToggle:()=>y(!w)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(P)}},"raw-request":{copyLabel:Pe?"Copy loaded raw request preview":"Copy raw request",copyText:le,copyCopied:F.copied,onCopy:F.copy,expansion:He?{isExpanded:me.isExpanded,isPending:me.isPending,onToggle:me.toggle}:null},...La(s,P.headers!==void 0&&Object.keys(P.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:Y,copyCopied:W.copied,onCopy:W.copy,expansion:null}}:{},...Pa(s,P.rawHeaders!==void 0&&Object.keys(P.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:de,copyCopied:Z.copied,onCopy:Z.copy,expansion:null}}:{},raw:{copyLabel:Re?"Copy loaded response preview":"Copy response",copyText:ce,copyCopied:ne.copied,onCopy:ne.copy,expansion:Le?{isExpanded:we.isExpanded,isPending:we.isPending,onToggle:we.toggle}:null}}),[se,Pe,He,Ne,xe,w,P,P.rawRequestBody,le,F,me,Y,W,de,Z,P.responseText,Re,Le,ce,ne,we,We,s,r,c]),ie=l.useMemo(()=>$e!==null?Ye.anatomySegments($e):null,[Ye,$e]),oe=l.useMemo(()=>ql($e),[$e]),ke=P.warnings??[],ze=l.useMemo(()=>{if(ie!==null)return new Set(ie.map(Me=>Me.path))},[ie]),Kn=fN({containerRef:fe,setExpandToPath:I,ensureTabActive:()=>{b!=="request"&&(re.current=!0,j("request"))}}),$t=l.useCallback((Me,jt)=>{const et=Me==="request"?te:Q;et(st=>({...st,status:"loading",error:null}));const Ls=new URLSearchParams({part:Me,offset:String(jt),limit:String(dC)});Be(`/api/logs/${String(e.id)}/body?${Ls.toString()}`,wu,cC).then(st=>{je.current===e.id&&et(Rt=>({status:"success",text:st.offset===0?st.text:`${Rt.text}${st.text}`,offset:st.nextOffset??st.totalBytes,totalBytes:st.totalBytes,hasMore:st.hasMore,error:null}))}).catch(st=>{je.current===e.id&&et(Rt=>({...Rt,status:"failed",error:hC(st)}))})},[e.id]),an=l.useCallback(()=>{he.current||(yN(e.id),k(null),O("idle"),K(null),D(Me=>Me+1))},[e.id]),ia=l.useCallback(()=>{const Me=!u;Me&&(re.current=!1,j(ie!==null?"anatomy":"request")),m(Me)},[ie,u]),Yn=l.useCallback(()=>{Oe&&(re.current=!0,j("sse"))},[Oe]),la=l.useCallback(Me=>{re.current=!0,j(Me)},[]);return l.useEffect(()=>{je.current=e.id,he.current=!1,k(null),O("idle"),K(null),D(0),re.current=!1,te(kr(e.rawRequestBodyBytes??null)),Q(kr(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{u&&(re.current||b==="request"&&ie!==null&&j("anatomy"))},[b,ie,u]),l.useEffect(()=>{b!=="sse"||Oe||j("parsed")},[b,Oe]),l.useEffect(()=>{if(!u||!mC(b)||!uC(e)||M!==null||he.current)return;const Me=Vf(e.id);if(Me!==null){k(Me),O("idle"),K(null);return}let jt=!1;return he.current=!0,O("loading"),K(null),wN(e.id,()=>Be(`/api/logs/${String(e.id)}`,Xs,lC)).then(et=>{jt||(he.current=!1,k(et),O("idle"),K(null))}).catch(et=>{jt||(he.current=!1,O("failed"),K(gN(et)))}),()=>{jt=!0,he.current=!1}},[b,u,M,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,ee]),l.useEffect(()=>{u&&X&&H.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||$t("request",0))},[b,u,$t,H.status,X]),l.useEffect(()=>{u&&X&&U.status==="idle"&&(b!=="parsed"&&b!=="raw"||$t("response",0))},[b,u,$t,U.status,X]),l.useEffect(()=>{const Me=jt=>{const et=ra(jt);et!==null&&et.logId===e.id&&(m(!0),re.current=!0,j(iC(et.tab,ie)),et.tab==="response"&&et.toolCallIndex!==void 0&&(N(et.toolCallIndex),E(Ls=>Ls+1)))};return window.addEventListener(rn,Me),()=>{window.removeEventListener(rn,Me)}},[ie,e.id]),t.jsxs(Ps,{children:[t.jsxs("div",{className:L("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:[t.jsx(VN,{log:P,displayNumber:n,messageCount:ot.messageCount,toolCount:ot.toolCount,toolEvents:p,expanded:u,onToggle:ia,cacheTrend:i,slowResponseThresholdSeconds:o,showClientMetadata:d,timeDisplayFormat:a,activeTab:b,tabActions:Ee,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&t.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Me=>Me.stopPropagation(),onKeyDown:Me=>Me.stopPropagation(),children:[t.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"}),t.jsx(eo,{feature:"Log details",children:t.jsxs(qf,{value:b,onValueChange:la,className:"gap-2",children:[t.jsxs(Hf,{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:[Pa(s,P.rawHeaders!==void 0&&Object.keys(P.rawHeaders).length>0)&&t.jsx(Zt,{className:cn,value:"raw-headers",children:"Raw Headers"}),La(s,P.headers!==void 0&&Object.keys(P.headers).length>0)&&t.jsx(Zt,{className:cn,value:"headers",children:"Headers"}),ie!==null&&t.jsx(Zt,{className:cn,value:"anatomy",children:"Context"}),td(We,s,r)&&t.jsx(Zt,{className:cn,value:"raw-request",children:"Raw Request"}),t.jsx(Zt,{className:cn,value:"request",children:"Request"}),s==="full"&&t.jsx(Zt,{className:cn,value:"raw",children:"Raw Response"}),t.jsx(Zt,{className:cn,value:"parsed",children:"Response"}),Oe&&t.jsx(Zt,{className:cn,value:"sse",children:"SSE"})]}),td(We,s,r)&&t.jsx(ut,{value:"raw-request",children:b==="raw-request"&&t.jsxs(dn,{children:[t.jsx(Tr,{status:R,error:$,footprint:Se,onRetry:an}),X&&t.jsx(Er,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>$t("request",H.offset)}),le===null?t.jsx(Jr,{children:X?"Request preview is loading":"No request body"}):me.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(rs,{}),children:t.jsx(Mi,{data:me.parsedData,bulkDepth:me.bulkDepth,bulkRevision:me.bulkRevision})}):t.jsx(_r,{children:le})]})}),t.jsx(ut,{value:"request",children:b==="request"&&t.jsxs(dn,{children:[t.jsx(Tr,{status:R,error:$,footprint:Se,onRetry:an}),X&&t.jsx(Er,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>$t("request",H.offset)}),ke.length>0&&t.jsxs(Ts,{tone:"warning",children:[t.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[t.jsx(yn,{className:"size-3.5"}),"Tool schema warnings"]}),t.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ke.map(Me=>t.jsx("li",{children:Me},Me))})]}),t.jsx(tC,{summary:oe,calledToolNames:z}),w?t.jsx(vC,{rawBody:P.rawRequestBody,displayedBody:se,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):t.jsx("div",{ref:fe,children:se===null?t.jsx(Jr,{children:X?"Request preview is loading":"No request body"}):xe.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(rs,{}),children:t.jsx(Mi,{data:xe.parsedData,bulkDepth:xe.bulkDepth,bulkRevision:xe.bulkRevision,anatomyPaths:ze,expandToPath:A})}):t.jsx(_r,{children:se})})]})}),ie!==null&&t.jsx(ut,{value:"anatomy",children:b==="anatomy"&&t.jsx(dn,{className:"p-0",children:t.jsx(l.Suspense,{fallback:t.jsx(rs,{}),children:t.jsx(lN,{parsed:xe.parsedData,inputTokens:P.inputTokens??null,model:P.model,segments:ie,onSegmentActivate:Kn})})})}),La(s,P.headers!==void 0&&Object.keys(P.headers).length>0)&&t.jsx(ut,{value:"headers",children:b==="headers"&&t.jsxs(dn,{children:[t.jsx("div",{className:"flex justify-end gap-2 mb-2",children:nC(s,P.rawHeaders!==void 0&&Object.keys(P.rawHeaders).length>0)&&t.jsx(bC,{active:g,onClick:Me=>{Me.stopPropagation(),v(!g)}})}),g?t.jsx(yC,{rawHeaders:P.rawHeaders,headers:P.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):t.jsx(rd,{headers:P.headers,emptyLabel:"No headers captured"})]})}),Pa(s,P.rawHeaders!==void 0&&Object.keys(P.rawHeaders).length>0)&&t.jsx(ut,{value:"raw-headers",children:b==="raw-headers"&&t.jsx(dn,{children:t.jsx(rd,{headers:P.rawHeaders,emptyLabel:"No raw headers captured"})})}),t.jsx(ut,{value:"raw",children:b==="raw"&&t.jsxs(dn,{className:"space-y-3",children:[t.jsx(Tr,{status:R,error:$,footprint:Se,onRetry:an}),X&&t.jsx(Er,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>$t("response",U.offset)}),t.jsx(za,{responseStatus:P.responseStatus,captureIncompleteReason:P.captureIncompleteReason,error:P.error,onOpenSse:Oe?Yn:void 0}),ce!==null&&Le?t.jsx(l.Suspense,{fallback:t.jsx(rs,{}),children:t.jsx(uN,{text:ce,defaultExpandDepth:0,bulkDepth:we.bulkDepth,bulkRevision:we.bulkRevision})}):ce!==null?t.jsx(_r,{children:ce}):t.jsx(Jr,{children:X?"Response preview is loading":"No response"}),Oe&&t.jsx(gC,{onOpenSse:Yn})]})}),Oe&&t.jsx(ut,{value:"sse",children:b==="sse"&&t.jsxs(dn,{className:"space-y-3",children:[t.jsx(za,{responseStatus:P.responseStatus,captureIncompleteReason:P.captureIncompleteReason,error:P.error}),t.jsx(l.Suspense,{fallback:t.jsx(rs,{}),children:t.jsx(dN,{logId:P.id,truncated:P.streamingChunksPath!==null})})]})}),t.jsx(ut,{value:"parsed",children:b==="parsed"&&t.jsxs(dn,{children:[t.jsx(Tr,{status:R,error:$,footprint:Se,onRetry:an}),X&&t.jsx(Er,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>$t("response",U.offset)}),t.jsx(za,{responseStatus:P.responseStatus,captureIncompleteReason:P.captureIncompleteReason,error:P.error,onOpenSse:Oe?Yn:void 0}),Re&&!Le?t.jsx(_r,{children:ce}):t.jsx(l.Suspense,{fallback:t.jsx(rs,{}),children:t.jsx(cN,{responseText:ce,responseStatus:P.responseStatus,streaming:P.streaming,inputTokens:P.inputTokens,outputTokens:P.outputTokens,cacheCreationInputTokens:P.cacheCreationInputTokens,cacheReadInputTokens:P.cacheReadInputTokens,apiFormat:We,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),t.jsx(eo,{feature:"Replay",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(iN,{log:P,displayNumber:n,open:f,onOpenChange:h})})})]})});function jC(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 Da(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function SC({stopReason:e,isPending:n,isFirst:s,isTurnStart:r,isOnlyEntry:o=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const p=Hl(e),u=o&&r&&p,m=n&&!p,f=c&&d!==void 0,h=l.useMemo(()=>Vl(i),[i]),g=l.useMemo(()=>GS(i),[i]),v=y=>{!f||d===void 0||(y.stopPropagation(),d())},w=y=>{!f||d===void 0||y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),d())};return t.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&t.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:Da(f),onClick:v,onKeyDown:w,children:t.jsx(g,{className:L("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):p?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:jC(e),className:Da(f),onClick:v,onKeyDown:w,children:t.jsx(h,{className:L("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):r?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:Da(f),onClick:v,onKeyDown:w,children:t.jsx(h,{className:L("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?t.jsx("span",{title:n?"Current end of open turn (processing)":"Current end of open turn",children:t.jsx(h,{className:L("size-3.5 text-cyan-300/85",m?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):m?t.jsx("span",{title:"Processing",children:t.jsx(h,{className:L("size-3.5 text-amber-300/80","animate-crab-crawl")})}):t.jsx("span",{title:"Request in turn",children:t.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!p&&!a&&t.jsx("div",{className:L("w-0.5 h-full",n?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const od=180;function NC(e){const n=Tf(e.path);return n==="unknown"?e.apiFormat:n}function CC(e,n){const s=e.responseText;if(s===null)return!1;switch(n){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function Zf(e){if(e===null)return null;try{const n=JSON.parse(e);return typeof n=="string"?JSON.parse(n):n}catch{return null}}function kC(e){if(e==null)return null;const n=typeof e=="string"?e:JSON.stringify(e);if(n===void 0)return null;const s=n.replace(/\s+/g," ").trim();return s.length===0?null:s.length>od?`${s.slice(0,od-1)}...`:s}function TC(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const n=JSON.stringify(e,null,2);return n===void 0||n.length===0?null:n}function jn({log:e,provider:n,index:s,name:r,input:o}){return{id:`${String(e.id)}-${n}-tool-${String(s)}`,logId:e.id,index:s,provider:n,name:r,argumentsText:TC(o),argumentsPreview:kC(o)}}function _C(e){const n=Zf(e.responseText),s=G(n,"content");if(!Array.isArray(s))return[];const r=[];for(const o of s){if(G(o,"type")!=="tool_use")continue;const i=G(o,"name");if(typeof i!="string"||i.length===0)continue;const c=G(o,"input");r.push(jn({log:e,provider:"anthropic",index:r.length,name:i,input:c}))}return r}function EC(e){const n=Zf(e.responseText),s=G(n,"choices"),r=[];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 m=G(u,"function"),f=G(m,"name");if(typeof f!="string"||f.length===0)continue;const h=G(m,"arguments");r.push(jn({log:e,provider:"openai",index:r.length,name:f,input:h}))}const d=G(i,"function_call"),p=G(d,"name");if(typeof p=="string"&&p.length>0){const u=G(d,"arguments");r.push(jn({log:e,provider:"openai",index:r.length,name:p,input:u}))}}const o=G(n,"output");if(Array.isArray(o))for(const a of o){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");r.push(jn({log:e,provider:"openai",index:r.length,name:i,input:c}))}return r}function Qf(e){if(typeof e.data=="string")try{return JSON.parse(e.data)}catch{return e.data}return e.data}function Xr(e,n,s){const r=`${s.provider}:${s.name}:${s.index}`;n.has(r)||(n.add(r),e.push(s))}function RC(e){const n=e.streamingChunks?.chunks??[],s=[],r=new Set;for(const o of n){const a=Qf(o),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");Xr(s,r,jn({log:e,provider:"anthropic",index:o.index,name:c,input:d}))}return s.map((o,a)=>({...o,id:`${String(e.id)}-anthropic-tool-${String(a)}`,index:a}))}function MC(e){const n=e.streamingChunks?.chunks??[],s=[],r=new Set;for(const o of n){const a=Qf(o),i=G(a,"choices");if(Array.isArray(i))for(const d of i){const p=G(d,"delta"),u=G(p,"tool_calls");if(Array.isArray(u))for(const h of u){const g=G(h,"function"),v=G(g,"name");if(typeof v!="string"||v.length===0)continue;const w=G(g,"arguments");Xr(s,r,jn({log:e,provider:"openai",index:s.length,name:v,input:w}))}const m=G(p,"function_call"),f=G(m,"name");if(typeof f=="string"&&f.length>0){const h=G(m,"arguments");Xr(s,r,jn({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 p=G(c,"arguments");Xr(s,r,jn({log:e,provider:"openai",index:s.length,name:d,input:p}))}}}return s.map((o,a)=>({...o,id:`${String(e.id)}-openai-tool-${String(a)}`,index:a}))}function AC(e){if(e.toolTraceEvents!==void 0&&e.toolTraceEvents.length>0)return e.toolTraceEvents;const n=NC(e);if(CC(e,n))switch(n){case"anthropic":return _C(e);case"openai":return EC(e);case"unknown":return[]}switch(n){case"anthropic":return RC(e);case"openai":return MC(e);case"unknown":return[]}}const ad=new WeakMap;function IC(e){return e>1}function Pi(e){const n=[];let s=[],r=0;for(let o=0;o<e.length;o+=1){const a=e[o];if(a===void 0)continue;s.push({log:a,stopReason:Ff(a),sessionLogNumber:o+1});const i=s[s.length-1];i!==void 0&&Hl(i.stopReason)&&(n.push({entries:s,turnIndex:r}),s=[],r+=1)}return s.length>0&&n.push({entries:s,turnIndex:r}),n}function PC(e){const n=new Map;for(const s of e)for(let r=1;r<s.logs.length;r+=1){const o=s.logs[r],a=s.logs[r-1];if(o===void 0||a===void 0)continue;const i=bo(o),c=bo(a);i==="unknown"||i!==c||n.set(o.id,a)}return n}function Gl(e){const n=ad.get(e);if(n!==void 0&&n.apiFormat===e.apiFormat&&n.responseText===e.responseText&&n.toolTraceEvents===e.toolTraceEvents)return n.events;const s=AC(e);return ad.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,toolTraceEvents:e.toolTraceEvents,events:s}),s}function LC(e,n,s=0){let r=0,o=0,a=0,i=0,c=0,d=0,p=0,u=0,m=null,f=0;for(const h of e)h.responseStatus===null?o+=1:h.responseStatus>=400&&(r+=1),h.elapsedMs!==null&&n>0&&h.elapsedMs>n*1e3&&(a+=1),h.inputTokens!==null&&(i+=h.inputTokens),h.outputTokens!==null&&(c+=h.outputTokens),h.cacheCreationInputTokens!==null&&(d+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(p+=h.cacheReadInputTokens),h.elapsedMs!==null&&(u+=h.elapsedMs,m=m===null?h.elapsedMs:Math.max(m,h.elapsedMs)),f+=Gl(h).length;return{llmCallCount:e.length,toolCallCount:f,failedCallCount:r,pendingCallCount:o,slowCallCount:a,totalInputTokens:i,totalOutputTokens:c,totalCacheCreationInputTokens:d,totalCacheReadInputTokens:p,totalElapsedMs:u,maxElapsedMs:m,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:s}}function $a(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const OC=l.memo(function({entries:n,viewMode:s,strip:r,slowResponseThresholdSeconds:o,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:p,pendingFocusRequest:u,showLogClientMetadata:m=!0}){const f=n.length-1,h=n[f]?.stopReason??null,g=h!==null?Hl(h):!1,v=n[f]?.log.responseStatus===null,w=n.length===1,y=IC(n.length),[b,j]=l.useState(!1),S=l.useRef(!1);l.useEffect(()=>{y?g&&!S.current&&j(!0):j(!1),S.current=g},[y,g]),l.useEffect(()=>{const D=H=>{const te=ra(H);te!==null&&n.some(U=>U.log.id===te.logId)&&y&&j(!1)};return window.addEventListener(rn,D),()=>{window.removeEventListener(rn,D)}},[y,n]),l.useEffect(()=>{if(u===void 0||!n.some(H=>H.log.id===u.logId))return;y&&j(!1);const D=window.setTimeout(()=>{ks({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(D)},[y,n,u]);const N=l.useCallback(()=>{y&&j(D=>!D)},[y]),C=l.useMemo(()=>{let D=0,H=0,te=null,U=!1;for(const Q of n)Q.log.inputTokens!==null&&(D+=Q.log.inputTokens,U=!0),Q.log.outputTokens!==null&&(H+=Q.log.outputTokens,U=!0),Q.log.elapsedMs!==null&&(te=te===null?Q.log.elapsedMs:Math.max(te,Q.log.elapsedMs));return{totalInput:D,totalOutput:H,hasTokens:U,maxElapsed:te}},[n,f]),E=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",A=C.maxElapsed!==null&&o>0&&C.maxElapsed>o*1e3,I=l.useMemo(()=>{const D=new Map;for(const H of n){const te=Gl(H.log);te.length>0&&D.set(H.log.id,te)}return D},[n]),[M,k]=l.useState(0),R=l.useRef(null);l.useEffect(()=>{const D=R.current;if(!D)return;let H=0;const te=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(U=>U+1))});return te.observe(D),()=>{te.disconnect(),window.cancelAnimationFrame(H)}},[]);const O=n[0]?.log.id??d,$=`Turn ${String(d+1)}`,K=l.useMemo(()=>Vl(O%12),[O]),ee=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:b?"48px":"160px"}),[b]);return t.jsx("div",{ref:R,style:ee,tabIndex:b?void 0:0,role:b?void 0:"group","aria-label":b?void 0:$,"data-nav-id":b?void 0:`turn-${String(O)}`,className:L("rounded-[8px] transition-[background-color,box-shadow]",v?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!b&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:b?t.jsxs("div",{"data-nav-id":`turn-collapsed-${String(O)}`,"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:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),N())},children:[t.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),t.jsx(K,{className:L("size-3.5",v?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",v?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:t.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?t.jsx(K,{className:L("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):t.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:t.jsx(K,{className:L("size-3.5 text-cyan-300/85",v?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),n.length>1&&t.jsxs("div",{className:L("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",E),children:[t.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:$}),t.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(n[0]?.log.id??"?")} ~ ${String(n[f]?.log.id??"?")}`,children:["#",n[0]?.sessionLogNumber??"?"," ~ #",n[f]?.sessionLogNumber??"?"]}),t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[n.length," request",n.length>1?"s":""]}),C.maxElapsed!==null&&t.jsx(Ps,{children:t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsxs("span",{className:L("flex items-center gap-1 shrink-0",A?"text-amber-400":"text-muted-foreground"),children:[t.jsx(en,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:$a(C.maxElapsed)}),A&&t.jsx(yn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsx(ft,{children:A?`Slow response: ${$a(C.maxElapsed)} exceeds ${$a(o*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Zs,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[t.jsxs("span",{className:"text-blue-400",children:["IN ",Ie(C.totalInput)]})," / ",t.jsxs("span",{className:"text-amber-400",children:["OUT ",Ie(C.totalOutput)]})]})]}),t.jsx("span",{className:"flex-1 min-w-0"}),t.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:t.jsx(ct,{className:"size-4 shrink-0"})})]})]}):n.map((D,H)=>{const{log:te,stopReason:U}=D,Q=H===0;return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx(SC,{stopReason:U,isPending:te.responseStatus===null,isFirst:H===0,isTurnStart:Q,isOnlyEntry:w,isOpenTurnTail:H===f&&!g,crabIndex:te.id%12,collapsible:y&&Q,onToggle:N}),t.jsx("div",{className:L("flex-1 min-w-0 mb-0.5 rounded-[8px]",E),children:t.jsx(wC,{log:te,displayNumber:D.sessionLogNumber,viewMode:s,strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:p,cacheTrend:a?.get(te.id)??null,showClientMetadata:m,toolEvents:I.get(te.id),onCompareWithPrevious:c.has(te.id)?i:void 0})})]},te.id)})})}),zC=24,DC=132,$C=8;function FC(e){return e>zC}function BC(e){const n=new Map;for(let s=0;s<e.length;s++){const r=e[s];if(r!==void 0)for(const o of r.entries)n.set(o.log.id,s)}return n}function eh(e,n,s){return t.jsx(OC,{entries:e.entries,viewMode:n.viewMode,strip:n.strip,slowResponseThresholdSeconds:n.slowResponseThresholdSeconds,timeDisplayFormat:n.timeDisplayFormat,cacheTrends:n.cacheTrends,onCompareWithPrevious:n.onCompareWithPrevious,comparisonPredecessors:n.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:n.showLogClientMetadata},e.turnIndex)}function UC(e){return FC(e.turnGroups.length)?t.jsx(qC,{...e}):t.jsx(t.Fragment,{children:e.turnGroups.map(n=>eh(n,e))})}function qC(e){const{turnGroups:n}=e,[s,r]=l.useState(null),o=MS({count:n.length,estimateSize:()=>DC,overscan:$C,getItemKey:i=>n[i]?.turnIndex??i}),a=l.useMemo(()=>BC(n),[n]);return l.useEffect(()=>{const i=c=>{const d=ra(c);if(d===null||d.source==="virtualizer")return;const p=a.get(d.logId);p!==void 0&&(o.scrollToIndex(p,{align:"center"}),r(u=>({...d,turnIndex:p,nonce:u===null?1:u.nonce+1})))};return window.addEventListener(rn,i),()=>{window.removeEventListener(rn,i)}},[a,o]),t.jsx("div",{className:"relative w-full",style:{height:`${o.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:o.getVirtualItems().map(i=>{const c=n[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return t.jsx("div",{"data-index":i.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:eh(c,e,d)},i.key)})})}const Kl=pe(["episode","procedure","preference","project-fact"]),HC=pe(["draft","promoted","failed"]),th=T({source:ae("agent-inspector"),sessionId:x(),logIds:V(Lt),project:x().nullable(),models:V(x())}),VC=T({redacted:Ce(),patterns:V(x())}),fr=T({id:x(),type:Kl,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),sessionId:x(),logIds:V(Lt),evidence:th,status:HC,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:VC});T({idempotencyKey:x(),type:Kl,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),project:x().nullable(),evidence:th});const WC=T({id:x(),type:Kl.or(x()),title:x(),content:x(),score:_().nullable(),source:x().nullable(),project:x().nullable(),evidence:Gs().optional()});T({results:V(WC),warning:x().nullable()});const GC=T({candidates:V(fr)}),KC=T({candidate:fr}),YC=T({error:x().optional(),candidate:fr.optional()}),JC=T({candidate:fr}),XC=3e4,ZC=15e3,QC=15e3,ek={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 Li(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function tk(e,n,s){return e===null||n===null?null:Lo(e,n,s)}function nk(e){return`${String(e)} candidate${e===1?"":"s"}`}function nh(e){return`log-${String(e)}`}function sh(e){const n=nh(e),s=document.getElementById(n);window.history.replaceState(null,"",`#${n}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function sk(e){for(const n of e)if(n.responseStatus!==null&&n.responseStatus>=400)return n;return null}function rk(e){let n=null,s=-1;for(const r of e)r.elapsedMs!==null&&r.elapsedMs>s&&(n=r,s=r.elapsedMs);return n}function ok(e){for(const n of e)if(Gl(n).length>0)return n;return null}function ak(e){const n=new Map;for(let s=0;s<e.length;s+=1){const r=e[s];r!==void 0&&n.set(r.id,s+1)}return n}function gs(e,n){return String(n.get(e)??e)}function ik(e){const n=[{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=ok(e.logs);e.summary.toolCallCount>0&&s!==null&&n.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${gs(s.id,e.displayNumberByLogId)}`,logId:s.id});const r=sk(e.logs);r!==null&&n.push({kind:"failure",title:`Failure #${String(r.responseStatus)}`,detail:`First failed request is #${gs(r.id,e.displayNumberByLogId)}`,logId:r.id});const o=rk(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&n.push({kind:"slow",title:`Slowest ${Li(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${gs(o.id,e.displayNumberByLogId)}`,logId:o.id}),e.candidates.length>0){const a=e.candidates.filter(c=>c.status==="draft").length,i=e.candidates.filter(c=>c.status==="promoted").length;n.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 n}function lk(e){switch(e){case"session":return t.jsx(Po,{className:"size-3.5 text-blue-400"});case"tool":return t.jsx(cr,{className:"size-3.5 text-sky-400/70"});case"slow":return t.jsx(en,{className:"size-3.5 text-amber-400"});case"failure":return t.jsx(Uu,{className:"size-3.5 text-destructive"});case"candidate":return t.jsx(Fu,{className:"size-3.5 text-emerald-400"})}}function ck({insights:e}){return e.length===0?null:t.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(n=>t.jsxs("button",{type:"button",className:L("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:()=>{n.logId!==null&&sh(n.logId)},disabled:n.logId===null,children:[lk(n.kind),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium text-foreground/90",children:n.title}),t.jsx("span",{className:"block truncate font-mono text-[10px]",children:n.detail})]})]},`${n.kind}-${n.title}`))})}function dk(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function uk(e,n){if(n)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function pk(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function mk(e,n){const s=e.replace(/\s+/g," ").trim();return s.length<=n?s:`${s.slice(0,n-3)}...`}function fk(e,n){const s=e[0],r=e[e.length-1];if(s===void 0)return"No evidence logs";const o=gs(s,n);return r===void 0||s===r?`#${o}`:`#${o}-#${gs(r,n)}`}function id(e){return e.join(", ")}function hk(e){return e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}function xk({candidate:e,isPromoting:n,isUpdating:s,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,p]=l.useState(e.type),[u,m]=l.useState(e.title),[f,h]=l.useState(e.content),[g,v]=l.useState(id(e.tags)),[w,y]=l.useState(null),b=e.status!=="promoted",j=e.status!=="promoted",S=l.useCallback(()=>{p(e.type),m(e.title),h(e.content),v(id(e.tags)),y(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),E=f.trim(),A=hk(g);if(C.length===0){y("Title is required.");return}if(E.length===0){y("Content is required.");return}if(A.length===0){y("At least one tag is required.");return}y(null),await o(e.id,{type:d,title:C,content:E,tags:A})&&c(!1)},[e.id,f,g,u,d,o]);return i?t.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("select",{value:d,disabled:s,onChange:C=>{const E=fr.shape.type.safeParse(C.currentTarget.value);E.success&&p(E.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:[t.jsx("option",{value:"episode",children:"episode"}),t.jsx("option",{value:"procedure",children:"procedure"}),t.jsx("option",{value:"preference",children:"preference"}),t.jsx("option",{value:"project-fact",children:"project-fact"})]}),t.jsx("input",{value:u,disabled:s,onChange:C=>m(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"})]}),t.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"}),t.jsx("input",{value:g,disabled:s,onChange:C=>v(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"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[t.jsx(mc,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),t.jsx("span",{className:"flex-1"}),w!==null&&t.jsx("span",{className:"text-[10px] text-destructive",children:w}),t.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{S(),c(!1)},children:[t.jsx(dr,{className:"size-3.5"}),"Cancel"]}),t.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?t.jsx(lt,{className:"size-3.5 animate-spin"}):t.jsx(O1,{className:"size-3.5"}),"Save"]})]})]})}):t.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Te,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),t.jsx(Te,{variant:"outline",className:L("h-5 shrink-0 px-1.5 text-[10px] font-mono",ek[e.status]),children:dk(e.status)})]}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:mk(e.content,360)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(D0,{className:"size-3"}),fk(e.logIds,a)]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(mc,{className:"size-3"}),pk(e)]}),e.status==="promoted"&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[t.jsx(ys,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[t.jsx(Uu,{className:"size-3"}),e.error]})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const E=gs(C,a);return t.jsxs("a",{href:`#${nh(C)}`,onClick:A=>{A.preventDefault(),sh(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 ${E}`,title:`Log ID ${String(C)}`,children:["#",E]},C)}),t.jsx("span",{className:"flex-1"}),j&&t.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||n,onClick:()=>c(!0),children:[t.jsx(Ju,{className:"size-3"}),"Review"]}),t.jsxs(J,{type:"button",variant:b?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>r(e.id),disabled:!b||n||s,children:[n?t.jsx(lt,{className:"size-3 animate-spin"}):b?t.jsx(v0,{className:"size-3"}):t.jsx(ys,{className:"size-3"}),uk(e,n)]})]})]})}function gk({candidates:e,promotingCandidateIds:n,updatingCandidateIds:s,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:a}){return e.length===0?null:t.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>t.jsx(xk,{candidate:i,isPromoting:n.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:a},i.id))})}function bk({logs:e,scopeId:n,slowResponseThresholdSeconds:s,showRollupMetrics:r,timeDisplayFormat:o}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[p,u]=l.useState({status:"idle",error:null}),[m,f]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),v=a.length>0,w=l.useMemo(()=>LC(e,s,a.length),[a.length,e,s]),y=l.useMemo(()=>ak(e),[e]),b=l.useMemo(()=>ik({logs:e,scopeId:n,summary:w,candidates:a,displayNumberByLogId:y}),[a,y,e,n,w]),j=r||w.maxElapsedMs!==null,S=l.useMemo(()=>tk(w.startedAt,w.endedAt,o),[w.endedAt,w.startedAt,o]),N=l.useCallback(()=>{e.length===0||p.status==="loading"||(u({status:"loading",error:null}),(async()=>{try{const A=await Be(`/api/knowledge/sessions/${encodeURIComponent(n)}/candidates`,GC,XC,{method:"POST"},I=>`Candidate generation failed with ${String(I.status)}`);i(A.candidates),d(A.candidates.length>0),u(A.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(A){u({status:"failed",error:A instanceof Error?A.message:"Candidate response was invalid"})}})())},[p.status,e.length,n]),C=l.useCallback(A=>{f(I=>{if(I.has(A))return I;const M=new Set(I);return M.add(A),M}),(async()=>{try{const I=await vn(`/api/knowledge/candidates/${encodeURIComponent(A)}/promote`,ZC,{method:"POST"}),M=await I.json().catch(()=>null),k=KC.safeParse(M);if(I.ok&&k.success){i(O=>O.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const R=YC.safeParse(M);R.success&&R.data.candidate!==void 0&&i(O=>O.map($=>$.id===R.data.candidate?.id?R.data.candidate:$)),u({status:"failed",error:R.success?R.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(I.status)}`})}catch(I){u({status:"failed",error:I instanceof Error?I.message:"Candidate promotion failed"})}finally{f(I=>{const M=new Set(I);return M.delete(A),M})}})()},[]),E=l.useCallback(async(A,I)=>{g(M=>{if(M.has(A))return M;const k=new Set(M);return k.add(A),k});try{const M=await Be(`/api/knowledge/candidates/${encodeURIComponent(A)}`,JC,QC,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(R=>R.id===M.candidate.id?M.candidate:R)),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(A),k})}},[]);return e.length===0?null:t.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[r&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[t.jsx(Po,{className:"size-3.5 text-blue-400"}),w.llmCallCount," LLM"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(cr,{className:"size-3.5 text-sky-400/70"}),w.toolCallCount," tools"]}),r&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Zs,{className:"size-3.5 text-emerald-400"}),t.jsxs("span",{className:"font-mono",children:[Ie(w.totalInputTokens)," / ",Ie(w.totalOutputTokens)]})]}),(w.totalCacheCreationInputTokens>0||w.totalCacheReadInputTokens>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Zs,{className:"size-3.5 text-purple-400"}),t.jsxs("span",{className:"font-mono",children:["KV Cache +",Ie(w.totalCacheCreationInputTokens)," / ~",Ie(w.totalCacheReadInputTokens)]})]}),j&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(en,{className:"size-3.5"}),r&&t.jsx("span",{className:"font-mono",children:Li(w.totalElapsedMs)}),w.maxElapsedMs!==null&&t.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Li(w.maxElapsedMs)]})]}),r&&S!==null&&t.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(w.failedCallCount>0||w.pendingCallCount>0||w.slowCallCount>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[t.jsx(yn,{className:"size-3.5"}),t.jsxs("span",{className:"font-mono",children:[w.failedCallCount," fail / ",w.pendingCallCount," pending /"," ",w.slowCallCount," slow"]})]}),t.jsx("span",{className:"flex-1"}),v&&t.jsx(Te,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:nk(w.knowledgeCandidateCount)}),t.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:N,disabled:p.status==="loading",children:[p.status==="loading"?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Fu,{className:"size-3.5"}),"Candidate"]}),v&&t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(A=>!A),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?t.jsx(Ze,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"})})]}),p.status==="failed"&&t.jsx("p",{className:"mt-2 text-xs text-destructive",children:p.error}),t.jsx(ck,{insights:b}),c&&t.jsx(gk,{candidates:a,promotingCandidateIds:m,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:E,displayNumberByLogId:y})]})}function vk(e){let n=0,s=0;for(const r of e)r.inputTokens!==null&&(n+=r.inputTokens),r.outputTokens!==null&&(s+=r.outputTokens);return{totalInputTokens:n,totalOutputTokens:s}}function yk(e){const n=new Map;for(const s of e){if(s.model===null)continue;const r=R5(s.model);if(r==="unknown")continue;let o=n.get(r);o===void 0&&(o=new Set,n.set(r,o)),o.add(s.model)}return[...n.entries()].map(([s,r])=>({provider:s,models:[...r]}))}function wk(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function jk(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const Sk=l.memo(function({group:e,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:r,cacheTrends:o,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:p=!0,showLogClientMetadata:u=!0,defaultExpanded:m=!1,timeDisplayFormat:f,expanded:h,onExpandedChange:g}){const[v,w]=l.useState(m),y=h??v,b=l.useCallback(k=>{if(g!==void 0){g(k);return}w(k)},[g]);l.useEffect(()=>{!m||h!==void 0||w(!0)},[h,m]);const j=l.useMemo(()=>vk(e.logs),[e.logs]),S=l.useMemo(()=>yk(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),E=e.logs.some(k=>k.responseStatus===null),A=l.useMemo(()=>wk(e.logs),[e.logs]),I=l.useMemo(()=>jk(e.logs),[e.logs]),M=l.useMemo(()=>Pi(e.logs),[e.logs]);return l.useEffect(()=>{const k=R=>{const O=ra(R);O!==null&&e.logs.some($=>$.id===O.logId)&&b(!0)};return window.addEventListener(rn,k),()=>{window.removeEventListener(rn,k)}},[e.logs,b]),t.jsxs("div",{className:"mb-1.5",children:[t.jsx(uS,{conversationId:e.conversationId,startTime:N,endTime:C,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:y,onToggle:()=>b(!y),providers:S,isLoading:E,userAgent:e.logs[0]?.userAgent??null,clientPid:A,clientProjectFolder:I,showClientIdentity:d,showProcessMetadata:p,timeDisplayFormat:f,onClear:()=>c(e.logs.map(k=>k.id))}),y&&t.jsxs("div",{children:[t.jsx(bk,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:!1,timeDisplayFormat:f}),t.jsx(UC,{turnGroups:M,viewMode:n,strip:s,slowResponseThresholdSeconds:r,timeDisplayFormat:f,cacheTrends:o,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),Nk="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",Ck="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function kk(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function Tk(e){return e==="full"}function _k(e){return e==="raw"}function Ek(e,n){const s=n>0;return{redacted:s,raw:s&&Tk(e)}}function Rk(e,n){const s=e[0],r=e[e.length-1];return s===void 0||r===void 0?null:Lo(s.timestamp,r.timestamp,n)}function Mk(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function Ak(e){const n=new Set;for(const r of e)r.model!==null&&r.model.length>0&&n.add(r.model);const s=[...n].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function Ik(e){const n=new Set;for(const r of e)r.providerName!==null&&r.providerName!==void 0&&r.providerName.length>0&&n.add(r.providerName);const s=[...n].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function Pk(e){if(e<1e3)return`${e}ms`;if(e<6e4){const o=e/1e3;return`${o<10?o.toFixed(1):o.toFixed(0)}s`}const n=Math.round(e/1e3),s=Math.floor(n/60),r=n%60;return`${s}m ${r}s`}function Lk(e,n){return`${Ie(e)} in / ${Ie(n)} out`}function Ok(e,n){if(e.length===0)return 0;if(n.length===0)return Pi(e).length;let s=0;for(const r of n)s+=Pi(r.logs).length;return s}function zk({stopReason:e,pending:n,lastFailureLogNumber:s}){if(n>0)return{label:"In flight",detail:`${n} request${n===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 Dk(e){if(e===null)return!1;const n=e.toLowerCase();return n.includes("abort")||n.includes("cancel")||n.includes("client disconnected")||n.includes("stream disconnected")||n.includes("connection closed")}function $k({pending:e,failures:n,lengthStops:s,stopReason:r,lastFailure:o}){if(o!==null&&(o.status===499||Dk(o.error)))return{label:"Client aborted",detail:`Request #${o.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(o!==null&&o.status!==null&&o.status>=500)return{label:"Provider error",detail:`Request #${o.logNumber} returned HTTP ${o.status}`,tone:"danger"};if(n>0&&o!==null)return{label:"Failed",detail:`Request #${o.logNumber} needs attention`,tone:"danger"};if(s>0||r==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(r){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 Fk({logs:e,conversationGroups:n,isLoading:s,timeDisplayFormat:r,slowResponseThresholdSeconds:o}){let a=0,i=0,c=0,d=0,p=0,u=0,m=null,f=null,h=null,g=null,v=null,w=0,y=0,b=0,j=null;const S=o*1e3;for(let I=0;I<e.length;I+=1){const M=e[I];if(M===void 0)continue;const k=I+1,R=Ff(M);R!==null&&(m=R),R==="length"&&(d+=1),Mk(M)&&(a+=1,f=k,h={logNumber:k,status:M.responseStatus,error:M.error??null}),M.responseStatus===null&&(i+=1),o>0&&M.elapsedMs!==null&&M.elapsedMs>=S&&(c+=1),M.inputTokens!==null&&(p+=M.inputTokens),M.outputTokens!==null&&(u+=M.outputTokens),M.elapsedMs!==null&&(g===null||M.elapsedMs>g)&&(g=M.elapsedMs,v=k);const O=M.inputTokens??0,$=M.outputTokens??0,K=O+$;K>w&&(w=K,y=O,b=$,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",E=zk({stopReason:m,pending:i,lastFailureLogNumber:f}),A=$k({pending:i,failures:a,lengthStops:d,stopReason:m,lastFailure:h});return{status:N,statusLabel:C,modelLabel:Ak(e),providerLabel:Ik(e),requests:e.length,turns:Ok(e,n),failures:a,pending:i,slow:c,lengthStops:d,timeRange:Rk(e,r),tokenLabel:`${Ie(p)} in / ${Ie(u)} out`,finishLabel:E.label,finishDetail:E.detail,finishTone:E.tone,outcomeLabel:A.label,outcomeDetail:A.detail,outcomeTone:A.tone,slowestLabel:g===null?"n/a":Pk(g),slowestDetail:v===null?"Latency pending":`Request #${v}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${Lk(y,b)}`}}function Bk({pinnedSessionId:e,selectedSession:n,sessions:s,logs:r}){if(e!==void 0){const i=r.filter(c=>c.sessionId===e);return i.length===0?null:{label:e,sessionId:e,logs:i,showBackLink:!0}}if(n!=="__all__"){const i=r.filter(c=>c.sessionId===n);return i.length===0?null:{label:n,sessionId:n,logs:i,showBackLink:!0}}const o=s.length===1?s[0]??null:null;return o!==null&&r.every(c=>c.sessionId===o)?{label:o,sessionId:o,logs:[...r],showBackLink:!1}:s.length===0&&r.length>0&&r.every(i=>i.sessionId===null)?{label:"Visible requests",sessionId:null,logs:[...r],showBackLink:!1}:null}function Uk({logs:e,pagination:n}){if(n.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const s=e[0],r=e[e.length-1],o=s===void 0||r===void 0?"Current page":`#${s.id}-#${r.id}`;return n.total===null?`Showing ${e.length} logs (${o})`:n.total<=e.length?`Showing all ${n.total} logs`:`Showing ${e.length} of ${n.total} logs (${o})`}function nr({...e}){return t.jsx(Am,{"data-slot":"select",...e})}function wo({...e}){return t.jsx(Om,{"data-slot":"select-value",...e})}function sr({className:e,size:n="default",children:s,...r}){return t.jsxs(Pm,{"data-slot":"select-trigger","data-size":n,className:L("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),...r,children:[s,t.jsx(zm,{asChild:!0,children:t.jsx(Ze,{className:"size-4 opacity-50"})})]})}function rr({className:e,children:n,position:s="popper",align:r="center",...o}){return t.jsx($m,{children:t.jsxs(Fm,{"data-slot":"select-content",className:L("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:r,...o,children:[t.jsx(qk,{}),t.jsx(Vm,{className:L("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:n}),t.jsx(Hk,{})]})})}function it({className:e,children:n,...s}){return t.jsxs(Ym,{"data-slot":"select-item",className:L("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:[t.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:t.jsx(Zm,{children:t.jsx(De,{className:"size-4"})})}),t.jsx(Jm,{children:n})]})}function qk({className:e,...n}){return t.jsx(Qm,{"data-slot":"select-scroll-up-button",className:L("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(al,{className:"size-4"})})}function Hk({className:e,...n}){return t.jsx(ef,{"data-slot":"select-scroll-down-button",className:L("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Ze,{className:"size-4"})})}const Vk=pe(["critical","warning","notice"]),Wk=pe(["open"]),Gk=pe(["proxy","tool-schema","run","group"]),rh=pe(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),Kk=pe(["log","session","run","group"]),Yk=pe(["anthropic","openai","unknown"]),Jk=T({kind:Kk,id:x(),label:x(),href:x().nullable()}),Xk=T({id:x(),fingerprint:x(),severity:Vk,category:rh,source:Gk,status:Wk,title:x(),message:x(),count:_().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:V(Lt),sessionIds:V(x()),runIds:V(x()),groupIds:V(x()),provider:x().nullable(),model:x().nullable(),apiFormat:Yk.nullable(),evidence:V(Jk),metadata:qe(x(),Xe)}),Zk=T({category:rh,count:_().int().nonnegative()}),oh=T({total:_().int().nonnegative(),open:_().int().nonnegative(),critical:_().int().nonnegative(),warning:_().int().nonnegative(),notice:_().int().nonnegative(),byCategory:V(Zk)}),Qk=T({alerts:V(Xk),total:_().int().nonnegative(),limit:_().int().positive(),summary:oh}),e3=8e3,t3=1e4;function n3(e){const n=new URLSearchParams;e.severity!==void 0&&n.set("severity",e.severity),e.category!==void 0&&n.set("category",e.category),e.source!==void 0&&n.set("source",e.source),e.limit!==void 0&&n.set("limit",String(e.limit));const s=n.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function s3(e,n){const s=qt(n?n3(e):null,r=>Be(r,Qk,t3));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 r3(){const e=qt("/api/alerts/summary",n=>Be(n,oh,e3),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Gn="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",o3=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function ah(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function a3(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Yl(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 i3(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 l3(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function c3(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function d3(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return t.jsx(G1,{className:"size-3.5"});case"request-timeout":case"slow-response":return t.jsx(x0,{className:"size-3.5"});case"tool-schema":return t.jsx(yn,{className:"size-3.5"});case"group-incomplete":return t.jsx(Ig,{className:"size-3.5"})}}function Oi(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function gt(e){return e.toLocaleString()}function ih(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 u3(e,n){const s={limit:100};return e!=="all"&&(s.severity=e),n!=="all"&&(s.category=n),s}function p3(e,n){if(n!==null){const s=e.find(r=>r.id===n);if(s!==void 0)return s}return e[0]??null}function Rr({label:e,count:n,tone:s}){const r=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 t.jsxs("div",{className:L("rounded-md border px-3 py-2",r),children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),t.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:gt(n)})]})}function Mr({value:e,active:n,label:s,count:r,onClick:o}){return t.jsxs(J,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>o(e),className:"h-7 px-2",children:[s,r!==null?t.jsx(Te,{variant:"outline",children:gt(r)}):null]})}function m3({category:e,active:n,count:s,onClick:r}){return t.jsxs(J,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>r(e),className:"h-7 px-2",children:[d3(e),Yl(e),t.jsx(Te,{variant:"outline",children:gt(s)})]})}function f3({alerts:e,selectedAlertId:n,isLoading:s,error:r,onSelect:o}){return s?t.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[t.jsx(Ue,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):r!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:r.message}):e.length===0?t.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."}):t.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===n;return t.jsxs("button",{type:"button",onClick:()=>o(a.id),className:L("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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:L("size-2 rounded-full",l3(a.severity))}),t.jsx("span",{className:L("text-xs font-semibold",c3(a.severity)),children:ah(a.severity)}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Yl(a.category)})]}),t.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?t.jsxs(Te,{variant:"outline",className:"shrink-0",children:["x",gt(a.count)]}):null]}),t.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 leading-snug",children:ih(a)}),t.jsx("span",{className:"shrink-0",children:Oi(a.lastSeenAt)})]})]},a.id)})})}function h3({alert:e,onNavigate:n}){return e.evidence.length===0?t.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):t.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?t.jsx(Te,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):t.jsx(Te,{variant:"outline",asChild:!0,children:t.jsx("a",{href:s.href,onClick:n,children:s.label})},`${s.kind}:${s.id}`))})}function x3({alert:e,onNavigate:n}){return e===null?t.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."}):t.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[t.jsx("div",{className:L("border-b px-4 py-3",i3(e.severity)),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Te,{variant:"outline",children:ah(e.severity)}),t.jsx(Te,{variant:"outline",children:a3(e.source)}),t.jsx(Te,{variant:"outline",children:Yl(e.category)})]}),t.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),t.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?t.jsxs(Te,{variant:"outline",className:"shrink-0",children:[gt(e.count)," hits"]}):null]})}),t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(un,{label:"Target",value:ih(e)}),t.jsx(un,{label:"Last seen",value:Oi(e.lastSeenAt)}),t.jsx(un,{label:"First seen",value:Oi(e.firstSeenAt)}),t.jsx(un,{label:"Protocol",value:e.apiFormat??"n/a"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),t.jsx(h3,{alert:e,onNavigate:n})]}),t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(un,{label:"Logs",value:e.logIds.length===0?"n/a":gt(e.logIds.length)}),t.jsx(un,{label:"Sessions",value:e.sessionIds.length===0?"n/a":gt(e.sessionIds.length)}),t.jsx(un,{label:"Runs",value:e.runIds.length===0?"n/a":gt(e.runIds.length)}),t.jsx(un,{label:"Groups",value:e.groupIds.length===0?"n/a":gt(e.groupIds.length)})]})]})]})}function un({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:n})]})}function g3(){const[e,n]=l.useState(!1),[s,r]=l.useState("all"),[o,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:p}=r3(),u=l.useMemo(()=>u3(s,o),[o,s]),{alerts:m,total:f,isLoading:h,error:g,mutate:v}=s3(u,e),w=l.useMemo(()=>p3(m,i),[m,i]);l.useEffect(()=>{!e||i!==null&&m.some(E=>E.id===i)||c(m[0]?.id??null)},[m,e,i]);const y=d?.total??0,b=d?.critical??0,j=d?.warning??0,S=d?.notice??0,N=b>0?"bg-status-danger text-primary-foreground":j>0?"bg-status-watch text-primary-foreground":"bg-status-cool text-primary-foreground";return t.jsxs(Nt,{open:e,onOpenChange:n,children:[t.jsx(Vn,{asChild:!0,children:t.jsxs(J,{type:"button",variant:"ghost",size:"icon",className:Gn,"aria-label":"Alerts",title:"Alerts",children:[t.jsx(ao,{className:"size-4"}),p?t.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):y>0?t.jsx("span",{className:L("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:gt(y)}):null,t.jsx("span",{className:"sr-only",children:"Alerts"})]})}),t.jsxs(Ct,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[t.jsxs(Tt,{children:[t.jsxs(_t,{className:"flex items-center gap-2 pr-8",children:[t.jsx(ao,{className:"size-5 text-status-danger"}),t.jsx("span",{children:"Alerts"}),t.jsx(Te,{variant:"outline",children:gt(y)})]}),t.jsx(Is,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(Rr,{label:"Open",count:d?.open??0,tone:"neutral"}),t.jsx(Rr,{label:"Critical",count:b,tone:"critical"}),t.jsx(Rr,{label:"Warning",count:j,tone:"warning"}),t.jsx(Rr,{label:"Notice",count:S,tone:"notice"})]}),t.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(Mr,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:r}),t.jsx(Mr,{value:"critical",active:s==="critical",label:"Critical",count:b,onClick:r}),t.jsx(Mr,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:r}),t.jsx(Mr,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:r})]}),t.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{v()},children:[t.jsx(lt,{className:"size-3.5"}),"Refresh"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(J,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>a("all"),className:"h-7 px-2",children:"All categories"}),o3.map(C=>{const E=d?.byCategory.find(A=>A.category===C)?.count??0;return E===0?null:t.jsx(m3,{category:C,active:o===C,count:E,onClick:a},C)})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[gt(f)," matched"]}),t.jsx("span",{children:m.length<f?`${gt(m.length)} shown`:"Latest"})]}),t.jsx(f3,{alerts:m,selectedAlertId:w?.id??null,isLoading:h,error:g,onSelect:c})]}),t.jsx(x3,{alert:w,onNavigate:()=>n(!1)})]})]})]})}const b3=12e3;function v3(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function y3(e){const n=qt(v3(e),s=>Be(s,ig,b3));return{evidenceResponse:n.data??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}const w3=8e3;function j3(){const e=qt("/api/groups",n=>Be(n,zu,w3));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const S3=3e3;function N3(e,n){return{id:(e?.id??0)+1,message:n.message,tone:n.tone??"error"}}function lh(){const[e,n]=l.useState(null),s=l.useCallback(o=>{n(a=>N3(a,o))},[]),r=l.useCallback(()=>{n(null)},[]);return l.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{n(null)},S3);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:s,dismissToast:r}}function ch({notice:e,onDismiss:n}){if(e===null)return null;const s=e.tone==="error",r=s?yn:ys;return t.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:t.jsxs("div",{className:L("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:[t.jsx(r,{className:L("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),t.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),t.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:n,children:t.jsx(dr,{className:"size-3.5"})})]},e.id)})}const Fa=2e4;function C3(e,n){const s=`/api/groups/${encodeURIComponent(e)}`;return n?`${s}?deleteEvidence=1`:s}function k3(e){return"/api/groups"}function dh(e){let n=0,s=0,r=0,o=0;for(const a of e.members)switch(a.status){case"completed":n+=1;break;case"failed":case"cancelled":s+=1;break;case"running":r+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:n,failedMembers:s,runningMembers:r,missingStatusMembers:o}}function T3(e,n,s=null){return n!==null&&n.group.id===e.id?n.members.map(r=>({member:r.member,exportMember:r,source:"export"})):s!==null&&s.group.id===e.id&&s.members!==null?s.members.map(r=>({member:r.member,exportMember:r,source:"evidence"})):e.members.map(r=>({member:r,exportMember:null,source:"group"}))}function Jl(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 Xl(e){return e??"unknown"}function _3(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 oa(e){return e===null||e.trim().length===0?"-":e}function xt(e){return e.toLocaleString()}function zi(e){return e==null?"-":e<1e3?`${xt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function _s(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function ld(e){return e===null?"-":_s(e)}function E3(e){const n=JSON.stringify(e),s=n===void 0?String(e):n;return s.length<=160?s:`${s.slice(0,157)}...`}function uh(...e){for(const n of e)if(n!==null&&n.trim().length>0)return n;return"-"}function R3(...e){for(const n of e)if(n!=null&&n.trim().length>0)return n;return null}function M3(e){const n=e.provider,s=e.model;return n!==null&&n.length>0&&s!==null&&s.length>0?`${n} / ${s}`:uh(n,s)}function A3(e,n){if(n!==null){const s=e.find(r=>r.id===n);if(s!==void 0)return s}return e[0]??null}function I3(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function P3(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function L3(e,n){return n!==null&&n.group.id===e.id?n.evidence:e.evidence}function O3(e,n,s){return n!==null&&n.group.id===e.id?n.summary:s!==null&&s.group.id===e.id?s.summary:null}function z3(e,n,s){return n!==null&&n.group.id===e.id?n.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function D3({labelledTrigger:e=!1}){const[n,s]=l.useState(!1),[r,o]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[p,u]=l.useState(null),[m,f]=l.useState(null),[h,g]=l.useState(!1),[v,w]=l.useState(null),[y,b]=l.useState(null),[j,S]=l.useState(!1),{notice:N,showToast:C,dismissToast:E}=lh(),{groups:A,isLoading:I,error:M,mutate:k}=j3(),R=l.useMemo(()=>A3(A,r),[A,r]);l.useEffect(()=>{!n||r!==null&&A.some(P=>P.id===r)||o(A[0]?.id??null)},[A,n,r]);const O=R!==null&&p!==null&&p.group.id===R.id?p:null,{evidenceResponse:$,isLoading:K,error:ee,mutate:D}=y3(R),H=l.useCallback(()=>{k()},[k]),te=l.useCallback(async()=>{if(!(A.length===0||j)){S(!0),f(null),g(!1),b(null),d(null);try{const re=await Be(k3(!1),Pu,Fa,{method:"DELETE"},P=>`Clear failed with status ${String(P.status)}`);u(null),o(null),await k(),await D(),C({message:`Cleared ${xt(re.deleted)} group${re.deleted===1?"":"s"}.`,tone:"success"})}catch(re){C({message:re instanceof Error?re.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,A.length,k,D,C]),U=l.useCallback(async re=>{i(re.id),d(null);try{const P=await Be(`/api/groups/${encodeURIComponent(re.id)}/evidence`,lg,Fa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},X=>`Export failed with status ${String(X.status)}`);u(P),await k(),await D()}catch(P){d(P instanceof Error?P.message:String(P))}finally{i(null)}},[k,D]),Q=l.useCallback(re=>{f(re),g(!1),b(null)},[]),fe=l.useCallback(()=>{v===null&&(f(null),g(!1),b(null))},[v]),je=l.useCallback(re=>{o(re),f(null),g(!1),b(null)},[]),he=l.useCallback(async()=>{const re=m;if(re!==null){w(re.id),b(null);try{await Be(C3(re.id,h),Iu,Fa,{method:"DELETE"},P=>`Delete failed with status ${String(P.status)}`),u(P=>P!==null&&P.group.id===re.id?null:P),o(P=>P===re.id?null:P),f(null),g(!1),await k(),await D()}catch(P){b(P instanceof Error?P.message:String(P))}finally{w(null)}}},[h,m,k,D]);return t.jsxs(Nt,{open:n,onOpenChange:s,children:[t.jsx(ch,{notice:N,onDismiss:E}),t.jsx(Vn,{asChild:!0,children:t.jsxs(J,{type:"button",variant:"ghost",size:e?"default":"icon",className:L(Gn,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:[t.jsx(uc,{className:"size-4"}),I?t.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):A.length>0?t.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:A.length}):null,t.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),t.jsxs(Ct,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Tt,{children:t.jsxs(_t,{className:"flex items-center gap-2 pr-8",children:[t.jsx(uc,{className:"size-5 text-muted-foreground"}),t.jsx("span",{children:"Groups"}),t.jsx(Te,{variant:"outline",children:xt(A.length)})]})}),t.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsxs(J,{type:"button",variant:"outline",size:"sm",disabled:A.length===0||j,onClick:()=>{te()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Sn,{className:"size-3.5"}),"Clear"]}),t.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:H,children:[t.jsx(lt,{className:"size-3.5"}),"Refresh"]})]})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[t.jsx($3,{groups:A,selectedGroupId:R?.id??null,isLoading:I,error:M,onSelect:je}),t.jsx(F3,{group:R,deleteTarget:m,deleteEvidence:h,exportResult:O,evidenceResponse:$,evidenceLoading:K,evidenceError:ee,exportError:c,deleteError:y,exportingGroupId:a,deletingGroupId:v,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:Q,onCancelDelete:fe,onConfirmDelete:()=>{he()}})]})]})]})}function $3({groups:e,selectedGroupId:n,isLoading:s,error:r,onSelect:o}){return s?t.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..."}):r!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:r.message}):e.length===0?t.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."}):t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=dh(a),c=n===a.id;return t.jsxs("button",{type:"button",onClick:()=>o(a.id),className:L("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:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),t.jsx(Te,{variant:"outline",className:Jl(a.status),children:Xl(a.status)})]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[t.jsxs("span",{children:[i.memberCount," sessions"]}),t.jsx("span",{children:_s(a.updatedAt)})]})]},a.id)})})})}function F3({group:e,deleteTarget:n,deleteEvidence:s,exportResult:r,evidenceResponse:o,evidenceLoading:a,evidenceError:i,exportError:c,deleteError:d,exportingGroupId:p,deletingGroupId:u,onDeleteEvidenceChange:m,onExport:f,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:v}){if(e===null)return t.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 w=dh(e),y=O3(e,r,o),b=z3(e,r,o),j=L3(e,r),S=T3(e,r,o),N=p===e.id,C=u===e.id,E=n?.id===e.id;return t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),t.jsx(Te,{variant:"outline",className:Jl(e.status),children:Xl(e.status)}),t.jsx(Te,{variant:"outline",children:e.kind})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:oa(e.project)}),t.jsxs("span",{children:["updated ",_s(e.updatedAt)]})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(J,{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?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Sn,{className:"size-3.5"})}),t.jsxs(J,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{f(e)},children:[N?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Rs,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&t.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),E&&t.jsx(B3,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:m,onCancel:g,onConfirm:v}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(pn,{label:"Members",value:w.memberCount}),t.jsx(pn,{label:"Done",value:w.completedMembers}),t.jsx(pn,{label:"Failed",value:w.failedMembers}),t.jsx(pn,{label:"Running",value:w.runningMembers})]}),y!==null&&t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(pn,{label:"Requests",value:y.requestCount}),t.jsx(pn,{label:"Errors",value:y.errorCount}),t.jsx(pn,{label:"Tokens",value:y.tokenUsage.total}),t.jsx(pn,{label:"Missing",value:y.missingSessions})]}),t.jsx(U3,{report:b,loading:a,error:i,hasEvidence:j!==null}),t.jsx(q3,{evidence:j}),c!==null&&t.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&&!E&&t.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}),t.jsx(H3,{rows:S})]})})}function B3({group:e,deleteEvidence:n,isDeleting:s,error:r,onDeleteEvidenceChange:o,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(Sn,{className:"size-4 text-status-danger"}),t.jsx("span",{children:"Delete group?"})]}),t.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",t.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),t.jsxs("label",{className:L("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:n,disabled:!c||s,onChange:p=>o(p.currentTarget.checked)}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),t.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),r!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:r})]}),t.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),t.jsxs(J,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Sn,{className:"size-3.5"}),"Delete"]})]})]})})}function pn({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:xt(n)})]})}function U3({report:e,loading:n,error:s,hasEvidence:r}){const{copied:o,copy:a}=xn(e?.markdown??null);return e===null&&!n&&s===void 0?null:n?t.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:[t.jsx(Ue,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&r?t.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:t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),t.jsx(Te,{variant:"outline",className:_3(e.status),children:e.status})]}),t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:a,children:o?t.jsx(De,{className:"size-3.5 text-status-success"}):t.jsx(yt,{className:"size-3.5"})})]}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function q3({evidence:e}){return e===null?t.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."}):t.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:_s(e.exportedAt)})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(Ba,{label:"JSON",value:e.jsonPath}),t.jsx(Ba,{label:"Markdown",value:e.markdownPath}),t.jsx(Ba,{label:"HTML",value:e.htmlPath})]})]})}function Ba({label:e,value:n}){const{copied:s,copy:r}=xn(n);return t.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[t.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:n}),t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":s?`Copied ${e} path`:`Copy ${e} path`,onClick:r,children:s?t.jsx(De,{className:"size-3.5 text-status-success"}):t.jsx(yt,{className:"size-3.5"})})]})}function H3({rows:e}){const[n,s]=l.useState(null),r=l.useCallback(o=>{s(a=>a===o?null:o)},[]);return e.length===0?t.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."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[t.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),t.jsx("tbody",{children:e.map(o=>{const a=n===o.member.id;return t.jsxs(l.Fragment,{children:[t.jsx(V3,{row:o,isExpanded:a,onToggleDetails:r}),t.jsx(W3,{row:o,isExpanded:a})]},o.member.id)})})]})})]})}function V3({row:e,isExpanded:n,onToggleDetails:s}){const r=e.member,o=e.exportMember?.session??null,a=I3(e),i=o?.inspectorPath??xu(r.sessionId),c=e.source!=="evidence",d=o?.requestCount??null,p=o?.errorCount??null,u=o?.tokenUsage.total??null,m=a?.firstChunkMs??null,f=uh(r.label,r.sessionId),h=R3(o?.clientUserAgent,a?.userAgent,r.agent),g=o?.clientProjectFolder??null,v=$l({userAgent:h,conversationId:r.sessionId,clientProjectFolder:g}),w=na(v);return t.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[t.jsxs("td",{className:"max-w-56 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":n?`Hide member ${f}`:`Show member ${f}`,title:n?"Hide member details":"Show member details",onClick:()=>{s(r.id)},children:n?t.jsx(Ze,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"})}),w!==null&&t.jsx(sa,{client:v,className:"size-5"}),c?t.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:[t.jsx("span",{className:"min-w-0 truncate",children:f}),t.jsx(lr,{className:"size-3 shrink-0 text-muted-foreground"})]}):t.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(r.id)},children:[t.jsx("span",{className:"min-w-0 truncate",children:f}),t.jsx(Te,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:oa(r.agent)})]}),t.jsx("td",{className:"max-w-52 px-3 py-2",children:t.jsx("span",{className:"block whitespace-normal leading-snug",children:M3(r)})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx(Te,{variant:"outline",className:Jl(r.status),children:Xl(r.status)})}),t.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":xt(d)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:p===null?"-":xt(p)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:zi(m)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":xt(u)})]})}function W3({row:e,isExpanded:n}){if(!n)return null;const s=e.member,r=e.exportMember,o=r?.session??null,a=r?.run??null,i=Object.entries(s.metadata);return t.jsx("tr",{className:"border-b border-border bg-muted/10",children:t.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:t.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(tt,{label:"Source",value:P3(e.source)}),t.jsx(tt,{label:"Member ID",value:s.id,mono:!0}),t.jsx(tt,{label:"Session ID",value:s.sessionId,mono:!0}),t.jsx(tt,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),t.jsx(tt,{label:"Created",value:_s(s.addedAt)}),t.jsx(tt,{label:"Updated",value:_s(s.updatedAt)}),t.jsx(tt,{label:"Session created",value:ld(o?.createdAt??null)}),t.jsx(tt,{label:"Session updated",value:ld(o?.updatedAt??null)})]}),o===null?t.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."}):t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(tt,{label:"Log coverage",value:o.logCoverage}),t.jsx(tt,{label:"Runtime",value:oa(o.runtimeMode)}),t.jsx(tt,{label:"Requests",value:xt(o.requestCount),mono:!0}),t.jsx(tt,{label:"Errors",value:xt(o.errorCount),mono:!0}),t.jsx(tt,{label:"Input tokens",value:xt(o.tokenUsage.input),mono:!0}),t.jsx(tt,{label:"Output tokens",value:xt(o.tokenUsage.output),mono:!0}),t.jsx(tt,{label:"Cache read",value:xt(o.tokenUsage.cacheRead),mono:!0}),t.jsx(tt,{label:"Total tokens",value:xt(o.tokenUsage.total),mono:!0})]}),t.jsx(G3,{logs:o?.latestLogs??[]}),t.jsx(K3,{entries:i})]})})})}function tt({label:e,value:n,mono:s=!1}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),t.jsx("div",{className:L("truncate text-xs text-foreground",s?"font-mono":""),title:n,children:n})]})}function G3({logs:e}){const n=e.slice(0,5);return n.length===0?t.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."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.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"}),t.jsx("div",{className:"divide-y divide-border",children:n.map(s=>{const r=s.sessionLogNumber??s.id;return t.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[t.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",r]}),t.jsxs("span",{className:"min-w-0 truncate",children:[oa(s.model)," · ",s.apiFormat," · ",s.path]}),t.jsx("span",{className:"font-mono text-muted-foreground",children:zi(s.firstChunkMs)}),t.jsx("span",{className:"font-mono text-muted-foreground",children:zi(s.latencyMs)})]},s.id)})})]})}function K3({entries:e}){return e.length===0?null:t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.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"}),t.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([n,s])=>{const r=E3(s);return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"mr-2 text-muted-foreground",children:n}),t.jsx("span",{className:"font-mono text-foreground",title:r,children:r})]},n)})})]})}const Y3=T({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:pe(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:V(x()),sourceTool:pe(["claude-code","opencode","mimo-code"]),alreadyExists:Ce()}),J3=T({scanId:x().uuid(),providers:V(Y3),warnings:V(x()).optional()});T({scanId:x().uuid(),selectionIds:V(x().uuid()).min(1).max(100)});const X3=T({success:Ce().optional(),imported:_().optional(),message:x().optional(),errors:V(x()).optional()}),cd=2e4;function Z3({open:e,onOpenChange:n,onImportComplete:s}){const[r,o]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[p,u]=l.useState([]),[m,f]=l.useState([]),[h,g]=l.useState(new Set),[v,w]=l.useState(!1),[y,b]=l.useState(null),[j,S]=l.useState(null),N=l.useRef(0),C=l.useRef(0),E=l.useCallback(()=>{const k=N.current+1;N.current=k,o(!0),i(null),f([]),d(null),u([]),g(new Set),b(null),S(null),Be("/api/providers/scan",J3,cd,{method:"POST"},R=>`Scan failed (${String(R.status)})`).then(R=>{if(N.current!==k)return;d(R.scanId),u(R.providers),f(R.warnings??[]);const O=new Set;R.providers.forEach(($,K)=>{$.alreadyExists||O.add(K)}),g(O)}).catch(R=>{N.current===k&&i(R instanceof Error?R.message:String(R))}).finally(()=>{N.current===k&&o(!1)})},[]);l.useEffect(()=>{e&&E()},[e,E]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,o(!1),w(!1))},[e]);const A=l.useCallback(k=>{g(R=>{const O=new Set(R);return O.has(k)?O.delete(k):O.add(k),O})},[]),I=l.useCallback(()=>{const k=p.filter((O,$)=>h.has($));if(k.length===0||c===null)return;const R=C.current+1;C.current=R,w(!0),S(null),b(null),Be("/api/providers/import",X3,cd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(O=>O.selectionId)})},O=>`Import failed (${String(O.status)})`).then(O=>{C.current===R&&(u($=>$.map((K,ee)=>h.has(ee)?{...K,alreadyExists:!0}:K)),g(new Set),O.errors!==void 0&&O.errors.length>0&&O.message!==void 0?b(O.message):b(`Imported ${O.imported??k.length} provider(s)`),s())}).catch(O=>{C.current===R&&S(O instanceof Error?O.message:String(O))}).finally(()=>{C.current===R&&w(!1)})},[p,c,h,s]),M=p.some(k=>!k.alreadyExists);return t.jsx(Nt,{open:e,onOpenChange:n,children:t.jsxs(Ct,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(Tt,{children:[t.jsx(_t,{children:"Import from External Tools"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&t.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[t.jsx(Ue,{className:"size-4 animate-spin"}),t.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&t.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[t.jsx(tn,{className:"size-4"}),a]}),!r&&a===null&&p.length===0&&t.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",t.jsx("br",{}),t.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!r&&p.map((k,R)=>t.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&t.jsx("input",{type:"checkbox",checked:h.has(R),disabled:v,onChange:()=>A(R),className:"mt-0.5 size-4"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(sa,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),t.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`:""]}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),m.length>0&&t.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:m.map((k,R)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(tn,{className:"size-3"}),k]},R))}),y!==null&&t.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:y}),j!==null&&t.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),t.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[t.jsxs(J,{variant:"outline",size:"sm",onClick:E,disabled:r,children:[t.jsx(Ue,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),t.jsxs(J,{size:"sm",onClick:I,disabled:!M||h.size===0||v,children:[t.jsx(Rs,{className:"size-3 mr-1"}),v?"Importing...":`Import Selected (${h.size})`]})]})]})})}const ph=T({id:x().min(1).max(fi),aliases:V(x().max(fi)).max(wn).optional().default([]),contextWindow:_().int().positive().optional(),outputLimit:_().int().positive().optional(),sourceUrl:x().optional()}),Q3=T({name:x().min(1).optional(),aliases:V(x()).max(wn).optional().default([]),baseUrls:V(x()).max(wn).optional().default([]),models:V(ph).min(1).max(wn)});T({version:_().int().positive().optional(),updatedAt:x().optional(),providers:V(Q3).max(wn).optional().default([]),models:V(ph).max(wn).optional().default([])});function dd(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function e4(e){const n=e.models.filter(s=>s.trim()!=="");return n.length>0?n:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Zl(e,n){const s=dd(n);return(e.modelMetadata??[]).find(o=>dd(o.model)===s)??null}function t4(e){const n=e4(e);return n.length===0?!1:n.every(s=>{const r=Zl(e,s);return r!==null&&r.contextWindow!==void 0})}function n4(e,n){if(e===null)return null;for(const s of n){const r=Zl(s,e);if(r!==null&&r.contextWindow!==void 0)return{providerName:s.name,model:r.model,tokens:r.contextWindow,sourceUrl:r.sourceUrl}}return null}function or(e){return Object.prototype.hasOwnProperty.call(e,"success")}function aa(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function St(e){return e!==void 0&&e!==""}function rt(e){return e!==void 0&&e.trim()!==""}function Ar(e){return e!=null}function bs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function mh(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function fh(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 s4(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?bs(e.firstChunkMs):e.latencyMs!==void 0?bs(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?bs(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?mh(e.tokensPerSecond):null}function r4(e){return aa(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:or(e)?e.success?{tone:"success",label:"Pass",metric:s4(e),hasDetails:!0}:{tone:"failure",label:fh(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function o4(e,n){if(n===void 0)return[];const s=[];return St(e.anthropicBaseUrl)&&s.push(n.anthropic),St(e.openaiBaseUrl)&&s.push(n.openaiChat),St(e.openaiResponsesBaseUrl)&&s.push(n.openaiResponses),s}function a4(e,n){const s={total:0,passed:0,failed:0,testing:0};for(const r of o4(e,n))for(const o of[r.nonStreaming,r.streaming])aa(o)||(s.total+=1,or(o)?o.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function ud(e){if(e===void 0)return;const n=Object.entries(e).map(([s,r])=>`${s}: ${r}`);return n.length===0?void 0:n.join(`
|
|
58
|
+
`)}function mn({title:e,children:n}){return t.jsxs("section",{className:"space-y-1.5",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),n]})}function Mn({value:e}){return t.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 An({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[t.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),t.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:n,children:n})]})}function i4({result:e}){const n=Ar(e.inputTokens)||Ar(e.outputTokens),s=Ar(e.cacheCreationInputTokens)||Ar(e.cacheReadInputTokens);return rt(e.model)||n||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?t.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[rt(e.model)&&t.jsx(An,{label:"Model",value:e.model}),e.latencyMs!==void 0&&t.jsx(An,{label:"Latency",value:bs(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&t.jsx(An,{label:"First chunk",value:bs(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&t.jsx(An,{label:"Stream total",value:bs(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&t.jsx(An,{label:"Token rate",value:`${mh(e.tokensPerSecond)} tok`}),n&&t.jsx(An,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&t.jsx(An,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function l4({result:e}){const n=e.debug,s=n?.requestUrl,r=n?.requestMethod??"POST",o=ud(n?.requestHeaders),a=ud(n?.responseHeaders),i=n?.responseStatus===void 0?void 0:`${String(n.responseStatus)}${rt(n.responseStatusText)?` ${n.responseStatusText}`:""}`,c=n?.responseBody??e.rawResponse;return rt(e.error?.hint)||rt(e.error?.details)||rt(s)||o!==void 0||rt(n?.requestBody)||rt(i)||a!==void 0||rt(c)?t.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[rt(e.error?.hint)&&t.jsx(mn,{title:"Hint",children:t.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),rt(e.error?.details)&&t.jsx(mn,{title:"Error details",children:t.jsx(Mn,{value:e.error.details})}),rt(s)&&t.jsx(mn,{title:"Request",children:t.jsx(Mn,{value:`${r} ${s}`})}),o!==void 0&&t.jsx(mn,{title:"Request headers",children:t.jsx(Mn,{value:o})}),rt(n?.requestBody)&&t.jsx(mn,{title:"Request body",children:t.jsx(Mn,{value:n.requestBody})}),rt(i)&&t.jsx(mn,{title:"Response status",children:t.jsx(Mn,{value:i})}),a!==void 0&&t.jsx(mn,{title:"Response headers",children:t.jsx(Mn,{value:a})}),rt(c)&&t.jsx(mn,{title:"Response body",children:t.jsx(Mn,{value:c})})]}):null}function c4({result:e,probeLabel:n,children:s}){const r=e.error?.message??"Connection failed";return t.jsxs(Nt,{children:[t.jsx(Vn,{asChild:!0,children:s}),t.jsxs(Ct,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[t.jsxs(Tt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[e.success?t.jsx(ir,{className:"size-4 text-status-success"}):t.jsx(tn,{className:"size-4 text-status-danger"}),t.jsx(_t,{className:"text-base",children:n})]}),t.jsx(Is,{children:e.success?"Connection probe passed.":r})]}),t.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&t.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[t.jsx("div",{className:"font-medium",children:fh(e.error?.type??"unknown")}),t.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:r})]}),t.jsx(i4,{result:e}),t.jsx(l4,{result:e})]})]})]})}function d4(e){const n="size-3 shrink-0";switch(e){case"timeout":return t.jsx(en,{className:n});case"network_unreachable":return t.jsx(ob,{className:n});case"connection_refused":return t.jsx(ib,{className:n});case"auth_failed":return t.jsx(s1,{className:n});case"rate_limited":return t.jsx(il,{className:n});case"server_error":return t.jsx(Qu,{className:n});case"invalid_response":return t.jsx(o0,{className:n});case"unknown":return t.jsx(tn,{className:n})}}const u4={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 pd({result:e,probeLabel:n}){const s=r4(e),r=aa(e)?t.jsx(Yu,{className:"size-3 shrink-0"}):or(e)?e.success?t.jsx(ir,{className:"size-3 shrink-0"}):d4(e.error?.type??"unknown"):t.jsx(oo,{className:"size-3 shrink-0 animate-spin"}),o=t.jsxs(t.Fragment,{children:[r,t.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=L("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",u4[s.tone]);return or(e)&&s.hasDetails?t.jsx(c4,{result:e,probeLabel:n,children:t.jsx("button",{type:"button",className:a,"aria-label":`Open ${n} result: ${s.label}`,children:o})}):t.jsx("div",{className:a,children:o})}function md({label:e}){return t.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:[t.jsx(Yu,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e})]})}function Ua({label:e,results:n,configured:s=!0}){return t.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:[t.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&n!==void 0?t.jsx(pd,{result:n.nonStreaming,probeLabel:`${e} non-stream`}):t.jsx(md,{label:s?"Not tested":"Off"}),s&&n!==void 0?t.jsx(pd,{result:n.streaming,probeLabel:`${e} stream`}):t.jsx(md,{label:s?"Not tested":"Off"})]})}function hh({provider:e,results:n}){const s=St(e.anthropicBaseUrl),r=St(e.openaiBaseUrl),o=St(e.openaiResponsesBaseUrl);return!s&&!r&&!o?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):t.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:t.jsxs("div",{className:"min-w-[20rem]",children:[t.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:[t.jsx("span",{children:"Protocol"}),t.jsx("span",{children:"Non-stream"}),t.jsx("span",{children:"Stream"})]}),s&&t.jsx(Ua,{label:"Anthropic",results:n?.anthropic}),r&&t.jsx(Ua,{label:"OpenAI Chat",results:n?.openaiChat}),o&&t.jsx(Ua,{label:"OpenAI Responses",results:n?.openaiResponses})]})})}function p4(e){const n={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])aa(s)||(n.total+=1,or(s)?s.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function qa({label:e,results:n}){const s=p4(n),r=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",o=s.failed>0?`${s.failed} fail`:s.testing>0?"running":s.total===0?"off":`${s.passed}/${s.total}`;return t.jsxs("span",{className:L("rounded border px-1.5 py-0.5 text-[10px]",r),children:[e," ",o]})}function m4({provider:e,modelName:n,results:s,expanded:r,onToggle:o}){return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:o,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":r,children:[r?t.jsx(Ze,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(ct,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:n,children:n}),t.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[St(e.anthropicBaseUrl)&&t.jsx(qa,{label:"A",results:s.anthropic}),St(e.openaiBaseUrl)&&t.jsx(qa,{label:"Chat",results:s.openaiChat}),St(e.openaiResponsesBaseUrl)&&t.jsx(qa,{label:"Resp",results:s.openaiResponses})]})]}),r&&t.jsx("div",{className:"px-2 pb-3",children:t.jsx(hh,{provider:e,results:s})})]})}function f4({provider:e,testResults:n}){const s=Object.entries(n.models??{}),[r,o]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:t.jsxs("section",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>o(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":r,children:[r?t.jsx(Ze,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"}),"Model probes",t.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),r&&t.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>t.jsx(m4,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(p=>p===c?null:c)},c))})]})}function h4({provider:e,testResults:n,isTesting:s}){const r=St(e.anthropicBaseUrl)||St(e.openaiBaseUrl)||St(e.openaiResponsesBaseUrl),o=a4(e,n);return s?t.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:[t.jsx(oo,{className:"size-3 animate-spin"}),"Testing"]}):r?n===void 0||o.total===0?t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):o.failed>0?t.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:[t.jsx(tn,{className:"size-3"}),o.failed," failed"]}):o.testing>0||o.passed<o.total?t.jsxs("span",{className:"rounded border border-status-watch/30 bg-status-watch/10 px-2 py-1 text-xs text-status-watch",children:[o.passed,"/",o.total]}):t.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:[t.jsx(ir,{className:"size-3"}),o.passed,"/",o.total]}):t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const x4={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function Ha(e){return e!==void 0&&e!==""}function Va({label:e}){return t.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:[t.jsx(ir,{className:"size-3"}),e]})}function g4({provider:e}){const n=Ha(e.anthropicBaseUrl),s=Ha(e.openaiBaseUrl),r=Ha(e.openaiResponsesBaseUrl);return!n&&!s&&!r?t.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[n&&t.jsx(Va,{label:"Anthropic"}),s&&t.jsx(Va,{label:"OpenAI Chat"}),r&&t.jsx(Va,{label:"OpenAI Responses"})]})}function b4(e){const n=e.models??[];if(n.length===0)return"No models configured";const s=n.slice(0,2).join(", "),r=n.length-2;return r>0?`${s} +${r} more`:s}function v4({provider:e,model:n}){const s=Zl(e,n),r=w4(s?.sourceUrl);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:n}),s!==null&&s.contextWindow!==void 0&&t.jsx("span",{className:"font-mono text-foreground/80",children:bu(s.contextWindow)}),r!==null&&t.jsx(Ps,{children:t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsx("a",{href:r.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":r.title,children:r.label})}),t.jsx(ft,{children:r.title})]})})]})}function y4(e){const n=Date.now(),s=new Date(e).getTime(),r=n-s,o=Math.floor(r/1e3);if(o<60)return"just now";const a=Math.floor(o/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 w4(e){if(e===void 0||e.trim()==="")return null;try{const n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return null;const s=n.hostname.toLowerCase(),r=s==="huggingface.co"||s.endsWith(".huggingface.co");return{label:r?"HF":"Source",title:r?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function j4({provider:e,testResults:n,isTesting:s,testingTimeLeft:r,isHighlighted:o,onEdit:a,onDelete:i,onTest:c,onRefreshMetadata:d,isRefreshingMetadata:p=!1}){const[u,m]=l.useState(!1),f=e.apiDocsUrl??Object.entries(x4).find(([b])=>e.name.toLowerCase().includes(b))?.[1],h=t4(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",v=g?"Refresh":"Import defaults",w=s??!1,y=e.source==="company"?t.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"?t.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 t.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 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-medium leading-snug",children:e.name}),y]}),t.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:b4(e)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(h4,{provider:e,testResults:n,isTesting:w}),f!==void 0&&t.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:[t.jsx(lr,{className:"size-3"}),t.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsx(g4,{provider:e}),n?.testedAt!==void 0&&t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(en,{className:"size-3"}),y4(n.testedAt)]})]}),!h&&t.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:[t.jsx("span",{children:"Context window metadata missing"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:p,children:[t.jsx(oo,{className:`size-3 ${p?"animate-spin":""}`}),v]}),!g&&t.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&t.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ir,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(b=>t.jsx(v4,{provider:e,model:b},b))}),t.jsxs("section",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),t.jsx(hh,{provider:e,results:n})]}),n!==void 0&&t.jsx(f4,{provider:e,testResults:n})]}),t.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("button",{type:"button",onClick:()=>m(b=>!b),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,children:[u?t.jsx(Ze,{className:"size-3"}):t.jsx(ct,{className:"size-3"}),"Details"]}),t.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:w,children:[t.jsx(oo,{className:`size-3 ${w?"animate-spin":""}`}),w?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:w,children:[t.jsx(Ju,{className:"size-3"}),"Edit"]}),t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:w,children:[t.jsx(Sn,{className:"size-3"}),"Delete"]})]})]})]})}const vs="/v1/chat/completions",Di="/v1/responses",S4="/v1/messages";function N4(e,n){const s=e.endsWith("/")?e.slice(0,-1):e,r=xh(n),o=n.indexOf("?"),a=o>=0?n.slice(o):"";return r!==""&&s.endsWith(r)?s+a:bh(s)&&gh(n)||s.endsWith("/v1")&&n.startsWith("/v1/")?s+n.slice(3):s+n}function C4(e,n,s={}){const r=e.trim().replace(/\/+$/,""),o=xh(n),a=N4(r,n),i=[];return o!==""&&r.endsWith(o)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):bh(r)&&gh(n)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):r.endsWith("/v1")&&n.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),fd(o)&&T4(r)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),k4(o)&&_4(r)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),fd(o)&&E4(r,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function xh(e){return e.split("?")[0]??e}function gh(e){return e===vs||e.startsWith(`${vs}?`)||e.startsWith(`${vs}/`)}function k4(e){return e===vs||e.startsWith(`${vs}/`)}function fd(e){return e===Di||e.startsWith(`${Di}/`)}function T4(e){return e.toLowerCase().endsWith("/chat/completions")}function _4(e){return e.toLowerCase().endsWith("/responses")}function E4(e,n){const s=n?.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 bh(e){try{const n=new URL(e),s=n.pathname.replace(/\/+$/,"");return n.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function Wa(e){return e!==void 0&&e.trim()!==""}function hd(e){const n=Wa(e?.anthropicBaseUrl),s=Wa(e?.openaiBaseUrl),r=Wa(e?.openaiResponsesBaseUrl);return{anthropic:n,openai:s||r,openaiChat:s,openaiResponses:r}}function Ga(e,n,s){if(!e)return s?"":void 0;const r=n.trim();return r===""?void 0:r}const xd=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],gd=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],Ir=S4,Pr=vs,Lr=Di,R4={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"}},bd=["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"],vd=["qwen3.6-plus","qwen3.7-max"],yd=["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__",jo="__custom__",vh=[{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 In(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function wd(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function yh(e,n){const s=wd(n);return e?.modelMetadata?.find(r=>wd(r.model)===s)??null}function wh(e){const n=to(e);if(n===null)return null;for(const s of vh)if(to(s.value)===n)return s.value;return null}function M4(e){return e.trim()===""?"unset":wh(e)!==null?"preset":"custom"}function A4(e){switch(e.contextWindowMode){case"unset":return $i;case"custom":return jo;case"preset":return wh(e.contextWindow)??jo}}function Ka(e){const n=e.trim().replaceAll(",","");if(n==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(n);if(s===null)return{amount:n,unit:"K"};const r=s[1];if(r===void 0)return{amount:n,unit:"K"};const o=s[2];if(o===void 0||o==="")return{amount:r,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:r,unit:"K"};case"m":return{amount:r,unit:"M"};default:return{amount:n,unit:"K"}}}function jd(e,n){const s=e.trim();if(s==="")return"";switch(n){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function Sd(e,n){return n.map(s=>{const r=yh(e,s),o=r?.contextWindow!==void 0?lx(r.contextWindow):"";return{contextWindow:o,contextWindowMode:M4(o),outputLimit:r?.outputLimit?.toString()??""}})}function Nd(e){const n=e.trim();if(n==="")return null;const s=Number(n);return!Number.isInteger(s)||s<=0?null:s}function os(e,n){if(e===void 0)return"";const s=e.trim(),r=s.replace(/\/+$/,"");return r.endsWith(n)?r.slice(0,-n.length).replace(/\/+$/,""):s}function I4(e,n,s){const r=e.trim();return r===""?null:C4(r,n,{providerName:s})}function Ya({baseUrl:e,endpoint:n,providerName:s}){const r=I4(e,n,s);return r===null?null:t.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[t.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),t.jsx("div",{className:"break-all font-mono text-foreground",children:r.finalUrl}),r.diagnostics.length>0&&t.jsx("div",{className:"mt-2 space-y-1",children:r.diagnostics.map(o=>t.jsx("div",{className:o.severity==="warning"?"text-status-watch":"text-muted-foreground",children:o.message},`${o.severity}:${o.message}`))})]})}function P4({provider:e,onSubmit:n,onCancel:s}){const r=hd(e),[o,a]=l.useState(e?.name??""),[i,c]=l.useState(""),[d,p]=l.useState(!1),[u,m]=l.useState(!1),f=e?.models,[h,g]=l.useState(f!==void 0&&f.length>0?f:[""]),[v,w]=l.useState(()=>Sd(e,f!==void 0&&f.length>0?f:[""])),[y,b]=l.useState(r.anthropic),[j,S]=l.useState(r.openai),[N,C]=l.useState(r.openaiChat),[E,A]=l.useState(r.openaiResponses),[I,M]=l.useState(os(e?.anthropicBaseUrl,Ir)),[k,R]=l.useState(os(e?.openaiBaseUrl,Pr)),[O,$]=l.useState(os(e?.openaiResponsesBaseUrl,Lr)),[K,ee]=l.useState(e?.apiDocsUrl??""),[D,H]=l.useState(e?.modelMetadataUrl??""),[te,U]=l.useState(e?.source),[Q,fe]=l.useState({}),[je,he]=l.useState(!1),[re,P]=l.useState(null),X=l.useRef([]);l.useEffect(()=>{if(re===null)return;const z=re;function Y(de){if(!(de.target instanceof Node))return;const Ne=X.current[z];Ne!=null&&!Ne.contains(de.target)&&P(null)}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[re]);const[Se,_e]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!1),Re=o.toLowerCase().includes("minimax"),Fe=o.toLowerCase().includes("alibaba"),dt=[...xd,...gd].some(z=>o.toLowerCase().includes(z)),He=Re?bd:dt?yd:Fe?vd:[],Le=e?.modelMetadata?.some(z=>z.contextWindow!==void 0)??!1;function We(){bt(i).then(z=>{z&&(m(!0),setTimeout(()=>m(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),p(!1);const z=(e.models?.length??0)>0?e.models:[""];g(z),w(Sd(e,z));const Y=hd(e);b(Y.anthropic),S(Y.openai),C(Y.openaiChat),A(Y.openaiResponses),M(os(e.anthropicBaseUrl,Ir)),R(os(e.openaiBaseUrl,Pr)),$(os(e.openaiResponsesBaseUrl,Lr)),ee(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),U(e.source),_e(!1),le(!1),Pe(!1)}},[e]),l.useEffect(()=>{const z=o.toLowerCase();for(const[Y,de]of Object.entries(R4))if(z.includes(Y)){de.anthropicBaseUrl!==void 0&&!Se&&M(de.anthropicBaseUrl),de.openaiBaseUrl!==void 0&&!ge&&R(de.openaiBaseUrl),de.openaiResponsesBaseUrl!==void 0&&!ce&&$(de.openaiResponsesBaseUrl),de.apiDocsUrl!==void 0&&!K&&ee(de.apiDocsUrl),Y==="minimax"&&h.length===1&&h[0]===""&&g([bd[0]??""]),Y==="alibaba"&&h.length===1&&h[0]===""&&g([vd[0]??""]),(xd.includes(Y)||gd.includes(Y))&&h.length===1&&h[0]===""&&g([yd[0]??""]);break}},[o]);function Ye(){const z={};return o.trim()||(z.name="Name is required"),e===void 0&&!i.trim()&&(z.apiKey="API key is required"),(h.length===0||h.every(Y=>!Y.trim()))&&(z.models="At least one model is required"),!y&&!j&&(z.capabilities="Select at least one API capability"),j&&!N&&!E&&(z.openaiCapabilities="Select Chat Completions, Responses, or both"),y&&(I.trim()===""?z.anthropicBaseUrl="Anthropic base URL is required":Qe(I.trim())||(z.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?z.openaiBaseUrl="OpenAI Chat base URL is required":Qe(k.trim())||(z.openaiBaseUrl="Invalid URL format")),j&&E&&(O.trim()===""?z.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Qe(O.trim())||(z.openaiResponsesBaseUrl="Invalid URL format")),D.trim()&&!Qe(D.trim())&&(z.modelMetadataUrl="Invalid URL format"),v.forEach((Y,de)=>{const Ne=to(Y.contextWindow),F=Nd(Y.outputLimit);Y.contextWindow.trim()!==""&&Ne===null&&(z[`modelMetadata.${de}.contextWindow`]="Context window must be a positive number, optionally using K or M"),Y.outputLimit.trim()!==""&&F===null&&(z[`modelMetadata.${de}.outputLimit`]="Output limit must be a positive integer"),Ne!==null&&F!==null&&F>Ne&&(z[`modelMetadata.${de}.outputLimit`]="Output limit should not exceed context window")}),fe(z),Object.keys(z).length===0}function Qe(z){try{return new URL(z),!0}catch{return!1}}function ot(z,Y){g(de=>{const Ne=[...de];return Ne[z]=Y,Ne})}function nt(z,Y){w(de=>{const Ne=[...de];return Ne[z]={...Ne[z]??In(),...Y},Ne})}function q(z,Y){switch(Y){case $i:nt(z,{contextWindow:"",contextWindowMode:"unset"});return;case jo:{const de=v[z]??In();nt(z,{contextWindow:de.contextWindow,contextWindowMode:"custom"});return}default:nt(z,{contextWindow:Y,contextWindowMode:"preset"});return}}function se(z,Y){const de=v[z]??In(),Ne=Ka(de.contextWindow);nt(z,{contextWindow:jd(Y,Ne.unit),contextWindowMode:"custom"})}function xe(z,Y){const de=v[z]??In(),Ne=Ka(de.contextWindow);switch(Y){case"K":case"M":case"tokens":nt(z,{contextWindow:jd(Ne.amount,Y),contextWindowMode:"custom"});return;default:return}}function me(z){g(Y=>Y.filter((de,Ne)=>Ne!==z)),w(Y=>Y.filter((de,Ne)=>Ne!==z))}function we(){g(z=>[...z,""]),w(z=>[...z,In()])}function Oe(){const z=new Date().toISOString(),Y=[];return h.forEach((de,Ne)=>{const F=de.trim();if(F==="")return;const W=v[Ne]??In(),Z=to(W.contextWindow),ne=Nd(W.outputLimit);if(Z===null&&ne===null)return;const Ee=yh(e,F);if(Ee!==null&&Ee.contextWindow===(Z??void 0)&&Ee.outputLimit===(ne??void 0)){Y.push({...Ee,model:F});return}const ie={model:F,source:"manual",updatedAt:z};Z!==null&&(ie.contextWindow=Z),ne!==null&&(ie.outputLimit=ne),Y.push(ie)}),Y.length>0?Y:e?.modelMetadata!==void 0?[]:void 0}function $e(z){if(z.preventDefault(),!Ye())return;he(!0);const Y=e!==void 0;try{n({name:o.trim(),apiKey:i.trim(),models:h.map(de=>de.trim()).filter(de=>de!==""),anthropicBaseUrl:Ga(y,I,Y),openaiBaseUrl:Ga(j&&N,k,Y),openaiResponsesBaseUrl:Ga(j&&E,O,Y),apiDocsUrl:K.trim()||void 0,modelMetadataUrl:D.trim()||void 0,modelMetadata:Oe(),source:te})}finally{he(!1)}}return t.jsxs("form",{onSubmit:$e,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx("input",{id:"provider-name",type:"text",value:o,onChange:z=>a(z.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"}),Q.name!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.name})]}),t.jsxs("fieldset",{className:"space-y-3",children:[t.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[t.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[t.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:z=>S(z.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&t.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:z=>C(z.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),t.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:E,onChange:z=>A(z.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),Q.openaiCapabilities!==void 0&&j&&t.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:Q.openaiCapabilities})]}),t.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${y?"bg-primary/[0.04]":""}`,children:[t.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:y,onChange:z=>b(z.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),Q.capabilities!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.capabilities})]}),(y||j&&(N||E))&&t.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[t.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),y&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.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:[t.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:I,onChange:z=>{_e(!0),M(z.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"}),t.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:Ir})]}),Q.anthropicBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.anthropicBaseUrl}),t.jsx(Ya,{baseUrl:I,endpoint:Ir,providerName:o})]}),j&&N&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.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:[t.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:z=>{le(!0),R(z.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"}),t.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:Pr})]}),Q.openaiBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.openaiBaseUrl}),t.jsx(Ya,{baseUrl:k,endpoint:Pr,providerName:o})]}),j&&E&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.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:[t.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:O,onChange:z=>{Pe(!0),$(z.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"}),t.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:Lr})]}),Q.openaiResponsesBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.openaiResponsesBaseUrl}),t.jsx(Ya,{baseUrl:O,endpoint:Lr,providerName:o})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),t.jsxs("select",{id:"provider-source",value:te??"",onChange:z=>U(z.target.value==="company"||z.target.value==="personal"?z.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:[t.jsx("option",{value:"",children:"Unspecified"}),t.jsx("option",{value:"personal",children:"个人 (Personal)"}),t.jsx("option",{value:"company",children:"公司 (Company)"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),t.jsx("input",{id:"provider-model-metadata-url",type:"text",value:D,onChange:z=>H(z.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"}),Q.modelMetadataUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.modelMetadataUrl}),D.trim()===""&&t.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&&!Le&&D.trim()===""&&t.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),D.trim()!==""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:z=>c(z.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"}),t.jsx("button",{type:"button",onClick:()=>p(z=>!z),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?t.jsx(M0,{className:"size-4"}):t.jsx(Hu,{className:"size-4"})}),t.jsx("button",{type:"button",onClick:We,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?t.jsx(De,{className:"size-4 text-status-success"}):t.jsx(yt,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),Q.apiKey!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.apiKey})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"text-sm font-medium",children:["Models ",t.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((z,Y)=>{const de=v[Y]??In(),Ne=Q[`modelMetadata.${Y}.contextWindow`],F=Q[`modelMetadata.${Y}.outputLimit`],W=A4(de),Z=Ka(de.contextWindow);return t.jsxs("div",{ref:ne=>{X.current[Y]=ne},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx("input",{type:"text",value:z,onChange:ne=>ot(Y,ne.target.value),placeholder:He.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"}),He.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>P(re===Y?null:Y),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:t.jsx(Ze,{className:"size-4"})}),re===Y&&t.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:He.map(ne=>t.jsx("button",{type:"button",onClick:()=>{ot(Y,ne),P(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ne},ne))})]})]}),h.length>1&&t.jsx("button",{type:"button",onClick:()=>me(Y),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:t.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:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Context Window"}),t.jsxs(nr,{value:W,onValueChange:ne=>q(Y,ne),children:[t.jsx(sr,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(wo,{})}),t.jsxs(rr,{className:"max-h-64",children:[t.jsx(it,{value:$i,children:"Not set"}),vh.map(ne=>t.jsxs(it,{value:ne.value,children:[ne.label," · ",ne.value]},ne.value)),t.jsx(it,{value:jo,children:"Custom"})]})]}),de.contextWindowMode==="custom"&&t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[t.jsx("input",{type:"text",inputMode:"decimal",value:Z.amount,onChange:ne=>se(Y,ne.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]"}),t.jsxs(nr,{value:Z.unit,onValueChange:ne=>xe(Y,ne),children:[t.jsx(sr,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(wo,{})}),t.jsxs(rr,{children:[t.jsx(it,{value:"K",children:"K"}),t.jsx(it,{value:"M",children:"M"}),t.jsx(it,{value:"tokens",children:"tokens"})]})]})]}),Ne!==void 0&&t.jsx("span",{className:"block text-destructive",children:Ne})]}),t.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Output Limit"}),t.jsx("input",{type:"number",min:1,step:1e3,value:de.outputLimit,onChange:ne=>nt(Y,{outputLimit:ne.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]"}),F!==void 0&&t.jsx("span",{className:"block text-destructive",children:F})]})]})]},Y)}),t.jsx("button",{type:"button",onClick:we,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),Q.models!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Q.models})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),t.jsx("input",{id:"provider-api-docs-url",type:"text",value:K,onChange:z=>ee(z.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"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),t.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:[t.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:je,children:"Cancel"}),t.jsx(J,{type:"submit",disabled:je,children:je?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const L4=pe(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),O4=T({message:x(),type:L4,details:x().optional(),hint:x().optional()}),z4=T({type:pe(["text","thinking"]),text:x().optional(),thinking:x().optional()}),D4=T({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:qe(x(),x()).optional(),requestBody:x().optional(),responseStatus:_().optional(),responseStatusText:x().optional(),responseHeaders:qe(x(),x()).optional(),responseBody:x().optional()}),Or=_().nullable().optional(),$4=T({success:Ce(),error:O4.optional(),model:x().optional(),inputTokens:Or,outputTokens:Or,cacheCreationInputTokens:Or,cacheReadInputTokens:Or,latencyMs:_().optional(),firstChunkMs:_().nullable().optional(),totalStreamMs:_().nullable().optional(),tokensPerSecond:_().nullable().optional(),content:V(z4).optional(),rawResponse:x().optional(),streaming:Ce().optional(),streamingChunks:T({chunks:V(yu),truncated:Ce().default(!1)}).optional(),requestHeaders:qe(x(),x()).optional(),debug:D4.optional()}),Cd=Gt([$4,T({notConfigured:ae(!0)}),T({testing:ae(!0)})]),bn=T({nonStreaming:Cd,streaming:Cd});function So(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const F4=T({anthropic:bn,openai:bn.optional(),openaiChat:bn.optional(),openaiResponses:bn.optional()}).transform(e=>{const n=e.openaiChat??e.openai??So();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??So()}}),B4=T({anthropic:bn,openai:bn.optional(),openaiChat:bn.optional(),openaiResponses:bn.optional(),models:qe(x(),F4).optional(),testedAt:x().optional()}).transform(e=>{const n=e.openaiChat??e.openai??So();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??So()}});function U4(){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 kd(e,n){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:n}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const q4=T({providerConfig:x()}),H4=T({success:Ce().optional(),imported:_().optional(),message:x().optional(),errors:V(x()).optional()}),V4=T({provider:lo,imported:_(),matchedModels:V(x()),missingModels:V(x()),sourceUrl:x()}),zr="Network error: could not reach the server. Is the proxy running?",W4=5e3,G4=5e3,Td=15e3,K4=1e4,Y4=2e4,J4=2e4,X4=3e4;function Ja(e,n){return(e?.length??0)>0?e:n&&e!==void 0?"":void 0}function _d(e,n=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ja(e.anthropicBaseUrl,n),openaiBaseUrl:Ja(e.openaiBaseUrl,n),openaiResponsesBaseUrl:Ja(e.openaiResponsesBaseUrl,n),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 Z4(e,n){const s=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,s)*n}async function Q4(e,n){if(n.models!==void 0)try{await vn(`/api/providers/${e}/test/log`,G4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}function eT({externalProviders:e,isLoading:n=!1,externalTestResults:s,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[p,u]=l.useState(!1),[m,f]=l.useState(),[h,g]=l.useState(null),[v,w]=l.useState({}),[y,b]=l.useState(new Set),[j,S]=l.useState({}),[N,C]=l.useState(null),[E,A]=l.useState(!1),[I,M]=l.useState(null),[k,R]=l.useState(!1),[O,$]=l.useState(!1),[K,ee]=l.useState(null),[D,H]=l.useState("all"),[te,U]=l.useState(new Set),{providerTestTimeoutSeconds:Q}=rl(),fe=l.useRef(null),je=l.useRef(null),he=e??[],re=l.useMemo(()=>{const q=D==="all"?he:he.filter(se=>se.source===D);return D==="all"?[...q].sort((se,xe)=>{const me={personal:0,company:1};return(me[se.source??""]??2)-(me[xe.source??""]??2)}):q},[he,D]),P=s??v,X=r??y,Se=o??j,_e=d?(q,se)=>d(q,se):(q,se)=>{S(se===void 0?xe=>{const me={...xe};return delete me[q],me}:xe=>({...xe,[q]:se}))};l.useEffect(()=>{(async()=>{try{const q=await Be("/api/config/paths",q4,W4);C(q.providerConfig)}catch{}})()},[]);const ge=l.useCallback(q=>{je.current!==null&&clearTimeout(je.current),M(q),fe.current?.scrollTo({top:fe.current.scrollHeight,behavior:"smooth"}),je.current=setTimeout(()=>{M(null),je.current=null},2e3)},[]);l.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const le=l.useCallback(()=>{a?.().catch(()=>{})},[a]),ce=l.useCallback((q,se)=>{i?i(q,se):w(xe=>({...xe,[q]:se}))},[i]),Pe=l.useCallback((q,se)=>{if(c){c(q,se);return}b(xe=>{const me=new Set(xe);return se?me.add(q):me.delete(q),me})},[c]),Re=l.useCallback(async q=>{ce(q,U4()),Pe(q,!0);const se=new AbortController,xe=he.find($e=>$e.id===q),me=Z4(xe,Q);let we=me;_e(q,we);const Oe=setInterval(()=>{we--,_e(q,we),we<=0&&(clearInterval(Oe),se.abort())},1e3);try{const $e=await Be(`/api/providers/${q}/test`,B4,me*1e3+1e3,{method:"POST",signal:se.signal},z=>`HTTP ${z.status}: ${z.statusText}`);ce(q,$e),await Q4(q,$e)}catch($e){const z=$e instanceof Error&&$e.name==="AbortError",Y=$e instanceof Ao;z||Y?ce(q,kd("Request timed out","timeout")):$e instanceof Error&&ce(q,kd($e.message,"server_error"))}finally{clearInterval(Oe),_e(q,void 0),Pe(q,!1)}},[Q,he,_e,ce,Pe]),Fe=l.useCallback(async(q,se,xe=!0)=>{U(me=>{const we=new Set(me);return we.add(q),we});try{const me=se!==void 0&&se.trim()!==""?{url:se}:{},we=await Be(`/api/providers/${q}/model-metadata`,V4,X4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(me)},()=>"Failed to refresh model metadata");return we.imported===0&&xe?g("No matching model metadata found for this provider."):g(null),ge(we.provider.id),le(),we.imported>0}catch(me){return xe&&g(me instanceof Error?me.message:zr),!1}finally{U(me=>{const we=new Set(me);return we.delete(q),we})}},[le,ge]);function dt(q){(async()=>{try{const se=await Be("/api/providers",lo,Td,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_d(q))},()=>"Failed to add provider");u(!1),ge(se.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Fe(se.id,q.modelMetadataUrl,!1),le(),await Re(se.id)}catch(se){g(se instanceof Error?se.message:zr)}})()}function He(q){m&&(async()=>{try{const se=await Be(`/api/providers/${m.id}`,lo,Td,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_d(q,!0))},()=>"Failed to update provider");f(void 0),ge(se.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Fe(se.id,q.modelMetadataUrl,!1),le(),(q.apiKey.trim()!==""||JSON.stringify(q.models)!==JSON.stringify(m.models)||(q.anthropicBaseUrl??"")!==(m.anthropicBaseUrl??"")||(q.openaiBaseUrl??"")!==(m.openaiBaseUrl??"")||(q.openaiResponsesBaseUrl??"")!==(m.openaiResponsesBaseUrl??""))&&await Re(se.id)}catch(se){g(se instanceof Error?se.message:zr)}})()}function Le(q){ee(q),$(!0)}function We(){const q=K;q!==null&&(async()=>{let se;try{se=await vn(`/api/providers/${q}`,K4,{method:"DELETE"})}catch{g(zr);return}if(!se.ok){g(await cx(se,"Failed to delete provider"));return}le()})()}const Ye=l.useRef(null);function Qe(q){const se="/api/providers/export";(async()=>{try{const xe=await vn(se,Y4);if(!xe.ok){g("Failed to export providers");return}const me=await xe.blob(),we=URL.createObjectURL(me),Oe=document.createElement("a");Oe.href=we,Oe.download=xe.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Oe),Oe.click(),document.body.removeChild(Oe),URL.revokeObjectURL(we)}catch{g("Failed to export providers")}})()}function ot(){Ye.current?.click()}function nt(q){const se=q.target.files?.[0];se&&(async()=>{try{const xe=await se.text(),me=await vn("/api/providers/import",J4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xe)}),we=await vu(me,H4);me.ok&&we.imported!==void 0&&we.imported>0?(le(),g(null)):we.errors&&we.errors.length>0?g(we.errors.join("; ")):g(we.message??"Import failed")}catch{g("Failed to import providers")}q.target.value=""})()}return n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):p||m?t.jsxs("div",{className:"space-y-4",children:[t.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:t.jsx("h3",{className:"text-lg font-medium",children:m?"Edit Provider":"Add New Provider"})}),t.jsx(P4,{provider:m,onSubmit:m?He:dt,onCancel:()=>{u(!1),f(void 0)}})]}):t.jsxs("div",{className:"space-y-4",children:[t.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:[t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>Qe(),className:"gap-1 hover:bg-muted",children:[t.jsx(Rs,{className:"size-3"}),"Export"]}),t.jsxs(J,{variant:"outline",size:"sm",onClick:ot,className:"gap-1 hover:bg-muted",children:[t.jsx(tp,{className:"size-3"}),"Import"]}),t.jsx("input",{type:"file",ref:Ye,accept:".json",onChange:nt,style:{display:"none"}}),t.jsxs(J,{variant:"outline",size:"sm",onClick:()=>R(!0),className:"gap-1",children:[t.jsx(D1,{className:"size-3"}),"Scan"]}),t.jsxs(J,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[t.jsx(pc,{className:"size-4"}),"Add Provider"]})]}),N!==null&&t.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-mono truncate",title:N,children:N}),t.jsx("button",{type:"button",onClick:()=>{bt(N).then(q=>{q&&(A(!0),setTimeout(()=>A(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":E?"Copied config file path":"Copy config file path",children:E?t.jsx(De,{className:"size-3 text-status-success"}):t.jsx(yt,{className:"size-3"})})]}),h!==null&&t.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:[t.jsx(tn,{className:"size-4 shrink-0"}),h]}),he.length===0?t.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),t.jsxs(J,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[t.jsx(pc,{className:"size-4"}),"Add Your First Provider"]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(q=>t.jsx("button",{type:"button",onClick:()=>H(q),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${D===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:q==="all"?"All":q==="personal"?"Personal":"Company"},q))}),t.jsx("div",{ref:fe,className:"space-y-3",children:re.map(q=>t.jsx(j4,{provider:q,testResults:P[q.id],isTesting:X.has(q.id),testingTimeLeft:Se[q.id],isHighlighted:q.id===I,onEdit:se=>f(se),onDelete:Le,onRefreshMetadata:se=>{Fe(se)},isRefreshingMetadata:te.has(q.id),onTest:se=>{Re(se)}},q.id))})]}),t.jsx(Z3,{open:k,onOpenChange:R,onImportComplete:()=>{a!==void 0&&a()}}),t.jsx(Dl,{open:O,onOpenChange:$,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:We})]})}const tT=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function nT(){return t.jsx(Hf,{"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:tT.map(e=>t.jsx(Zt,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function sT(){const[e,n]=l.useState(!1),[s,r]=l.useState("providers"),{providers:o,isLoading:a,mutate:i}=ml(),[c,d]=l.useState({}),[p,u]=l.useState(new Set),[m,f]=l.useState({}),h=l.useCallback((w,y)=>{d(b=>({...b,[w]:y}))},[]),g=l.useCallback((w,y)=>{u(b=>{const j=new Set(b);return y?j.add(w):j.delete(w),j})},[]),v=l.useCallback((w,y)=>{f(b=>{if(y===void 0){const j={...b};return delete j[w],j}return{...b,[w]:y}})},[]);return t.jsxs(Nt,{open:e,onOpenChange:n,children:[t.jsx(Vn,{asChild:!0,children:t.jsxs(J,{variant:"ghost",size:"icon",className:Gn,"aria-label":"Settings",title:"Settings",children:[t.jsx(V1,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Settings"})]})}),t.jsxs(Ct,{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:[t.jsx(Tt,{children:t.jsx(_t,{children:"Settings"})}),t.jsxs(qf,{value:s,onValueChange:r,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[t.jsx(nT,{}),t.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[t.jsx(ut,{value:"providers",children:t.jsx(eT,{externalProviders:o,isLoading:a,externalTestResults:c,externalTestingProviders:p,externalTestingTimeLeft:m,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:v})}),t.jsx(ut,{value:"proxy",children:t.jsx(uT,{})}),t.jsx(ut,{value:"storage",children:t.jsx(aT,{})}),t.jsx(ut,{value:"mcp",children:t.jsx(dT,{})}),t.jsx(ut,{value:"onboarding",children:t.jsx(cT,{})})]})]})]})]})}const rT=T({kind:x(),root:x(),sensitivity:x(),cleanupBehavior:x(),fileCount:_(),bytes:_(),oldestModifiedAt:x().nullable(),newestModifiedAt:x().nullable()}),Ed=T({memoryCount:_(),inventory:T({checkedAt:x(),totalFiles:_(),totalBytes:_(),artifacts:V(rT)}),policy:T({maxAgeMs:_(),maxTotalBytes:_()}),reclaimableBytes:_(),lastGc:T({checkedAt:x(),filesDeleted:_(),bytesDeleted:_(),errors:_(),beforeTotalBytes:_(),afterTotalBytes:_()}).nullable()}),Rd=1e4;function Ws(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 oT(e){return`${Math.round(e/1e3/60/60/24).toLocaleString()} days`}function aT(){const[e,n]=l.useState(null),[s,r]=l.useState(null),[o,a]=l.useState(!1),[i,c]=l.useState(!1),[d,p]=l.useState(null),u=l.useCallback(async()=>{a(!0),r(null);try{const h=await Be("/api/storage",Ed,Rd,void 0,g=>`Failed to load storage stats: HTTP ${String(g.status)}`);n(h)}catch(h){r(h instanceof Error?h.message:String(h))}finally{a(!1)}},[]);l.useEffect(()=>{u()},[u]);const m=l.useCallback((h,g)=>{bt(g).then(v=>{v&&(p(h),setTimeout(()=>p(null),1600))})},[]),f=l.useCallback(async()=>{c(!0),r(null);try{const h=await Be("/api/storage",Ed,Rd,{method:"POST"},g=>`Failed to run storage GC: HTTP ${String(g.status)}`);n(h)}catch(h){r(h instanceof Error?h.message:String(h))}finally{c(!1)}},[]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Storage lifecycle"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local captured-data footprint, retention policy, and safe reclaim actions."})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>{f()},disabled:i,children:i?"Running...":"Run GC now"}),t.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:o?"Refreshing...":"Refresh"})]})]}),e!==null&&t.jsxs("div",{className:"grid gap-2 text-xs",children:[t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsx(Dr,{label:"Persisted footprint",value:`${e.inventory.totalFiles.toLocaleString()} files / ${Ws(e.inventory.totalBytes)}`,detail:`Checked ${new Date(e.inventory.checkedAt).toLocaleString()}`}),t.jsx(Dr,{label:"Auto-reclaimable",value:Ws(e.reclaimableBytes),detail:`Retention ${oT(e.policy.maxAgeMs)} / max ${Ws(e.policy.maxTotalBytes)}`}),t.jsx(Dr,{label:"In-memory logs",value:`${e.memoryCount.toLocaleString()} loaded`,detail:"Recent completed entries kept hot for the UI"}),t.jsx(Dr,{label:"Last GC",value:e.lastGc===null?"Not run yet":`${e.lastGc.filesDeleted.toLocaleString()} files / ${Ws(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=>t.jsx(lT,{artifact:h,copiedId:d,onCopy:m},`${h.kind}:${h.root}`))]}),s!==null&&t.jsx("p",{className:"text-xs text-destructive",children:s})]})}function iT(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 Dr({label:e,value:n,detail:s}){return t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:e}),t.jsx("div",{className:"mt-1 font-mono text-muted-foreground",children:n}),t.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:s})]})}function lT({artifact:e,copiedId:n,onCopy:s}){const r=`storage-${e.kind}`,o=e.oldestModifiedAt===null?"none":new Date(e.oldestModifiedAt),a=e.newestModifiedAt===null?"none":new Date(e.newestModifiedAt);return t.jsxs("div",{className:"rounded-md border border-border/45 bg-muted/15 px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium",children:e.kind}),t.jsxs("div",{className:"mt-1 text-[11px] text-muted-foreground",children:[iT(e.cleanupBehavior)," · ",e.sensitivity]})]}),t.jsxs("div",{className:"text-right font-mono text-muted-foreground",children:[e.fileCount.toLocaleString()," files / ",Ws(e.bytes)]})]}),t.jsxs("div",{className:"mt-2 grid gap-1 text-[11px] text-muted-foreground sm:grid-cols-2",children:[t.jsxs("div",{children:["Oldest: ",o instanceof Date?o.toLocaleString():o]}),t.jsxs("div",{children:["Newest: ",a instanceof Date?a.toLocaleString():a]})]}),t.jsx("div",{className:"mt-2",children:t.jsx(Ql,{id:r,label:"Root path",value:e.root,copiedId:n,onCopy:s})})]})}function Ql({id:e,label:n,value:s,copiedId:r,onCopy:o}){const a=r===e;return t.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:[t.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:n}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),t.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,s),"aria-label":a?`Copied ${n}`:`Copy ${n}`,children:a?t.jsx(De,{className:"size-3.5 text-status-success"}):t.jsx(yt,{className:"size-3.5"})})]})]})}function cT(){const[e,n]=l.useState(null),[s,r]=l.useState(null);l.useEffect(()=>ll(r),[]);const o=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)=>{bt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qn,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),t.jsx("div",{className:"grid gap-2",children:o.map(i=>t.jsx(Ql,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),t.jsxs("div",{className:"grid gap-2 rounded-md border border-status-info/25 bg-status-info/10 px-3 py-2 text-xs",children:[t.jsx("div",{className:"font-medium text-foreground",children:"Verified first trace flow"}),t.jsxs("ol",{className:"ml-4 list-decimal space-y-1 text-muted-foreground",children:[t.jsx("li",{children:"Start Agent Inspector and confirm the application bar shows Live."}),t.jsx("li",{children:"Copy the Proxy URL or MCP URL that matches your coding agent."}),t.jsx("li",{children:"Run a tiny coding-agent prompt such as “say hello and stop”."}),t.jsx("li",{children:"Return to Logs and confirm one new request appears with request, response, tokens, and tool activity when present."})]})]}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(De,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(De,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(De,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",t.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."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(De,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["OpenCode onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(De,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.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"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(De,{className:"mt-0.5 size-3.5 text-status-success"}),t.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."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(De,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["If the first trace does not appear, run"," ",t.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"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/"})," ","versus"," ",t.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 dT(){const[e,n]=l.useState(null),[s,r]=l.useState(null);l.useEffect(()=>ll(i=>{r(i?.mcp??null)}),[]);const o=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
|
+
command = "agent-inspector-mcp"
|
|
60
|
+
args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{bt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qn,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.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."}),t.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?t.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."}):t.jsx("div",{className:"grid gap-2",children:o.map(i=>t.jsx(Ql,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function uT(){const{strip:e,slowResponseThresholdSeconds:n,providerTestTimeoutSeconds:s,timeDisplayFormat:r,isLoading:o,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=rl(),[p,u]=l.useState(null),[m,f]=l.useState(!1),h=l.useCallback(async y=>{u(null),f(!0);try{await a(y)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[a]),g=l.useCallback(async y=>{u(null),f(!0);try{await i(y)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[i]),v=l.useCallback(async y=>{u(null),f(!0);try{await c(y)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[c]),w=l.useCallback(async y=>{u(null),f(!0);try{await d(y)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[d]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),t.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 ",t.jsx("code",{children:"config.json"}),"."]})]}),t.jsxs("label",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||m,onChange:y=>{h(y.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",t.jsx("code",{children:"0"})," to disable it."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:ai,step:1,value:n,disabled:o||m,onChange:y=>{const b=Number(y.currentTarget.value);Number.isInteger(b)&&(b<0||b>ai||g(b))},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"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:ii,step:1,value:s,disabled:o||m,onChange:y=>{const b=Number(y.currentTarget.value);Number.isInteger(b)&&(b<1||b>ii||v(b))},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"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),t.jsxs("select",{id:"time-display-format",value:r,disabled:o||m,onChange:y=>{const b=Du.safeParse(y.currentTarget.value);b.success&&w(b.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx("option",{value:"time",children:"Time only"}),t.jsx("option",{value:"full",children:"Full ISO"})]})]}),p!==null&&t.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",p]})]})}const pT=pe(["installed","update-available","available","planned","unknown"]),mT=T({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:pT,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Ce()}),fT=T({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:V(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),hT=T({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Ce(),runnable:Ce()}),xT=T({checkedAt:x(),packages:V(mT),runnerPresets:V(fT),recipes:V(hT)}),jh=pe(["install","upgrade","help","runner-presets","recipe"]),Sh="RUN_LOCAL_COMMAND",gT=T({action:jh,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:_().int().positive(),scope:x()}),bT=T({nonce:x().uuid(),phrase:ae(Sh),expiresAt:x().datetime(),plan:gT}),ec=T({confirmation:bT});Tn("intent",[T({intent:ae("prepare")}),T({intent:ae("confirm"),nonce:x().uuid(),confirmation:ae(Sh)})]);const vT=pe(["queued","running","succeeded","failed"]),Nh=T({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:jh,status:vT,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:_().nullable(),error:x().nullable()}),No=T({task:Nh}),yT=T({tasks:V(Nh)}),wT="https://registry.npmjs.org/@tonyclaw%2fagent-inspector/latest",jT=1e4,ST=1e3,Md="https://gitcode.com/TonyClaw/agent-inspector",Ad="/api/ecosystem/packages/inspector/upgrade",NT=T({version:x().min(1)});function Id(e){if(e===void 0)return 0;const n=Number.parseInt(e,10);return Number.isFinite(n)?n:0}function CT(e,n){const[s="",r]=e.split("-",2),[o="",a]=n.split("-",2),i=s.split("."),c=o.split(".");for(let d=0;d<3;d+=1){const p=Id(i[d])-Id(c[d]);if(p!==0)return p}return r===void 0&&a!==void 0?1:r!==void 0&&a===void 0?-1:0}function kT({state:e}){switch(e.kind){case"idle":return t.jsx("p",{className:"text-xs text-muted-foreground",children:"Check npm for the latest stable Agent Inspector release."});case"checking":return t.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(lt,{className:"size-3.5 animate-spin"}),"Checking the latest release..."]});case"current":return t.jsxs("p",{className:"flex items-center gap-2 text-xs text-status-success",role:"status",children:[t.jsx(ys,{className:"size-3.5"}),"You are up to date. Latest version: v",e.latestVersion]});case"available":return t.jsxs("p",{className:"flex items-center gap-2 text-xs text-amber-400",role:"status",children:[t.jsx(e0,{className:"size-3.5"}),"Update available: v",e.latestVersion]});case"error":return t.jsxs("p",{className:"flex items-start gap-2 text-xs text-destructive",role:"alert",children:[t.jsx(tn,{className:"mt-0.5 size-3.5"}),t.jsx("span",{children:e.message})]})}}function TT({initiallyOpen:e=!1}){const[n,s]=l.useState(e),[r,o]=l.useState({kind:"idle"}),[a,i]=l.useState(!1),[c,d]=l.useState(null),[p,u]=l.useState(null),[m,f]=l.useState(!1),h=l.useCallback(async()=>{o({kind:"checking"});try{const y=await vn(wT,jT,{headers:{accept:"application/json"}});if(!y.ok){o({kind:"error",message:`Update service returned HTTP ${String(y.status)}. Try again later.`});return}const b=await vu(y,NT);o(CT(b.version,io.version)>0?{kind:"available",latestVersion:b.version}:{kind:"current",latestVersion:b.version})}catch(y){o({kind:"error",message:y instanceof Ao?"Update check timed out. Check your network and try again.":"Unable to reach the update service. Check your network and try again."})}},[]);l.useEffect(()=>{!n||r.kind!=="idle"||h()},[h,n,r.kind]),l.useEffect(()=>{if(c===null||c.status!=="queued"&&c.status!=="running")return;const y=()=>{Ke(`/api/ecosystem/tasks/${encodeURIComponent(c.id)}`,No,void 0,j=>`Upgrade status returned HTTP ${String(j.status)}`).then(j=>d(j.task)).catch(j=>{u(j instanceof Error?j.message:"Unable to read the upgrade status.")})},b=setInterval(y,ST);return y(),()=>clearInterval(b)},[c]);const g=l.useCallback(async()=>{f(!0),u(null);try{const y=await Ke(Ad,ec,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},j=>`Unable to prepare the upgrade: HTTP ${String(j.status)}`),b=await Ke(Ad,No,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:y.confirmation.nonce,confirmation:y.confirmation.phrase})},j=>`Unable to start the upgrade: HTTP ${String(j.status)}`);d(b.task)}catch(y){u(y instanceof Error?y.message:"Unable to start the upgrade.")}finally{f(!1)}},[]),v=r.kind==="checking",w=m||c?.status==="queued"||c?.status==="running";return t.jsxs(Nt,{open:n,onOpenChange:s,children:[t.jsx(Vn,{asChild:!0,children:t.jsxs(J,{variant:"ghost",size:"icon",className:Gn,"aria-label":"About Agent Inspector",title:"About Agent Inspector",children:[t.jsx(Ku,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"About Agent Inspector"})]})}),t.jsxs(Ct,{className:"max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-xl overflow-y-auto p-4 sm:p-6",children:[t.jsx(Tt,{children:t.jsx(_t,{children:"About"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("section",{className:"flex flex-col items-center px-4 py-3 text-center",children:[t.jsx("div",{className:"flex size-14 items-center justify-center rounded-2xl border border-amber-500/20 bg-amber-500/10 text-amber-500 shadow-sm",children:t.jsx(Vi,{className:"size-9"})}),t.jsx("h2",{className:"mt-3 text-xl font-bold tracking-tight",children:"Agent Inspector"}),t.jsxs("p",{className:"mt-1 font-mono text-xs text-muted-foreground",children:["Version ",io.version]}),t.jsx("p",{className:"mt-3 max-w-md text-xs leading-5 text-muted-foreground",children:"A local-first observability and knowledge-capture layer for AI coding agents. Inspect requests, streaming responses, tools, tokens, sessions, and provider routing in real time."})]}),t.jsxs("section",{className:"rounded-lg border border-border/60 bg-muted/15 p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 sm:flex-nowrap",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Application updates"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Keep Agent Inspector current for fixes, performance improvements, and features."})]}),t.jsxs(J,{type:"button",variant:"outline",size:"sm",disabled:v,onClick:()=>{h()},children:[t.jsx(lt,{className:v?"size-3.5 animate-spin":"size-3.5"}),v?"Checking...":"Check for updates"]})]}),t.jsx("div",{className:"mt-3 rounded-md border border-border/45 bg-background/45 px-3 py-2",children:t.jsx(kT,{state:r})}),r.kind==="available"&&t.jsxs("div",{className:"mt-3 space-y-3 text-xs",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono",children:"npm i -g @tonyclaw/agent-inspector@latest"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("a",{href:Md,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-primary hover:underline",children:["View release",t.jsx(lr,{className:"size-3"})]}),t.jsxs(J,{type:"button",size:"sm",disabled:w||c?.status==="succeeded",onClick:()=>i(!0),children:[w?t.jsx(lt,{className:"size-3.5 animate-spin"}):t.jsx(Rs,{className:"size-3.5"}),w?"Upgrading...":"Upgrade now"]})]})]}),c!==null&&t.jsx(_T,{task:c,latestVersion:r.latestVersion}),p!==null&&t.jsxs("p",{className:"flex items-start gap-2 text-destructive",role:"alert",children:[t.jsx(tn,{className:"mt-0.5 size-3.5"}),t.jsx("span",{children:p})]})]})]}),t.jsxs("section",{className:"rounded-lg border border-border/60 bg-muted/15 px-3 py-2 text-xs",children:[t.jsx($r,{label:"Package",value:"@tonyclaw/agent-inspector",mono:!0}),t.jsx($r,{label:"Release channel",value:"npm latest"}),t.jsx($r,{label:"License",value:"MIT License"}),t.jsx($r,{label:"Source",value:"AgentInspector",href:Md})]}),t.jsxs("footer",{className:"border-t border-border/60 pt-4 text-center text-[11px] leading-5 text-muted-foreground",children:[t.jsx("p",{children:"MIT License · Copyright © 2026 TonyClaw"}),t.jsx("p",{children:"Local First. Evidence First."})]})]})]}),t.jsx(Dl,{open:a,onOpenChange:i,title:"Upgrade Agent Inspector?",description:"Agent Inspector will run its allowlisted npm upgrade task on this machine. Existing configuration and captured data are preserved. Restart Agent Inspector after installation to load the new version.",confirmLabel:"Upgrade now",onConfirm:()=>{g()}})]})}function _T({task:e,latestVersion:n}){switch(e.status){case"queued":return t.jsx("p",{className:"text-muted-foreground",children:"Upgrade queued..."});case"running":return t.jsxs("p",{className:"text-cyan-300",children:["Installing v",n,"..."]});case"succeeded":return t.jsxs("p",{className:"flex items-start gap-2 text-status-success",role:"status",children:[t.jsx(ys,{className:"mt-0.5 size-3.5"}),t.jsxs("span",{children:["v",n," installed. Restart Agent Inspector to load the update."]})]});case"failed":return t.jsxs("p",{className:"flex items-start gap-2 text-destructive",role:"alert",children:[t.jsx(tn,{className:"mt-0.5 size-3.5"}),t.jsx("span",{children:e.error??"Upgrade failed. Review the task output and try again."})]})}}function $r({label:e,value:n,mono:s=!1,href:r}){return t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-4 border-b border-border/40 py-2 last:border-b-0",children:[t.jsx("span",{className:"font-medium text-muted-foreground",children:e}),r===void 0?t.jsx("span",{className:s?"truncate font-mono text-foreground":"truncate text-foreground",children:n}):t.jsxs("a",{href:r,target:"_blank",rel:"noreferrer",className:"inline-flex min-w-0 items-center gap-1 text-primary hover:underline",children:[t.jsx("span",{className:"truncate",children:n}),t.jsx(lr,{className:"size-3 shrink-0"})]})]})}const Ch={title:"Inspector is ready",description:"This walkthrough uses your running Inspector and real traffic—no sample data."},Us=[Ch,{title:"Check a Provider",description:"A Provider tells Inspector where matching model requests should be forwarded."},{title:"Connect your coding agent",description:"Copy the Base URL for your tool, then start it from the same terminal."},{title:"Send one real request",description:"Ask your coding agent a question. Inspector will detect the request automatically."}],ET=[Qu,f0,ci,li];function as({ready:e,children:n}){return t.jsxs("div",{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-sm ${e?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-border bg-muted/30 text-muted-foreground"}`,children:[e?t.jsx(ys,{className:"size-4"}):t.jsx(d0,{className:"size-4"}),n]})}function Pd({command:e,label:n}){const[s,r]=l.useState(!1);return t.jsxs("div",{className:"rounded-md border border-border/70 bg-muted/30 p-3",children:[t.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:n}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("code",{className:"min-w-0 flex-1 overflow-x-auto whitespace-nowrap text-xs text-foreground",children:e}),t.jsxs(J,{type:"button",size:"sm",variant:"outline",onClick:()=>{bt(e).then(o=>{r(o),o&&globalThis.setTimeout(()=>r(!1),1800)})},"aria-label":`Copy ${n}`,children:[s?t.jsx(De,{className:"size-3.5"}):t.jsx(yt,{className:"size-3.5"}),s?"Copied":"Copy"]})]})]})}function RT({step:e,endpoints:n,liveConnection:s,providerCount:r,sessionCount:o,capturedLogCount:a}){const i=n!==null,c=s===void 0||s.status==="live";switch(e){case 0:return t.jsxs("div",{className:"space-y-3",children:[t.jsx(as,{ready:i,children:"Agent-facing endpoints discovered"}),t.jsx(as,{ready:c,children:"Live UI stream connected"}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"The proxy forwards traffic while the UI groups requests, responses, tool calls, timing, and token usage into Sessions."})]});case 1:return t.jsxs("div",{className:"space-y-3",children:[t.jsx(as,{ready:r>0,children:r>0?`${r} Provider${r===1?"":"s"} configured`:"No Provider configured yet"}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Open Settings → Providers to add or test one. Model matching and protocol support must both succeed before traffic can be forwarded."})]});case 2:return t.jsxs("div",{className:"space-y-3",children:[n===null?t.jsx(as,{ready:!1,children:"Waiting for the public agent endpoint"}):t.jsxs(t.Fragment,{children:[t.jsx(Pd,{label:"Claude Code (PowerShell)",command:`$env:ANTHROPIC_BASE_URL="${n.proxy}"; claude`}),t.jsx(Pd,{label:"OpenAI-compatible agent (PowerShell)",command:`$env:OPENAI_BASE_URL="${n.openAiV1}"`})]}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"If the agent runs in another container or machine, replace localhost with an address it can reach."})]});case 3:return t.jsxs("div",{className:"space-y-3",children:[t.jsx(as,{ready:a>0,children:a>0?`${a} request${a===1?"":"s"} visible in this view`:"Waiting for a real request"}),t.jsx(as,{ready:o>0,children:o>0?`${o} Session${o===1?"":"s"} available`:"A Session will appear after capture"}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Keep this dialog open while you send the request. These checks update automatically. Close it to inspect the captured request, response, and Tool Calling timeline."})]});default:return t.jsx("div",{})}}function MT(e){const[n,s]=l.useState(!1),[r,o]=l.useState(0),a=Us[r]??Ch,i=r===Us.length-1;return t.jsxs(Nt,{open:n,onOpenChange:c=>{s(c),c&&o(0)},children:[t.jsx(Vn,{asChild:!0,children:t.jsxs(J,{type:"button",variant:"ghost",size:"icon",className:Gn,"aria-label":"Interactive guide",title:"Interactive guide",children:[t.jsx(li,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Interactive guide"})]})}),t.jsxs(Ct,{className:"max-w-xl",children:[t.jsxs(Tt,{children:[t.jsxs("div",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:["Interactive guide · Step ",r+1," of ",Us.length]}),t.jsx(_t,{children:a.title}),t.jsx(Is,{children:a.description})]}),t.jsx("ol",{"aria-label":"Guide progress",className:"grid grid-cols-4 gap-2",children:Us.map((c,d)=>{const p=ET[d]??li;return t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>o(d),"aria-current":d===r?"step":void 0,"aria-label":`Step ${d+1}: ${c.title}`,className:`flex h-10 w-full items-center justify-center rounded-md border transition-colors ${d===r?"border-primary bg-primary/10 text-primary":d<r?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600":"border-border text-muted-foreground hover:bg-muted"}`,children:t.jsx(p,{className:"size-4"})})},c.title)})}),t.jsx("div",{className:"min-h-44 py-1",children:t.jsx(RT,{step:r,...e})}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs(J,{type:"button",variant:"outline",onClick:()=>o(c=>Math.max(0,c-1)),disabled:r===0,children:[t.jsx(Bu,{className:"size-4"}),"Back"]}),i?t.jsxs(J,{type:"button",onClick:()=>s(!1),children:["Inspect results",t.jsx(De,{className:"size-4"})]}):t.jsxs(J,{type:"button",onClick:()=>o(c=>Math.min(Us.length-1,c+1)),children:["Next",t.jsx(ct,{className:"size-4"})]})]})]})]})}const AT=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:yg},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:lt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:ol},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:g1}];async function IT(e){return Ke(e,xT,void 0,n=>`Failed to load ecosystem packages: ${String(n.status)}`)}async function PT(e){return Ke(e,No,void 0,n=>`Failed to load ecosystem task: ${String(n.status)}`)}async function LT(e){return Ke(e,yT,void 0,n=>`Failed to load ecosystem tasks: ${String(n.status)}`)}async function OT(e,n){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${n}`,r=await Ke(s,ec,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem task: ${String(o.status)}`);return{endpoint:s,confirmation:r.confirmation}}async function zT(e){const n=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ke(n,ec,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},r=>`Failed to prepare ecosystem recipe: ${String(r.status)}`);return{endpoint:n,confirmation:s.confirmation}}async function DT(e){return(await Ke(e.endpoint,No,{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 $T(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 FT(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 BT(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 Ks(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 UT(e){switch(e.status){case"queued":return"Queued";case"running":return`${Ks(e.action)} running`;case"succeeded":return`${Ks(e.action)} complete`;case"failed":return`${Ks(e.action)} failed`}}function kh(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 qT(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function HT({pkg:e,activeTask:n,onStartTask:s}){const r=qT(e),o=n!==null&&n.packageId===e.id&&n.status==="running";return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(w1,{className:"size-4 shrink-0 text-white/55"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),t.jsx(Te,{className:L("shrink-0",FT(e.state)),variant:"outline",children:$T(e.state)})]}),t.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:BT(e)}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r!==null&&t.jsxs(J,{type:"button",size:"sm",variant:"secondary",disabled:o,onClick:()=>s(e.id,r),children:[o?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Rs,{className:"size-3.5"}),Ks(r)]}),t.jsxs(J,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>s(e.id,"help"),children:[t.jsx(qn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&t.jsxs(J,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[t.jsx(ol,{className:"size-3.5"}),"Presets"]})]})]})}function VT({task:e}){if(e===null)return null;const n=e.status==="queued"||e.status==="running";return t.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:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n?t.jsx(Ue,{className:"size-4 animate-spin text-cyan-200/75"}):t.jsx(qn,{className:"size-4 text-white/55"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold",children:UT(e)}),t.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),t.jsx(Te,{variant:"outline",className:L("shrink-0",kh(e.status)),children:e.status})]}),t.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&&t.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function WT({workflow:e}){const n=e.icon;return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(n,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),t.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),t.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function GT(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 KT({preset:e}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(Xu,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.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}`:""]})]}),t.jsxs(Te,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[t.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function YT({recipe:e,copied:n,running:s,onCopy:r,onRun:o}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(Vu,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),t.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),t.jsx(Te,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),t.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}),t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(J,{type:"button",size:"sm",variant:"outline",onClick:()=>r(e),children:[n?t.jsx(De,{className:"size-3.5"}):t.jsx(yt,{className:"size-3.5"}),n?"Copied":"Copy"]}),e.runnable&&t.jsxs(J,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>o(e),children:[s?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Xu,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function JT({task:e,selected:n,onSelect:s}){const r=e.recipeId??Ks(e.action);return t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Gu,{className:"size-3.5 shrink-0 text-white/40"}),t.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:r}),t.jsx(Te,{variant:"outline",className:L("shrink-0",kh(e.status)),children:e.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[t.jsx("span",{children:e.packageId}),t.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&t.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),t.jsx(J,{type:"button",size:"sm",variant:n?"secondary":"outline",onClick:()=>s(e),children:n?"Open":"View"})]})}function XT({pending:e,busy:n,onOpenChange:s,onConfirm:r}){const o=e?.confirmation.plan??null;return t.jsx(Nt,{open:e!==null,onOpenChange:s,children:t.jsxs(Ct,{className:"max-w-xl",children:[t.jsxs(Tt,{children:[t.jsx(_t,{children:"Confirm local command"}),t.jsx(Is,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),o!==null&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Source"}),t.jsx("div",{className:"mt-1 break-words font-medium",children:o.source})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),t.jsxs("div",{className:"mt-1 font-medium",children:[String(o.timeoutMs/1e3)," seconds"]})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[t.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),t.jsx("div",{className:"mt-1 font-medium",children:o.scope})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),t.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:o.command})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",t.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(J,{type:"button",variant:"outline",disabled:n,onClick:()=>s(!1),children:"Cancel"}),t.jsxs(J,{type:"button",variant:"secondary",disabled:n||o===null,onClick:r,children:[n?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(qn,{className:"size-3.5"}),n?"Starting":"Confirm & Run"]})]})]})})}function ZT({currentSessionId:e,logCount:n,labelledTrigger:s=!1}){const[r,o]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[p,u]=l.useState(null),[m,f]=l.useState(null),[h,g]=l.useState(null),[v,w]=l.useState(null),[y,b]=l.useState(!1),j=qt("/api/ecosystem/packages",IT,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=qt(m===null?null:`/api/ecosystem/tasks/${m}`,PT,{refreshInterval:U=>{const Q=U?.task;return Q!==void 0&&(Q.status==="queued"||Q.status==="running")?900:0},revalidateOnFocus:!1}),N=qt(r?"/api/ecosystem/tasks":null,LT,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],E=j.data?.runnerPresets??[],A=j.data?.recipes??[],I=(N.data?.tasks??[]).slice(0,6),M=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=GT(e),R="npx @tonyclaw/eval-harness runner-presets",O=()=>{bt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{bt(R).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},K=U=>{bt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},ee=U=>{g(null),zT(U.id).then(Q=>{w(Q)}).catch(Q=>{g(Q instanceof Error?Q.message:"Failed to prepare ecosystem recipe")})},D=S.data?.task??null;l.useEffect(()=>{D!==null&&(N.mutate(),D.status==="succeeded"&&j.mutate())},[D,j,N]);const H=(U,Q)=>{g(null),OT(U,Q).then(fe=>{w(fe)}).catch(fe=>{g(fe instanceof Error?fe.message:"Failed to prepare ecosystem task")})},te=()=>{v!==null&&(g(null),b(!0),DT(v).then(U=>{f(U.id),w(null),S.mutate({task:U},{revalidate:!0}),N.mutate()}).catch(U=>{g(U instanceof Error?U.message:"Failed to start ecosystem task")}).finally(()=>{b(!1)}))};return t.jsxs(Nt,{open:r,onOpenChange:o,children:[t.jsx(Vn,{asChild:!0,children:t.jsxs(J,{variant:"ghost",size:s?"default":"icon",className:L(Gn,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:[t.jsx(Vu,{className:"size-4"}),t.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),t.jsxs(Ct,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Tt,{children:t.jsxs(_t,{className:"flex items-center gap-2",children:[t.jsx(di,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),t.jsxs("div",{className:"overflow-y-auto pr-2",children:[t.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),t.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."})]}),t.jsxs(Te,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(M),"/",String(C.length)," packages"]})]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:AT.map(U=>t.jsx(WT,{workflow:U},U.id))})]}),t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),t.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),t.jsxs(Te,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(n)," logs"]})]}),t.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}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(J,{size:"sm",variant:"secondary",onClick:O,children:[a?t.jsx(De,{className:"size-3.5"}):t.jsx(yt,{className:"size-3.5"}),a?"Copied":"Copy"]}),t.jsxs(J,{size:"sm",variant:"outline",onClick:$,children:[t.jsx(ol,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(di,{className:"size-3.5"}),"copy-ready workflows"]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[A.map(U=>t.jsx(YT,{recipe:U,copied:p===U.id,running:D!==null&&D.recipeId===U.id&&(D.status==="queued"||D.status==="running"),onCopy:K,onRun:ee},U.id)),j.isLoading&&A.length===0&&[0,1].map(U=>t.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))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(qn,{className:"size-3.5"}),R]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[E.map(U=>t.jsx(KT,{preset:U},U.id)),j.isLoading&&E.length===0&&[0,1,2,3].map(U=>t.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))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&t.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&t.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."}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>t.jsx(HT,{pkg:U,activeTask:D,onStartTask:H},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>t.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&&t.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}),I.length>0&&t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),t.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(I.length)]})]}),t.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:I.map(U=>t.jsx(JT,{task:U,selected:m===U.id,onSelect:Q=>{f(Q.id),S.mutate({task:Q},{revalidate:!0})}},U.id))})]}),t.jsx(VT,{task:D})]})]}),t.jsx(XT,{pending:v,busy:y,onOpenChange:U=>{!U&&!y&&w(null)},onConfirm:te})]})}function QT(e){return[...new Set(e.evidence.map(n=>n.logId).filter(n=>n!==null))]}const e_=[{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?"}],t_=4e3,Xa=12;function Ld(){return{messages:[],question:"",error:null}}function n_(e){return e.filter(n=>n.content.trim().length>0).slice(-10).map(n=>({role:n.role,content:n.content.trim().slice(0,t_)}))}function at(e,...n){for(const s of n){const r=G(e,s);if(typeof r=="string"&&r.trim().length>0)return r}return null}function hn(e,...n){for(const s of n){const r=G(e,s);if(typeof r=="number"&&Number.isFinite(r))return r}return null}function s_(e,n){const s=G(e,n);return Array.isArray(s)?s.filter(r=>typeof r=="string").slice(0,8):[]}function r_(e){const n=at(e,"source")??"log",s=at(e,"id")??"",r=hn(e,"logId","id");if(s===""&&r===null||r!==null&&(!Number.isInteger(r)||r<0))return null;const o=hn(e,"inputTokens"),a=hn(e,"outputTokens"),i=hn(e,"totalTokens","tokenCount"),c=hn(e,"responseStatus","status"),d=at(e,"responseStatus","status");return{source:n,id:s!==""?s:String(r),logId:r,sessionId:at(e,"sessionId"),timestamp:at(e,"timestamp"),model:at(e,"model"),providerName:at(e,"providerName","provider"),path:at(e,"path"),status:c??d,elapsedMs:hn(e,"elapsedMs","latencyMs"),inputTokens:o,outputTokens:a,totalTokens:i??(o===null&&a===null?null:(o??0)+(a??0)),score:hn(e,"score","relevanceScore"),matchedFields:s_(e,"matchedFields"),excerpt:at(e,"excerpt","snippet")??"No excerpt available."}}function Za(e){const n=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return n.length===0?"Metric":`${n[0]?.toUpperCase()??""}${n.slice(1)}`}function Od(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 n=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return n.length>0?n.join(", "):null}return null}function zd(e){return Object.getOwnPropertyNames(e).map(n=>[n,G(e,n)])}function Dd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const n=[];for(const[s,r]of zd(e)){const o=Od(r);if(o!==null){if(n.push({key:s,label:Za(s),value:o}),n.length>=Xa)break;continue}if(!(r===null||typeof r!="object"||Array.isArray(r))){for(const[a,i]of zd(r)){const c=Od(i);if(c===null)continue;const d=`${s}.${a}`;if(n.push({key:d,label:`${Za(s)} ${Za(a).toLowerCase()}`,value:c}),n.length>=Xa)break}if(n.length>=Xa)break}}return n}function o_(e){const n=at(e,"answer"),s=at(e,"providerId"),r=at(e,"providerName"),o=at(e,"model"),a=at(e,"protocol"),i=hn(e,"logCount");if(n===null||s===null||r===null||o===null||a===null||i===null)return null;const c=G(e,"evidence"),d=Array.isArray(c)?c.map(r_).filter(p=>p!==null).slice(0,12):[];return{answer:n,providerId:s,providerName:r,model:o,protocol:a,logCount:i,evidence:d,summaryMetrics:Dd(G(e,"summary")),queryMetrics:Dd(G(e,"queryStats"))}}const a_=l.lazy(()=>Kt(()=>import("./index-d2B_ndVR.js"),__vite__mapDeps([10,1,2]),import.meta.url)),i_="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]",Qa=96*1024;function l_({text:e}){const[n,s]=l.useState(!1),r=e.length>Qa,o=r&&!n?e.slice(0,Qa):e;return l.useEffect(()=>{s(!1)},[e]),t.jsxs("div",{className:"space-y-2",children:[r&&!n&&t.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 ",Qa.toLocaleString()," characters for fast rendering. The full response is preserved."]}),t.jsx("div",{className:i_,children:t.jsx(l.Suspense,{fallback:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:t.jsx(a_,{children:o})})}),r&&t.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:n?"Collapse fast preview":`Render full response (${e.length.toLocaleString()} chars)`})]})}const $d="What looks abnormal, slow, or likely to hang?";function c_(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function d_(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function u_(e){return e.toSorted((n,s)=>{const r=n.source==="company"?0:1,o=s.source==="company"?0:1;return r!==o?r-o:n.name.localeCompare(s.name)})}function Fd(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Ln({label:e,value:n,tone:s="muted"}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[t.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),n!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/55",children:":"}),t.jsx("span",{className:"truncate text-muted-foreground",children:n})]})]})}function p_({metrics:e}){return e.length===0?null:t.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(n=>t.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[t.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:n.label}),t.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:n.value})]},n.key))})}function m_({evidence:e}){const n=()=>{e.logId!==null&&ks({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return t.jsxs("button",{type:"button",onClick:n,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:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&t.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&t.jsx("span",{children:e.providerName}),e.model!==null&&t.jsx("span",{children:e.model}),e.status!==null&&t.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&t.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),t.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function f_({response:e}){return t.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:[t.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:[t.jsx(Ln,{label:"assistant@inspector",value:"output",tone:"cyan"}),t.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),t.jsxs("div",{className:"space-y-3 p-3",children:[t.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:t.jsx(l_,{text:e.answer})}),t.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[t.jsx(Ln,{label:"provider",value:e.providerName}),t.jsx(Ln,{label:"model",value:e.model}),t.jsx(Ln,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Ln,{label:"metrics",tone:"cyan"}),t.jsx(p_,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Ln,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(n=>t.jsx(m_,{evidence:n},`${n.source}-${n.id}`))]})]})]})}function h_({message:e}){return e.role==="assistant"&&e.response!==null?t.jsx(f_,{response:e.response}):t.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:t.jsx(Ln,{label:"user@inspector",value:"query",tone:"cyan"})}),t.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[t.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function x_({currentSessionId:e,logCount:n,onResultChange:s}){const{providers:r}=ml(),o=l.useMemo(()=>u_(r.filter(c_)),[r]),[a,i]=l.useState(()=>({...Ld(),question:$d})),[c,d]=l.useState("__auto__"),[p,u]=l.useState("__auto__"),[m,f]=l.useState(!1),g=o.find(C=>C.id===c)?.models??[],v=a.question,w=v.trim()!==""&&o.length>0&&!m;if(o.length===0)return null;const y=C=>{i(E=>({...E,question:C.currentTarget.value}))},b=C=>{d(C),u("__auto__")},j=()=>{i({...Ld(),question:$d}),s(null)},S=C=>{i(E=>({...E,question:C,error:null}))},N=()=>{if(!w)return;const C=v.trim(),E=n_(a.messages),A={id:Fd("user"),role:"user",content:C,response:null};f(!0),i(M=>({...M,messages:[...M.messages,A],question:"",error:null}));const I={question:C,history:E,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...p!=="__auto__"?{model:p}:{},logLimit:16};dx("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(I)}).then(async M=>{const k=await M.text();if(!M.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(M.status)} ${k}`}));return}const R=JSON.parse(k),O=o_(R);if(O===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:Fd("assistant"),role:"assistant",content:O.answer,response:O}]})),s({question:C,logIds:QT(O),reportedLogCount:O.logCount})}).catch(M=>{i(k=>({...k,error:M instanceof Error?M.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(zg,{className:"size-4 text-cyan-200"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),t.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:t.jsx(Zu,{className:"size-3.5"})})]}),a.messages.length===0&&t.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.jsxs(nr,{value:c,onValueChange:b,children:[t.jsx(sr,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(wo,{placeholder:"Provider"})}),t.jsxs(rr,{children:[t.jsx(it,{value:"__auto__",children:"Auto provider"}),o.map(C=>t.jsxs(it,{value:C.id,children:[C.name," / ",d_(C)]},C.id))]})]}),t.jsxs(nr,{value:p,onValueChange:u,children:[t.jsx(sr,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(wo,{placeholder:"Model"})}),t.jsxs(rr,{children:[t.jsx(it,{value:"__auto__",children:"Auto model"}),g.map(C=>t.jsx(it,{value:C,children:C},C))]})]})]}),a.messages.length===0&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:e_.map(C=>t.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:[t.jsx(di,{className:"size-3"}),t.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&t.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>t.jsx(h_,{message:C},C.id)),m&&t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx(Ue,{className:"size-3.5 animate-spin"}),t.jsx("span",{children:"Searching Inspector..."})]})]}),t.jsx("textarea",{value:v,onChange:y,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..."}),t.jsxs("button",{type:"button",onClick:N,disabled:!w,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:[m?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(U1,{className:"size-3.5"}),t.jsx("span",{children:m?"Searching...":"Ask Assistant"})]}),a.error!==null&&t.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),n===0&&t.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function g_(e){const n=new Map;for(const s of e){const r=s.logs;for(let o=1;o<r.length;o++){const a=r[o-1],i=r[o];a===void 0||i===void 0||n.set(i.id,{creation:Bd(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:Bd(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return n}function Bd(e,n){return n===null||e===null?null:n>e?{direction:"up",delta:n-e}:n<e?{direction:"down",delta:e-n}:null}function Th(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function is(e,n,s){const r=Th(e.lastSuccessAt),o=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=r===null?"":` Last update ${r}.`;return`${n}${i}${o}${a}`}function _h(e,n,s){switch(e){case"connecting":return{label:"Connecting",description:is(n,"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:is(n,"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:is(n,"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:is(n,"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:is(n,n.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:is(n,n.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 b_({state:e}){const n=_h(e.status,e,!1),s=Th(e.lastSuccessAt),r=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return t.jsxs("span",{role:"status","aria-label":n.description,"data-connection-state":e.status,className:L("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",n.toneClass),children:[t.jsx("span",{className:L("size-1.5 shrink-0 rounded-full",n.dotClass)}),t.jsx("span",{className:"shrink-0",children:n.label}),r!==null&&t.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:r}),s!==null&&t.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function v_({state:e,hasLogs:n,onRetry:s,onStop:r}){const o=_h(e.status,e,n);return t.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:L("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",o.toneClass),children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:L("size-2 shrink-0 rounded-full",o.dotClass)}),t.jsx("span",{className:"shrink-0 font-semibold",children:o.label}),t.jsx("span",{className:"min-w-0 text-current/75",children:o.description})]}),(o.canRetry||o.canStop)&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.canRetry&&t.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:[t.jsx(lt,{className:"size-3"}),"Retry now"]}),o.canStop&&t.jsxs("button",{type:"button",onClick:r,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:[t.jsx(i0,{className:"size-3"}),"Stop retrying"]})]})]})}function y_(){const[e,n]=l.useState(!1),[s,r]=l.useState(!1);l.useEffect(()=>{const i=()=>{n(document.fullscreenElement!==null),r(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return i(),document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]);const o=l.useCallback(()=>{if(s){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{n(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{n(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return t.jsxs(J,{type:"button",variant:"ghost",size:"icon",className:Gn,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:o,children:[e?t.jsx(l1,{className:"size-4"}):t.jsx(o1,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:a})]})}function w_({liveConnection:e,alertsAction:n,guideAction:s,aboutAction:r,settingsAction:o}){return t.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:t.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:[t.jsxs("a",{href:Wi("/"),"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:[t.jsx(Vi,{className:"size-7 shrink-0 text-amber-500"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),t.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),t.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",io.version]})]}),t.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?t.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:[t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):t.jsx(b_,{state:e})}),t.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[t.jsx(y_,{}),n,s,o,r]})]})})}function j_(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function Zr({progress:e}){const n=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(n*100)),r=Math.max(0,e.timeoutMs-e.elapsedMs),o=n>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${j_(r)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return t.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",children:e.label}),t.jsx("span",{className:L("shrink-0 tabular-nums",o&&"text-amber-300"),children:a.join(" / ")})]}),t.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:t.jsx("div",{className:L("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",o?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${s.toString()}%`}})})]})}function Eh(e){return e?"auto":"smooth"}function Rh(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function S_(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function It(e,n){switch(n.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:n.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return n.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:n.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:n.message}}}function N_(e){return e===void 0||e.status==="live"?"empty":e.status}function C_(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 Ud="agent-inspector.hierarchy.collapsedClients",qd="agent-inspector.hierarchy.collapsedProcesses";function Co(e){return e.some(n=>n.responseStatus===null)}function Mh(e){return e.filter(n=>n.responseStatus===null).length}function Ah(e){for(const n of e){const s=n.userAgent;if(s!=null&&s!=="")return s}return null}function k_(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function Ih(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function T_(e){return $l({userAgent:Ah(e.logs),conversationId:e.conversationId,clientProjectFolder:Ih(e.logs)})}function __(e){if(e===null||e==="")return"Unknown client";const n=e.split(/[ /;]/)[0]??"";return n===""?"Unknown client":n}function E_(e,n){const s=na(e);return s!==null?s:__(n)}function ko(e){return e===null||e===""?"unknown":String(e)}function R_(e,n,s){return e!=="unknown"?e:`unknown:${ko(n)}:${ko(s)}`}function M_(e,n){return`${ko(e)}:${ko(n)}`}function Hd(e){return[...e].sort((n,s)=>n.timestamp.localeCompare(s.timestamp))}function Vd(e){let n="";for(const s of e)s.timestamp>n&&(n=s.timestamp);return n}function Wd(e){return Co(e)?0:e.some(n=>n.error!==null&&n.error!==void 0||n.responseStatus!==null&&n.responseStatus!==void 0&&n.responseStatus>=400)?1:2}function ei(e){return[...e].sort((n,s)=>{const r=Wd(n.logs)-Wd(s.logs);if(r!==0)return r;const o=Vd(s.logs).localeCompare(Vd(n.logs));return o!==0?o:n.id.localeCompare(s.id)})}function A_(e){const n=new Map;for(const r of e){const o=Ah(r.logs),a=Ih(r.logs),i=T_(r),c=R_(i,o,a);let d=n.get(c);d===void 0&&(d={id:c,client:i,label:E_(i,o),userAgent:o,processes:new Map,logs:[]},n.set(c,d)),d.logs.push(...r.logs);const p=k_(r.logs),u=`${c}:${M_(p,a)}`;let m=d.processes.get(u);m===void 0&&(m={id:u,clientPid:p,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,m)),m.sessions.push(r),m.logs.push(...r.logs)}const s=[];for(const r of n.values()){const o=ei([...r.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:ei(a.sessions),logs:Hd(a.logs)})));s.push({id:r.id,client:r.client,label:r.label,userAgent:r.userAgent,processes:o,logs:Hd(r.logs)})}return ei(s)}function To(e){return e<=0?"0":Ie(e)}function Ph(e){let n=0,s=0;for(const r of e)r.inputTokens!==null&&r.inputTokens!==void 0&&(n+=r.inputTokens),r.outputTokens!==null&&r.outputTokens!==void 0&&(s+=r.outputTokens);return{inputTokens:n,outputTokens:s}}function I_(e){let n=0;for(const s of e)n+=s.sessions.length;return n}function Gd(e){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(e);if(n===null)return null;const s=JSON.parse(n);return Array.isArray(s)?new Set(s.filter(r=>typeof r=="string")):null}catch{return null}}function Kd(e,n){try{window.localStorage.setItem(e,JSON.stringify([...n]))}catch{}}function Yd(e,n){let s=!1;const r=new Set(e);for(const o of n)r.delete(o)&&(s=!0);return s?r:e}function P_(e){const n=new Set;for(const s of e)for(let r=1;r<s.processes.length;r++){const o=s.processes[r];o!==void 0&&!Co(o.logs)&&n.add(o.id)}return n}function L_(e){if(e===null||e==="")return null;const n=e.replaceAll("\\","/").split("/").filter(o=>o!==""),s=n[n.length-1];if(s===void 0)return e;const r=n[n.length-2];return r===void 0?s:`${r}/${s}`}function _o({label:e,value:n,className:s}){return t.jsxs("span",{className:L("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),t.jsx("span",{className:"font-mono tabular-nums text-foreground",children:n})]})}function Lh({count:e}){const n=`${e} open turn${e===1?"":"s"}`;return t.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":n,title:n,children:[t.jsx(Ue,{className:"size-3 animate-spin"}),e>1&&t.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 O_({groups:e,...n}){const s=l.useMemo(()=>A_(e),[e]),[r,o]=l.useState(()=>new Set),[a,i]=l.useState(()=>P_(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const m=Gd(Ud),f=Gd(qd);m!==null&&o(m),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(Kd(Ud,r),Kd(qd,a))},[r,a,c]),l.useEffect(()=>{const m=new Set(s.filter(h=>Co(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>Co(g.logs)).map(g=>g.id)));o(h=>Yd(h,m)),i(h=>Yd(h,f))},[s]);const p=l.useCallback(m=>{o(f=>{const h=new Set(f);return h.has(m)?h.delete(m):h.add(m),h})},[]),u=l.useCallback(m=>{i(f=>{const h=new Set(f);return h.has(m)?h.delete(m):h.add(m),h})},[]);return t.jsx("div",{className:"space-y-2",children:s.map(m=>t.jsx(z_,{group:m,collapsed:r.has(m.id),collapsedProcessIds:a,onToggleClient:()=>p(m.id),onToggleProcess:u,conversationProps:n},m.id))})}function z_({group:e,collapsed:n,collapsedProcessIds:s,onToggleClient:r,onToggleProcess:o,conversationProps:a}){const i=Ph(e.logs),c=I_(e.processes),d=e.logs.length,p=Mh(e.logs),u=p>0;return t.jsxs("section",{className:L("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[t.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:r,"aria-expanded":!n,children:[e.client==="unknown"?t.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:t.jsx(u1,{className:"size-4"})}):t.jsx(sa,{client:e.client,className:"size-9 rounded-md",decorative:!0}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),t.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:g5(e.client)}),u&&t.jsx(Lh,{count:p})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),t.jsxs("span",{children:[c," session",c!==1?"s":""]}),t.jsxs("span",{children:[d," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(_o,{label:"IN",value:To(i.inputTokens)}),t.jsx(_o,{label:"OUT",value:To(i.outputTokens)})]}),t.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:n?t.jsx(ct,{className:"size-4"}):t.jsx(Ze,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(m=>t.jsx(D_,{group:m,collapsed:s.has(m.id),onToggle:()=>o(m.id),conversationProps:a},m.id))})]})}function D_({group:e,collapsed:n,onToggle:s,conversationProps:r}){const o=Ph(e.logs),a=L_(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=Mh(e.logs),p=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return t.jsxs("section",{className:"relative pl-3",children:[t.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":!n,children:[t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:t.jsx(C0,{className:"size-4"})}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),p&&t.jsx(Lh,{count:d}),a!==null&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[t.jsx(G0,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate font-mono",children:a})]})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[i," session",i!==1?"s":""]}),t.jsxs("span",{children:[c," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(_o,{label:"IN",value:To(o.inputTokens)}),t.jsx(_o,{label:"OUT",value:To(o.outputTokens)})]}),t.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:n?t.jsx(ct,{className:"size-4"}):t.jsx(Ze,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(m=>t.jsx(Sk,{group:m,...r,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},m.id))})]})}const $_="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",F_=[{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 B_({onCancel:e,onExportRedacted:n,onConfirmRaw:s}){return t.jsxs(t.Fragment,{children:[t.jsxs(Tt,{children:[t.jsx(_t,{children:"Export unredacted logs?"}),t.jsx(Is,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),t.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[t.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),t.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:F_.map(r=>t.jsxs("li",{children:[t.jsxs("span",{className:"font-semibold text-foreground",children:[r.label,":"]})," ",r.detail]},r.label))}),t.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."})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),t.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Export redacted instead"}),t.jsx(J,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const Eo="data-nav-id",U_="data-nav-action";function Jd(e){return Array.from(e.querySelectorAll(`[${Eo}]`))}function Xd(e){return e instanceof HTMLElement}function q_(e,n){let s=e;for(;s!==null&&s!==n;){if(s.hasAttribute(Eo))return s;s=s.parentElement}return e.hasAttribute(Eo)?e:null}function ti(e){const n=e.getAttribute(U_);return n==="toggle"||n==="expand"||n==="collapse"?n:null}function qs(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Hs(e,n){return e[n]??null}function Oh(e){const n=e.tagName;return!!(n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable)}function Zd(e){const n=e.tagName;return n==="BUTTON"||n==="A"||Oh(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function H_(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function V_(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Fr(e,n){return e.key===n&&e.shiftKey}function W_(e,n,s={}){const r=n??e,o=s.pageWide===!0,a=l.useCallback(i=>{const c=e.current,d=r.current;if(!c||!d)return;const p=i.target;if(!Xd(p)||p!==d)return;const u=Jd(c),m=Hs(u,0);m!==null&&qs(m)},[e,r]);l.useEffect(()=>{const i=c=>{if(c.altKey||c.ctrlKey||c.metaKey)return;const d=e.current;if(!d)return;const p=c.target;if(!Xd(p)||Oh(p)||V_())return;const u=d.contains(p);if(u&&Zd(p)&&!p.hasAttribute(Eo)||!u&&(!o||Zd(p)||H_(p)))return;const m=Jd(d);if(m.length===0)return;const f=q_(p,d),h=f!==null?m.indexOf(f):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!Fr(c,"W"))break;c.preventDefault();const v=h>0?h-1:h===-1?m.length-1:-1;if(v!==-1){const w=Hs(m,v);w!==null&&qs(w)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!Fr(c,"S"))break;c.preventDefault();const v=h<m.length-1?h+1:h===-1?0:-1;if(v!==-1){const w=Hs(m,v);w!==null&&qs(w)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!Fr(c,"A")||f===null)break;if(c.preventDefault(),ti(f)==="collapse")f.click();else if(h>0){const w=Hs(m,h-1);w!==null&&qs(w)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!Fr(c,"D")||f===null)break;if(c.preventDefault(),ti(f)==="expand")f.click();else if(h<m.length-1){const w=Hs(m,h+1);w!==null&&qs(w)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),ti(f)!==null&&f.click(),g=!0;break}}g&&c.stopPropagation()};return document.addEventListener("keydown",i,{capture:!0}),()=>document.removeEventListener("keydown",i,{capture:!0})},[e,o,r]),l.useEffect(()=>(document.addEventListener("focusin",a),()=>document.removeEventListener("focusin",a)),[a])}const G_={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},K_={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"},Y_={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"},ni=12,Br=1,Qd=80,eu=24;function J_(e){return e.length<=eu?e:`${e.slice(0,eu-3)}...`}function X_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=Qd?n:`${n.slice(0,Qd)}...`}function Ur(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const Z_=l.memo(function({segments:n,totalTokens:s,showLabels:r=!0,onActivate:o}){const a=l.useMemo(()=>s>0?s:n.reduce((w,y)=>w+y.size,0),[n,s]),i=n.slice(0,ni),c=n.slice(ni),d=c.reduce((w,y)=>w+y.size,0),p=c.length,u=ni,m=u+p-1,f=p>0,h=o!==void 0,g=l.useMemo(()=>i.reduce((w,y)=>w+y.size,0),[i]),v=l.useMemo(()=>`Request context: ~${Ie(a)} tokens across ${n.length} segment${n.length===1?"":"s"}`,[n.length,a]);return n.length===0||a<=0?t.jsx("div",{role:"img","aria-label":v,className:"h-6"}):t.jsx(Ps,{delayDuration:150,children:t.jsxs("div",{role:"img","aria-label":v,className:"flex flex-col gap-1.5",children:[t.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((w,y)=>{const b=a>0?w.size/a*100:0,j=Math.max(Br,b),S=L("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",K_[w.role],h?Y_[w.role]:""),N={width:`${j}%`},C=`${w.label}, ${Ur(b)}, ~${Ie(w.size)} tokens`;return t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:h?t.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(w),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),o(w))},"data-anatomy-path":w.path,"aria-label":C,className:S,style:N}):t.jsx("span",{"aria-label":C,className:S,style:N})}),t.jsxs(ft,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[t.jsxs("div",{className:"font-semibold",children:[w.label," - ",Ur(b)," - ~",Ie(w.size)," ","tokens"]}),t.jsx("div",{className:"text-muted-foreground",children:G_[w.role]}),t.jsxs("div",{className:"text-muted-foreground",children:[w.characters.toLocaleString()," chars"]}),w.text.length>0&&t.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:X_(w.text)})]})]},`${w.path}-${y}`)}),f&&t.jsxs(pt,{children:[t.jsx(mt,{asChild:!0,children:t.jsxs("div",{role:"img","aria-label":`${p} 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(Br,d/a*100)}%`},children:["... +",p]})}),t.jsxs(ft,{side:"bottom",className:"text-xs",children:[p," more segment",p===1?"":"s"," (indices"," ",u,"-",m,")"]})]})]}),r&&t.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[i.map((w,y)=>{const b=a>0?w.size/a*100:0,j=Math.max(Br,b);return t.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${w.label} - ${Ur(b)} - ~${Ie(w.size)} tokens`,children:[t.jsx("span",{className:"truncate font-mono text-foreground/80",children:J_(w.label)}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Ur(b)," - ~",Ie(w.size)]})]},`label-${w.path}-${y}`)}),f&&t.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Br,d/a*100)}%`},children:[t.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",p]}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ie(d)]})]})]}),g<a*.1&&t.jsx("div",{className:"h-0"})]})})}),zh=.75,Dh=.9,Fi=8e3,Q_=.35,$h=40,Fh=160,eE=5,tE=8,nE=18,sE=6e4,rE=.7,tu=3e3,oE=.3,nu=160,aE=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),iE=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],lE=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],cE=[{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"]}],dE={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function uE(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return null}function Bh(e,n){for(const s of n){const r=uE(G(e,s));if(r!==null)return r}return null}function pE(e){const n=G(e,"model");if(typeof n!="string")return null;const s=n.trim();return s===""?null:s}function mE(e,n){switch(n.mode){case"prefix":return n.patterns.some(s=>e.startsWith(s));case"includes":return n.patterns.some(s=>e.includes(s))}}function fE(e,n,s=[]){const r=Bh(n,iE);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=n4(e,s);if(o!==null)return{tokens:o.tokens,label:`${o.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 cE)if(mE(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function hE(e){return e<0?0:e>1?1:e}function xE(e){return e===null?"unknown":e>=Dh?"danger":e>=zh?"watch":"ok"}function gE(e,n){return e.filter(s=>s.role===n).reduce((s,r)=>s+r.size,0)}function bE(e,n){return["system","user","assistant","tool","tools"].map(r=>{const o=gE(e,r);return{role:r,label:dE[r],tokens:o,percent:n>0?o/n:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function Bi(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function vE(e){const n=e.replace(/\s+/g," ").trim();return n.length<=nu?n:`${n.slice(0,nu-3)}...`}function yE(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function wE(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function jE(e){const n=e.trim();return n.startsWith("{")||n.startsWith("[")}function SE(e){if(!jE(e))return null;try{return JSON.parse(e)}catch{return null}}function NE(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function CE(e){for(let n=e.length-1;n>=0;n-=1){const s=e[n]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function kE(e){const n=CE(e);return n===null?!1:aE.has(NE(n))}function TE(e){return e.map(n=>n.startsWith("[")?n:`.${n}`).join("").replace(/^\./,"")}function _E(e,n,s){const r=Bl(n);if(r<Fh)return null;const o=Fl(n);return o<$h?null:{role:e.role,label:`${e.label} ${TE(s)}`,path:e.path,tokens:o,characters:r,text:n}}function Ui({value:e,segment:n,path:s,depth:r,candidates:o}){if(!(o.length>=tE)&&!(r>eE)){if(typeof e=="string"){if(!kE(s))return;const a=_E(n,e,s);a!==null&&o.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Ui({value:a,segment:n,path:[...s,`[${String(i)}]`],depth:r+1,candidates:o}));return}Ul(e)&&Object.entries(e).forEach(([a,i])=>Ui({value:i,segment:n,path:[...s,a],depth:r+1,candidates:o}))}}function EE(e){const n=wE(e),s=SE(e.text);if(s===null)return[n];const r=[];Ui({value:s,segment:e,path:[],depth:0,candidates:r});const o=Bi(e.text),a=new Set([o]),i=r.filter(c=>{const d=Bi(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[n,...i]}function RE(e){const n=new Map;for(const r of e){const o=EE(r);for(const a of o){if(a.tokens<$h||a.characters<Fh)continue;const i=Bi(a.text);if(i==="")continue;const c=n.get(i);if(c===void 0){n.set(i,{tokens:a.tokens,candidates:[a]});continue}n.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const r of n.values()){if(r.candidates.length<2)continue;const o=r.candidates[0]??null;if(o===null)continue;const a=r.tokens-o.tokens;s.push({key:`${o.path}:${o.label}:${String(r.candidates.length)}:${String(r.tokens)}`,count:r.candidates.length,totalTokens:r.tokens,repeatedTokens:a,preview:vE(o.text),firstLabel:o.label,segments:r.candidates.map(yE)})}return s.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function ME(e){if(e.length===0)return null;const n=e.length,s=e.reduce((o,a)=>o+a.count,0),r=e.reduce((o,a)=>o+a.repeatedTokens,0);return{kind:"duplicate",severity:r>=Fi?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(n)} group${n===1?"":"s"}, ~${String(r)} repeated tokens.`}}function AE(e){return e.reduce((n,s)=>n+s.repeatedTokens,0)}function IE(e,n,s){const r=[],o=e.find(d=>d.role==="tools")??null;o!==null&&(o.tokens>=Fi||o.percent>=Q_&&o.tokens>=tu)&&r.push({kind:"tool-schema",severity:o.tokens>=Fi?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(o.percent*100)}% of request context.`});const a=e.find(d=>d.role==="system")??null;a!==null&&a.tokens>=tu&&a.percent>=oE&&r.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,p)=>d+p.tokens,0),c=n>0?i/n:0;return s>=nE&&(i>=sE||c>=rE)&&r.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.`}),r}function PE({risk:e,contextWindow:n,diagnostics:s,duplicateGroups:r}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),n.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:AE(r)}}function LE({segments:e,inputTokens:n,parsed:s,model:r,providers:o=[]}){const a=e.reduce((C,E)=>C+E.size,0),i=r??pE(s),c=n??a,d=Bh(s,lE),p=fE(i,s,o),u=d??0,m=p.tokens===null?null:c+u,f=p.tokens===null?null:p.tokens-c,h=p.tokens===null?null:p.tokens-c-u,g=p.tokens===null||m===null?null:hE(m/p.tokens),v=bE(e,a),w=v[0]??null,y=e.filter(C=>C.role!=="tools").length,b=RE(e),j=ME(b),S=IE(v,a,y);j!==null&&S.unshift(j);const N=xE(g);return{model:i,contextWindow:p,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:m,remainingInputTokens:f,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:v,largestRole:w,diagnostics:S,duplicateGroups:b,health:PE({risk:N,contextWindow:p,diagnostics:S,duplicateGroups:b})}}const JR={watch:zh,danger:Dh},su=new WeakMap;function OE(e){return e.map(n=>{const s=n.modelMetadata?.map(r=>`${r.model}:${String(r.contextWindow??"")}`).join(",")??"";return`${n.id}:${n.updatedAt}:${n.models.join(",")}:${s}`}).join("|")}function zE(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function DE(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function $E(e,n){const s=zE(e.rawRequestBody);if(s===null)return null;const o=If(bo(e)).anatomySegments(s);if(o===null)return null;const a=LE({segments:o,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:n}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(DE);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,p)=>d+p.size,0)}}function FE(e,n,s){const r=su.get(e);if(r!==void 0&&r.id===e.id&&r.rawRequestBody===e.rawRequestBody&&r.inputTokens===e.inputTokens&&r.model===e.model&&r.path===e.path&&r.apiFormat===e.apiFormat&&r.timestamp===e.timestamp&&r.providersSignature===s)return r.snapshot;const o=$E(e,n);return su.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:o}),o}function BE(e,n){return e.usagePercent!==null&&n.usagePercent!==null?e.usagePercent>n.usagePercent:e.usagePercent!==null&&n.usagePercent===null?!0:e.usagePercent===null&&n.usagePercent!==null?!1:e.estimatedInputTokens>n.estimatedInputTokens}function ru(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function UE(e,n){const s=ru(n.latest.riskLevel)-ru(e.latest.riskLevel);if(s!==0)return s;const r=e.peak.usagePercent??-1,a=(n.peak.usagePercent??-1)-r;return a!==0?a:n.latest.logId-e.latest.logId}function qE(e,n){return e.usagePercent===null||n.usagePercent===null?null:(n.usagePercent-e.usagePercent)*100}function HE(e){for(let n=1;n<e.length;n++){const s=e[n-1],r=e[n];if(!(s===void 0||r===void 0)&&s.id>r.id)return[...e].sort((o,a)=>o.id-a.id)}return e}function VE(e,n=[]){const s=HE(e),r=OE(n),o=new Map;for(const i of s){const c=FE(i,n,r);if(c===null)continue;const d=o.get(c.model);if(d===void 0){o.set(c.model,{model:c.model,requestCount:1,first:c,latest:c,peak:c});continue}o.set(c.model,{model:d.model,requestCount:d.requestCount+1,first:d.first,latest:c,peak:BE(c,d.peak)?c:d.peak})}return{models:[...o.values()].map(i=>({model:i.model,requestCount:i.requestCount,first:i.first,latest:i.latest,peak:i.peak,trendPercent:qE(i.first,i.latest)})).sort(UE)}}function zn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function WE(e){const n=new Map;for(const s of e)for(let r=0;r<s.logs.length;r+=1){const o=s.logs[r];o!==void 0&&n.set(o.id,r+1)}return n}function ou(e,n){return n.get(e.id)??e.id}function au(e){let n=0,s=0;for(const r of e)r.inputTokens!==null&&(n+=r.inputTokens),r.outputTokens!==null&&(s+=r.outputTokens);return{totalIn:n,totalOut:s}}function GE(e){for(const n of e)if(n.userAgent!==null&&n.userAgent!==void 0&&n.userAgent!=="")return n.userAgent;return null}function KE(e,n){const s=e[0],r=e[e.length-1];return s===void 0||r===void 0?null:Lo(s.timestamp,r.timestamp,n)}function YE(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 JE(e){switch(e){case"rolling":return t.jsx(lt,{className:"size-3 text-status-cool"});case"failed":return t.jsx(ao,{className:"size-3 text-status-danger"});case"watch":return t.jsx(ep,{className:"size-3 text-status-watch"});case"clear":return t.jsx(De,{className:"size-3 text-status-success"})}}function XE(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function ZE(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 ls({label:e,value:n,detail:s,icon:r,tone:o="neutral"}){return t.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[r,e]}),t.jsx("div",{className:L("mt-2 font-mono text-sm font-semibold",YE(o)),children:n}),t.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function QE({stats:e}){return e.requests===0?null:t.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[t.jsx("div",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[t.jsx(p0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),t.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),t.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[t.jsx(ls,{label:"Status",value:e.statusLabel,detail:ZE(e),icon:JE(e.status),tone:XE(e.status)}),t.jsx(ls,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:t.jsx(H0,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),t.jsx(ls,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:t.jsx(ao,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),t.jsx(ls,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:t.jsx(ep,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),t.jsx(ls,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:t.jsx(il,{className:"size-3 text-muted-foreground"})}),t.jsx(ls,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Ys(e){if(e===null)return"Unknown";const n=e*100;return n>=10?`${n.toFixed(0)}%`:n>=1?`${n.toFixed(1)}%`:n>0?"<1%":"0%"}function eR(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function qi(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function tR(e,n){if(n===null)return null;const s=qi(e),r=qi(n);return r<=0||Math.abs(r-s)<.5?null:r}function nR(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 sR(e){const n=e.latest.contextWindow.tokens;return n===null?"Context window unknown":`Context window ${bu(n)}`}const rR=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Uh(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 si(e,n){if(e===null)return null;const s=e.metadata[n];return s===void 0?null:Uh(s)}function oR(e){const n=e.toLowerCase();return n.includes("reject")||n.includes("fail")||n.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":n.includes("partial")||n.includes("pending")||n.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":n.includes("pass")||n.includes("complete")||n.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function aR(e){const n=[];for(const s of rR){const r=e.metadata[s];if(r===void 0)continue;const o=Uh(r);o!==null&&n.push({key:s,value:o})}return n}function iu({memberships:e,defaultOpen:n=!1}){const[s,r]=l.useState(n);if(e.length===0)return null;const o=e[0],a=o?.member??null,i=si(a,"score"),c=si(a,"decision"),d=si(a,"final_status"),p=[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 t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>r(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:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&t.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),t.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),p.length>0&&t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:p.slice(0,4).map(u=>t.jsx("span",{className:L("rounded border px-1.5 py-0.5 font-mono text-[10px]",oR(u.value)),children:u.label},u.label))})]}),s?t.jsx(al,{className:"size-4 shrink-0 text-muted-foreground"}):t.jsx(Ze,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&t.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const m=u.member,f=aR(m);return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),m.status!==null&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",m.status]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsx("span",{className:"font-mono",title:m.sessionId,children:zn(m.sessionId)}),m.label!==null&&t.jsx("span",{children:m.label}),m.provider!==null&&t.jsx("span",{children:m.provider}),m.model!==null&&t.jsx("span",{className:"font-mono",children:m.model}),m.runId!==null&&t.jsxs("span",{className:"font-mono",title:m.runId,children:["run ",zn(m.runId)]})]}),f.length>0&&t.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>t.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[t.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),t.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${m.id}`)})})]})}function qr({label:e,title:n,icon:s,disabled:r,onClick:o}){return t.jsxs("button",{type:"button",onClick:o,disabled:r,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:n,children:[s,t.jsx("span",{children:e})]})}function lu({logs:e,pagination:n,embedded:s=!1}){if(n===void 0)return null;const r=n.isLoading;return t.jsxs("nav",{"aria-label":"Session log pagination",className:L("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:[t.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[t.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[Uk({logs:e,pagination:n}),n.isLoading&&e.length>0&&t.jsx("span",{className:"ml-2",children:"Loading..."})]}),n.loadProgress!==void 0&&t.jsx(Zr,{progress:n.loadProgress})]}),t.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[t.jsx(qr,{label:"Oldest",title:"Load the oldest logs in this session",icon:t.jsx(Gg,{className:"size-3.5"}),disabled:r||!n.hasOlder,onClick:n.onOldest}),t.jsx(qr,{label:"Older",title:"Load older logs",icon:t.jsx(Bu,{className:"size-3.5"}),disabled:r||!n.hasOlder,onClick:n.onOlder}),t.jsx(qr,{label:"Newer",title:"Load newer logs",icon:t.jsx(ct,{className:"size-3.5"}),disabled:r||!n.hasNewer,onClick:n.onNewer}),t.jsx(qr,{label:"Newest",title:"Load the newest logs in this session",icon:t.jsx(Yg,{className:"size-3.5"}),disabled:r||!n.hasNewer,onClick:n.onNewest})]})]})}function iR(e){return`${e} ${e===1?"request":"requests"}`}function cu(e){return`#${String(e)}`}function du(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 lR(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 cR(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const dR=10,uR=80;function pR(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function mR(e){const n=document.getElementById(`log-${String(e)}`);return n instanceof HTMLElement?(n.scrollIntoView({block:"center",behavior:Eh(Rh())}),n.focus({preventScroll:!0}),pR(n),!0):!1}function qh(e){ks({logId:e,tab:"anatomy"});let n=0;const s=()=>{ks({logId:e,tab:"anatomy"}),!mR(e)&&(n+=1,n<dR&&window.setTimeout(s,uR))};window.setTimeout(s,0)}function fR({command:e}){const[n,s]=l.useState(!1),r=l.useCallback(()=>{bt(e).then(o=>{o&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return t.jsxs("div",{"data-command-example":"true",className:Nk,children:[t.jsx("pre",{className:Ck,children:e}),t.jsx("button",{type:"button",onClick:r,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:n?t.jsx(De,{className:"size-4"}):t.jsx(yt,{className:"size-4"})})]})}function ri({label:e,children:n,className:s}){return t.jsxs("section",{className:L("rounded-[8px] border border-border/60 bg-card/55",s),children:[t.jsx("div",{className:"px-3 pt-3",children:t.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),t.jsx("div",{className:"p-3 pt-2",children:n})]})}function Hr({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[t.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:n}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function hR(){const{themeMode:e,setThemeMode:n}=sv();return t.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:[t.jsx("button",{type:"button",onClick:()=>n("light"),className:L("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:t.jsx(Z1,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("eye-care"),className:L("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:t.jsx(Hu,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("dark"),className:L("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:t.jsx(m1,{className:"size-3.5"})})]})}function xR({visible:e,onToggle:n}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return t.jsx("button",{type:"button",onClick:n,className:L("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:t.jsx(Vi,{className:L("size-4 transition-opacity",!e&&"opacity-45")})})}function gR({preference:e,resolvedScale:n,onChange:s}){const r=cv(n),o=e==="auto"?`Auto (${r})`:`${e}%`;return t.jsxs(nr,{value:e,onValueChange:a=>s(ul(a)),children:[t.jsxs(sr,{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: ${o}`,children:[t.jsx(bg,{className:"size-3.5"}),t.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:r})]}),t.jsxs(rr,{align:"end",children:[t.jsx(it,{value:"auto",children:"Auto"}),t.jsx(it,{value:"100",children:"100%"}),t.jsx(it,{value:"125",children:"125%"}),t.jsx(it,{value:"150",children:"150%"})]})]})}const Hh="agent-inspector.detailsPanelCollapsed",Vh="agent-inspector.detailsPanelWidth",Wh="agent-inspector.pet.visible",ms=360,bR=288,vR=520;function Gh(e){return Math.min(Math.max(e,bR),vR)}function yR(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Hh);return e===null||e==="1"}catch{return!0}}function wR(){if(typeof window>"u")return ms;try{const e=window.localStorage.getItem(Vh);if(e===null)return ms;const n=Number.parseInt(e,10);return Number.isFinite(n)?Gh(n):ms}catch{return ms}}function jR(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Wh)!=="0"}catch{return!0}}function uu({label:e,logId:n}){return t.jsxs("button",{type:"button",onClick:()=>qh(n),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 ${cu(n)}`,children:[e," ",cu(n)]})}function SR({latestPercent:e,peakPercent:n,risk:s,onOpenContext:r}){const o=qi(e),a=tR(e,n),i=n===null?`Latest context window usage ${Ys(e)}`:`Latest context window usage ${Ys(e)}, peak ${Ys(n)}`;return t.jsx("button",{type:"button",onClick:r,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:t.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(o),children:[t.jsx("span",{className:L("block h-full rounded-full transition-[width]",nR(s)),style:{width:`${o}%`}}),a!==null&&t.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 NR({summary:e}){const n=e.trendPercent,s=n===null||Math.abs(n)<.1?null:n>0?_g:jg,r=e.latest.diagnostics[0]??null,o=Ys(e.latest.usagePercent),a=Ys(e.peak.usagePercent),i=()=>{qh(e.latest.logId)};return t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.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}),t.jsx("span",{className:L("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",lR(e.latest.health.level)),children:cR(e.latest.health.level)})]}),t.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:[t.jsx("span",{children:iR(e.requestCount)}),t.jsx("span",{children:sR(e)})]})]}),t.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[t.jsx(SR,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),t.jsx("div",{className:L("mt-0.5 font-mono",du(e.latest.riskLevel)),children:o}),t.jsx(uu,{label:"Log",logId:e.latest.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),t.jsx("div",{className:L("mt-0.5 font-mono",du(e.peak.riskLevel)),children:a}),t.jsx(uu,{label:"Log",logId:e.peak.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&t.jsx(s,{className:L("size-3",n!==null&&n>0?"text-amber-300":"text-cyan-300")}),eR(n)]}),t.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),t.jsxs("div",{className:"min-w-0 space-y-1.5",children:[t.jsx(Z_,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&t.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.windowUsedTokens)," used"]}),r!==null&&t.jsx("span",{className:"truncate",children:r})]})]})]})}function CR({summary:e}){return e.models.length===0?null:t.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),t.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),t.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(n=>t.jsx(NR,{summary:n},n.model))})]})}function kR(e){const n=e.models.filter(r=>r.latest.health.level==="risk").length;if(n>0)return`${n} risk`;const s=e.models.filter(r=>r.latest.health.level==="optimizable").length;return s>0?`${s} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function TR({label:e,sessionId:n,logs:s,totalIn:r,totalOut:o,timeDisplayFormat:a,contextSummary:i,showBackLink:c}){const[d,p]=l.useState(!1),[u,m]=l.useState(!1),[f,h]=l.useState(!1),g=l.useMemo(()=>KE(s,a),[s,a]),v=l.useMemo(()=>GE(s),[s]),w=l.useMemo(()=>kR(i),[i]),y=l.useCallback(()=>{n!==null&&bt(n).then(j=>{j&&(p(!0),setTimeout(()=>p(!1),2e3))})},[n]),b=l.useCallback(()=>{bt(window.location.href).then(j=>{j&&(m(!0),setTimeout(()=>m(!1),2e3))})},[]);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c&&t.jsx("a",{href:Wi("/"),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:t.jsx(kg,{className:"size-3.5"})}),t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:zn(e)}),n!==null&&t.jsx("button",{type:"button",onClick:y,className:"hover:bg-white/[0.065] inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground","aria-label":d?"Copied session ID":"Copy session ID",title:d?"Copied session ID":"Copy session ID",children:d?t.jsx(De,{className:"size-3"}):t.jsx(yt,{className:"size-3"})}),v!==null&&t.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:v,children:v})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsxs("span",{children:[s.length," request",s.length!==1?"s":""]}),g!==null&&t.jsx("span",{children:g}),(r>0||o>0)&&t.jsxs("span",{className:"font-mono",children:[Ie(r)," in / ",Ie(o)," out"]})]})]}),i.models.length>0&&t.jsxs("button",{type:"button",onClick:()=>h(j=>!j),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":f,title:f?"Hide context details":"Show context details",children:[t.jsx("span",{children:w}),f?t.jsx(al,{className:"size-3.5"}):t.jsx(Ze,{className:"size-3.5"})]}),t.jsx("button",{type:"button",onClick:b,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":u?"Copied session link":"Copy session link",title:u?"Copied session link":"Copy session link",children:u?t.jsx(De,{className:"size-3.5"}):t.jsx(yt,{className:"size-3.5"})})]}),f&&t.jsx(CR,{summary:i})]})}function _R({logs:e,sessions:n,selectedSession:s,selectedModel:r,onSessionChange:o,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:p,onImportLogs:u,viewMode:m,captureMode:f,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:v,isLoading:w=!1,liveConnection:y,onRetryLiveConnection:b,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:E=[],hideSessionFilter:A=!1,pinnedSessionId:I}){const{totalIn:M,totalOut:k}=l.useMemo(()=>au(e),[e]),{providers:R}=ml(),{uiScalePreference:O,resolvedUiScale:$,setUiScalePreference:K}=mv(),[ee,D]=l.useState(null),[H,te]=l.useState(null),[U,Q]=l.useState(!1),[fe,je]=l.useState(!1),[he,re]=l.useState(null),[P,X]=l.useState(null),[Se,_e]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!0),[Re,Fe]=l.useState(ms),[dt,He]=l.useState(!1),[Le,We]=l.useState(!1),[Ye,Qe]=l.useState(!0),[ot,nt]=l.useState(!1),[q,se]=l.useState(null),[xe,me]=l.useState(null),we=l.useRef(null),Oe=l.useRef(null),$e=l.useRef(null),z=l.useRef(null),Y=l.useRef(0),de=l.useRef(null);W_(we,Oe,{pageWide:!0});const[Ne,F]=l.useState(null);l.useEffect(()=>ll(F),[]);const W=l.useCallback(()=>{Y.current+=1,z.current?.abort(),z.current=null,D(null),te(null)},[]);l.useEffect(()=>()=>{Y.current+=1,z.current?.abort(),z.current=null},[]),l.useEffect(()=>{Pe(yR()),Fe(wR()),We(!0)},[]),l.useEffect(()=>{Le&&window.localStorage.setItem(Hh,ce?"1":"0")},[ce,Le]),l.useEffect(()=>{if(Le)try{window.localStorage.setItem(Vh,String(Re))}catch{}},[Le,Re]),l.useEffect(()=>{Qe(jR()),nt(!0)},[]),l.useEffect(()=>{if(ot)try{window.localStorage.setItem(Wh,Ye?"1":"0")}catch{}},[ot,Ye]),l.useEffect(()=>{if(I===void 0){document.title="Agent Inspector";return}const ye=e.length===1?"1 req":`${e.length} req`;document.title=`${zn(I)} - ${ye} - Agent Inspector`},[e.length,I]);const Z=l.useCallback(async ye=>{z.current?.abort();const Ge=new AbortController;z.current=Ge;const Mt=Y.current+1;Y.current=Mt,D(ye),te(null);try{const Xt=await Zb(e,ye,{signal:Ge.signal});if(Y.current!==Mt)return;if(!Xt.ok){if(Xt.canceled===!0)return;p!==void 0?p({message:Xt.message,tone:"error"}):te(Xt.message)}}finally{Y.current===Mt&&(z.current=null,D(null))}},[e,p]),ne=l.useCallback(ye=>{if(_k(ye)){Q(!0);return}Z(ye)},[Z]),Ee=l.useCallback(()=>{Q(!1),Z("redacted")},[Z]),ie=l.useCallback(()=>{Q(!1),Z("raw")},[Z]),oe=l.useCallback(()=>{$e.current?.click()},[]),ke=l.useCallback(ye=>{const Ge=ye.currentTarget.files?.[0];ye.currentTarget.value="",!(Ge===void 0||u===void 0)&&(je(!0),X(null),re(null),u(Ge).then(Mt=>{const Xt=Mt.skipped>0?`, skipped ${String(Mt.skipped)}`:"",lc=`Imported ${String(Mt.imported)} logs as ${Mt.sessionId}${Xt}.`;p!==void 0?p({message:lc,tone:"success"}):re(lc)}).catch(Mt=>{const Xt=Mt instanceof Error?Mt.message:"Failed to import logs";p!==void 0?p({message:Xt,tone:"error"}):X(Xt)}).finally(()=>{je(!1)}))},[u,p]);l.useEffect(()=>{W(),me(null),se(null)},[W,s,r]);const ze=l.useCallback(()=>{W(),re(null),X(null),me(null),a()},[W,a]),Kn=l.useCallback(()=>{_e(!0)},[]),$t=l.useCallback(()=>{W(),re(null),X(null),me(null),i!==void 0&&(le(!0),i().then(()=>{_e(!1)}).catch(ye=>{const Ge=ye instanceof Error?ye.message:"Failed to delete stored logs";p!==void 0?p({message:Ge,tone:"error"}):X(Ge)}).finally(()=>{le(!1)}))},[W,i,p]),an=l.useCallback(()=>{c!==void 0&&(W(),re(null),X(null),me(null),c())},[W,c]),ia=l.useCallback(()=>{me(null)},[]),Yn=l.useCallback(()=>{Pe(ye=>!ye)},[]),la=l.useCallback(ye=>{de.current={startX:ye.clientX,startWidth:Re,pointerId:ye.pointerId},ye.currentTarget.setPointerCapture(ye.pointerId),He(!0)},[Re]),Me=l.useCallback(ye=>{const Ge=de.current;Ge===null||Ge.pointerId!==ye.pointerId||Fe(Gh(Ge.startWidth+Ge.startX-ye.clientX))},[]),jt=l.useCallback(ye=>{const Ge=de.current;Ge===null||Ge.pointerId!==ye.pointerId||(ye.currentTarget.hasPointerCapture(ye.pointerId)&&ye.currentTarget.releasePointerCapture(ye.pointerId),de.current=null,He(!1))},[]),et=l.useCallback(()=>{Fe(ms)},[]),Ls=l.useCallback(()=>{Qe(ye=>!ye)},[]),st=l.useMemo(()=>q===null?null:new Set(q.logIds),[q]),Rt=l.useMemo(()=>st===null?e:e.filter(ye=>st.has(ye.id)),[st,e]),Ft=l.useMemo(()=>mS(Rt),[Rt]),nc=l.useMemo(()=>WE(Ft),[Ft]),ln=l.useMemo(()=>Bk({pinnedSessionId:I,selectedSession:s,sessions:n,logs:e}),[e,I,s,n]),Jn=ln?.logs??[],Os=ln!==null&&Jn.length>0,{totalIn:sc,totalOut:rc}=l.useMemo(()=>au(Jn),[Jn]),Yh=l.useMemo(()=>VE(Jn,R),[Jn,R]),Jh=l.useMemo(()=>g_(Ft),[Ft]),ca=l.useMemo(()=>PC(Ft),[Ft]),oc=Ek(f,e.length),Xh=I!==void 0,Zh=e.length>0,Qh=i!==void 0&&(e.length>0||s!=="__all__"),ex=s==="__all__"?"all sessions":"this session",tx=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.",nx=e.length===0?"Load":"Reload",da=Os&&ln!==null?zn(ln.label):s==="__all__"?"All sessions":zn(s),ac=N_(y),ua=C_(ac),sx=l.useMemo(()=>Fk({logs:Rt,conversationGroups:Ft,isLoading:w,timeDisplayFormat:v,slowResponseThresholdSeconds:g}),[Rt,Ft,w,g,v]),rx=l.useCallback(ye=>{const Ge=ca.get(ye.id);Ge!==void 0&&me([Ge,ye])},[ca]),ic=I!==void 0?I:s==="__all__"?null:s;return t.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:[t.jsx(w_,{liveConnection:y,alertsAction:t.jsx(g3,{}),guideAction:t.jsx(MT,{endpoints:Ne,liveConnection:y,providerCount:R.length,sessionCount:n.length,capturedLogCount:e.length}),aboutAction:t.jsx(TT,{}),settingsAction:t.jsx(sT,{})}),t.jsxs("button",{type:"button",onClick:Yn,className:L("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":ce?"Show details panel":"Hide details panel",title:ce?"Show details panel":"Hide details panel",children:[t.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),ce?t.jsx(C1,{className:"size-3.5"}):t.jsx(S1,{className:"size-3.5"})]}),ot&&Ye&&t.jsx(eo,{feature:"Inspector Pet",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(aN,{logs:e})})}),t.jsxs("div",{className:L("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",dt&&"cursor-col-resize select-none"),children:[!ce&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:Yn,"aria-label":"Close details panel"}),t.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:Re},children:[t.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:la,onPointerMove:Me,onPointerUp:jt,onPointerCancel:jt,onDoubleClick:et,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:t.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),t.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[t.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:[t.jsx(ri,{label:"View",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx(hR,{}),t.jsx(gR,{preference:O,resolvedScale:$,onChange:K})]})}),t.jsx(ri,{label:"Workspace",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(D3,{labelledTrigger:!0}),t.jsx(ZT,{currentSessionId:ic,logCount:e.length,labelledTrigger:!0})]})})]}),t.jsxs(ri,{label:"Current scope",children:[t.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[t.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:da,children:da}),t.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:Xh?"Pinned session":"Live Inspector data"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(Hr,{label:q===null?"Requests":"Results",value:Rt.length}),t.jsx(Hr,{label:"Sessions",value:n.length}),t.jsx(Hr,{label:"Input",value:Ie(Os?sc:M)}),t.jsx(Hr,{label:"Output",value:Ie(Os?rc:k)})]}),N!==void 0&&t.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:t.jsx(Zr,{progress:N})})]}),Os&&ln!==null&&t.jsx(TR,{label:ln.label,sessionId:ln.sessionId,logs:Jn,totalIn:sc,totalOut:rc,timeDisplayFormat:v,contextSummary:Yh,showBackLink:ln.showBackLink}),Os&&I!==void 0&&E.length>0&&t.jsx(iu,{memberships:E}),t.jsx("div",{className:"flex-1"}),t.jsx(x_,{currentSessionId:ic,logCount:e.length,onResultChange:se})]})]})]}),t.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[t.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:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),t.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:da})]}),t.jsx(xR,{visible:Ye,onToggle:Ls}),u!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:$e,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:ke}),t.jsx("button",{type:"button",onClick:oe,disabled:fe,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:fe?t.jsx("span",{children:"Importing..."}):t.jsxs(t.Fragment,{children:[t.jsx(tp,{className:"size-3.5"}),t.jsx("span",{children:"Import"})]})})]}),oc.redacted&&t.jsx("button",{type:"button",onClick:()=>{ne("redacted")},disabled:ee!==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:ee==="redacted"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(Rs,{className:"size-3.5"}),t.jsx("span",{children:"Export"})]})}),oc.raw&&t.jsx("button",{type:"button",onClick:()=>{ne("raw")},disabled:ee!==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:ee==="raw"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(P0,{className:"size-3.5"}),t.jsx("span",{children:"Raw"})]})}),c!==void 0&&t.jsxs("button",{type:"button",onClick:an,disabled:w,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:[t.jsx(lt,{className:L("size-3.5",w&&"animate-spin motion-reduce:animate-none")}),t.jsx("span",{children:nx})]}),t.jsxs("button",{type:"button",onClick:ze,disabled:!Zh,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:[t.jsx(Sn,{className:"size-3.5"}),t.jsx("span",{children:"Clear"})]}),i!==void 0&&t.jsxs("button",{type:"button",onClick:Kn,disabled:!Qh||ge,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:[t.jsx(Sn,{className:"size-3.5"}),t.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&t.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:t.jsx(Zr,{progress:N})}),C!==void 0&&t.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:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&t.jsxs("button",{type:"button",onClick:an,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:[t.jsx(lt,{className:"size-3"}),"Retry"]})]}),q!==null&&t.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:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:q.question}),t.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(Rt.length)," loaded logs from"," ",String(q.logIds.length)," linked results"]})]}),t.jsxs("button",{type:"button",onClick:()=>se(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:[t.jsx(dr,{className:"size-3"}),"All logs"]})]}),q===null&&t.jsx(lu,{logs:e,pagination:S,embedded:!0}),p===void 0&&H!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:H}),p===void 0&&P!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:P}),p===void 0&&he!==null&&P===null&&t.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:he}),y!==void 0&&y.status!=="live"&&b!==void 0&&j!==void 0&&t.jsx(v_,{state:y,hasLogs:e.length>0,onRetry:b,onStop:j})]}),t.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[t.jsx(QE,{stats:sx}),q!==null&&Rt.length===0?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.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:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),t.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."}),t.jsx("button",{type:"button",onClick:()=>se(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__"?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.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:[t.jsx("p",{className:"text-sm font-medium",children:w?"Loading session data...":C===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),t.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:zn(s)}),N!==void 0&&t.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:t.jsx(Zr,{progress:N})}),E.length>0&&t.jsx("div",{className:"text-left",children:t.jsx(iu,{memberships:E})}),!w&&t.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[t.jsx("p",{children:"Stored logs may still be available."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&t.jsxs("button",{type:"button",onClick:an,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:[t.jsx(lt,{className:"size-3.5"}),t.jsx("span",{children:"Load session"})]}),A?t.jsx("a",{href:Wi("/"),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"}):t.jsx("button",{type:"button",onClick:()=>o("__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"})]})]})]})}):t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.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:[t.jsx("p",{className:"text-sm font-medium",children:ua.title}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:ua.description}),ac==="empty"&&n.length>0&&t.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."}),ua.showConnectionCommands&&Ne!==null&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-col items-center gap-2",children:kk(Ne).map(ye=>t.jsx(fR,{command:ye},ye))}),t.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."})]})]})}):t.jsxs("div",{ref:Oe,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:[t.jsx("div",{ref:we,children:t.jsx(O_,{groups:Ft,viewMode:m,strip:h,slowResponseThresholdSeconds:g,cacheTrends:Jh,onCompareWithPrevious:rx,comparisonPredecessors:ca,onClearGroup:d,defaultExpanded:Ft.length===1,timeDisplayFormat:v})}),q===null&&t.jsx("div",{className:"mt-3",children:t.jsx(lu,{logs:e,pagination:S})})]})]})]})]}),t.jsx(Nt,{open:U,onOpenChange:Q,children:t.jsx(Ct,{className:$_,children:t.jsx(B_,{onCancel:()=>Q(!1),onExportRedacted:Ee,onConfirmRaw:ie})})}),t.jsx(Nt,{open:Se,onOpenChange:_e,children:t.jsxs(Ct,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[t.jsxs(Tt,{children:[t.jsxs(_t,{children:["Delete ",ex," history?"]}),t.jsx(Is,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),t.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:[t.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),t.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:tx})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(J,{type:"button",variant:"outline",size:"sm",disabled:ge,onClick:()=>_e(!1),children:"Cancel"}),t.jsx(J,{type:"button",variant:"destructive",size:"sm",disabled:ge,onClick:$t,children:ge?"Deleting...":"Delete history"})]})]})}),xe!==null&&t.jsx(eo,{feature:"Compare",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(oN,{left:xe[0],right:xe[1],leftDisplayNumber:ou(xe[0],nc),rightDisplayNumber:ou(xe[1],nc),onClose:ia})})})]})}function ER(e,n,s){return n==="__all__"&&s==="__all__"?e:e.filter(r=>!(n!=="__all__"&&r.sessionId!==n||s!=="__all__"&&r.model!==s))}function RR(e,n){if(e.length===0)return[...n];if(n.length===0)return[...e];const s=new Map;for(const r of e)s.set(r.id,r);for(const r of n)s.set(r.id,r);return[...s.values()].toSorted((r,o)=>r.id-o.id)}function pu(e,n){return n.retainIds?.has(e.id)===!0||n.retainSessionId!==void 0&&e.sessionId===n.retainSessionId}function mu(e,n){const s=e.reduce((a,i)=>a+(pu(i,n)?0:1),0);if(s<=n.recentLimit)return e;let r=s-n.recentLimit;const o=[];for(const a of e){if(r>0&&!pu(a,n)){r-=1;continue}o.push(a)}return o}function On(e){const n=new Map;for(let s=0;s<e.length;s+=1){const r=e[s];r!==void 0&&n.set(r.id,s)}return n}function oi(e,n,s,r){if(s.length===0){const p=mu([...e],r);return{logs:p,index:On(p)}}const o=[...e];let a=o.length===0?Number.NEGATIVE_INFINITY:o.at(-1)?.id??0,i=!0;for(const p of s){const u=n.get(p.id);if(u!==void 0&&u>=0&&u<o.length){o[u]=p;continue}o.push(p),p.id<a&&(i=!1),a=Math.max(a,p.id)}const c=i?o:o.toSorted((p,u)=>p.id-u.id),d=mu(c,r);return{logs:d,index:On(d)}}function Pn(e,n){const s=new Set;for(const r of e)r!==""&&s.add(r);for(const r of n)r!==""&&s.add(r);return[...s].sort()}function MR(e){const n=new URLSearchParams({compact:"1"});e!==void 0&&n.set("sessionId",e);const s=ux();return s.ok?px(s.runtime,`/api/logs/stream?${n.toString()}`):null}function AR(e){const n=MR(e);return n===null?null:new EventSource(n)}const IR=Gt([T({type:ae("init"),logs:V(Xs)}),T({type:ae("update"),log:Xs}),T({type:ae("progress"),logId:_().int().positive(),chunkBase64:x(),responseBytes:_().int().nonnegative(),responseStatus:_().int().nullable(),elapsedMs:_().int().nonnegative().nullable(),terminal:Ce()})]),PR=T({logs:V(Xs),total:_().int().nonnegative(),limit:_().int().positive(),hasOlder:Ce(),hasNewer:Ce(),oldestLogId:_().int().positive().nullable(),newestLogId:_().int().positive().nullable()}),LR=V(x()),fu=T({success:Ce(),cleared:_().int().nonnegative(),logFilesRewritten:_().int().nonnegative().optional(),chunkFilesDeleted:_().int().nonnegative(),sessionArchiveLogsDeleted:_().int().nonnegative().optional()});function OR(e,n){const s=[];for(const r of e)for(const o of r.members)o.sessionId===n&&s.push({groupId:r.id,groupTitle:r.title,groupKind:r.kind,groupStatus:r.status,groupTask:r.task,groupProject:r.project,groupEvidence:r.evidence,member:o});return s}function Vr(e){const n=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&n.add(s.sessionId);return[...n]}function zR(e){const n=new Set;for(const s of e)s.model!==null&&s.model!==""&&n.add(s.model);return[...n]}const DR=100,$R=12,FR=1800,tc=100,Ro=500,Kh=200,Hi=2e4,BR=1e4,UR=3e3,qR=1e4,HR=2e3;function VR(e,n,s=tc){const r=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(n.kind){case"oldest":r.set("anchor","oldest");break;case"older":r.set("beforeLogId",String(n.beforeLogId));break;case"newer":r.set("afterLogId",String(n.afterLogId));break}return`/api/logs?${r.toString()}`}function Js(e,n,s=tc){return Be(VR(e,n,s),PR,Hi)}async function WR(e,n){const s=new Set;let r=await Js(e,{kind:"oldest"},Ro);for(const a of r.logs)s.add(a.id);n(s.size,1);let o=1;for(;r.hasNewer&&r.newestLogId!==null&&o<Kh;){r=await Js(e,{kind:"newer",afterLogId:r.newestLogId},Ro);for(const a of r.logs)s.add(a.id);o+=1,n(s.size,o)}return{ids:[...s],truncated:r.hasNewer}}async function GR(){try{return{deleted:(await Ke("/api/groups",Pu,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function XR({initialSessionId:e}={}){const[n,s]=l.useState([]),[r,o]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:p,showToast:u,dismissToast:m}=lh(),[f,h]=l.useState(S_),[g,v]=l.useState(null),[w,y]=l.useState(e!==void 0),[b,j]=l.useState(null),[S,N]=l.useState(void 0),[C,E]=l.useState([]),[,A]=l.useTransition(),I=l.useRef(null),M=l.useRef(null),k=l.useRef(null),R=l.useRef(!0),O=l.useRef(null),$=l.useRef(0),K=l.useRef(null),ee=l.useRef(null),D=l.useRef(new Map),H=l.useRef([]),te=l.useRef(new Map),U=l.useRef(new Map),Q=l.useRef(new Map),fe=l.useRef(null),je=l.useCallback(()=>({recentLimit:HR,retainSessionId:e??(r==="__all__"?void 0:r)}),[e,r]),he=l.useCallback(F=>{u({message:F,tone:"error"})},[u]),re=l.useCallback(()=>{ee.current!==null&&(clearInterval(ee.current),ee.current=null),K.current=null,N(void 0)},[]),P=l.useCallback((F,W,Z=0,ne=0)=>{ee.current!==null&&clearInterval(ee.current);const Ee=Date.now();K.current=Ee;const ie=()=>{$.current===W&&N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:Hi,loadedLogs:Z,loadedPages:ne})};ie(),ee.current=setInterval(ie,250)},[]),X=l.useCallback((F,W,Z,ne)=>{const Ee=K.current;Ee===null||$.current!==W||N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:Hi,loadedLogs:Z,loadedPages:ne})},[]),Se=l.useMemo(()=>ER(n,r,a),[n,r,a]),_e=l.useMemo(()=>Pn(c,Vr(n)),[n,c]),ge=l.useMemo(()=>zR(n),[n]),le=l.useCallback(()=>{Ke("/api/sessions",LR).then(F=>{d(W=>Pn(W,F))}).catch(()=>{})},[]),ce=l.useCallback(()=>{fe.current=null;const F=H.current;H.current=[],F.length!==0&&A(()=>{s(W=>{const Z=oi(W,D.current,F,je());return D.current=Z.index,Z.logs})})},[je,A]),Pe=l.useCallback(F=>{const W=te.current.get(F.id),Z=Q.current.get(F.id);H.current.push(W!==void 0&&F.responseText===null?{...F,responseText:W,responseTextBytes:Z?.responseBytes??new TextEncoder().encode(W).byteLength,responseStatus:Z?.responseStatus??F.responseStatus,elapsedMs:Z?.elapsedMs??F.elapsedMs,totalStreamMs:Z?.elapsedMs??F.totalStreamMs,streaming:!0,bodyContentMode:"full"}:F),fe.current===null&&(fe.current=setTimeout(ce,DR))},[ce]),Re=l.useCallback(F=>{const W=atob(F.chunkBase64),Z=Uint8Array.from(W,oe=>oe.charCodeAt(0)),ne=U.current.get(F.logId)??new TextDecoder("utf-8");U.current.set(F.logId,ne);const ie=`${te.current.get(F.logId)??""}${ne.decode(Z,{stream:!F.terminal})}`;te.current.set(F.logId,ie),Q.current.set(F.logId,{responseBytes:F.responseBytes,responseStatus:F.responseStatus,elapsedMs:F.elapsedMs}),F.terminal&&U.current.delete(F.logId),s(oe=>{const ke=D.current.get(F.logId);if(ke===void 0)return oe;const ze=oe[ke];if(ze===void 0)return oe;const Kn=[...oe];return Kn[ke]={...ze,responseText:ie,responseTextBytes:F.responseBytes,responseStatus:F.responseStatus??ze.responseStatus,elapsedMs:F.elapsedMs??ze.elapsedMs,totalStreamMs:F.elapsedMs??ze.totalStreamMs,streaming:!0,bodyContentMode:"full"},Kn})},[]),Fe=l.useCallback(()=>{I.current&&I.current.close(),M.current!==null&&(clearTimeout(M.current),M.current=null),h(W=>It(W,{type:"connect-requested"}));const F=AR(e);if(F===null){h(W=>It(W,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),he("Failed to resolve the live stream endpoint");return}I.current=F,F.onmessage=W=>{try{const Z=String(W.data),ne=JSON.parse(Z),Ee=IR.safeParse(ne);if(!Ee.success){h(oe=>It(oe,{type:"recoverable-error",message:"The live stream returned invalid data."})),he("Failed to parse SSE data");return}const ie=Ee.data;switch(ie.type){case"init":{fe.current!==null&&(clearTimeout(fe.current),fe.current=null),H.current=[],s(oe=>{const ke=oi(oe,D.current,ie.logs,je());return D.current=ke.index,ke.logs}),d(oe=>Pn(oe,Vr(ie.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(oe=>It(oe,{type:"message-received",at:Date.now()})),m();break}case"update":{d(oe=>ie.log.sessionId===null||ie.log.sessionId===""?oe:Pn(oe,[ie.log.sessionId])),Pe(ie.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(oe=>It(oe,{type:"message-received",at:Date.now()}));break}case"progress":{Re(ie),h(oe=>It(oe,{type:"message-received",at:Date.now()}));break}}}catch{h(Z=>It(Z,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),he("Failed to parse SSE data")}},F.onerror=()=>{const W=navigator.onLine;h(Z=>It(Z,{type:"connection-lost",online:W,message:"The live stream disconnected."})),F.close(),!(!W||!R.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(Z=>It(Z,{type:"stale-timeout"}))},qR)),M.current=setTimeout(Fe,UR))}},[Re,m,e,Pe,he]),dt=l.useCallback(()=>{R.current=!0,M.current!==null&&(clearTimeout(M.current),M.current=null),Fe()},[Fe]),He=l.useCallback(()=>{R.current=!1,I.current?.close(),I.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(F=>It(F,{type:"stop-retrying"}))},[]),Le=l.useCallback(F=>{if(e===void 0)return;const W=$.current+1;$.current=W,y(!0),j(null),P("Loading session logs",W),m(),Js(e,F).then(Z=>{if($.current!==W)return;const ne=Z.logs;D.current=On(ne),s(ne),v(Z),o(e),y(!1),j(null),re(),m()}).catch(Z=>{if($.current!==W)return;y(!1),re();const ne=Z instanceof Error?Z.message:"Failed to load session logs";j(ne),he(ne)})},[m,e,he,P,re]),We=l.useCallback(F=>{const W=$.current+1;$.current=W,y(!0),j(null),P("Reloading full session",W),m(),(async()=>{const Z=[];let ne=await Js(F,{kind:"oldest"},Ro);Z.push(...ne.logs),X("Reloading full session",W,Z.length,1);let Ee=1;for(;ne.hasNewer&&ne.newestLogId!==null&&Ee<Kh;)ne=await Js(F,{kind:"newer",afterLogId:ne.newestLogId},Ro),Z.push(...ne.logs),Ee+=1,X("Reloading full session",W,Z.length,Ee);$.current===W&&(s(ie=>{const oe=oi(ie,D.current,Z,je());return D.current=oe.index,oe.logs}),d(ie=>Pn(ie,[F])),y(!1),j(null),re(),ne.hasNewer?u({message:`Loaded ${String(Z.length)} logs for this session. More history is available.`,tone:"success"}):m())})().catch(Z=>{if($.current!==W)return;y(!1),re();const ne=Z instanceof Error?Z.message:"Failed to reload session logs";j(ne),he(ne)})},[m,he,u,P,re,X]);l.useEffect(()=>{if(e===void 0){E([]);return}let F=!1;return Be("/api/groups",zu,BR).then(W=>W.groups).then(W=>{F||W===null||E(OR(W,e))}).catch(()=>{F||E([])}),()=>{F=!0}},[e]),l.useEffect(()=>{le()},[le]),l.useEffect(()=>()=>{re()},[re]),l.useEffect(()=>{e!==void 0&&Le({kind:"newest"})},[e,Le]),l.useEffect(()=>{e===void 0&&r!=="__all__"&&We(r)},[e,We,r]),l.useEffect(()=>{Fe();const F=()=>{I.current?.close(),I.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Z=>It(Z,{type:"browser-offline"}))},W=()=>{R.current&&Fe()};return window.addEventListener("offline",F),window.addEventListener("online",W),()=>{window.removeEventListener("offline",F),window.removeEventListener("online",W),I.current&&(I.current.close(),I.current=null),M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),fe.current!==null&&(clearTimeout(fe.current),fe.current=null)}},[Fe,e]),l.useEffect(()=>{const F=window.location.hash;if(!F.startsWith("#log-")||O.current===F)return;const W=F.slice(1),Z=Number(W.replace(/^log-/,""));Number.isInteger(Z)&&Z>0&&ks({logId:Z,tab:"request"});let ne=!1,Ee=0,ie=null,oe=null;const ke=()=>{if(ne)return;const ze=document.getElementById(W);if(ze!==null){O.current=F,ze.scrollIntoView({block:"center",behavior:Eh(Rh())}),ze instanceof HTMLElement&&(ie=ze,ze.setAttribute("data-deep-link-highlight","true"),oe=window.setTimeout(()=>{ze.removeAttribute("data-deep-link-highlight")},FR),ze.focus({preventScroll:!0}),ze.getAttribute("data-nav-action")==="expand"&&ze.click());return}Ee+=1,Ee<$R&&window.setTimeout(ke,100)};return ke(),()=>{ne=!0,oe!==null&&window.clearTimeout(oe),ie!==null&&ie.removeAttribute("data-deep-link-highlight")}},[Se.length]);const Ye=l.useCallback(()=>{const F=Vr(n);re(),y(!1),D.current.clear(),s([]),v(null),d(W=>Pn(W,F)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[n,u,re]),Qe=l.useCallback(F=>{if(F.length===0)return;const W=new Set(F);s(Z=>{const ne=Z.filter(ie=>W.has(ie.id)),Ee=Z.filter(ie=>!W.has(ie.id));return d(ie=>Pn(ie,Vr(ne))),D.current=On(Ee),Ee}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),ot=l.useCallback(async()=>{const F=$.current+1;$.current=F,y(!0),re(),m();try{if(r==="__all__"){P("Deleting stored history",F);const oe=await Ke("/api/logs",fu,{method:"DELETE"}),ke=await GR();if($.current!==F)return;s([]),D.current.clear(),v(null),d([]),E([]),y(!1),re();const ze=ke.ok?` Cleared ${ke.deleted.toString()} group${ke.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${oe.cleared.toString()} stored log${oe.cleared===1?"":"s"} across all sessions.${ze}`,tone:ke.ok?"success":"error"});return}const W=r;P("Deleting session history",F);const Z=await WR(W,(oe,ke)=>{X("Deleting session history",F,oe,ke)}),ne=new Set(Z.ids);for(const oe of n)oe.sessionId===W&&ne.add(oe.id);const Ee=[...ne].filter(oe=>Number.isInteger(oe)&&oe>=0);if(Ee.length===0){if($.current!==F)return;s(oe=>{const ke=oe.filter(ze=>ze.sessionId!==W);return D.current=On(ke),ke}),v(oe=>oe===null?null:{...oe,logs:oe.logs.filter(ke=>ke.sessionId!==W)}),d(oe=>oe.filter(ke=>ke!==W)),y(!1),re(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ie=await Ke("/api/logs",fu,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:Ee})});if($.current!==F)return;s(oe=>{const ke=oe.filter(ze=>ze.sessionId!==W);return D.current=On(ke),ke}),v(oe=>oe===null?null:{...oe,logs:oe.logs.filter(ke=>ke.sessionId!==W)}),d(oe=>oe.filter(ke=>ke!==W)),y(!1),re(),u({message:`Deleted ${ie.cleared.toString()} stored log${ie.cleared===1?"":"s"} for this session${Z.truncated?". More history may remain.":"."}`,tone:Z.truncated?"error":"success"})}finally{$.current===F&&(y(!1),re())}},[n,m,r,u,P,re,X]),nt=l.useCallback(()=>{if(e!==void 0){Le({kind:"newest"});return}if(r==="__all__"){le();return}We(r)},[e,Le,le,We,r]),q=l.useCallback(async F=>{const W=new FormData;W.set("file",F);const Z=await Ke("/api/logs/import",cg,{method:"POST",body:W});return s(ne=>{const Ee=new Set(Z.logs.map(oe=>oe.id)),ie=RR(ne.filter(oe=>!Ee.has(oe.id)),Z.logs);return D.current=On(ie),ie}),o(Z.sessionId),i("__all__"),v(null),m(),Z},[m]),{strip:se,captureMode:xe,slowResponseThresholdSeconds:me,timeDisplayFormat:we}=rl(),Oe=xe,$e=l.useCallback(()=>{Le({kind:"oldest"})},[Le]),z=l.useCallback(()=>{Le({kind:"newest"})},[Le]),Y=l.useCallback(()=>{const F=n[0],W=g?.oldestLogId??F?.id??null;W!==null&&Le({kind:"older",beforeLogId:W})},[n,Le,g]),de=l.useCallback(()=>{const F=n[n.length-1],W=g?.newestLogId??F?.id??null;W!==null&&Le({kind:"newer",afterLogId:W})},[n,Le,g]),Ne=l.useMemo(()=>{if(e!==void 0)return{isLoading:w,loadProgress:S,total:g?.total??null,pageSize:g?.limit??tc,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:$e,onOlder:Y,onNewer:de,onNewest:z}},[e,z,de,Y,$e,g,S,w]);return t.jsxs(t.Fragment,{children:[t.jsx(ch,{notice:p,onDismiss:m}),t.jsx(xb,{}),t.jsx(_R,{logs:Se,sessions:_e,models:ge,selectedSession:r,selectedModel:a,onSessionChange:o,onModelChange:i,onClearAll:Ye,onDeleteCurrentView:ot,onReloadSession:e!==void 0||r!=="__all__"?nt:void 0,onClearGroup:Qe,onNotify:u,onImportLogs:e===void 0?q:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||w,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:dt,onStopLiveConnection:He,pagination:Ne,sessionLoadProgress:S,sessionLoadError:b??void 0,sessionMemberships:C,viewMode:Oe,captureMode:xe,strip:se,slowResponseThresholdSeconds:me,timeDisplayFormat:we,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{yn as $,G_ as A,Te as B,j0 as C,Nt as D,JR as E,Ze as F,be as G,WN as H,Ku as I,YR as J,Fu as K,uN as L,Yu as M,GN as N,KN as O,XR as P,qn as Q,P1 as R,Z_ as S,qf as T,Mi as U,vo as V,l_ as W,dr as X,i0 as Y,Zs as Z,G as _,pS as a,Ue as a0,yu as a1,sN as a2,Vg as a3,pc as b,B as c,Ju as d,ct as e,De as f,If as g,yt as h,Ct as i,Tt as j,_t as k,Zu as l,Hf as m,Zt as n,ut as o,l1 as p,Ps as q,bo as r,pt as s,mt as t,ml as u,ft as v,ks as w,Xs as x,LE as y,K_ as z};
|