@tonyclaw/agent-inspector 4.0.13 → 4.0.15
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 +2 -2
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-C1qBqYEd.mjs → router-Bo_F-5h9.mjs} +1 -1
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-B6l7sK_o.js → CompareDrawer-CNPUAqqq.js} +1 -1
- package/.output/ui/assets/{InspectorPet-Dv-hDdxU.js → InspectorPet-DxAsc8lx.js} +1 -1
- package/.output/ui/assets/ProxyViewerContainer-Bwe4QL2S.js +60 -0
- package/.output/ui/assets/{ReplayDialog-BACtWGKs.js → ReplayDialog-Bc4vimjF.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-DqG3yRes.js → RequestAnatomy-yeN5GbTc.js} +1 -1
- package/.output/ui/assets/{ResponseView-CwqmhaXg.js → ResponseView-CK_ptAYd.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DMdSkso8.js → StreamingChunkSequence-BDKjhP6X.js} +1 -1
- package/.output/ui/assets/{_sessionId-Ca0TjDw_.js → _sessionId-CVhc5tvd.js} +1 -1
- package/.output/ui/assets/{_sessionId-C_2LW0jh.js → _sessionId-CvW-74yT.js} +1 -1
- package/.output/ui/assets/{index-DZdFLvt4.js → index-C38ZXMiO.js} +1 -1
- package/.output/ui/assets/{index-Dt0cOy7U.js → index-C93Za-A-.js} +1 -1
- package/.output/ui/assets/index-CIvE7pNX.css +1 -0
- package/.output/ui/assets/{index-OquTzqLZ.js → index-aIBPEJYm.js} +3 -3
- package/.output/ui/assets/{index-C85xqQrL.js → index-vyBnNK5P.js} +1 -1
- package/.output/ui/assets/{json-viewer-DIr-vdVp.js → json-viewer-6eqK-eC8.js} +1 -1
- package/.output/ui/assets/{jszip.min-D5ch91g-.js → jszip.min-BnFCqmFJ.js} +1 -1
- package/.output/ui/index.html +5 -4
- package/package.json +4 -4
- package/.output/ui/assets/ProxyViewerContainer-B5SUiugd.js +0 -60
- package/.output/ui/assets/index-B-Qod-aA.css +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-BnFCqmFJ.js","./index-aIBPEJYm.js","./index-CIvE7pNX.css","./CompareDrawer-CNPUAqqq.js","./InspectorPet-DxAsc8lx.js","./ReplayDialog-Bc4vimjF.js","./ResponseView-CK_ptAYd.js","./RequestAnatomy-yeN5GbTc.js","./StreamingChunkSequence-BDKjhP6X.js","./json-viewer-6eqK-eC8.js","./index-C93Za-A-.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as Zh,u as Gt,s as x,n as T,b as Ce,_ as Xr,a as V,c as qe,o as _,d as pe,e as ae,f as _n,g as qs,h as qt,i as uu,k as Ke,r as l,j as t,m as Kt,p as vn,A as rc,q as Qh,t as da,v as Eo,w as Cs,x as P,B as Q,y as qn,z as pu,C as Ie,D as mu,E as wt,F as Ro,G as ex,H as Be,L as Zr,I as fu,J as tx,K as Qr,M as hu,N as nx,O as Fi,P as sx,Q as Bi,T as rx,U as ox}from"./index-aIBPEJYm.js";const Xe=Zh(()=>Gt([x(),T(),Ce(),Xr(),V(Xe),qe(x(),Xe)])),Mt=T().int().nonnegative().max(Number.MAX_SAFE_INTEGER),ax=pe(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),xu=_({index:T(),timestamp:T(),type:x(),data:Xe}),ix=_({id:x(),logId:Mt,index:T().int().nonnegative(),provider:pe(["anthropic","openai"]),name:x(),argumentsText:x().nullable(),argumentsPreview:x().nullable()}),lx=pe(["end_turn","tool_use","stop","length"]),cx=lx.nullable(),dx=_({chunks:V(xu),truncated:Ce().optional().default(!1)}),ux=pe(["request","response"]),gu=_({logId:Mt,part:ux,text:x(),offset:T().int().nonnegative(),limit:T().int().positive(),totalBytes:T().int().nonnegative(),textBytes:T().int().nonnegative(),nextOffset:T().int().nonnegative().nullable(),hasMore:Ce(),contentMode:pe(["empty","partial","full"])}),Gs=_({id:Mt,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:T().nullable(),responseText:x().nullable(),inputTokens:T().nullable(),outputTokens:T().nullable(),cacheCreationInputTokens:T().nullable(),cacheReadInputTokens:T().nullable(),elapsedMs:T().nullable(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().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:Mt.nullable().optional(),providerName:x().nullable().optional(),clientPort:T().nullable().optional(),clientPid:T().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:dx.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:T().int().nonnegative().nullable().optional(),responseTextBytes:T().int().nonnegative().nullable().optional(),bodyContentMode:pe(["full","compact","truncated"]).optional(),captureIncomplete:Ce().optional(),droppedChunks:T().int().nonnegative().optional(),droppedBytes:T().int().nonnegative().optional(),captureIncompleteReason:ax.nullable().optional(),warnings:V(x()).optional(),toolTraceEvents:V(ix).optional(),stopReason:cx.optional(),error:x().nullable().optional()}),Ui=_({type:x(),ttl:x().optional(),scope:x().optional()}),qi=_({type:ae("text"),text:x(),cache_control:Ui.optional()}),bu=_({type:ae("thinking"),thinking:x(),signature:x().optional()}),px=_({type:ae("think"),thinking:x(),signature:x().optional()}),mx=_({type:ae("base64"),media_type:x(),data:x()}),vu=_({type:ae("image"),source:mx}),yu=_({type:ae("tool_use"),id:x(),name:x(),input:qe(x(),Xe)}),fx=_n("type",[qi,vu]),hx=_({type:ae("tool_result"),tool_use_id:x().optional(),content:Gt([x(),V(fx)]),is_error:Ce().optional()}),xx=_n("type",[qi,bu,vu,yu,hx]),gx=Gt([x(),V(xx)]),bx=_({role:pe(["user","assistant"]),content:gx}),vx=_({type:ae("text"),text:x(),cache_control:Ui.optional()}),yx=_({type:x(),properties:qe(x(),qe(x(),Xe)).optional(),required:V(x()).optional(),additionalProperties:Ce().optional(),$schema:x().optional()}),wx=_({name:x(),description:x().optional(),input_schema:yx.optional(),cache_control:Ui.optional()}),jx=_n("type",[_({type:ae("enabled"),budget_tokens:T()}),_({type:ae("disabled")}),_({type:ae("adaptive")})]),Sx=_({model:x(),messages:V(bx),system:V(vx).optional(),tools:V(wx).optional(),max_tokens:T().optional(),temperature:T().optional(),stream:Ce().optional(),thinking:jx.optional(),metadata:_({user_id:x().optional()}).optional()}),Hi=_n("type",[qi,bu,px,yu]),Nx=_({input_tokens:T().nullable().optional(),output_tokens:T().nullable().optional(),cache_creation_input_tokens:T().nullable().optional(),cache_read_input_tokens:T().nullable().optional()}).passthrough(),Cx=_({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V(Hi),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:Nx}).passthrough(),kx=_({type:ae("message_start"),message:_({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V(Hi),stop_reason:Xr(),stop_sequence:Xr(),usage:_({input_tokens:T(),cache_creation_input_tokens:T().optional(),cache_read_input_tokens:T().optional()}).passthrough()})}),_x=_({type:ae("content_block_start"),index:T(),content_block:Hi}),Tx=_n("type",[_({type:ae("text_delta"),text:x()}),_({type:ae("input_json_delta"),partial_json:x()}),_({type:ae("thinking_delta"),thinking:x()}),_({type:ae("signature_delta"),signature:x()})]),Ex=_({type:ae("content_block_delta"),index:T(),delta:Tx}),Rx=_({type:ae("content_block_stop"),index:T()}),Mx=_({type:ae("message_delta"),delta:_({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:_({output_tokens:T(),input_tokens:T().optional(),cache_creation_input_tokens:T().optional(),cache_read_input_tokens:T().optional()}).passthrough()}),Ax=_({type:ae("message_stop")}),Ix=_({type:ae("ping")}),Px=_({type:ae("error"),error:_({type:x(),message:x()})});_n("type",[kx,_x,Ex,Rx,Mx,Ax,Ix,Px]);const Lx=Gt([x(),V(_n("type",[_({type:ae("text"),text:x()}),_({type:ae("image_url"),image_url:_({url:x(),detail:x().optional()})})]))]),wu=_({role:pe(["system","user","assistant","tool"]),content:Lx,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),Ox=_({name:x(),arguments:x()}),ju=_({index:T().optional(),id:x().optional(),type:ae("function").optional(),function:_({name:x().optional(),arguments:x().optional()})});wu.extend({content:Gt([x(),V(_({type:ae("text"),text:x()}))]).optional(),function_call:Ox.optional(),tool_calls:V(ju).optional()});const Dx=_({type:ae("function"),function:_({name:x(),description:x().optional(),parameters:qe(x(),Xe)})}),zx=_({model:x(),messages:V(wu),temperature:T().optional(),max_tokens:T().optional(),stream:Ce().optional(),tools:V(Dx).optional(),tool_choice:Gt([pe(["auto","none","required"]),_({type:ae("auto")}),_({type:ae("none")}),_({type:ae("function"),function:_({name:x()})})]).optional(),user:x().optional()}),$x=_({type:x(),name:x().optional(),description:x().optional(),parameters:Xe.optional(),function:_({name:x().optional(),description:x().optional(),parameters:Xe.optional()}).optional()}).passthrough(),Fx=_({model:x(),input:qs().optional(),instructions:Gt([x(),Xr()]).optional(),stream:Ce().optional(),tools:V($x).optional(),tool_choice:qs().optional(),max_output_tokens:T().optional(),temperature:T().optional(),user:x().optional(),metadata:qe(x(),qs()).optional()}).passthrough(),Su=_({role:pe(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:_({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:V(_({index:T(),id:x().optional(),type:ae("function").optional(),function:_({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),Bx=_({index:T(),message:_({role:pe(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:_({name:x(),arguments:x()}).nullable().optional(),tool_calls:V(ju).optional()}).optional(),delta:Su.optional(),finish_reason:x().nullable()}),Ux=_({id:x(),object:ae("chat.completion"),created:T(),model:x(),choices:V(Bx),usage:_({prompt_tokens:T().nullable().optional(),completion_tokens:T().nullable().optional(),total_tokens:T().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();_({id:x(),object:ae("chat.completion.chunk"),created:T(),model:x(),choices:V(_({index:T(),delta:Su,finish_reason:x().nullable().optional()})),usage:_({prompt_tokens:T().nullable().optional(),completion_tokens:T().nullable().optional(),total_tokens:T().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const qx=_({input_tokens:T().nullable().optional(),output_tokens:T().nullable().optional(),total_tokens:T().nullable().optional(),input_tokens_details:_({cached_tokens:T().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:_({reasoning_tokens:T().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Hx=_({type:x()}).passthrough(),Vx=_({id:x(),object:ae("response").optional(),created_at:T().optional(),status:x().nullable().optional(),model:x().optional(),output:V(Hx).optional(),output_text:x().optional(),usage:qx.nullable().optional(),error:qs().optional()}).passthrough();_({type:x()}).passthrough();function Wx(e){try{const n=JSON.parse(e),s=Ux.safeParse(n);return s.success?s.data:null}catch{return null}}function Gx(e){try{const n=JSON.parse(e),s=Vx.safeParse(n);return s.success?s.data:null}catch{return null}}const Nu=_({input:T().int().nonnegative(),output:T().int().nonnegative(),cacheCreate:T().int().nonnegative(),cacheRead:T().int().nonnegative(),total:T().int().nonnegative()}),Kx=_({id:Mt,sessionLogNumber:T().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:pe(["anthropic","openai","unknown"]),method:x(),path:x(),status:T().nullable(),isStreaming:Ce(),hasError:Ce(),error:x().nullable(),latencyMs:T().nullable(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),tokens:_({input:T().nullable(),output:T().nullable(),cacheCreate:T().nullable(),cacheRead:T().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:T().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Cu=_({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:T().int().nonnegative(),activeRequests:T().int().nonnegative(),completedRequests:T().int().nonnegative(),failedRequests:T().int().nonnegative(),queuedTasks:T().int().nonnegative(),runningTasks:T().int().nonnegative(),lastTaskError:x().nullable(),logCount:T().int().nonnegative(),errorCount:T().int().nonnegative(),models:V(x()),providers:V(x()),tokenUsage:Nu,lastLogId:Mt.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:T().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:T().int().positive(),latestLogs:V(Kx)}),sr=pe(["created","running","completed","failed","cancelled"]),Vi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Yx=pe(["run-created","session-started","request","session-finished","evidence-exported"]),Jx=pe(["info","success","warning","error"]),Xx=_({timestamp:x(),kind:Yx,severity:Jx,title:x(),details:x(),logId:Mt.nullable(),status:T().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:T().nullable(),isStreaming:Ce().nullable()}),Zx=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"]),ku=_({outcome:pe(["success","failure","active","unknown"]),severity:pe(["none","low","medium","high"]),category:Zx,summary:x(),evidenceLogIds:V(Mt),hints:V(x())}),Wi=_({status:pe(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),_u=Wi,Gi=_({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:sr,tags:V(x()),metadata:qe(x(),Xe),evidence:Vi.nullable(),createdAt:x(),updatedAt:x()});_({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:sr.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()}).optional();_({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:sr.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()});_({includeHistory:Ce().optional(),latestLogLimit:T().int().positive().max(50).optional()}).optional();_({run:Gi,evidence:Vi,session:Cu.nullable(),timeline:V(Xx),classification:ku,jenkinsReport:Wi});const Qx=_({run:Gi,classification:ku,evidence:Vi.nullable(),jenkinsReport:Wi.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});_({failures:V(Qx),total:T().int().nonnegative(),limit:T().int().positive()});const Ki=pe(["created","running","completed","failed","cancelled"]),Yi=pe(["evaluation","batch","manual"]),Ji=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Tu=_({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:sr.nullable(),metadata:qe(x(),Xe),addedAt:x(),updatedAt:x()}),Xi=_({id:x(),title:x(),kind:Yi,task:x().nullable(),project:x().nullable(),status:Ki,tags:V(x()),metadata:qe(x(),Xe),evidence:Ji.nullable(),members:V(Tu),createdAt:x(),updatedAt:x()});_({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Yi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ki.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()}).optional();_({title:x().min(1).optional(),kind:Yi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ki.optional(),tags:V(x()).optional(),metadata:qe(x(),Xe).optional()});_({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:sr.nullable().optional(),metadata:qe(x(),Xe).optional()});_({includeHistory:Ce().optional(),latestLogLimit:T().int().positive().max(50).optional()}).optional();_({deleteEvidence:Ce().optional()});const Eu=_({groupId:x(),deleted:Ce(),evidenceDeleted:Ce(),evidencePath:x().nullable()}),Ru=_({deleted:T().int().nonnegative(),groups:V(Eu)}),Mu=_({member:Tu,run:Gi.nullable(),session:Cu.nullable()}),Au=_({memberCount:T().int().nonnegative(),sessionsWithData:T().int().nonnegative(),missingSessions:T().int().nonnegative(),requestCount:T().int().nonnegative(),errorCount:T().int().nonnegative(),tokenUsage:Nu,models:V(x()),providers:V(x()),completedMembers:T().int().nonnegative(),failedMembers:T().int().nonnegative(),runningMembers:T().int().nonnegative()}),eg=_({group:Xi,evidence:Ji,members:V(Mu).nullable(),markdown:x(),summary:Au.nullable(),report:_u.nullable()}),tg=_({group:Xi,evidence:Ji,members:V(Mu),summary:Au,jenkinsReport:_u}),Iu=_({groups:V(Xi)}),ng=_({sessionId:x(),imported:T().int().nonnegative(),skipped:T().int().nonnegative(),warnings:V(x()),logs:V(Gs)}),eo=10,si=600,to=60,ri=600,no="time",Zi="simple",Pu=pe(["time","full"]),sg=pe(["simple","full"]),Mo=_({stripClaudeCodeBillingHeader:Ce(),hasSeenOnboarding:Ce().default(!1),slowResponseThresholdSeconds:T().int().min(0).max(si).default(eo),providerTestTimeoutSeconds:T().int().min(1).max(ri).default(to),timeDisplayFormat:Pu.default(no),captureMode:sg.default(Zi)}),is="/api/config";async function rg(e){return Ke(e,Mo,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function mr(e){return Ke(is,Mo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function Qi(){const e=qt(is,rg,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=uu(),s=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??Zi,o=e.data?.slowResponseThresholdSeconds??eo,a=e.data?.providerTestTimeoutSeconds??to,i=e.data?.timeDisplayFormat??no,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??eo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??to,timeDisplayFormat:e.data?.timeDisplayFormat??no,captureMode:r,...f}),d=async f=>{await n(is,mr({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await n(is,mr({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await n(is,mr({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await n(is,mr({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 Lu=(...e)=>e.filter((n,s,r)=>!!n&&n.trim()!==""&&r.indexOf(n)===s).join(" ").trim();const og=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const ag=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,s,r)=>r?r.toUpperCase():s.toLowerCase());const oc=e=>{const n=ag(e);return n.charAt(0).toUpperCase()+n.slice(1)};var ig={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 lg=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const cg=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,...ig,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:Lu("lucide",o),...!a&&!lg(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(cg,{ref:a,iconNode:n,className:Lu(`lucide-${og(oc(e))}`,`lucide-${e}`,r),...o}));return s.displayName=oc(e),s};const dg=[["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"}]],ug=B("a-large-small",dg);const pg=[["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"}]],mg=B("activity",pg);const fg=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],hg=B("arrow-down-right",fg);const xg=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],gg=B("arrow-down",xg);const bg=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],vg=B("arrow-left",bg);const yg=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],wg=B("arrow-up-right",yg);const jg=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sg=B("arrow-up",jg);const Ng=[["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"}]],el=B("beaker",Ng);const Cg=[["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"}]],kg=B("bell",Cg);const _g=[["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"}]],Tg=B("blocks",_g);const Eg=[["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"}]],Rg=B("brain-circuit",Eg);const Mg=[["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"}]],Ou=B("brain",Mg);const Ag=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],$e=B("check",Ag);const Ig=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ze=B("chevron-down",Ig);const Pg=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Lg=B("chevron-left",Pg);const Og=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],bt=B("chevron-right",Og);const Dg=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],tl=B("chevron-up",Dg);const zg=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],$g=B("chevrons-down",zg);const Fg=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Bg=B("chevrons-left",Fg);const Ug=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],qg=B("chevrons-right",Ug);const Hg=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Vg=B("chevrons-up",Hg);const Wg=[["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",Wg);const Gg=[["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"}]],Kg=B("circle-arrow-up",Gg);const Yg=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],rr=B("circle-check-big",Yg);const Jg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ks=B("circle-check",Jg);const Xg=[["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"}]],Zg=B("circle-question-mark",Xg);const Qg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],e0=B("circle-stop",Qg);const t0=[["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"}]],Du=B("circle-x",t0);const n0=[["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"}]],s0=B("clapperboard",n0);const r0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],o0=B("clock-3",r0);const a0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],en=B("clock",a0);const i0=[["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"}]],l0=B("cloud-upload",i0);const c0=[["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"}]],zu=B("code-xml",c0);const d0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],u0=B("columns-2",d0);const p0=[["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"}]],St=B("copy",p0);const m0=[["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"}]],f0=B("cpu",m0);const h0=[["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"}]],ks=B("download",h0);const x0=[["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"}]],g0=B("ellipsis",x0);const b0=[["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"}]],or=B("external-link",b0);const v0=[["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"}]],y0=B("eye-off",v0);const w0=[["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"}]],$u=B("eye",w0);const j0=[["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"}]],S0=B("file-braces",j0);const N0=[["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"}]],C0=B("file-diff",N0);const k0=[["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"}]],_0=B("file-search",k0);const T0=[["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"}]],E0=B("file-terminal",T0);const R0=[["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"}]],M0=B("file-text",R0);const A0=[["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"}]],I0=B("flag",A0);const P0=[["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"}]],Fu=B("flask-conical",P0);const L0=[["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"}]],O0=B("folder-open",L0);const D0=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],nl=B("gauge",D0);const z0=[["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"}]],$0=B("git-compare-arrows",z0);const F0=[["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"}]],Bu=B("globe",F0);const B0=[["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"}]],Uu=B("history",B0);const U0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],qu=B("info",U0);const q0=[["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"}]],ac=B("layers",q0);const H0=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=B("loader-circle",H0);const V0=[["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"}]],W0=B("lock",V0);const G0=[["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"}]],K0=B("maximize-2",G0);const Y0=[["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"}]],Ao=B("message-square",Y0);const J0=[["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"}]],X0=B("minimize-2",J0);const Z0=[["path",{d:"M5 12h14",key:"1ays0h"}]],Hu=B("minus",Z0);const Q0=[["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"}]],e1=B("monitor",Q0);const t1=[["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"}]],n1=B("moon",t1);const s1=[["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"}]],r1=B("mouse-pointer-click",s1);const o1=[["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"}]],a1=B("network",o1);const i1=[["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"}]],l1=B("octagon-alert",i1);const c1=[["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"}]],d1=B("package-check",c1);const u1=[["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"}]],p1=B("panel-right-close",u1);const m1=[["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"}]],f1=B("panel-right-open",m1);const h1=[["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"}]],Vu=B("pencil",h1);const x1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ic=B("plus",x1);const g1=[["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"}]],lc=B("radio",g1);const b1=[["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",b1);const v1=[["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"}]],Wu=B("rocket",v1);const y1=[["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"}]],Gu=B("rotate-ccw",y1);const w1=[["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"}]],so=B("rotate-cw",w1);const j1=[["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"}]],S1=B("rows-3",j1);const N1=[["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"}]],C1=B("save",N1);const k1=[["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"}]],_1=B("scan",k1);const T1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],E1=B("search",T1);const R1=[["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"}]],M1=B("send",R1);const A1=[["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"}]],I1=B("server",A1);const P1=[["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"}]],L1=B("settings",P1);const O1=[["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"}]],D1=B("shield-alert",O1);const z1=[["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"}]],cc=B("shield-check",z1);const $1=[["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"}]],ro=B("siren",$1);const F1=[["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"}]],oi=B("sparkles",F1);const B1=[["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"}]],U1=B("sun",B1);const q1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Hn=B("terminal",q1);const H1=[["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"}]],Ku=B("timer",H1);const V1=[["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",V1);const W1=[["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",W1);const G1=[["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"}]],Yu=B("upload",G1);const K1=[["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"}]],Y1=B("wifi-off",K1);const J1=[["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"}]],X1=B("wifi",J1);const Z1=[["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"}]],ar=B("wrench",Z1);const Q1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ir=B("x",Q1);const eb=[["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"}]],Ys=B("zap",eb),ai="/api/config";async function tb(e){return Ke(e,Mo,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function nb(e){return Ke(ai,Mo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function sb(){const e=qt(ai,tb,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=uu(),s=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??Zi,o=async()=>{await n(ai,nb({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??eo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??to,timeDisplayFormat:e.data?.timeDisplayFormat??no,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:r,isLoading:e.isLoading,markSeen:o}}function rb({isLoading:e,hasSeenOnboarding:n,dismissedInView:s}){return!e&&!n&&!s}function ob({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(qu,{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($e,{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(ir,{className:"size-3.5"})})]})})}function ab(){const{hasSeenOnboarding:e,isLoading:n,markSeen:s}=sb(),[r,o]=l.useState(!1),[a,i]=l.useState(!1);return rb({isLoading:n,hasSeenOnboarding:e,dismissedInView:a})?t.jsx(ob,{expanded:r,onToggle:()=>o(c=>!c),onDismiss:()=>{i(!0),s().catch(()=>{})}}):null}const ib="@tonyclaw/agent-inspector",lb="4.0.15",cb="module",db="Agent observability and knowledge capture layer for AI coding tools.",ub="MIT",pb={node:">=22.0.0"},mb="TonyClaw",fb={type:"git",url:"git+https://gitcode.com/TonyClaw/OpenInspector.git"},hb="https://gitcode.com/TonyClaw/OpenInspector#readme",xb=["packages/*"],gb={url:"https://gitcode.com/TonyClaw/OpenInspector/issues"},bb={access:"public",registry:"https://registry.npmjs.org/"},vb=["claude","anthropic","openai","proxy","api-inspector","agent-observability","agent-memory","debugging","llm","ai-coding-tools"],yb={"agent-inspector":"bin/agent-inspector.js"},wb=["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"],jb={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"},Sb={"@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"},Nb={"@tonyclaw/agent-inspector-backend-darwin-arm64":"4.0.15","@tonyclaw/agent-inspector-backend-linux-x64-gnu":"4.0.15","@tonyclaw/agent-inspector-backend-win32-x64-msvc":"4.0.15","better-sqlite3":"^12.11.1",rcedit:"4.0.1"},Cb={"@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"},kb={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"},oo={name:ib,version:lb,type:cb,description:db,license:ub,engines:pb,author:mb,repository:fb,homepage:hb,workspaces:xb,bugs:gb,publishConfig:bb,keywords:vb,bin:yb,files:wb,scripts:jb,dependencies:Sb,optionalDependencies:Nb,devDependencies:Cb,overrides:kb};function ls(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ju="[REDACTED]",_b=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,Tb=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],dc=200,Eb=25e6,Xu=50,Rb=1e4,Mb=1024*1024,Ab=64,Ib=1e4;function Pb(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function Lb(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 Ob(e){if(e.length>dc)return`Export is limited to ${dc} logs at once. Narrow the filter and try again.`;const n=Lb(e);return n>Eb?`Export is too large (${Pb(n)} of text). Narrow the filter and try again.`:null}function fr(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function Db(e,n){try{const s=await vn(`/api/logs/${e}/chunks`,Rb,{signal:n});if(!s.ok)return null;const r=await s.json();return JSON.stringify(r,null,2)}catch{return null}}function zb(e,n){switch(n){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function uc(e,n,s){const r=zb(e,n);if(r!==null)return r;let o=0,a="";for(let i=0;i<Ab;i+=1){const c=new URLSearchParams({part:n,offset:String(o),limit:String(Mb)});try{const d=await vn(`/api/logs/${String(e.id)}/body?${c.toString()}`,Ib,{signal:s});if(!d.ok)return a.length>0?a:null;const p=await d.json(),u=gu.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 ii(e){if(Array.isArray(e))return e.map(s=>ii(s));if(!ls(e))return e;const n={};for(const[s,r]of Object.entries(e))n[s]=_b.test(s)?Ju:ii(r);return n}function $b(e){const n=s=>{let r=s;for(const o of Tb)r=r.replace(o,Ju);return r};try{const s=JSON.parse(e);return n(JSON.stringify(ii(s),null,2))}catch{return n(e)}}function ua(e,n){return n==="redacted"?$b(e):e}function Fb(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 Bb(e,n,s,r=new Date().toISOString()){return{version:oo.version,exportedAt:r,mode:n,redacted:n==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:Xu,streamingChunkLogIds:s.map(o=>o.id)}}async function Ub(e,n="redacted",s={}){const r=fr(s.signal);if(r!==null)return r;const o=Ob(e);if(o!==null)return{ok:!1,message:o};const{default:a}=await Kt(async()=>{const{default:h}=await import("./jszip.min-BnFCqmFJ.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,Xu);i.file("manifest.json",JSON.stringify(Bb(e,n,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>Fb(h,n)),null,2));for(const h of e){const g=fr(s.signal);if(g!==null)return g;const v=await uc(h,"request",s.signal);v!==null&&i.file(`#${h.id}.Request.json`,ua(v,n));const w=await uc(h,"response",s.signal);w!==null&&i.file(`#${h.id}.Response.json`,ua(w,n))}for(const h of d){const g=fr(s.signal);if(g!==null)return g;const v=await Db(h.id,s.signal);v!==null&&i.file(`#${h.id}.SSE.Response.json`,ua(v,n))}const p=await i.generateAsync({type:"blob"}),u=fr(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=da(e,"/proxy"),s=da(e,"/proxy/v1"),r=da(e,"/api/mcp");return n===null||s===null||r===null?null:{proxy:n,openAiV1:s,mcp:r}}function Hb(){const e=Qh();return e.ok?qb(e.runtime):null}function sl(e){const n=()=>e(Hb());return n(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(rc,n),()=>globalThis.removeEventListener(rc,n))}function li(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 Io(e,n,s){return`${li(e,s)} - ${li(n,s)}`}const rl="agent-inspector.theme";function Zu(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 pa(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function Vb(){if(typeof window>"u")return"dark";try{return Zu(window.localStorage.getItem(rl))}catch{return"dark"}}function Wb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(rl,e)}catch{}}function Gb(){const[e,n]=l.useState(Vb),s=l.useCallback(r=>{n(r),pa(r),Wb(r)},[]);return l.useEffect(()=>{pa(e)},[e]),l.useEffect(()=>{function r(o){if(o.key!==rl)return;const a=Zu(o.newValue);n(a),pa(a)}return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{themeMode:e,setThemeMode:s}}const ol="agent-inspector.uiScale",Kb=1.25,Yb=2200,Jb=3e3,Xb=12;function ma(e,n){return Number.isFinite(e)&&e>0?e:n}function al(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 Zb(e,n){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=ma(n.viewportWidth,1280),r=ma(n.screenWidth,s),o=ma(n.devicePixelRatio,1),a=Math.min(s,r);return o>Kb?1:a>=Jb?1.25:a>=Yb?1.125:1}}}function Qb(e){return`${Math.round(e*100)}%`}function fa(e,n){return Math.max(Xb,e*n)}function ev(){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 ha(e){const n=Zb(e,ev());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(fa(9,n))}px`),s.style.setProperty("--inspector-font-10",`${String(fa(10,n))}px`),s.style.setProperty("--inspector-font-11",`${String(fa(11,n))}px`),s.style.setProperty("--inspector-font-13",`${String(13*n)}px`),n}function tv(){if(typeof window>"u")return"auto";try{return al(window.localStorage.getItem(ol))}catch{return"auto"}}function nv(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ol,e)}catch{}}function sv(){const[e,n]=l.useState(tv),[s,r]=l.useState(1),o=l.useCallback(a=>{n(a),nv(a),r(ha(a))},[]);return l.useEffect(()=>{const a=()=>{r(ha(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==ol)return;const c=al(i.newValue);n(c),r(ha(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:o}}const rv=200,ov=512,av=256,wn=64,ci=256,Qu=64,iv=32,lv=2,cv=4,pc=16,ve=T().int().positive(),dv=_({proxy:_({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),control:_({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),upstream:_({fetchResponseBytes:ve,fetchDeadlineMs:ve,replayResponseBytes:ve,replayDeadlineMs:ve,metadataResponseBytes:ve,metadataDeadlineMs:ve,connectTimeoutMs:ve,idleTimeoutMs:ve}),pagination:_({restPageSize:ve,searchQueryChars:ve,searchProjectChars:ve}),sse:_({clients:ve,initLogs:ve,heartbeatMs:ve}),imports:_({archiveBytes:ve,entries:ve,entryBytes:ve,uncompressedBytes:ve,expansionRatio:ve}),fanOut:_({providerModels:ve,providerModelMetadata:ve,providerTestConcurrency:ve,activeProviderTests:ve}),queues:_({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"})});dv.parse({proxy:{requestBytes:64*1024*1024,responseBytes:256*1024*1024,headerBytes:64*1024,deadlineMs:12e4,idleTimeoutMs:3e4,activeRequests:pc},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:rv,searchQueryChars:ov,searchProjectChars:av},sse:{clients:iv,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:Qu,providerTestConcurrency:cv,activeProviderTests:lv},queues:{proxyRequests:pc,finalizerJobs:1e3,rawStreamMessages:16384,rawStreamBytes:64*1024*1024,backgroundWorkers:4}});const uv=pe(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),pv=Gt([ae(400),ae(413),ae(429),ae(503)]);_({error:x().min(1).max(300),code:uv,status:pv,resource:x().min(1).max(80),limit:T().int().positive(),retryable:Ce()});function hr(){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 il=x().max(ci),mv=V(il).max(wn),fv=_({model:il.min(1),contextWindow:T().int().positive().optional(),outputLimit:T().int().positive().optional(),source:pe(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),hv=V(fv).max(Qu),xv=_({id:x(),name:x(),apiKey:x(),model:il.optional(),models:mv.optional().default([]),format:pe(["anthropic","openai"]).optional(),baseUrl:hr().optional(),anthropicBaseUrl:hr().optional(),openaiBaseUrl:hr().optional(),openaiResponsesBaseUrl:hr().optional(),authHeader:pe(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:hv.optional(),source:pe(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),gv="configured",ao=xv.extend({apiKey:ae(gv)});async function bv(e){return Ke(e,ao.array(),void 0,n=>`Failed to fetch ${e}: ${n.status}`)}function ll(){const e=qt("/api/providers",bv,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function mc(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function vv(...e){return n=>{let s=!1;const r=e.map(o=>{const a=mc(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():mc(e[o],null)}}}}function Ae(...e){return l.useCallback(vv(...e),e)}function bs(e){const n=l.forwardRef((s,r)=>{let{children:o,...a}=s,i=null,c=!1;const d=[];fc(o)&&typeof xr=="function"&&(o=xr(o._payload)),l.Children.forEach(o,f=>{if(Cv(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;fc(g)&&typeof xr=="function"&&(g=xr(g._payload)),i=jv(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?Nv(i):void 0,u=Ae(r,p);if(!i){if(o||o===0)throw new Error(c?Ev(e):Tv(e));return o}const m=Sv(a,i.props??{});return i.type!==l.Fragment&&(m.ref=r?u:p),l.cloneElement(i,m)});return n.displayName=`${e}.Slot`,n}var yv=bs("Slot"),ep=Symbol.for("radix.slottable");function wv(e){const n=s=>"child"in s?s.children(s.child):s.children;return n.displayName=`${e}.Slottable`,n.__radixId=ep,n}var jv=(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 Sv(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 Nv(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 Cv(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ep}var kv=Symbol.for("react.lazy");function fc(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===kv&&"_payload"in e&&_v(e._payload)}function _v(e){return typeof e=="object"&&e!==null&&"then"in e}var Tv=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Ev=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,xr=Eo[" use ".trim().toString()],Rv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=Rv.reduce((e,n)=>{const s=bs(`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 Mv(e,n){e&&Cs.flushSync(()=>e.dispatchEvent(n))}var tp=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"}),Av="VisuallyHidden",np=l.forwardRef((e,n)=>t.jsx(be.span,{...e,ref:n,style:{...tp,...e.style}}));np.displayName=Av;var Iv=np;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,Pv(o,...n)]}function Pv(...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 sp(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=bs(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=bs(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:()=>{},Lv=Eo[" useInsertionEffect ".trim().toString()]||Ve;function $n({prop:e,defaultProp:n,onChange:s=()=>{},caller:r}){const[o,a,i]=Ov({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=Dv(u)?u(e):u;m!==e&&i.current?.(m)}else a(u)},[c,e,a,i]);return[d,p]}function Ov({defaultProp:e,onChange:n}){const[s,r]=l.useState(e),o=l.useRef(s),a=l.useRef(n);return Lv(()=>{a.current=n},[n]),l.useEffect(()=>{o.current!==s&&(a.current?.(s),o.current=s)},[s,o]),[s,r,a]}function Dv(e){return typeof e=="function"}function zv(e,n){return l.useReducer((s,r)=>n[s][r]??s,e)}var vt=e=>{const{present:n,children:s}=e,r=$v(n),o=typeof s=="function"?s({present:r.isPresent}):l.Children.only(s),a=Fv(r.ref,Bv(o));return typeof s=="function"||r.isPresent?l.cloneElement(o,{ref:a}):null};vt.displayName="Presence";function $v(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]=zv(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??Ps(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=Ps(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=Ps(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=Ps(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=Ps(m)}else r.current=null;s(u)},[])}}function hc(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Fv(...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=hc(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():hc(r[i],null)}}},[])}function Ps(e){return e?.animationName||"none"}function Bv(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 Uv=Eo[" useId ".trim().toString()]||(()=>{}),qv=0;function Ht(e){const[n,s]=l.useState(Uv());return Ve(()=>{s(r=>r??String(qv++))},[e]),e||(n?`radix-${n}`:"")}var Po="Collapsible",[Hv]=on(Po),[Vv,cl]=Hv(Po),rp=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:Po});return t.jsx(Vv,{scope:s,disabled:a,contentId:Ht(),open:d,onOpenToggle:l.useCallback(()=>p(u=>!u),[p]),children:t.jsx(be.div,{"data-state":ul(d),"data-disabled":a?"":void 0,...c,ref:n})})});rp.displayName=Po;var op="CollapsibleTrigger",ap=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,...r}=e,o=cl(op,s);return t.jsx(be.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":ul(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:n,onClick:ue(e.onClick,o.onOpenToggle)})});ap.displayName=op;var dl="CollapsibleContent",ip=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=cl(dl,e.__scopeCollapsible);return t.jsx(vt,{present:s||o.open,children:({present:a})=>t.jsx(Wv,{...r,ref:n,present:a})})});ip.displayName=dl;var Wv=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,present:r,children:o,...a}=e,i=cl(dl,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":ul(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 ul(e){return e?"open":"closed"}var Gv=rp,Kv=l.createContext(void 0);function Lo(e){const n=l.useContext(Kv);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 Yv="DismissableLayer",di="dismissableLayer.update",Jv="dismissableLayer.pointerDownOutside",Xv="dismissableLayer.focusOutside",xc,pl=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Oo=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(pl),[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=n2(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 M=[...u.branches].some(O=>O.contains(k));return N&&!M},[u.branches,N])}),A=s2(k=>{if(r&&C.current)return;const M=k.target;[...u.branches].some($=>$.contains(M))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),I=m?j===w.length-1:!1,R=Je(k=>{k.key==="Escape"&&(o?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(I)return h.addEventListener("keydown",R,{capture:!0}),()=>h.removeEventListener("keydown",R,{capture:!0})},[h,I,R]),l.useEffect(()=>{if(m)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(xc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(m)),u.layers.add(m),gc(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(m),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=xc))}},[m,h,s,u]),l.useEffect(()=>()=>{m&&(u.layers.delete(m),u.layersWithOutsidePointerEventsDisabled.delete(m),gc())},[m,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(di,k),()=>document.removeEventListener(di,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)})});Oo.displayName=Yv;var Zv="DismissableLayerBranch",Qv=l.forwardRef((e,n)=>{const s=l.useContext(pl),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})});Qv.displayName=Zv;function e2(){const e=l.useContext(pl),[n,s]=l.useState(null);return l.useEffect(()=>{if(n)return e.dismissableSurfaces.add(n),()=>{e.dismissableSurfaces.delete(n)}},[n,e.dismissableSurfaces]),s}var t2=()=>!0;function n2(e,n){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=t2}=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||lp(Jv,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 s2(e,n=globalThis?.document){const s=Je(e),r=l.useRef(!1);return l.useEffect(()=>{const o=a=>{a.target&&!r.current&&lp(Xv,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 gc(){const e=new CustomEvent(di);document.dispatchEvent(e)}function lp(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?Mv(o,a):o.dispatchEvent(a)}var xa="focusScope.autoFocusOnMount",ga="focusScope.autoFocusOnUnmount",bc={bubbles:!1,cancelable:!0},r2="FocusScope",ml=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){yc.add(h);const v=document.activeElement;if(!c.contains(v)){const y=new CustomEvent(xa,bc);c.addEventListener(xa,p),c.dispatchEvent(y),y.defaultPrevented||(o2(d2(cp(c)),{select:!0}),document.activeElement===v&&fn(c))}return()=>{c.removeEventListener(xa,p),setTimeout(()=>{const y=new CustomEvent(ga,bc);c.addEventListener(ga,u),c.dispatchEvent(y),y.defaultPrevented||fn(v??document.body,{select:!0}),c.removeEventListener(ga,u),yc.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]=a2(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})});ml.displayName=r2;function o2(e,{select:n=!1}={}){const s=document.activeElement;for(const r of e)if(fn(r,{select:n}),document.activeElement!==s)return}function a2(e){const n=cp(e),s=vc(n,e),r=vc(n.reverse(),e);return[s,r]}function cp(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 vc(e,n){const s=typeof n.checkVisibility=="function"&&n.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):i2(r,{upTo:n})))return r}function i2(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 l2(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&&l2(e)&&n&&e.select()}}var yc=c2();function c2(){let e=[];return{add(n){const s=e[0];n!==s&&s?.pause(),e=wc(e,n),e.unshift(n)},remove(n){e=wc(e,n),e[0]?.resume()}}}function wc(e,n){const s=[...e],r=s.indexOf(n);return r!==-1&&s.splice(r,1),s}function d2(e){return e.filter(n=>n.tagName!=="A")}var u2="Portal",Do=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?Cs.createPortal(t.jsx(be.div,{...r,ref:n}),i):null});Do.displayName=u2;var gr=0,Jn=null;function dp(){l.useEffect(()=>{Jn||(Jn={start:jc(),end:jc()});const{start:e,end:n}=Jn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==n&&document.body.insertAdjacentElement("beforeend",n),gr++,()=>{gr===1&&(Jn?.start.remove(),Jn?.end.remove(),Jn=null),gr=Math.max(0,gr-1)}},[])}function jc(){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 up(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 p2(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 Hr="right-scroll-bar-position",Vr="width-before-scroll-bar",m2="with-scroll-bars-hidden",f2="--removed-body-scroll-bar-size";function ba(e,n){return typeof e=="function"?e(n):e&&(e.current=n),e}function h2(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 x2=typeof window<"u"?l.useLayoutEffect:l.useEffect,Sc=new WeakMap;function g2(e,n){var s=h2(null,function(r){return e.forEach(function(o){return ba(o,r)})});return x2(function(){var r=Sc.get(s);if(r){var o=new Set(r),a=new Set(e),i=s.current;o.forEach(function(c){a.has(c)||ba(c,null)}),a.forEach(function(c){o.has(c)||ba(c,i)})}Sc.set(s,e)},[e]),s}function b2(e){return e}function v2(e,n){n===void 0&&(n=b2);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 y2(e){e===void 0&&(e={});var n=v2(null);return n.options=Bt({async:!0,ssr:!1},e),n}var pp=function(e){var n=e.sideCar,s=up(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))};pp.isSideCarExport=!0;function w2(e,n){return e.useMedium(n),pp}var mp=y2(),va=function(){},zo=l.forwardRef(function(e,n){var s=l.useRef(null),r=l.useState({onScrollCapture:va,onWheelCapture:va,onTouchMoveCapture:va}),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=up(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=g2([s,n]),E=Bt(Bt({},S),o);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:mp,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))});zo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};zo.classNames={fullWidth:Vr,zeroRight:Hr};var j2=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function S2(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var n=j2();return n&&e.setAttribute("nonce",n),e}function N2(e,n){e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n))}function C2(e){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(e)}var k2=function(){var e=0,n=null;return{add:function(s){e==0&&(n=S2())&&(N2(n,s),C2(n)),e++},remove:function(){e--,!e&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},_2=function(){var e=k2();return function(n,s){l.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&s])}},fp=function(){var e=_2(),n=function(s){var r=s.styles,o=s.dynamic;return e(r,o),null};return n},T2={left:0,top:0,right:0,gap:0},ya=function(e){return parseInt(e||"",10)||0},E2=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[ya(s),ya(r),ya(o)]},R2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return T2;var n=E2(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])}},M2=fp(),ps="data-scroll-locked",A2=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(m2,` {
|
|
4
|
+
overflow: hidden `).concat(r,`;
|
|
5
|
+
padding-right: `).concat(c,"px ").concat(r,`;
|
|
6
|
+
}
|
|
7
|
+
body[`).concat(ps,`] {
|
|
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(Hr,` {
|
|
21
|
+
right: `).concat(c,"px ").concat(r,`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.`).concat(Vr,` {
|
|
25
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.`).concat(Hr," .").concat(Hr,` {
|
|
29
|
+
right: 0 `).concat(r,`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.`).concat(Vr," .").concat(Vr,` {
|
|
33
|
+
margin-right: 0 `).concat(r,`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body[`).concat(ps,`] {
|
|
37
|
+
`).concat(f2,": ").concat(c,`px;
|
|
38
|
+
}
|
|
39
|
+
`)},Nc=function(){var e=parseInt(document.body.getAttribute(ps)||"0",10);return isFinite(e)?e:0},I2=function(){l.useEffect(function(){return document.body.setAttribute(ps,(Nc()+1).toString()),function(){var e=Nc()-1;e<=0?document.body.removeAttribute(ps):document.body.setAttribute(ps,e.toString())}},[])},P2=function(e){var n=e.noRelative,s=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;I2();var a=l.useMemo(function(){return R2(o)},[o]);return l.createElement(M2,{styles:A2(a,!n,o,s?"":"!important")})},ui=!1;if(typeof window<"u")try{var br=Object.defineProperty({},"passive",{get:function(){return ui=!0,!0}});window.addEventListener("test",br,br),window.removeEventListener("test",br,br)}catch{ui=!1}var Xn=ui?{passive:!1}:!1,L2=function(e){return e.tagName==="TEXTAREA"},hp=function(e,n){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[n]!=="hidden"&&!(s.overflowY===s.overflowX&&!L2(e)&&s[n]==="visible")},O2=function(e){return hp(e,"overflowY")},D2=function(e){return hp(e,"overflowX")},Cc=function(e,n){var s=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=xp(e,r);if(o){var a=gp(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},z2=function(e){var n=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[n,s,r]},$2=function(e){var n=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[n,s,r]},xp=function(e,n){return e==="v"?O2(n):D2(n)},gp=function(e,n){return e==="v"?z2(n):$2(n)},F2=function(e,n){return e==="h"&&n==="rtl"?-1:1},B2=function(e,n,s,r,o){var a=F2(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=gp(e,c),g=h[0],v=h[1],w=h[2],y=v-w-a*g;(g||y)&&xp(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},vr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},kc=function(e){return[e.deltaX,e.deltaY]},_c=function(e){return e&&"current"in e?e.current:e},U2=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
|
+
`)},H2=0,Zn=[];function V2(e){var n=l.useRef([]),s=l.useRef([0,0]),r=l.useRef(),o=l.useState(H2++)[0],a=l.useState(fp)[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=p2([e.lockRef.current],(e.shards||[]).map(_c),!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=vr(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,R=I?I===C||I.contains(C):!1;if(R)return!1;var k=Cc(E,C);if(!k)return!0;if(k?N=E:(N=E==="v"?"h":"v",k=Cc(E,C)),!k)return!1;if(!r.current&&"changedTouches"in v&&(j||S)&&(r.current=N),!N)return!0;var M=r.current||N;return B2(M,w,v,M==="h"?j:S)},[]),d=l.useCallback(function(v){var w=v;if(!(!Zn.length||Zn[Zn.length-1]!==a)){var y="deltaY"in w?kc(w):vr(w),b=n.current.filter(function(N){return N.name===w.type&&(N.target===w.target||w.target===N.shadowParent)&&U2(N.delta,y)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var j=(i.current.shards||[]).map(_c).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:W2(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=vr(v),r.current=void 0},[]),m=l.useCallback(function(v){p(v.type,kc(v),v.target,c(v,e.lockRef.current))},[]),f=l.useCallback(function(v){p(v.type,vr(v),v.target,c(v,e.lockRef.current))},[]);l.useEffect(function(){return Zn.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:f}),document.addEventListener("wheel",d,Xn),document.addEventListener("touchmove",d,Xn),document.addEventListener("touchstart",u,Xn),function(){Zn=Zn.filter(function(v){return v!==a}),document.removeEventListener("wheel",d,Xn),document.removeEventListener("touchmove",d,Xn),document.removeEventListener("touchstart",u,Xn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:q2(o)}):null,h?l.createElement(P2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function W2(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const G2=w2(mp,V2);var fl=l.forwardRef(function(e,n){return l.createElement(zo,Bt({},e,{ref:n,sideCar:G2}))});fl.classNames=zo.classNames;var K2=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Qn=new WeakMap,yr=new WeakMap,wr={},wa=0,bp=function(e){return e&&(e.host||bp(e.parentNode))},Y2=function(e,n){return n.map(function(s){if(e.contains(s))return s;var r=bp(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})},J2=function(e,n,s,r){var o=Y2(n,Array.isArray(e)?e:[e]);wr[s]||(wr[s]=new WeakMap);var a=wr[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=(Qn.get(f)||0)+1,w=(a.get(f)||0)+1;Qn.set(f,v),a.set(f,w),i.push(f),v===1&&g&&yr.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(),wa++,function(){i.forEach(function(m){var f=Qn.get(m)-1,h=a.get(m)-1;Qn.set(m,f),a.set(m,h),f||(yr.has(m)||m.removeAttribute(r),yr.delete(m)),h||m.removeAttribute(s)}),wa--,wa||(Qn=new WeakMap,Qn=new WeakMap,yr=new WeakMap,wr={})}},vp=function(e,n,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=K2(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),J2(r,o,s,"aria-hidden")):function(){return null}},$o="Dialog",[yp]=on($o),[X2,Ot]=yp($o),wp=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:$o});return t.jsx(X2,{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})};wp.displayName=$o;var jp="DialogTrigger",Sp=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Ot(jp,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":xl(o.open),...r,ref:a,onClick:ue(e.onClick,o.onOpenToggle)})});Sp.displayName=jp;var hl="DialogPortal",[Z2,Np]=yp(hl,{forceMount:void 0}),Cp=e=>{const{__scopeDialog:n,forceMount:s,children:r,container:o}=e,a=Ot(hl,n);return t.jsx(Z2,{scope:n,forceMount:s,children:l.Children.map(r,i=>t.jsx(vt,{present:s||a.open,children:t.jsx(Do,{asChild:!0,container:o,children:i})}))})};Cp.displayName=hl;var io="DialogOverlay",kp=l.forwardRef((e,n)=>{const s=Np(io,e.__scopeDialog),{forceMount:r=s.forceMount,...o}=e,a=Ot(io,e.__scopeDialog);return a.modal?t.jsx(vt,{present:r||a.open,children:t.jsx(ey,{...o,ref:n})}):null});kp.displayName=io;var Q2=bs("DialogOverlay.RemoveScroll"),ey=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Ot(io,s),a=e2(),i=Ae(n,a);return t.jsx(fl,{as:Q2,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(be.div,{"data-state":xl(o.open),...r,ref:i,style:{pointerEvents:"auto",...r.style}})})}),vs="DialogContent",_p=l.forwardRef((e,n)=>{const s=Np(vs,e.__scopeDialog),{forceMount:r=s.forceMount,...o}=e,a=Ot(vs,e.__scopeDialog);return t.jsx(vt,{present:r||a.open,children:a.modal?t.jsx(ty,{...o,ref:n}):t.jsx(ny,{...o,ref:n})})});_p.displayName=vs;var ty=l.forwardRef((e,n)=>{const s=Ot(vs,e.__scopeDialog),r=l.useRef(null),o=Ae(n,s.contentRef,r);return l.useEffect(()=>{const a=r.current;if(a)return vp(a)},[]),t.jsx(Tp,{...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())})}),ny=l.forwardRef((e,n)=>{const s=Ot(vs,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return t.jsx(Tp,{...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()}})}),Tp=l.forwardRef((e,n)=>{const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Ot(vs,s);return dp(),t.jsx(t.Fragment,{children:t.jsx(ml,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:t.jsx(Oo,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":xl(c.open),...i,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),Ep="DialogTitle",Rp=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Ot(Ep,s);return t.jsx(be.h2,{id:o.titleId,...r,ref:n})});Rp.displayName=Ep;var Mp="DialogDescription",Ap=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Ot(Mp,s);return t.jsx(be.p,{id:o.descriptionId,...r,ref:n})});Ap.displayName=Mp;var Ip="DialogClose",Pp=l.forwardRef((e,n)=>{const{__scopeDialog:s,...r}=e,o=Ot(Ip,s);return t.jsx(be.button,{type:"button",...r,ref:n,onClick:ue(e.onClick,()=>o.onOpenChange(!1))})});Pp.displayName=Ip;function xl(e){return e?"open":"closed"}function sy(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 ry(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 oy=["top","right","bottom","left"],Nn=Math.min,ft=Math.max,lo=Math.round,jr=Math.floor,Vt=e=>({x:e,y:e}),ay={left:"right",right:"left",bottom:"top",top:"bottom"},iy={start:"end",end:"start"};function pi(e,n,s){return ft(e,Nn(n,s))}function nn(e,n){return typeof e=="function"?e(n):e}function sn(e){return e.split("-")[0]}function _s(e){return e.split("-")[1]}function gl(e){return e==="x"?"y":"x"}function bl(e){return e==="y"?"height":"width"}const ly=new Set(["top","bottom"]);function Ut(e){return ly.has(sn(e))?"y":"x"}function vl(e){return gl(Ut(e))}function cy(e,n,s){s===void 0&&(s=!1);const r=_s(e),o=vl(e),a=bl(o);let i=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[a]>n.floating[a]&&(i=co(i)),[i,co(i)]}function dy(e){const n=co(e);return[mi(e),n,mi(n)]}function mi(e){return e.replace(/start|end/g,n=>iy[n])}const Tc=["left","right"],Ec=["right","left"],uy=["top","bottom"],py=["bottom","top"];function my(e,n,s){switch(e){case"top":case"bottom":return s?n?Ec:Tc:n?Tc:Ec;case"left":case"right":return n?uy:py;default:return[]}}function fy(e,n,s,r){const o=_s(e);let a=my(sn(e),s==="start",r);return o&&(a=a.map(i=>i+"-"+o),n&&(a=a.concat(a.map(mi)))),a}function co(e){return e.replace(/left|right|bottom|top/g,n=>ay[n])}function hy(e){return{top:0,right:0,bottom:0,left:0,...e}}function Lp(e){return typeof e!="number"?hy(e):{top:e,right:e,bottom:e,left:e}}function uo(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 Rc(e,n,s){let{reference:r,floating:o}=e;const a=Ut(n),i=vl(n),c=bl(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(_s(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 xy(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=Lp(h),w=c[f?m==="floating"?"reference":"floating":m],y=uo(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=uo(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 gy=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}=Rc(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:xy},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}=Rc(p,f,d)),w=-1)}return{x:u,y:m,placement:f,strategy:o,middlewareData:h}},by=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=Lp(u),f={x:s,y:r},h=vl(o),g=bl(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,R=Nn(m[y],I),k=Nn(m[b],I),M=R,O=E-v[g]-k,$=E/2-v[g]/2+A,K=pi(M,$,O),ee=!d.arrow&&_s(o)!=null&&$!==K&&a.reference[g]/2-($<M?R:k)-v[g]/2<0,z=ee?$<M?$-M:$-O:0;return{[h]:f[h]+z,data:{[h]:K,centerOffset:$-K-z,...ee&&{alignmentOffset:z}},reset:ee}}}),vy=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?[co(c)]:dy(c)),C=g!=="none";!f&&C&&N.push(...fy(c,v,g,S));const E=[c,...N],A=await d.detectOverflow(n,w),I=[];let R=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&I.push(A[y]),m){const $=cy(o,i,S);I.push(A[$[0]],A[$[1]])}if(R=[...R,{placement:o,overflows:I}],!I.every($=>$<=0)){var k,M;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,K=E[$];if(K&&(!(m==="alignment"?b!==Ut(K):!1)||R.every(H=>Ut(H.placement)===b?H.overflows[0]>0:!0)))return{data:{index:$,overflows:R},reset:{placement:K}};let ee=(M=R.filter(z=>z.overflows[0]<=0).sort((z,H)=>z.overflows[1]-H.overflows[1])[0])==null?void 0:M.placement;if(!ee)switch(h){case"bestFit":{var O;const z=(O=R.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];z&&(ee=z);break}case"initialPlacement":ee=c;break}if(o!==ee)return{reset:{placement:ee}}}return{}}}};function Mc(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function Ac(e){return oy.some(n=>e[n]>=0)}const yy=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=Mc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Ac(c)}}}case"escaped":{const i=await r.detectOverflow(n,{...a,altBoundary:!0}),c=Mc(i,s.floating);return{data:{escapedOffsets:c,escaped:Ac(c)}}}default:return{}}}}},Op=new Set(["left","top"]);async function wy(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=_s(s),d=Ut(s)==="y",p=Op.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 jy=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 wy(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}}}}},Sy=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=gl(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=pi(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=pi(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}}}}}},Ny=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=gl(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=Op.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}}}},Cy=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=_s(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 R=ft(u.left,0),k=ft(u.right,0),M=ft(u.top,0),O=ft(u.bottom,0);h?A=g-2*(R!==0||k!==0?R+k:ft(u.left,u.right)):E=v-2*(M!==0||O!==0?M+O:ft(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 Fo(){return typeof window<"u"}function Ts(e){return Dp(e)?(e.nodeName||"").toLowerCase():"#document"}function gt(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function Yt(e){var n;return(n=(Dp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function Dp(e){return Fo()?e instanceof Node||e instanceof gt(e).Node:!1}function At(e){return Fo()?e instanceof Element||e instanceof gt(e).Element:!1}function Wt(e){return Fo()?e instanceof HTMLElement||e instanceof gt(e).HTMLElement:!1}function Ic(e){return!Fo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gt(e).ShadowRoot}const ky=new Set(["inline","contents"]);function lr(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=It(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&!ky.has(o)}const _y=new Set(["table","td","th"]);function Ty(e){return _y.has(Ts(e))}const Ey=[":popover-open",":modal"];function Bo(e){return Ey.some(n=>{try{return e.matches(n)}catch{return!1}})}const Ry=["transform","translate","scale","rotate","perspective"],My=["transform","translate","scale","rotate","perspective","filter"],Ay=["paint","layout","strict","content"];function yl(e){const n=wl(),s=At(e)?It(e):e;return Ry.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)||My.some(r=>(s.willChange||"").includes(r))||Ay.some(r=>(s.contain||"").includes(r))}function Iy(e){let n=Cn(e);for(;Wt(n)&&!ys(n);){if(yl(n))return n;if(Bo(n))return null;n=Cn(n)}return null}function wl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Py=new Set(["html","body","#document"]);function ys(e){return Py.has(Ts(e))}function It(e){return gt(e).getComputedStyle(e)}function Uo(e){return At(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Cn(e){if(Ts(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Ic(e)&&e.host||Yt(e);return Ic(n)?n.host:n}function zp(e){const n=Cn(e);return ys(n)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(n)&&lr(n)?n:zp(n)}function Js(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=zp(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=gt(o);if(a){const c=fi(i);return n.concat(i,i.visualViewport||[],lr(o)?o:[],c&&s?Js(c):[])}return n.concat(o,Js(o,[],s))}function fi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $p(e){const n=It(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=lo(s)!==a||lo(r)!==i;return c&&(s=a,r=i),{width:s,height:r,$:c}}function jl(e){return At(e)?e:e.contextElement}function ms(e){const n=jl(e);if(!Wt(n))return Vt(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:a}=$p(n);let i=(a?lo(s.width):s.width)/r,c=(a?lo(s.height):s.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Ly=Vt(0);function Fp(e){const n=gt(e);return!wl()||!n.visualViewport?Ly:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function Oy(e,n,s){return n===void 0&&(n=!1),!s||n&&s!==gt(e)?!1:n}function Fn(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),a=jl(e);let i=Vt(1);n&&(r?At(r)&&(i=ms(r)):i=ms(e));const c=Oy(a,s,r)?Fp(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=gt(a),h=r&&At(r)?gt(r):r;let g=f,v=fi(g);for(;v&&r&&h!==g;){const w=ms(v),y=v.getBoundingClientRect(),b=It(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=gt(v),v=fi(g)}}return uo({width:u,height:m,x:d,y:p})}function qo(e,n){const s=Uo(e).scrollLeft;return n?n.left+s:Fn(Yt(e)).left+s}function Bp(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-qo(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function Dy(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Yt(r),c=n?Bo(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)&&((Ts(r)!=="body"||lr(i))&&(d=Uo(r)),Wt(r))){const h=Fn(r);p=ms(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=i&&!m&&!a?Bp(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 zy(e){return Array.from(e.getClientRects())}function $y(e){const n=Yt(e),s=Uo(e),r=e.ownerDocument.body,o=ft(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),a=ft(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let i=-s.scrollLeft+qo(e);const c=-s.scrollTop;return It(r).direction==="rtl"&&(i+=ft(n.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:c}}const Pc=25;function Fy(e,n){const s=gt(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=wl();(!u||u&&n==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const p=qo(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<=Pc&&(a-=g)}else p<=Pc&&(a+=p);return{width:a,height:i,x:c,y:d}}const By=new Set(["absolute","fixed"]);function Uy(e,n){const s=Fn(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,a=Wt(e)?ms(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 Lc(e,n,s){let r;if(n==="viewport")r=Fy(e,s);else if(n==="document")r=$y(Yt(e));else if(At(n))r=Uy(n,s);else{const o=Fp(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return uo(r)}function Up(e,n){const s=Cn(e);return s===n||!At(s)||ys(s)?!1:It(s).position==="fixed"||Up(s,n)}function qy(e,n){const s=n.get(e);if(s)return s;let r=Js(e,[],!1).filter(c=>At(c)&&Ts(c)!=="body"),o=null;const a=It(e).position==="fixed";let i=a?Cn(e):e;for(;At(i)&&!ys(i);){const c=It(i),d=yl(i);!d&&c.position==="fixed"&&(o=null),(a?!d&&!o:!d&&c.position==="static"&&!!o&&By.has(o.position)||lr(i)&&!d&&Up(e,i))?r=r.filter(u=>u!==i):o=c,i=Cn(i)}return n.set(e,r),r}function Hy(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const i=[...s==="clippingAncestors"?Bo(n)?[]:qy(n,this._c):[].concat(s),r],c=i[0],d=i.reduce((p,u)=>{const m=Lc(n,u,o);return p.top=ft(m.top,p.top),p.right=Nn(m.right,p.right),p.bottom=Nn(m.bottom,p.bottom),p.left=ft(m.left,p.left),p},Lc(n,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Vy(e){const{width:n,height:s}=$p(e);return{width:n,height:s}}function Wy(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=qo(o)}if(r||!r&&!a)if((Ts(n)!=="body"||lr(o))&&(c=Uo(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?Bp(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 ja(e){return It(e).position==="static"}function Oc(e,n){if(!Wt(e)||It(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return Yt(e)===s&&(s=s.ownerDocument.body),s}function qp(e,n){const s=gt(e);if(Bo(e))return s;if(!Wt(e)){let o=Cn(e);for(;o&&!ys(o);){if(At(o)&&!ja(o))return o;o=Cn(o)}return s}let r=Oc(e,n);for(;r&&Ty(r)&&ja(r);)r=Oc(r,n);return r&&ys(r)&&ja(r)&&!yl(r)?s:r||Iy(e)||s}const Gy=async function(e){const n=this.getOffsetParent||qp,s=this.getDimensions,r=await s(e.floating);return{reference:Wy(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ky(e){return It(e).direction==="rtl"}const Yy={convertOffsetParentRelativeRectToViewportRelativeRect:Dy,getDocumentElement:Yt,getClippingRect:Hy,getOffsetParent:qp,getElementRects:Gy,getClientRects:zy,getDimensions:Vy,getScale:ms,isElement:At,isRTL:Ky};function Hp(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function Jy(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=jr(m),v=jr(o.clientWidth-(u+f)),w=jr(o.clientHeight-(m+h)),y=jr(u),j={rootMargin:-g+"px "+-v+"px "+-w+"px "+-y+"px",threshold:ft(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&&!Hp(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 Xy(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=jl(e),u=o||a?[...p?Js(p):[],...Js(n)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",s,{passive:!0}),a&&y.addEventListener("resize",s)});const m=p&&c?Jy(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&&!Hp(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 Zy=jy,Qy=Sy,ew=vy,tw=Cy,nw=yy,Dc=by,sw=Ny,rw=(e,n,s)=>{const r=new Map,o={platform:Yy,...s},a={...o.platform,_c:r};return gy(e,n,{...o,platform:a})};var ow=typeof document<"u",aw=function(){},Wr=ow?l.useLayoutEffect:aw;function po(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(!po(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)&&!po(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}function Vp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zc(e,n){const s=Vp(e);return Math.round(n*s)/s}function Sa(e){const n=l.useRef(e);return Wr(()=>{n.current=e}),n}function iw(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);po(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,R=Sa(d),k=Sa(o),M=Sa(p),O=l.useCallback(()=>{if(!C.current||!E.current)return;const H={placement:n,strategy:s,middleware:f};k.current&&(H.platform=k.current),rw(C.current,E.current,H).then(te=>{const U={...te,isPositioned:M.current!==!1};$.current&&!po(A.current,U)&&(A.current=U,Cs.flushSync(()=>{m(U)}))})},[f,n,s,k,M]);Wr(()=>{p===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,m(H=>({...H,isPositioned:!1})))},[p]);const $=l.useRef(!1);Wr(()=>($.current=!0,()=>{$.current=!1}),[]),Wr(()=>{if(S&&(C.current=S),N&&(E.current=N),S&&N){if(R.current)return R.current(S,N,O);O()}},[S,N,O,R,I]);const K=l.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:j}),[b,j]),ee=l.useMemo(()=>({reference:S,floating:N}),[S,N]),z=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!ee.floating)return H;const te=zc(ee.floating,u.x),U=zc(ee.floating,u.y);return c?{...H,transform:"translate("+te+"px, "+U+"px)",...Vp(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:z}),[u,O,K,ee,z])}const lw=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?Dc({element:r.current,padding:o}).fn(s):{}:r?Dc({element:r,padding:o}).fn(s):{}}}},cw=(e,n)=>({...Zy(e),options:[e,n]}),dw=(e,n)=>({...Qy(e),options:[e,n]}),uw=(e,n)=>({...sw(e),options:[e,n]}),pw=(e,n)=>({...ew(e),options:[e,n]}),mw=(e,n)=>({...tw(e),options:[e,n]}),fw=(e,n)=>({...nw(e),options:[e,n]}),hw=(e,n)=>({...lw(e),options:[e,n]});var xw="Arrow",Wp=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"})})});Wp.displayName=xw;var gw=Wp,Sl="Popper",[Gp,Ho]=on(Sl),[bw,Kp]=Gp(Sl),Yp=e=>{const{__scopePopper:n,children:s}=e,[r,o]=l.useState(null),[a,i]=l.useState(void 0);return t.jsx(bw,{scope:n,anchor:r,onAnchorChange:o,placementState:a,setPlacementState:i,children:s})};Yp.displayName=Sl;var Jp="PopperAnchor",Xp=l.forwardRef((e,n)=>{const{__scopePopper:s,virtualRef:r,...o}=e,a=Kp(Jp,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&&Cl(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})});Xp.displayName=Jp;var Nl="PopperContent",[vw,yw]=Gp(Nl),Zp=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=Kp(Nl,s),[y,b]=l.useState(null),j=Ae(n,b),[S,N]=l.useState(null),C=ry(S),E=C?.width??0,A=C?.height??0,I=r+(a!=="center"?"-"+a:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(p)?p:[p],M=k.length>0,O={padding:R,boundary:k.filter(jw),altBoundary:M},{refs:$,floatingStyles:K,placement:ee,isPositioned:z,middlewareData:H}=iw({strategy:"fixed",placement:I,whileElementsMounted:(...Se)=>Xy(...Se,{animationFrame:h==="always"}),elements:{reference:w.anchor},middleware:[cw({mainAxis:o+A,alignmentAxis:i}),d&&dw({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?uw():void 0,...O}),d&&pw({...O}),mw({...O,apply:({elements:Se,rects:Te,availableWidth:ge,availableHeight:le})=>{const{width:ce,height:Pe}=Te.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&&hw({element:S,padding:c}),Sw({arrowWidth:E,arrowHeight:A}),f&&fw({strategy:"referenceHidden",...O,boundary:M?O.boundary:void 0})]}),te=w.setPlacementState;Ve(()=>(te(ee),()=>{te(void 0)}),[ee,te]);const[U,Z]=Cl(ee),fe=Je(g);Ve(()=>{z&&fe?.()},[z,fe]);const je=H.arrow?.x,he=H.arrow?.y,re=H.arrow?.centerOffset!==0,[L,J]=l.useState();return Ve(()=>{y&&J(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:z?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(vw,{scope:s,placedSide:U,placedAlign:Z,onArrowChange:N,arrowX:je,arrowY:he,shouldHideArrow:re,children:t.jsx(be.div,{"data-side":U,"data-align":Z,...v,ref:j,style:{...v.style,animation:z?void 0:"none"}})})})});Zp.displayName=Nl;var Qp="PopperArrow",ww={top:"bottom",right:"left",bottom:"top",left:"right"},em=l.forwardRef(function(n,s){const{__scopePopper:r,...o}=n,a=yw(Qp,r),i=ww[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(gw,{...o,ref:s,style:{...o.style,display:"block"}})})});em.displayName=Qp;function jw(e){return e!==null}var Sw=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]=Cl(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 Cl(e){const[n,s="center"]=e.split("-");return[n,s]}var tm=Yp,nm=Xp,sm=Zp,rm=em,Na=!1;function Nw(){const[e,n]=l.useState(Na);return l.useEffect(()=>{Na||(Na=!0,n(!0))},[]),e}var om=Eo[" useSyncExternalStore ".trim().toString()];function Cw(){return()=>{}}function kw(){return om(Cw,()=>!0,()=>!1)}var _w=typeof om=="function"?kw:Nw,Ca="rovingFocusGroup.onEntryFocus",Tw={bubbles:!1,cancelable:!0},cr="RovingFocusGroup",[hi,am,Ew]=sp(cr),[Rw,im]=on(cr,[Ew]),[Mw,Aw]=Rw(cr),lm=l.forwardRef((e,n)=>t.jsx(hi.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(hi.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Iw,{...e,ref:n})})}));lm.displayName=cr;var Iw=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=Lo(a),[v,w]=$n({prop:i,defaultProp:c??null,onChange:d,caller:cr}),[y,b]=l.useState(!1),j=Je(p),S=am(s),N=l.useRef(!1),[C,E]=l.useState(0);return l.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Ca,j),()=>A.removeEventListener(Ca,j)},[j]),t.jsx(Mw,{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 R=new CustomEvent(Ca,Tw);if(A.currentTarget.dispatchEvent(R),!R.defaultPrevented){const k=S().filter(ee=>ee.focusable),M=k.find(ee=>ee.active),O=k.find(ee=>ee.id===v),K=[M,O,...k].filter(Boolean).map(ee=>ee.ref.current);um(K,u)}}N.current=!1}),onBlur:ue(e.onBlur,()=>b(!1))})})}),cm="RovingFocusGroupItem",dm=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=Aw(cm,s),m=u.currentTabStopId===p,f=am(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:v}=u,w=_w();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(hi.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=Ow(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?Dw(S,N+1):S.slice(N+1)}setTimeout(()=>um(S))}}),children:typeof i=="function"?i({isCurrentTabStop:m,hasTabStop:v!=null}):i})})});dm.displayName=cm;var Pw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Lw(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ow(e,n,s){const r=Lw(e.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Pw[r]}function um(e,n=!1){const s=document.activeElement;for(const r of e)if(r===s||(r.focus({preventScroll:n}),document.activeElement!==s))return}function Dw(e,n){return e.map((s,r)=>e[(n+r)%e.length])}var zw=lm,$w=dm;function xi(e,[n,s]){return Math.min(s,Math.max(n,e))}function Fw(e,n){return l.useReducer((s,r)=>n[s][r]??s,e)}var kl="ScrollArea",[pm]=on(kl),[Bw,Nt]=pm(kl),mm=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),R=Lo(o);return t.jsx(Bw,{scope:s,type:r,dir:R,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:R,...i,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});mm.displayName=kl;var fm="ScrollAreaViewport",hm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,children:r,nonce:o,...a}=e,i=Nt(fm,s),c=l.useRef(null),d=Ae(n,c,i.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx(Uw,{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})})]})});hm.displayName=fm;var Uw=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",xm=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=Nt(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(Hw,{...r,ref:n,forceMount:s}):o.type==="auto"?t.jsx(gm,{...r,ref:n,forceMount:s}):o.type==="always"?t.jsx(_l,{...r,ref:n,"data-state":"visible"}):null});xm.displayName=Jt;var qw=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=Nt(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(vt,{present:s||a,children:t.jsx(gm,{"data-state":a?"visible":"hidden",...r,ref:n})})}),Hw=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=Nt(Jt,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Wo(()=>d("SCROLL_END"),100),[c,d]=Fw("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(vt,{present:s||c!=="hidden",children:t.jsx(_l,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:n,onPointerEnter:ue(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:ue(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),gm=l.forwardRef((e,n)=>{const s=Nt(Jt,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Wo(()=>{if(s.viewport){const p=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?p:u)}},10);return ws(s.viewport,d),ws(s.content,d),t.jsx(vt,{present:r||a,children:t.jsx(_l,{"data-state":a?"visible":"hidden",...o,ref:n})})}),_l=l.forwardRef((e,n)=>{const{orientation:s="vertical",...r}=e,o=Nt(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=jm(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 Jw(f,i.current,c,h)}return s==="horizontal"?t.jsx(Vw,{...u,ref:n,onThumbPositionChange:()=>{if(o.viewport&&a.current){const f=o.viewport.scrollLeft,h=$c(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(Ww,{...u,ref:n,onThumbPositionChange:()=>{if(o.viewport&&a.current){const f=o.viewport.scrollTop,h=$c(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}),Vw=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:r,...o}=e,a=Nt(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(vm,{"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":Vo(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),Nm(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:fo(i.paddingLeft),paddingEnd:fo(i.paddingRight)}})}})}),Ww=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:r,...o}=e,a=Nt(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(vm,{"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":Vo(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),Nm(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:fo(i.paddingTop),paddingEnd:fo(i.paddingBottom)}})}})}),[Gw,bm]=pm(Jt),vm=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=Nt(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=Wo(m,10);function A(I){if(y.current){const R=I.clientX-y.current.left,k=I.clientY-y.current.top;p({x:R,y:k})}}return l.useEffect(()=>{const I=R=>{const k=R.target;g?.contains(k)&&N(R,S)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[j,g,S,N]),l.useEffect(C,[r,C]),ws(g,E),ws(h.content,E),t.jsx(Gw,{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 R=I.target;R.hasPointerCapture(I.pointerId)&&R.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),mo="ScrollAreaThumb",ym=l.forwardRef((e,n)=>{const{forceMount:s,...r}=e,o=bm(mo,e.__scopeScrollArea);return t.jsx(vt,{present:s||o.hasThumb,children:t.jsx(Kw,{ref:n,...r})})}),Kw=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,style:r,...o}=e,a=Nt(mo,s),i=bm(mo,s),{onThumbPositionChange:c}=i,d=Ae(n,i.onThumbChange),p=l.useRef(void 0),u=Wo(()=>{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=Xw(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)})});ym.displayName=mo;var Tl="ScrollAreaCorner",wm=l.forwardRef((e,n)=>{const s=Nt(Tl,e.__scopeScrollArea),r=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&r?t.jsx(Yw,{...e,ref:n}):null});wm.displayName=Tl;var Yw=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,...r}=e,o=Nt(Tl,s),[a,i]=l.useState(0),[c,d]=l.useState(0),p=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:m}=o;return ws(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),d(f)}),ws(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 fo(e){return e?parseInt(e,10):0}function jm(e,n){const s=e/n;return isNaN(s)?0:s}function Vo(e){const n=jm(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-s)*n;return Math.max(r,18)}function Jw(e,n,s,r="ltr"){const o=Vo(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 Sm([d,p],m)(e)}function $c(e,n,s="ltr"){const r=Vo(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=xi(e,d);return Sm([0,i],[0,c])(p)}function Sm(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 Nm(e,n){return e>0&&e<n}var Xw=(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 Wo(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 ws(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 Zw=mm,Qw=hm,ej=wm,tj=[" ","Enter","ArrowUp","ArrowDown"],nj=[" ","Enter"],Bn="Select",[Go,Ko,sj]=sp(Bn),[Vn]=on(Bn,[sj,Ho]),Yo=Ho(),[rj,Tn]=Vn(Bn),[oj,aj]=Vn(Bn),ij="SelectProvider";function Cm(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=Yo(n),[y,b]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),E=Lo(p),[A,I]=$n({prop:r,defaultProp:o??!1,onChange:a,caller:Bn}),[R,k]=$n({prop:i,defaultProp:c,onChange:d,caller:Bn}),M=l.useRef(null),O=l.useRef(R);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),z=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})},[]),Z={required:h,trigger:y,onTriggerChange:b,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:z,value:R,onValueChange:k,open:A,onOpenChange:I,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:m,form:g,nativeOptions:K,nativeSelectKey:H,isFormControl:$};return t.jsx(tm,{...w,children:t.jsx(rj,{scope:n,...Z,children:t.jsx(Go.Provider,{scope:n,children:t.jsx(oj,{scope:n,onNativeOptionAdd:te,onNativeOptionRemove:U,children:Nj(v)?v(Z):s})})})})}Cm.displayName=ij;var km=e=>{const{__scopeSelect:n,children:s,...r}=e;return t.jsx(Cm,{__scopeSelect:n,...r,internal_do_not_use_render:({isFormControl:o})=>t.jsxs(t.Fragment,{children:[s,o?t.jsx(Zm,{__scopeSelect:n}):null]})})};km.displayName=Bn;var _m="SelectTrigger",Tm=l.forwardRef((e,n)=>{const{__scopeSelect:s,disabled:r=!1,...o}=e,a=Yo(s),i=Tn(_m,s),c=i.disabled||r,d=Ae(n,i.onTriggerChange),p=Ko(s),u=l.useRef("touch"),[m,f,h]=Qm(v=>{const w=p().filter(j=>!j.disabled),y=w.find(j=>j.value===i.value),b=ef(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(nm,{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":Jo(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===" ")&&tj.includes(v.key)&&(g(),v.preventDefault())})})})});Tm.displayName=_m;var Em="SelectValue",Rm=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:r,style:o,children:a,placeholder:i="",...c}=e,d=Tn(Em,s),{onValueNodeHasChildrenChange:p}=d,u=a!==void 0,m=Ae(n,d.onValueNodeChange);Ve(()=>{p(u)},[p,u]);const f=Jo(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")})});Rm.displayName=Em;var lj="SelectIcon",Mm=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:r,...o}=e;return t.jsx(be.span,{"aria-hidden":!0,...o,ref:n,children:r||"▼"})});Mm.displayName=lj;var Am="SelectPortal",[cj,dj]=Vn(Am,{forceMount:void 0}),Im=e=>{const{__scopeSelect:n,forceMount:s,...r}=e;return t.jsx(cj,{scope:e.__scopeSelect,forceMount:s,children:t.jsx(Do,{asChild:!0,...r})})};Im.displayName=Am;var kn="SelectContent",Pm=l.forwardRef((e,n)=>{const s=dj(kn,e.__scopeSelect),{forceMount:r=s.forceMount,...o}=e,a=Tn(kn,e.__scopeSelect),[i,c]=l.useState();return Ve(()=>{c(new DocumentFragment)},[]),t.jsx(vt,{present:r||a.open,children:({present:d})=>d?t.jsx(Dm,{...o,ref:n}):t.jsx(Lm,{...o,fragment:i})})});Pm.displayName=kn;var Lm=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:r,fragment:o}=e;return o?Cs.createPortal(t.jsx(Om,{scope:s,children:t.jsx(Go.Slot,{scope:s,children:t.jsx("div",{ref:n,children:r})})}),o):null});Lm.displayName="SelectContentFragment";var Rt=10,[Om,En]=Vn(kn),uj="SelectContentImpl",pj=bs("SelectContent.RemoveScroll"),Dm=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=Tn(kn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),E=Ae(n,S),[A,I]=l.useState(null),[R,k]=l.useState(null),M=Ko(s),[O,$]=l.useState(!1),K=l.useRef(!1);l.useEffect(()=>{if(j)return vp(j)},[j]),dp();const ee=l.useCallback(J=>{const[Se,...Te]=M().map(ce=>ce.ref.current),[ge]=Te.slice(-1),le=document.activeElement;for(const ce of J)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},[M,N]),z=l.useCallback(()=>ee([A,j]),[ee,A,j]);l.useEffect(()=>{O&&z()},[O,z]);const{onOpenChange:H,triggerPointerDownPosRef:te}=b;l.useEffect(()=>{if(j){let J={x:0,y:0};const Se=ge=>{J={x:Math.abs(Math.round(ge.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(ge.pageY)-(te.current?.y??0))}},Te=ge=>{J.x<=10&&J.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",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Se),document.removeEventListener("pointerup",Te,{capture:!0})}}},[j,H,te]),l.useEffect(()=>{const J=()=>H(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[H]);const[U,Z]=Qm(J=>{const Se=M().filter(le=>!le.disabled),Te=Se.find(le=>le.ref.current===document.activeElement),ge=ef(Se,J,Te);ge&&setTimeout(()=>ge.ref.current?.focus())}),fe=l.useCallback((J,Se,Te)=>{const ge=!K.current&&!Te;(b.value!==void 0&&b.value===Se||ge)&&(I(J),ge&&(K.current=!0))},[b.value]),je=l.useCallback(()=>j?.focus(),[j]),he=l.useCallback((J,Se,Te)=>{const ge=!K.current&&!Te;(b.value!==void 0&&b.value===Se||ge)&&k(J)},[b.value]),re=r==="popper"?gi:zm,L=re===gi?{side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:m,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:w}:{};return t.jsx(Om,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:fe,selectedItem:A,onItemLeave:je,itemTextRefCallback:he,focusSelectedItem:z,selectedItemText:R,position:r,isPositioned:O,searchRef:U,children:t.jsx(fl,{as:pj,allowPinchZoom:!0,children:t.jsx(ml,{asChild:!0,trapped:b.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:ue(o,J=>{b.trigger?.focus({preventScroll:!0}),J.preventDefault()}),children:t.jsx(Oo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:t.jsx(re,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:J=>J.preventDefault(),...y,...L,onPlaced:()=>$(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ue(y.onKeyDown,J=>{const Se=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!Se&&J.key.length===1&&Z(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ge=M().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ge=ge.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const le=J.target,ce=ge.indexOf(le);ge=ge.slice(ce+1)}setTimeout(()=>ee(ge)),J.preventDefault()}})})})})})})});Dm.displayName=uj;var mj="SelectItemAlignedPosition",zm=l.forwardRef((e,n)=>{const{__scopeSelect:s,onPlaced:r,...o}=e,a=Tn(kn,s),i=En(kn,s),[c,d]=l.useState(null),[p,u]=l.useState(null),m=Ae(n,u),f=Ko(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(),R=y.getBoundingClientRect();if(a.dir!=="rtl"){const le=R.left-A.left,ce=I.left-le,Pe=E.left-ce,Re=E.width+Pe,Fe=Math.max(Re,A.width),ct=window.innerWidth-Rt,He=xi(ce,[Rt,Math.max(Rt,ct-Fe)]);c.style.minWidth=Re+"px",c.style.left=He+"px"}else{const le=A.right-R.right,ce=window.innerWidth-I.right-le,Pe=window.innerWidth-E.right-ce,Re=E.width+Pe,Fe=Math.max(Re,A.width),ct=window.innerWidth-Rt,He=xi(ce,[Rt,Math.max(Rt,ct-Fe)]);c.style.minWidth=Re+"px",c.style.right=He+"px"}const k=f(),M=window.innerHeight-Rt*2,O=v.scrollHeight,$=window.getComputedStyle(p),K=parseInt($.borderTopWidth,10),ee=parseInt($.paddingTop,10),z=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),te=K+ee+O+H+z,U=Math.min(w.offsetHeight*5,te),Z=window.getComputedStyle(v),fe=parseInt(Z.paddingTop,10),je=parseInt(Z.paddingBottom,10),he=E.top+E.height/2-Rt,re=M-he,L=w.offsetHeight/2,J=w.offsetTop+L,Se=K+ee+J,Te=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,L+(le?je:0)+ce+z),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)+L)+Te;c.style.height=Pe+"px",v.scrollTop=Se-he+v.offsetTop}c.style.margin=`${Rt}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=M+"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(hj,{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}})})})});zm.displayName=mj;var fj="SelectPopperPosition",gi=l.forwardRef((e,n)=>{const{__scopeSelect:s,align:r="start",collisionPadding:o=Rt,...a}=e,i=Yo(s);return t.jsx(sm,{...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)"}})});gi.displayName=fj;var[hj,El]=Vn(kn,{}),bi="SelectViewport",$m=l.forwardRef((e,n)=>{const{__scopeSelect:s,nonce:r,...o}=e,a=En(bi,s),i=El(bi,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(Go.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-Rt*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})})})]})});$m.displayName=bi;var Fm="SelectGroup",[xj,gj]=Vn(Fm),bj=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e,o=Ht();return t.jsx(xj,{scope:s,id:o,children:t.jsx(be.div,{role:"group","aria-labelledby":o,...r,ref:n})})});bj.displayName=Fm;var Bm="SelectLabel",vj=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e,o=gj(Bm,s);return t.jsx(be.div,{id:o.id,...r,ref:n})});vj.displayName=Bm;var ho="SelectItem",[yj,Um]=Vn(ho),qm=l.forwardRef((e,n)=>{const{__scopeSelect:s,value:r,disabled:o=!1,textValue:a,...i}=e,c=Tn(ho,s),d=En(ho,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(yj,{scope:s,value:r,disabled:o,textId:w,isSelected:p,onItemTextChange:l.useCallback(j=>{m(S=>S||(j?.textContent??"").trim())},[]),children:t.jsx(Go.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===" "||(nj.includes(j.key)&&b(),j.key===" "&&j.preventDefault())})})})})});qm.displayName=ho;var Bs="SelectItemText",Hm=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:r,style:o,...a}=e,i=Tn(Bs,s),c=En(Bs,s),d=Um(Bs,s),p=aj(Bs,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&&!Jo(i.value)?Cs.createPortal(a.children,i.valueNode):null]})});Hm.displayName=Bs;var Vm="SelectItemIndicator",Wm=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e;return Um(Vm,s).isSelected?t.jsx(be.span,{"aria-hidden":!0,...r,ref:n}):null});Wm.displayName=Vm;var vi="SelectScrollUpButton",Gm=l.forwardRef((e,n)=>{const s=En(vi,e.__scopeSelect),r=El(vi,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(Ym,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Gm.displayName=vi;var yi="SelectScrollDownButton",Km=l.forwardRef((e,n)=>{const s=En(yi,e.__scopeSelect),r=El(yi,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(Ym,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Km.displayName=yi;var Ym=l.forwardRef((e,n)=>{const{__scopeSelect:s,onAutoScroll:r,...o}=e,a=En("SelectScrollButton",s),i=l.useRef(null),c=Ko(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()})})}),wj="SelectSeparator",jj=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e;return t.jsx(be.div,{"aria-hidden":!0,...r,ref:n})});jj.displayName=wj;var Jm="SelectArrow",Sj=l.forwardRef((e,n)=>{const{__scopeSelect:s,...r}=e,o=Yo(s);return En(Jm,s).position==="popper"?t.jsx(rm,{...o,...r,ref:n}):null});Sj.displayName=Jm;var Xm="SelectBubbleInput",Zm=l.forwardRef(({__scopeSelect:e,...n},s)=>{const r=Tn(Xm,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=sy(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:{...tp,...n.style},ref:g,defaultValue:v,children:[Jo(o)&&!y?t.jsx("option",{value:""}):null,Array.from(m)]},f)});Zm.displayName=Xm;function Nj(e){return typeof e=="function"}function Jo(e){return e===""||e===void 0}function Qm(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 ef(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=Cj(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 Cj(e,n){return e.map((s,r)=>e[(n+r)%e.length])}var Xo="Tabs",[kj]=on(Xo,[im]),tf=im(),[_j,Rl]=kj(Xo),nf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...p}=e,u=Lo(c),[m,f]=$n({prop:r,onChange:o,defaultProp:a??"",caller:Xo});return t.jsx(_j,{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})})});nf.displayName=Xo;var sf="TabsList",rf=l.forwardRef((e,n)=>{const{__scopeTabs:s,loop:r=!0,...o}=e,a=Rl(sf,s),i=tf(s);return t.jsx(zw,{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})})});rf.displayName=sf;var of="TabsTrigger",af=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:r,disabled:o=!1,...a}=e,i=Rl(of,s),c=tf(s),d=df(i.baseId,r),p=uf(i.baseId,r),u=r===i.value;return t.jsx($w,{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)})})})});af.displayName=of;var lf="TabsContent",cf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:r,forceMount:o,children:a,...i}=e,c=Rl(lf,s),d=df(c.baseId,r),p=uf(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(vt,{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})})});cf.displayName=lf;function df(e,n){return`${e}-trigger-${n}`}function uf(e,n){return`${e}-content-${n}`}var Tj=nf,Ej=rf,Rj=af,Mj=cf,[Zo]=on("Tooltip",[Ho]),Qo=Ho(),pf="TooltipProvider",Aj=700,wi="tooltip.open",[Ij,Ml]=Zo(pf),mf=e=>{const{__scopeTooltip:n,delayDuration:s=Aj,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(Ij,{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})};mf.displayName=pf;var Xs="Tooltip",[Pj,dr]=Zo(Xs),ff=e=>{const{__scopeTooltip:n,children:s,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=Ml(Xs,e.__scopeTooltip),p=Qo(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(wi))):d.onClose(),a?.(E)},caller:Xs}),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(tm,{...p,children:t.jsx(Pj,{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})})};ff.displayName=Xs;var ji="TooltipTrigger",hf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...r}=e,o=dr(ji,s),a=Ml(ji,s),i=Qo(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(nm,{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)})})});hf.displayName=ji;var Al="TooltipPortal",[Lj,Oj]=Zo(Al,{forceMount:void 0}),xf=e=>{const{__scopeTooltip:n,forceMount:s,children:r,container:o}=e,a=dr(Al,n);return t.jsx(Lj,{scope:n,forceMount:s,children:t.jsx(vt,{present:s||a.open,children:t.jsx(Do,{asChild:!0,container:o,children:r})})})};xf.displayName=Al;var js="TooltipContent",gf=l.forwardRef((e,n)=>{const s=Oj(js,e.__scopeTooltip),{forceMount:r=s.forceMount,side:o="top",...a}=e,i=dr(js,e.__scopeTooltip);return t.jsx(vt,{present:r||i.open,children:i.disableHoverableContent?t.jsx(bf,{side:o,...a,ref:n}):t.jsx(Dj,{side:o,...a,ref:n})})}),Dj=l.forwardRef((e,n)=>{const s=dr(js,e.__scopeTooltip),r=Ml(js,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=Bj(y,w.getBoundingClientRect()),j=Uj(y,b),S=qj(v.getBoundingClientRect()),N=Vj([...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=!Hj(y,i);b?f():j&&(f(),p())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,p,f]),t.jsx(bf,{...e,ref:a})}),[zj,$j]=Zo(Xs,{isInside:!1}),Fj=wv("TooltipContent"),bf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=dr(js,s),p=Qo(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(wi,u),()=>document.removeEventListener(wi,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(Oo,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:m=>m.preventDefault(),onDismiss:u,children:t.jsxs(sm,{"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(Fj,{children:r}),t.jsx(zj,{scope:s,isInside:!0,children:t.jsx(Iv,{id:d.contentId,role:"tooltip",children:o||r})})]})})});gf.displayName=js;var vf="TooltipArrow",yf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...r}=e,o=Qo(s);return $j(vf,s).isInside?null:t.jsx(rm,{...o,...r,ref:n})});yf.displayName=vf;function Bj(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 Uj(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 Hj(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 Vj(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),Wj(n)}function Wj(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 Gj=mf,Kj=ff,Yj=hf,Jj=xf,Xj=gf,Zj=yf;function Pt({...e}){return t.jsx(wp,{"data-slot":"dialog",...e})}function Es({...e}){return t.jsx(Sp,{"data-slot":"dialog-trigger",...e})}function Qj({...e}){return t.jsx(Cp,{"data-slot":"dialog-portal",...e})}function e5({className:e,...n}){return t.jsx(kp,{"data-slot":"dialog-overlay",className:P("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 Lt({className:e,children:n,...s}){return t.jsxs(Qj,{children:[t.jsx(e5,{}),t.jsxs(_p,{"data-slot":"dialog-content",className:P("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(Pp,{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(ir,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Dt({className:e,...n}){return t.jsx("div",{"data-slot":"dialog-header",className:P("flex flex-col space-y-1.5 text-center sm:text-left",e),...n})}function zt({className:e,...n}){return t.jsx(Rp,{"data-slot":"dialog-title",className:P("text-lg font-semibold leading-none tracking-tight",e),...n})}function ur({className:e,...n}){return t.jsx(Ap,{"data-slot":"dialog-description",className:P("text-sm text-muted-foreground",e),...n})}function Il({open:e,onOpenChange:n,title:s,description:r,confirmLabel:o="Confirm",variant:a="default",onConfirm:i}){return t.jsx(Pt,{open:e,onOpenChange:n,children:t.jsxs(Lt,{children:[t.jsx(Dt,{children:t.jsx(zt,{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(Q,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),t.jsx(Q,{variant:a,size:"sm",onClick:()=>{i(),n(!1)},children:o})]})]})})}const t5="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",n5="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",s5="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",r5="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",o5=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,a5={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function Sr(e){return e?.toLowerCase()??""}function es(e,n){for(const s of n)if(e.includes(s))return!0;return!1}function Pl(e){const n=[Sr(e.userAgent),Sr(e.conversationId),Sr(e.clientProjectFolder)].join(" ");return es(n,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":es(n,["mimocode","mimo-code","mimo code"])?"mimo-code":es(n,["opencode","open-code","open code"])?"opencode":es(n,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":es(n,["codex desktop","codex-cli","openai-codex","codex"])?"codex":es(Sr(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function ea(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return a5[e];case"unknown":return null}}function i5(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 l5={"agent-inspector":o5,codex:n5,opencode:s5,"mimo-code":r5,"claude-code":t5},c5={"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]"},d5={"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 ta({client:e,className:n,decorative:s=!1}){if(e==="unknown")return null;const r=ea(e);if(r===null)return null;if(e==="ai-sdk")return t.jsx("span",{className:P("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(zu,{className:"size-1/2","aria-hidden":"true"})});const o=l5[e];return t.jsx("span",{className:P("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",c5[e],n),"aria-label":s?void 0:r,"aria-hidden":s?!0:void 0,title:r,children:t.jsx("img",{src:o,alt:"",className:P("size-full object-contain",d5[e]),"aria-hidden":"true"})})}const u5="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",p5="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",m5="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",f5=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,h5=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,x5=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,g5=""+new URL("zhipuai-BPNAnxo-.svg",import.meta.url).href,b5={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function v5(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function y5(e){if(e===null)return"unknown";const n=e.toLowerCase();if(v5(n))return"zhipuai";for(const[s,r]of Object.entries(b5))if(n.startsWith(s.toLowerCase()))return r;return"unknown"}const Wn={width:24,height:24,objectFit:"contain"},w5=qn.memo(({className:e})=>t.jsx("img",{src:u5,alt:"Anthropic",className:e,style:Wn})),j5=qn.memo(({className:e})=>t.jsx("img",{src:p5,alt:"OpenAI",className:e,style:{...Wn,background:"white",borderRadius:"4px"}})),S5=qn.memo(({className:e})=>t.jsx("img",{src:m5,alt:"DeepSeek",className:e,style:Wn})),N5=qn.memo(({className:e})=>t.jsx("img",{src:f5,alt:"MiniMax",className:e,style:Wn})),C5=qn.memo(({className:e})=>t.jsx("img",{src:h5,alt:"Alibaba",className:e,style:Wn})),k5=qn.memo(({className:e})=>t.jsx("img",{src:x5,alt:"Qwen",className:e,style:Wn})),_5=qn.memo(({className:e})=>t.jsx("img",{src:g5,alt:"ZhipuAI",className:e,style:Wn}));function T5({provider:e,className:n}){switch(e){case"anthropic":return t.jsx(w5,{className:n});case"openai":return t.jsx(j5,{className:n});case"deepseek":return t.jsx(S5,{className:n});case"minimax":return t.jsx(N5,{className:n});case"alibaba":return t.jsx(C5,{className:n});case"qwen":return t.jsx(k5,{className:n});case"zhipuai":return t.jsx(_5,{className:n});case"unknown":return null}}function Rs({delayDuration:e=600,...n}){return t.jsx(Gj,{"data-slot":"tooltip-provider",delayDuration:e,...n})}function ut({...e}){return t.jsx(Kj,{"data-slot":"tooltip",...e})}function pt({...e}){return t.jsx(Yj,{"data-slot":"tooltip-trigger",...e})}function mt({className:e,sideOffset:n=0,children:s,...r}){return t.jsx(Jj,{children:t.jsxs(Xj,{"data-slot":"tooltip-content",sideOffset:n,className:P("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(Zj,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const E5=3;function R5({items:e,ariaLabel:n,className:s}){if(e.length===0)return t.jsx("span",{className:P("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const r=e.slice(0,E5),o=e.length-r.length;return t.jsx(Rs,{delayDuration:150,children:t.jsxs("span",{className:P("flex h-8 w-12 shrink-0 items-center",s),"aria-label":n,children:[r.map((a,i)=>t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsx("span",{className:P("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(T5,{provider:a.provider,className:"size-4"})})}),t.jsx(mt,{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 M5=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function wf(e){const n=e.split("?")[0]??"";for(const[s,r]of M5)if(n===s)return r;return"unknown"}function jf(e,n){for(const s of Array.from(e))n(s)}const A5=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Ll(e){if(e.length===0)return 0;let n=0,s=0;return jf(e,r=>{A5.test(r)?n+=1:s+=1}),Math.ceil(n*1)+Math.ceil(s/4)}function Ol(e){if(e.length===0)return 0;let n=0;return jf(e,()=>{n+=1}),n}function Dl(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 I5=["file","shell","browser","web","mcp","code","other"];function Si(e){const n=e.replace(/\s+/g," ").trim();return n.length<=120?n:`${n.slice(0,119)}...`}function Sf(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?Si(n.slice(0,s+1)):Si(n)}function P5(e,n){return`${e} ${n??""}`.toLowerCase()}function ts(e,n){return n.some(s=>e.includes(s))}function Nf(e,n){const s=P5(e,n);return e.startsWith("mcp__")||e.startsWith("inspector_")||ts(s,[" mcp","model context protocol"])?"mcp":ts(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":ts(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":ts(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":ts(s,["web","search","http","url","fetch"])?"web":ts(s,["code","typescript","javascript","python","repl"])?"code":"other"}function Cf(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 kf(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 L5(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:Sf(o),category:Nf(n,o),parameterCount:Cf(r).length,requiredParameters:kf(r),schema:r}}function O5(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:Sf(i),category:Nf(r,i),parameterCount:Cf(a).length,requiredParameters:kf(a),schema:a}}function D5(e){const n=O5(e);return n!==null?n:L5(e)}function z5(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:Si(o)}function $5(e){const n=new Map;for(const s of e)n.set(s.category,(n.get(s.category)??0)+1);return I5.flatMap(s=>{const r=n.get(s)??0;return r>0?[{category:s,count:r}]:[]})}function zl(e){const n=G(e,"tools");if(!Array.isArray(n)||n.length===0)return null;const s=[];for(const r of n){const o=D5(r);o!==null&&s.push(o)}return s.length===0?null:{tools:s,toolChoiceLabel:z5(G(e,"tool_choice")),categories:$5(s)}}function zn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const fs={parsed:null,toolNames:null};function F5(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 B5(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 U5(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 ka(e,n,s,r){return{role:e,label:n,text:s,size:Ll(s),characters:Ol(s),path:r}}const q5={format:"anthropic",analyzeRequest(e){if(e===null)return zn(e);try{const n=JSON.parse(e),s=zl(n)?.tools.length??null,r=Sx.safeParse(n);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:s}:zn(e)}catch{return zn(e)}},analyzeResponse(e){if(e===null)return fs;try{let n=JSON.parse(e);typeof n=="string"&&(n=JSON.parse(n));const s=Cx.safeParse(n);if(!s.success)return fs;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 fs}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(n.system!==void 0){const r=B5(n.system);r.length>0&&s.push(ka("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=F5(a.content);s.push(ka(i,`[${o}] ${i}`,c,`/messages/${o}`))}),Array.isArray(n.tools)&&n.tools.length>0){const r=U5(n.tools);s.push(ka("tools","tools",r,"/tools"))}return s.length>0?s:null}};function Ni(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 H5(e){const n=[],s=Ni(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 V5(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 W5(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function G5(e){if(typeof e=="string")return e;const n=G(e,"text");if(typeof n=="string")return n;const s=Ni(G(e,"content"));if(s.length>0)return s;const r=Ni(G(e,"output"));if(r.length>0)return r;const o=G(e,"arguments");return typeof o=="string"?o:""}function K5(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 Y5(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 Ls(e,n,s,r){return{role:e,label:n,text:s,size:Ll(s),characters:Ol(s),path:r}}const J5={format:"openai",analyzeRequest(e){if(e===null)return zn(e);try{const n=JSON.parse(e),s=zl(n)?.tools.length??null,r=zx.safeParse(n);if(!r.success){const o=Fx.safeParse(n);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:W5(o.data.input),toolCount:s}:zn(e)}return{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:s}}catch{return zn(e)}},analyzeResponse(e){if(e===null)return fs;const n=Wx(e);if(n===null){const r=Gx(e);if(r===null)return fs;const o=Y5(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(Ls("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=H5(a);s.push(Ls(i,`[${o}] ${i}`,c,`/messages/${o}`))}),Array.isArray(n.messages)||(typeof n.input=="string"&&n.input.length>0?s.push(Ls("user","input",n.input,"/input")):Array.isArray(n.input)&&n.input.forEach((r,o)=>{const a=K5(r),i=G5(r);s.push(Ls(a,`[${o}] ${a}`,i,`/input/${o}`))})),Array.isArray(n.tools)&&n.tools.length>0){const r=V5(n.tools);s.push(Ls("tools","tools",r,"/tools"))}return s.length>0?s:null}},X5={format:"unknown",analyzeRequest(e){return zn(e)},analyzeResponse(){return fs},anatomySegments(){return null}},Z5={anthropic:q5,openai:J5,unknown:X5};function _f(e){return Z5[e]}function xo(e){const n=wf(e.path);return n==="unknown"?e.apiFormat:n}const Fc="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 Tf(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function Q5(e){return Tf(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function _a({icon:e,children:n,title:s,className:r}){return t.jsxs("span",{className:P("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 eS(){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 tS({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(pu(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:K,models:ee})=>({provider:K,tooltip:ee.length===1?ee[0]??K:ee.join(", ")}))??[],C=Pl({userAgent:u,conversationId:e,clientProjectFolder:f}),E=ea(C),A=u!=null&&u!=="",I=E??u??null,R=E!==null&&A?`${E} - ${u}`:null,k=Tf(e),M=Q5(e),O=Io(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:P("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(R5,{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:M}),!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:R??I,children:[t.jsx(ta,{client:C,className:"size-4 shrink-0",decorative:!0}),t.jsx("span",{className:"font-mono leading-snug tabular-nums",children:I})]}),p&&t.jsx(eS,{})]}),t.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx(_a,{icon:t.jsx(en,{className:"size-3 shrink-0"}),title:O,children:O}),t.jsx(_a,{icon:t.jsx(Ao,{className:"size-3 shrink-0"}),children:$}),t.jsxs(_a,{icon:t.jsx(Ys,{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:Fc,children:t.jsx(or,{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:Fc,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(bt,{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(Il,{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 nS(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 sS(e){const n=new Map;for(const r of e){const o=nS(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 rS(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 ns(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 Bc(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const oS=(e,n)=>Math.abs(e-n)<1.01,aS=(e,n,s)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>n.apply(this,o),s)}};let Os;const Ta=()=>{if(Os!==void 0)return Os;if(typeof navigator>"u")return Os=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Os=!0;const e=navigator.maxTouchPoints;return Os=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Uc=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},iS=e=>e,lS=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},cS=(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(Uc(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(Uc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},Zs={passive:!0},dS=(e,n)=>{const s=e.scrollElement;if(!s)return;const r=()=>{n({width:s.innerWidth,height:s.innerHeight})};return r(),s.addEventListener("resize",r,Zs),()=>{s.removeEventListener("resize",r)}},uS=typeof window>"u"?!0:"onscrollend"in window,Ef=(e,n,s)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const a=e.options.useScrollendEvent&&uS;let i=0;const c=a?null:aS(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,Zs),a&&r.addEventListener("scrollend",u,Zs),()=>{r.removeEventListener("scroll",p),a&&r.removeEventListener("scrollend",u)}},pS=(e,n)=>Ef(e,n,s=>{const{horizontal:r,isRtl:o}=e.options;return r?s.scrollLeft*(o&&-1||1):s.scrollTop}),mS=(e,n)=>Ef(e,n,s=>e.options.horizontal?s.scrollX:s.scrollY),fS=(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"]},Rf=(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})},hS=Rf,xS=Rf;class gS{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:iS,rangeExtractor:lS,onChange:()=>{},measureElement:fS,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=ns(()=>(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,!(!Ta()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,Zs),a.addEventListener("touchend",c,Zs),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&&(Ta()&&(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=ns(()=>[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=ns(()=>[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=rS(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 R=g[S],k=R!==void 0?h[R]:void 0;N=k?k.end+p:r+o}else if(w===c){let R=0,k=v[0],M=g[0];for(let O=1;O<c;O++){const $=v[O];($<k||$===k&&g[O]<M)&&(R=O,k=$,M=g[O])}S=R,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=ns(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,r,o,a)=>s.length===0||r===0?(this.range=null,null):(this.range=vS(s,r,o,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ns(()=>{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=ns(()=>[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=Mf(0,r.length-1,a?c=>o[c*2]:c=>Bc(r[c]).start,s);return Bc(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&&(Ta()&&(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&&oS(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 Mf=(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 bS(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 vS(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=bS(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=Mf(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 Ea=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Af({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?Cs.flushSync(o):o()),(m=r.onChange)==null||m.call(r,p,u)}},[d]=l.useState(()=>{const p=new gS(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),Ea(()=>d._didMount(),[]),Ea(()=>d._willUpdate()),Ea(()=>{i(d)}),d}function yS(e){return Af({observeElementRect:cS,observeElementOffset:pS,scrollToFn:xS,...e})}function wS(e){return Af({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:dS,observeElementOffset:mS,scrollToFn:hS,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const rn="agent-inspector:focus-log";function Ss(e){window.dispatchEvent(new CustomEvent(rn,{detail:e}))}function na(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 qc(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function If(e){if(!ls(e))return null;if(typeof e.stop_reason=="string")return qc(e.stop_reason);if(ls(e.delta)&&typeof e.delta.stop_reason=="string")return qc(e.delta.stop_reason);if(Array.isArray(e.choices))for(const n of e.choices){if(!ls(n)||typeof n.finish_reason!="string")continue;const s=SS(n.finish_reason);if(s!==null)return s}if(Array.isArray(e.output)){for(const n of e.output)if(ls(n)&&n.type==="function_call")return"tool_use";if(e.status==="completed")return"stop"}if(e.status==="incomplete"&&ls(e.incomplete_details)){const n=e.incomplete_details.reason;if(typeof n=="string"&&NS(n))return"length"}return null}function jS(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=If(JSON.parse(o));a!==null&&(n=a)}catch{}}return n}function SS(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function NS(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Pf(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)),If(n)}catch{return jS(e.responseText)}}function $l(e){return e==="end_turn"||e==="stop"||e==="length"}function Ct({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:P("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"})]}),Lf=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 Of({className:e}){return t.jsx(Ct,{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 CS({className:e}){return t.jsx(Ct,{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:Lf,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 kS({className:e}){return t.jsx(Ct,{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 _S({className:e}){return t.jsx(Ct,{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 TS({className:e}){return t.jsx(Ct,{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 ES({className:e}){return t.jsx(Ct,{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 RS({className:e}){return t.jsx(Ct,{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:Lf,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 MS({className:e}){return t.jsx(Ct,{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 AS({className:e}){return t.jsx(Ct,{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 IS({className:e}){return t.jsx(Ct,{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 PS({className:e}){return t.jsx(Ct,{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 LS({className:e}){return t.jsx(Ct,{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 Ci=[Of,CS,kS,_S,TS,ES,RS,MS,AS,IS,PS,LS];function Fl(e){return Ci[Math.abs(e)%Ci.length]??Of}function OS(e){const n=Ci.length-2;return n<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%n+n)%n}function DS(e){return Fl(OS(e))}const zS="x-anthropic-billing-header:";function $S(e){return e.trimStart().toLowerCase().startsWith(zS)}function FS(e){return Dl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function BS(e){if(!Dl(e))return!1;const n=G(e,"type"),s=G(e,"text");return typeof n!="string"||n!=="text"||typeof s!="string"?!1:$S(s)}function US(e){let n;try{n=JSON.parse(e)}catch{return{body:e,removed:0}}if(!FS(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(BS(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,Hc=2e3;function HS(e){return Array.isArray(e)}function VS(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(HS(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 WS(e){const n=VS(e,Hc+1);return n<=qS?{depth:Number.POSITIVE_INFINITY}:n<=Hc?{depth:3}:{depth:2}}function GS(e){try{const n=JSON.parse(e);return{kind:"json",data:go(n)}}catch{return{kind:"text"}}}function Ra(e){const n=l.useMemo(()=>e===null?null:GS(e),[e]),s=n?.kind==="json"?n.data:null,r=l.useMemo(()=>s===null?null:WS(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 go(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=>go(s));const n={};for(const s of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,s);n[s]=go(r?.value)}return n}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function Df({className:e,orientation:n="horizontal",...s}){return t.jsx(Tj,{"data-slot":"tabs","data-orientation":n,orientation:n,className:P("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const KS=mu("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 zf({className:e,variant:n="default",...s}){return t.jsx(Ej,{"data-slot":"tabs-list","data-variant":n,className:P(KS({variant:n}),e),...s})}function Zt({className:e,...n}){return t.jsx(Rj,{"data-slot":"tabs-trigger",className:P("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 dt({className:e,...n}){return t.jsx(Mj,{"data-slot":"tabs-content",className:P("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&&wt(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 YS=l.lazy(()=>Kt(()=>import("./CompareDrawer-CNPUAqqq.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),JS=l.lazy(()=>Kt(()=>import("./InspectorPet-DxAsc8lx.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),XS=l.lazy(()=>Kt(()=>import("./ReplayDialog-Bc4vimjF.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),ZS=l.lazy(()=>Kt(()=>import("./RequestAnatomy-yeN5GbTc.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),QS=l.lazy(()=>Kt(()=>import("./ResponseView-CK_ptAYd.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),eN=l.lazy(()=>Kt(()=>import("./StreamingChunkSequence-BDKjhP6X.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),ki=l.lazy(()=>Kt(()=>import("./json-viewer-6eqK-eC8.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),tN=l.lazy(()=>Kt(()=>import("./json-viewer-6eqK-eC8.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),nN=1200,sN=12;function rN(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??nN)},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(sN))},[n,r,o,s])}var oN={};const Vc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.",Wc=64,Qt=new Map,Gr=new Map;function cs(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 aN(e,n){const s=[];return e!=null&&s.push(`Request ${cs(e)}`),n!=null&&s.push(`Response ${cs(n)}`),s.length===0?null:s.join(" · ")}function iN(e){if(e instanceof Ro)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===""?Vc:n}}return{title:"Full bodies could not be loaded",detail:Vc}}function lN(){const e=oN.AGENT_INSPECTOR_UI_DETAIL_CACHE_LIMIT;if(e===void 0||e==="")return Wc;const n=Number(e);return!Number.isSafeInteger(n)||n<1||n>1e3?Wc:n}function cN(e){for(Qt.delete(e.id),Qt.set(e.id,e);Qt.size>lN();){const n=Qt.keys().next().value;if(typeof n!="number")break;Qt.delete(n)}return e}function $f(e){const n=Qt.get(e);return n===void 0?null:(Qt.delete(e),Qt.set(e,n),n)}function dN(e){Qt.delete(e),Gr.delete(e)}async function uN(e,n){const s=$f(e);if(s!==null)return s;const r=Gr.get(e);if(r!==void 0)return await r;const o=n().then(cN).finally(()=>{Gr.delete(e)});return Gr.set(e,o),await o}class Ff{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 pN extends Ff{constructor(){super(...arguments),this.tokenize=Uf}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 mN=new pN;function Bf(e,n,s){return mN.diff(e,n,s)}function Uf(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 fN extends Ff{constructor(){super(...arguments),this.tokenize=Uf}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(_i(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 hN=new fN;function xN(e,n,s){return hN.diff(e,n,s)}function _i(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]=_i(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]=_i(e[d],n,s,r,d);n.pop(),s.pop()}else i=e;return i}function Gc(e){return e===void 0?[]:Object.entries(e).map(n=>[n[0].toLowerCase(),n[1]]).sort(([n],[s])=>n.localeCompare(s))}function Kc([e,n]){return`${e}: ${n}`}function Ti(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 gN(e,n){const s=Gc(e).map(Kc).join(`
|
|
56
|
+
`),r=Gc(n).map(Kc).join(`
|
|
57
|
+
`);if(s===r)return{lines:[],isEmpty:!0};const o=Bf(s,r);return{lines:Ti(o),isEmpty:!1}}function Yc(e){try{const n=JSON.parse(e);return n===null||typeof n=="string"||typeof n=="object"?n:null}catch{return null}}function bN(e,n){const s=e??"",r=n??"";if(s===r)return{lines:[],isEmpty:!0};const o=Yc(s),a=Yc(r);if(o!==null&&a!==null){const c=xN(o,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:Ti(c),isEmpty:!1}}const i=Bf(s,r);return{lines:Ti(i),isEmpty:!1}}const vN=22,Ma=1e4;function yN(e){return e==="added"?"+":e==="removed"?"-":" "}function wN(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 jN=function({result:n,emptyLabel:s}){const[r,o]=l.useState("unified"),a=l.useRef(null),i=yS({count:n.lines.length,getScrollElement:()=>a.current,estimateSize:()=>vN,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>Ma,p=d?n.lines.slice(0,Ma):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 ${Ma.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:P("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(S1,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:P("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(u0,{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(SN,{virtualizer:i,lines:p}):t.jsx(kN,{lines:p})})]})};function SN({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:P("flex items-start gap-3 px-2",wN(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:P("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:yN(r.kind)}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},s.key)})})}function NN(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 CN(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 kN({lines:e}){const n=NN(e);return t.jsx("div",{"data-testid":"diff-split",children:n.map((s,r)=>t.jsxs("div",{className:P("grid grid-cols-2 font-mono text-xs",CN(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:P("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:P("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 qf=l.memo(jN),_N=mu("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 _e({className:e,variant:n="default",asChild:s=!1,...r}){const o=s?yv:"span";return t.jsx(o,{"data-slot":"badge","data-variant":n,className:P(_N({variant:n}),e),...r})}const TN=3;function EN({event:e}){const n=s=>{s.stopPropagation(),Ss({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 RN({events:e}){if(e.length===0)return null;const n=e.slice(0,TN),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(ar,{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(EN,{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 MN={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"},AN={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"}},Ds="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",Tt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function zs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function IN(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function PN(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 Jc({trend:e}){if(e===null)return null;const n=e.direction==="up",s=n?Sg:gg,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 LN=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=ex(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:zs(y),S=b===null||b<=0?null:IN(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=AN[g],I=PN(g,e.responseStatus),R=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return t.jsx(Rs,{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:P("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:M=>{(M.key==="Enter"||M.key===" ")&&(M.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:P("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:li(e.timestamp,h)})]}),R&&t.jsxs(_e,{variant:"outline",className:P("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)]",MN[g]),children:[g==="success"?t.jsx($e,{className:"size-3","aria-label":"Success"}):g==="server_error"?t.jsx(l1,{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(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsxs(_e,{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(mt,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(v?t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsxs("span",{className:P(Tt,"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:zs(e.elapsedMs)}),t.jsx(yn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsxs(mt,{children:["Slow response: ",zs(e.elapsedMs)," exceeds"," ",zs(m*1e3)]})]}):t.jsxs("span",{className:P(Tt,"shrink-0 text-muted-foreground"),children:[t.jsx(en,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:zs(e.elapsedMs)})]})),e.streaming&&j!==null&&t.jsxs("span",{className:P(Tt,"shrink-0 text-cyan-300"),children:[t.jsx(lc,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&t.jsxs("span",{className:P(Tt,"shrink-0 text-cyan-300"),children:[t.jsx(nl,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:S})]}),w&&t.jsxs("span",{className:P(Tt,"min-w-0 sm:shrink-0"),children:[t.jsx(Ys,{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:P("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:P("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:P(Tt,"shrink-0"),children:[t.jsx(Jc,{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:P(Tt,"shrink-0"),children:[t.jsx(Jc,{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:P(Tt,"shrink-0 text-muted-foreground"),children:[t.jsx(Ao,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:s})]}),r!==null&&t.jsxs("span",{className:P(Tt,"shrink-0 text-muted-foreground"),children:[t.jsx(ar,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:r})]}),t.jsx(RN,{events:o}),e.origin!==null&&t.jsxs("span",{className:P(Tt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[t.jsx(Bu,{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:P(Tt,"hidden shrink-0 text-purple-300 xl:flex"),children:[t.jsx(E0,{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(lc,{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:M=>M.stopPropagation(),onKeyDown:M=>M.stopPropagation(),children:[p!==void 0&&d!==void 0&&(()=>{const M=p[d];return M===void 0?null:t.jsxs(t.Fragment,{children:[M.expansion!==null&&t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsx(Q,{variant:"outline",size:"icon",className:Ds,onClick:M.expansion.onToggle,disabled:M.expansion.isPending,"aria-pressed":M.expansion.isExpanded,"aria-label":M.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:M.expansion.isExpanded?t.jsx(Vg,{className:"size-3.5"}):t.jsx($g,{className:"size-3.5"})})}),t.jsx(mt,{children:M.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),M.diffWithRaw!==void 0&&t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsx(Q,{variant:"outline",size:"icon",className:P(Ds,M.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:M.diffWithRaw.onToggle,"aria-pressed":M.diffWithRaw.active,"aria-label":M.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:t.jsx(C0,{className:"size-3.5"})})}),t.jsx(mt,{children:M.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),M.diffWithPrevious!==void 0&&t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsx(Q,{variant:"outline",size:"icon",className:Ds,onClick:M.diffWithPrevious,"aria-label":"Diff with previous",children:t.jsx(Uu,{className:"size-3.5"})})}),t.jsx(mt,{children:"Compare this request with the immediately preceding one"})]}),M.copyText!==null&&t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsx(Q,{variant:"outline",size:"icon",className:Ds,onClick:M.onCopy,"aria-label":M.copyCopied?"Copied":M.copyLabel,children:M.copyCopied?t.jsx($e,{className:"size-3.5 text-cyan-300"}):t.jsx(St,{className:"size-3.5"})})}),t.jsx(mt,{children:M.copyCopied?"Copied to clipboard":M.copyLabel})]})]})})(),u!==void 0&&t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsx(Q,{variant:"outline",size:"icon",className:Ds,onClick:u,"aria-label":"Replay request",children:t.jsx(Gu,{className:"size-3.5"})})}),t.jsx(mt,{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(bt,{className:"size-4 shrink-0"})})]})]})})});function ON({...e}){return t.jsx(Gv,{"data-slot":"collapsible",...e})}function PR({...e}){return t.jsx(ap,{"data-slot":"collapsible-trigger",...e})}function DN({...e}){return t.jsx(ip,{"data-slot":"collapsible-content",...e})}function zN({className:e,children:n,...s}){return t.jsxs(Zw,{"data-slot":"scroll-area",className:P("relative overflow-hidden",e),...s,children:[t.jsx(Qw,{"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($N,{}),t.jsx(ej,{})]})}function $N({className:e,orientation:n="vertical",...s}){return t.jsx(xm,{"data-slot":"scroll-area-scrollbar",orientation:n,className:P("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(ym,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Hf={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},FN={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 BN({category:e}){switch(e){case"file":return t.jsx(M0,{className:"size-3.5"});case"shell":return t.jsx(Hn,{className:"size-3.5"});case"browser":return t.jsx(r1,{className:"size-3.5"});case"web":return t.jsx(Bu,{className:"size-3.5"});case"mcp":return t.jsx(Tg,{className:"size-3.5"});case"code":return t.jsx(zu,{className:"size-3.5"});case"other":return t.jsx(g0,{className:"size-3.5"})}}function UN({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(_e,{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(ON,{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(BN,{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(_e,{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(bt,{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($e,{className:"size-3.5 text-emerald-400"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx(DN,{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(UN,{names:e.requiredParameters}),e.schema!==null&&t.jsx(zN,{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(ki,{data:go(e.schema),defaultExpandDepth:0})})})]})})]})})}function HN(e,n){return n.length===0?!0:`${e.name} ${e.description??""} ${Hf[e.category]}`.toLowerCase().trim().includes(n)}const VN=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=>HN(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(ar,{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(_e,{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(_e,{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(_e,{variant:"outline",className:P("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",FN[f.category]),children:[f.count," ",Hf[f.category]]},f.category))})]})]}),t.jsxs(Q,{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(bt,{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(_e,{variant:"outline",className:P("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(E1,{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 Xc(e,n,s){return e==="anthropic"&&n==="full"&&s}function WN(e,n){return e==="full"&&n}function Aa(e,n){return e==="full"&&n}function Ia(e,n){return e==="full"&&n}function GN(e,n){return e==="full"&&n===!0}function KN(e,n,s,r){return e==="anthropic"&&n==="full"&&s&&r}function ss(){return t.jsx("div",{className:"h-1","aria-hidden":"true"})}function YN(e,n){switch(e){case"anatomy":return n===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const JN=15e3,XN=15e3,ZN=256*1024,gn=1024*1024,Zc=256*1024,Pa=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 Nr(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function bo(e){return e??0}function ds(e,n){return n??e?.length??0}function Bl(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Vf(e){return Bl(e)?bo(e.rawRequestBodyBytes)>gn||bo(e.responseTextBytes)>gn:!1}function QN(e){return Bl(e)&&!Vf(e)}function eC(e,n){return Bl(e)?!1:n?ds(e.rawRequestBody,e.rawRequestBodyBytes)<=gn&&ds(e.responseText,e.responseTextBytes)<=gn:ds(e.rawRequestBody,e.rawRequestBodyBytes)<=Zc&&ds(e.responseText,e.responseTextBytes)<=Zc}function tC(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 nC(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 sC(e){return e instanceof Ro?"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 Cr({status:e,error:n,footprint:s,onRetry:r}){switch(e){case"idle":return null;case"loading":return t.jsx(Un,{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(Un,{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(Q,{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 Qc(e,n){return e?n.text!==""?n.text:n.status==="success"?"":null:null}function dn({children:e,className:n}){return t.jsx("div",{className:P("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",n),children:e})}function Kr({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 kr({children:e}){const[n,s]=l.useState(!1),r=typeof e=="string"?e:null,o=r!==null&&r.length>Pa,a=r!==null&&o&&!n?r.slice(0,Pa):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 ",Pa.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 rC={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 Un({tone:e,title:n,children:s}){return t.jsxs("div",{className:P("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",rC[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 _r({label:e,state:n,expectedBytes:s,onLoadMore:r}){const o=n.totalBytes??s,a=o===null?cs(n.offset):`${cs(n.offset)} / ${cs(o)}`,i=n.status!=="loading"&&n.hasMore,c=n.status==="failed"?"Retry":"Load more";return t.jsx(Un,{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 ${cs(o)}. Loading the first preview chunk.`:`Loaded ${a}.`,n.status==="failed"&&n.error!==null&&` ${n.error}`]}),i&&t.jsx(Q,{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 ed({error:e,onOpenSse:n}){return e==null?null:t.jsx(Un,{tone:"danger",title:"SSE Error",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{className:"font-mono",children:e}),n!==void 0&&t.jsx(Q,{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:n,children:"View SSE"})]})})}function oC({onOpenSse:e}){return t.jsx(Un,{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(Q,{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 td({headers:e,emptyLabel:n}){const s=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return s.length===0?t.jsx(Kr,{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 aC({active:e,onClick:n}){return t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsxs(Q,{variant:e?"default":"outline",size:"sm",className:P("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($0,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),t.jsx(mt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const iC=l.memo(function({rawBody:e,displayedBody:n,emptyLabel:s}){const r=l.useMemo(()=>bN(e,n),[e,n]);return t.jsx(qf,{result:r,emptyLabel:s})}),lC=l.memo(function({rawHeaders:e,headers:n,emptyLabel:s}){const r=l.useMemo(()=>gN(e,n),[e,n]);return t.jsx(qf,{result:r,emptyLabel:s})}),cC=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),[R,k]=l.useState(null),[M,O]=l.useState("idle"),[$,K]=l.useState(null),[ee,z]=l.useState(0),[H,te]=l.useState(()=>Nr(e.rawRequestBodyBytes??null)),[U,Z]=l.useState(()=>Nr(e.responseTextBytes??null)),fe=l.useRef(null),je=l.useRef(e.id),he=l.useRef(!1),re=l.useRef(!1),L=R??e,J=R===null&&Vf(e),Se=l.useMemo(()=>aN(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Te=Qc(J,H),ge=Qc(J,U),le=L.rawRequestBody??Te,ce=L.responseText??ge,Pe=L.rawRequestBody===null&&Te!==null,Re=L.responseText===null&&ge!==null,Fe=ds(le,e.rawRequestBodyBytes)<=gn,ct=ds(ce,e.responseTextBytes)<=gn,He=Fe&&(!Pe||H.hasMore===!1&&bo(H.totalBytes)<=gn),Le=ct&&(!Re||U.hasMore===!1&&bo(U.totalBytes)<=gn),We=xo(L),Ye=_f(We),Qe=eC(L,u),ot=l.useMemo(()=>Ye.analyzeRequest(Qe?L.rawRequestBody:null),[Ye,Qe,L.rawRequestBody]),nt=l.useMemo(()=>Ye.analyzeResponse(Qe?L.responseText:null),[Ye,Qe,L.responseText]),se=l.useMemo(()=>!r||We!=="anthropic"||L.rawRequestBody===null?null:US(L.rawRequestBody).body,[L.rawRequestBody,We,r])??le,xe=Ra(u&&nC(b)&&He?se:null),me=Ra(b==="raw-request"&&He?le:null),we=Ra(b==="raw"&&Le?ce:null),Oe=GN(s,L.streaming),ze=xe.parsedData??ot.parsed,D=l.useMemo(()=>{const Me=nt.toolNames;return Me!==null?Me:p.map(yt=>yt.name)},[nt.toolNames,p]),Y=l.useMemo(()=>L.headers&&Object.keys(L.headers).length>0?JSON.stringify(L.headers,null,2):null,[L.headers]),de=l.useMemo(()=>L.rawHeaders&&Object.keys(L.rawHeaders).length>0?JSON.stringify(L.rawHeaders,null,2):null,[L.rawHeaders]),Ne=xn(se),F=xn(le),W=xn(Y),X=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:KN(We,s,r,L.rawRequestBody!==null)?{active:w,onToggle:()=>y(!w)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(L)}},"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},...Ia(s,L.headers!==void 0&&Object.keys(L.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:Y,copyCopied:W.copied,onCopy:W.copy,expansion:null}}:{},...Aa(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:de,copyCopied:X.copied,onCopy:X.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,L,L.rawRequestBody,le,F,me,Y,W,de,X,L.responseText,Re,Le,ce,ne,we,We,s,r,c]),ie=l.useMemo(()=>ze!==null?Ye.anatomySegments(ze):null,[Ye,ze]),oe=l.useMemo(()=>zl(ze),[ze]),ke=L.warnings??[],De=l.useMemo(()=>{if(ie!==null)return new Set(ie.map(Me=>Me.path))},[ie]),Gn=rN({containerRef:fe,setExpandToPath:I,ensureTabActive:()=>{b!=="request"&&(re.current=!0,j("request"))}}),$t=l.useCallback((Me,yt)=>{const et=Me==="request"?te:Z;et(st=>({...st,status:"loading",error:null}));const As=new URLSearchParams({part:Me,offset:String(yt),limit:String(ZN)});Be(`/api/logs/${String(e.id)}/body?${As.toString()}`,gu,XN).then(st=>{je.current===e.id&&et(kt=>({status:"success",text:st.offset===0?st.text:`${kt.text}${st.text}`,offset:st.nextOffset??st.totalBytes,totalBytes:st.totalBytes,hasMore:st.hasMore,error:null}))}).catch(st=>{je.current===e.id&&et(kt=>({...kt,status:"failed",error:sC(st)}))})},[e.id]),an=l.useCallback(()=>{he.current||(dN(e.id),k(null),O("idle"),K(null),z(Me=>Me+1))},[e.id]),oa=l.useCallback(()=>{const Me=!u;Me&&(re.current=!1,j(ie!==null?"anatomy":"request")),m(Me)},[ie,u]),Kn=l.useCallback(()=>{Oe&&(re.current=!0,j("sse"))},[Oe]),aa=l.useCallback(Me=>{re.current=!0,j(Me)},[]);return l.useEffect(()=>{je.current=e.id,he.current=!1,k(null),O("idle"),K(null),z(0),re.current=!1,te(Nr(e.rawRequestBodyBytes??null)),Z(Nr(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||!tC(b)||!QN(e)||R!==null||he.current)return;const Me=$f(e.id);if(Me!==null){k(Me),O("idle"),K(null);return}let yt=!1;return he.current=!0,O("loading"),K(null),uN(e.id,()=>Be(`/api/logs/${String(e.id)}`,Gs,JN)).then(et=>{yt||(he.current=!1,k(et),O("idle"),K(null))}).catch(et=>{yt||(he.current=!1,O("failed"),K(iN(et)))}),()=>{yt=!0,he.current=!1}},[b,u,R,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,ee]),l.useEffect(()=>{u&&J&&H.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||$t("request",0))},[b,u,$t,H.status,J]),l.useEffect(()=>{u&&J&&U.status==="idle"&&(b!=="parsed"&&b!=="raw"||$t("response",0))},[b,u,$t,U.status,J]),l.useEffect(()=>{const Me=yt=>{const et=na(yt);et!==null&&et.logId===e.id&&(m(!0),re.current=!0,j(YN(et.tab,ie)),et.tab==="response"&&et.toolCallIndex!==void 0&&(N(et.toolCallIndex),E(As=>As+1)))};return window.addEventListener(rn,Me),()=>{window.removeEventListener(rn,Me)}},[ie,e.id]),t.jsxs(Rs,{children:[t.jsxs("div",{className:P("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(LN,{log:L,displayNumber:n,messageCount:ot.messageCount,toolCount:ot.toolCount,toolEvents:p,expanded:u,onToggle:oa,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(Zr,{feature:"Log details",children:t.jsxs(Df,{value:b,onValueChange:aa,className:"gap-2",children:[t.jsxs(zf,{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:[Aa(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&t.jsx(Zt,{className:cn,value:"raw-headers",children:"Raw Headers"}),Ia(s,L.headers!==void 0&&Object.keys(L.headers).length>0)&&t.jsx(Zt,{className:cn,value:"headers",children:"Headers"}),ie!==null&&t.jsx(Zt,{className:cn,value:"anatomy",children:"Context"}),Xc(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"})]}),Xc(We,s,r)&&t.jsx(dt,{value:"raw-request",children:b==="raw-request"&&t.jsxs(dn,{children:[t.jsx(Cr,{status:M,error:$,footprint:Se,onRetry:an}),J&&t.jsx(_r,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>$t("request",H.offset)}),le===null?t.jsx(Kr,{children:J?"Request preview is loading":"No request body"}):me.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(ss,{}),children:t.jsx(ki,{data:me.parsedData,bulkDepth:me.bulkDepth,bulkRevision:me.bulkRevision})}):t.jsx(kr,{children:le})]})}),t.jsx(dt,{value:"request",children:b==="request"&&t.jsxs(dn,{children:[t.jsx(Cr,{status:M,error:$,footprint:Se,onRetry:an}),J&&t.jsx(_r,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>$t("request",H.offset)}),ke.length>0&&t.jsxs(Un,{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(VN,{summary:oe,calledToolNames:D}),w?t.jsx(iC,{rawBody:L.rawRequestBody,displayedBody:se,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):t.jsx("div",{ref:fe,children:se===null?t.jsx(Kr,{children:J?"Request preview is loading":"No request body"}):xe.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(ss,{}),children:t.jsx(ki,{data:xe.parsedData,bulkDepth:xe.bulkDepth,bulkRevision:xe.bulkRevision,anatomyPaths:De,expandToPath:A})}):t.jsx(kr,{children:se})})]})}),ie!==null&&t.jsx(dt,{value:"anatomy",children:b==="anatomy"&&t.jsx(dn,{className:"p-0",children:t.jsx(l.Suspense,{fallback:t.jsx(ss,{}),children:t.jsx(ZS,{parsed:xe.parsedData,inputTokens:L.inputTokens??null,model:L.model,segments:ie,onSegmentActivate:Gn})})})}),Ia(s,L.headers!==void 0&&Object.keys(L.headers).length>0)&&t.jsx(dt,{value:"headers",children:b==="headers"&&t.jsxs(dn,{children:[t.jsx("div",{className:"flex justify-end gap-2 mb-2",children:WN(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&t.jsx(aC,{active:g,onClick:Me=>{Me.stopPropagation(),v(!g)}})}),g?t.jsx(lC,{rawHeaders:L.rawHeaders,headers:L.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):t.jsx(td,{headers:L.headers,emptyLabel:"No headers captured"})]})}),Aa(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&t.jsx(dt,{value:"raw-headers",children:b==="raw-headers"&&t.jsx(dn,{children:t.jsx(td,{headers:L.rawHeaders,emptyLabel:"No raw headers captured"})})}),t.jsx(dt,{value:"raw",children:b==="raw"&&t.jsxs(dn,{className:"space-y-3",children:[t.jsx(Cr,{status:M,error:$,footprint:Se,onRetry:an}),J&&t.jsx(_r,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>$t("response",U.offset)}),t.jsx(ed,{error:L.error,onOpenSse:Oe?Kn:void 0}),ce!==null&&Le?t.jsx(l.Suspense,{fallback:t.jsx(ss,{}),children:t.jsx(tN,{text:ce,defaultExpandDepth:0,bulkDepth:we.bulkDepth,bulkRevision:we.bulkRevision})}):ce!==null?t.jsx(kr,{children:ce}):t.jsx(Kr,{children:J?"Response preview is loading":"No response"}),Oe&&t.jsx(oC,{onOpenSse:Kn})]})}),Oe&&t.jsx(dt,{value:"sse",children:b==="sse"&&t.jsxs(dn,{className:"space-y-3",children:[L.error!==void 0&&L.error!==null&&t.jsx(Un,{tone:"danger",title:"SSE Error",children:t.jsx("span",{className:"font-mono",children:L.error})}),t.jsx(l.Suspense,{fallback:t.jsx(ss,{}),children:t.jsx(eN,{logId:L.id,truncated:L.streamingChunksPath!==null})})]})}),t.jsx(dt,{value:"parsed",children:b==="parsed"&&t.jsxs(dn,{children:[t.jsx(Cr,{status:M,error:$,footprint:Se,onRetry:an}),J&&t.jsx(_r,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>$t("response",U.offset)}),t.jsx(ed,{error:L.error,onOpenSse:Oe?Kn:void 0}),Re&&!Le?t.jsx(kr,{children:ce}):t.jsx(l.Suspense,{fallback:t.jsx(ss,{}),children:t.jsx(QS,{responseText:ce,responseStatus:L.responseStatus,streaming:L.streaming,inputTokens:L.inputTokens,outputTokens:L.outputTokens,cacheCreationInputTokens:L.cacheCreationInputTokens,cacheReadInputTokens:L.cacheReadInputTokens,apiFormat:We,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),t.jsx(Zr,{feature:"Replay",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(XS,{log:L,displayNumber:n,open:f,onOpenChange:h})})})]})});function dC(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 La(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function uC({stopReason:e,isPending:n,isFirst:s,isTurnStart:r,isOnlyEntry:o=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const p=$l(e),u=o&&r&&p,m=n&&!p,f=c&&d!==void 0,h=l.useMemo(()=>Fl(i),[i]),g=l.useMemo(()=>DS(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:La(f),onClick:v,onKeyDown:w,children:t.jsx(g,{className:P("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:dC(e),className:La(f),onClick:v,onKeyDown:w,children:t.jsx(h,{className:P("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:La(f),onClick:v,onKeyDown:w,children:t.jsx(h,{className:P("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:P("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:P("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:P("w-0.5 h-full",n?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const nd=180;function pC(e){const n=wf(e.path);return n==="unknown"?e.apiFormat:n}function mC(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 Wf(e){if(e===null)return null;try{const n=JSON.parse(e);return typeof n=="string"?JSON.parse(n):n}catch{return null}}function fC(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>nd?`${s.slice(0,nd-1)}...`:s}function hC(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:hC(o),argumentsPreview:fC(o)}}function xC(e){const n=Wf(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 gC(e){const n=Wf(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 Gf(e){if(typeof e.data=="string")try{return JSON.parse(e.data)}catch{return e.data}return e.data}function Yr(e,n,s){const r=`${s.provider}:${s.name}:${s.index}`;n.has(r)||(n.add(r),e.push(s))}function bC(e){const n=e.streamingChunks?.chunks??[],s=[],r=new Set;for(const o of n){const a=Gf(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");Yr(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 vC(e){const n=e.streamingChunks?.chunks??[],s=[],r=new Set;for(const o of n){const a=Gf(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");Yr(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");Yr(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");Yr(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 yC(e){if(e.toolTraceEvents!==void 0&&e.toolTraceEvents.length>0)return e.toolTraceEvents;const n=pC(e);if(mC(e,n))switch(n){case"anthropic":return xC(e);case"openai":return gC(e);case"unknown":return[]}switch(n){case"anthropic":return bC(e);case"openai":return vC(e);case"unknown":return[]}}const sd=new WeakMap;function wC(e){return e>1}function Ei(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:Pf(a),sessionLogNumber:o+1});const i=s[s.length-1];i!==void 0&&$l(i.stopReason)&&(n.push({entries:s,turnIndex:r}),s=[],r+=1)}return s.length>0&&n.push({entries:s,turnIndex:r}),n}function jC(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=xo(o),c=xo(a);i==="unknown"||i!==c||n.set(o.id,a)}return n}function Ul(e){const n=sd.get(e);if(n!==void 0&&n.apiFormat===e.apiFormat&&n.responseText===e.responseText&&n.toolTraceEvents===e.toolTraceEvents)return n.events;const s=yC(e);return sd.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,toolTraceEvents:e.toolTraceEvents,events:s}),s}function SC(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+=Ul(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 Oa(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const NC=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?$l(h):!1,v=n[f]?.log.responseStatus===null,w=n.length===1,y=wC(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 z=H=>{const te=na(H);te!==null&&n.some(U=>U.log.id===te.logId)&&y&&j(!1)};return window.addEventListener(rn,z),()=>{window.removeEventListener(rn,z)}},[y,n]),l.useEffect(()=>{if(u===void 0||!n.some(H=>H.log.id===u.logId))return;y&&j(!1);const z=window.setTimeout(()=>{Ss({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(z)},[y,n,u]);const N=l.useCallback(()=>{y&&j(z=>!z)},[y]),C=l.useMemo(()=>{let z=0,H=0,te=null,U=!1;for(const Z of n)Z.log.inputTokens!==null&&(z+=Z.log.inputTokens,U=!0),Z.log.outputTokens!==null&&(H+=Z.log.outputTokens,U=!0),Z.log.elapsedMs!==null&&(te=te===null?Z.log.elapsedMs:Math.max(te,Z.log.elapsedMs));return{totalInput:z,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 z=new Map;for(const H of n){const te=Ul(H.log);te.length>0&&z.set(H.log.id,te)}return z},[n]),[R,k]=l.useState(0),M=l.useRef(null);l.useEffect(()=>{const z=M.current;if(!z)return;let H=0;const te=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(U=>U+1))});return te.observe(z),()=>{te.disconnect(),window.cancelAnimationFrame(H)}},[]);const O=n[0]?.log.id??d,$=`Turn ${String(d+1)}`,K=l.useMemo(()=>Fl(O%12),[O]),ee=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:b?"48px":"160px"}),[b]);return t.jsx("div",{ref:M,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:P("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:z=>{(z.key==="Enter"||z.key===" ")&&(z.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:P("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:P("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:P("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:P("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(Rs,{children:t.jsxs(ut,{children:[t.jsx(pt,{asChild:!0,children:t.jsxs("span",{className:P("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:Oa(C.maxElapsed)}),A&&t.jsx(yn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsx(mt,{children:A?`Slow response: ${Oa(C.maxElapsed)} exceeds ${Oa(o*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Ys,{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(bt,{className:"size-4 shrink-0"})})]})]}):n.map((z,H)=>{const{log:te,stopReason:U}=z,Z=H===0;return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx(uC,{stopReason:U,isPending:te.responseStatus===null,isFirst:H===0,isTurnStart:Z,isOnlyEntry:w,isOpenTurnTail:H===f&&!g,crabIndex:te.id%12,collapsible:y&&Z,onToggle:N}),t.jsx("div",{className:P("flex-1 min-w-0 mb-0.5 rounded-[8px]",E),children:t.jsx(cC,{log:te,displayNumber:z.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)})})}),CC=24,kC=132,_C=8;function TC(e){return e>CC}function EC(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 Kf(e,n,s){return t.jsx(NC,{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 RC(e){return TC(e.turnGroups.length)?t.jsx(MC,{...e}):t.jsx(t.Fragment,{children:e.turnGroups.map(n=>Kf(n,e))})}function MC(e){const{turnGroups:n}=e,[s,r]=l.useState(null),o=wS({count:n.length,estimateSize:()=>kC,overscan:_C,getItemKey:i=>n[i]?.turnIndex??i}),a=l.useMemo(()=>EC(n),[n]);return l.useEffect(()=>{const i=c=>{const d=na(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:Kf(c,e,d)},i.key)})})}const ql=pe(["episode","procedure","preference","project-fact"]),AC=pe(["draft","promoted","failed"]),Yf=_({source:ae("agent-inspector"),sessionId:x(),logIds:V(Mt),project:x().nullable(),models:V(x())}),IC=_({redacted:Ce(),patterns:V(x())}),pr=_({id:x(),type:ql,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),sessionId:x(),logIds:V(Mt),evidence:Yf,status:AC,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:IC});_({idempotencyKey:x(),type:ql,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),project:x().nullable(),evidence:Yf});const PC=_({id:x(),type:ql.or(x()),title:x(),content:x(),score:T().nullable(),source:x().nullable(),project:x().nullable(),evidence:qs().optional()});_({results:V(PC),warning:x().nullable()});const LC=_({candidates:V(pr)}),OC=_({candidate:pr}),DC=_({error:x().optional(),candidate:pr.optional()}),zC=_({candidate:pr}),$C=3e4,FC=15e3,BC=15e3,UC={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 Ri(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function qC(e,n,s){return e===null||n===null?null:Io(e,n,s)}function HC(e){return`${String(e)} candidate${e===1?"":"s"}`}function Jf(e){return`log-${String(e)}`}function Xf(e){const n=Jf(e),s=document.getElementById(n);window.history.replaceState(null,"",`#${n}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function VC(e){for(const n of e)if(n.responseStatus!==null&&n.responseStatus>=400)return n;return null}function WC(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 GC(e){for(const n of e)if(Ul(n).length>0)return n;return null}function KC(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 hs(e,n){return String(n.get(e)??e)}function YC(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=GC(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 #${hs(s.id,e.displayNumberByLogId)}`,logId:s.id});const r=VC(e.logs);r!==null&&n.push({kind:"failure",title:`Failure #${String(r.responseStatus)}`,detail:`First failed request is #${hs(r.id,e.displayNumberByLogId)}`,logId:r.id});const o=WC(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&n.push({kind:"slow",title:`Slowest ${Ri(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${hs(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 JC(e){switch(e){case"session":return t.jsx(Ao,{className:"size-3.5 text-blue-400"});case"tool":return t.jsx(ar,{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(Du,{className:"size-3.5 text-destructive"});case"candidate":return t.jsx(Ou,{className:"size-3.5 text-emerald-400"})}}function XC({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:P("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&&Xf(n.logId)},disabled:n.logId===null,children:[JC(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 ZC(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function QC(e,n){if(n)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function ek(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function tk(e,n){const s=e.replace(/\s+/g," ").trim();return s.length<=n?s:`${s.slice(0,n-3)}...`}function nk(e,n){const s=e[0],r=e[e.length-1];if(s===void 0)return"No evidence logs";const o=hs(s,n);return r===void 0||s===r?`#${o}`:`#${o}-#${hs(r,n)}`}function rd(e){return e.join(", ")}function sk(e){return e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}function rk({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(rd(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(rd(e.tags)),y(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),E=f.trim(),A=sk(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=pr.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(cc,{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(Q,{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(ir,{className:"size-3.5"}),"Cancel"]}),t.jsxs(Q,{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(C1,{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(_e,{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(_e,{variant:"outline",className:P("h-5 shrink-0 px-1.5 text-[10px] font-mono",UC[e.status]),children:ZC(e.status)})]}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:tk(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(_0,{className:"size-3"}),nk(e.logIds,a)]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(cc,{className:"size-3"}),ek(e)]}),e.status==="promoted"&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[t.jsx(Ks,{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(Du,{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=hs(C,a);return t.jsxs("a",{href:`#${Jf(C)}`,onClick:A=>{A.preventDefault(),Xf(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(Q,{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(Vu,{className:"size-3"}),"Review"]}),t.jsxs(Q,{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(l0,{className:"size-3"}):t.jsx(Ks,{className:"size-3"}),QC(e,n)]})]})]})}function ok({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(rk,{candidate:i,isPromoting:n.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:a},i.id))})}function ak({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(()=>SC(e,s,a.length),[a.length,e,s]),y=l.useMemo(()=>KC(e),[e]),b=l.useMemo(()=>YC({logs:e,scopeId:n,summary:w,candidates:a,displayNumberByLogId:y}),[a,y,e,n,w]),j=r||w.maxElapsedMs!==null,S=l.useMemo(()=>qC(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`,LC,$C,{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 R=new Set(I);return R.add(A),R}),(async()=>{try{const I=await vn(`/api/knowledge/candidates/${encodeURIComponent(A)}/promote`,FC,{method:"POST"}),R=await I.json().catch(()=>null),k=OC.safeParse(R);if(I.ok&&k.success){i(O=>O.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const M=DC.safeParse(R);M.success&&M.data.candidate!==void 0&&i(O=>O.map($=>$.id===M.data.candidate?.id?M.data.candidate:$)),u({status:"failed",error:M.success?M.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 R=new Set(I);return R.delete(A),R})}})()},[]),E=l.useCallback(async(A,I)=>{g(R=>{if(R.has(A))return R;const k=new Set(R);return k.add(A),k});try{const R=await Be(`/api/knowledge/candidates/${encodeURIComponent(A)}`,zC,BC,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(M=>M.id===R.candidate.id?R.candidate:M)),u({status:"ready",error:null}),!0}catch(R){return u({status:"failed",error:R instanceof Error?R.message:"Candidate update failed"}),!1}finally{g(R=>{const k=new Set(R);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(Ao,{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(ar,{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(Ys,{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(Ys,{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:Ri(w.totalElapsedMs)}),w.maxElapsedMs!==null&&t.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Ri(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(_e,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:HC(w.knowledgeCandidateCount)}),t.jsxs(Q,{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(Ou,{className:"size-3.5"}),"Candidate"]}),v&&t.jsx(Q,{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(bt,{className:"size-3.5"})})]}),p.status==="failed"&&t.jsx("p",{className:"mt-2 text-xs text-destructive",children:p.error}),t.jsx(XC,{insights:b}),c&&t.jsx(ok,{candidates:a,promotingCandidateIds:m,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:E,displayNumberByLogId:y})]})}function ik(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 lk(e){const n=new Map;for(const s of e){if(s.model===null)continue;const r=y5(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 ck(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function dk(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const uk=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(()=>ik(e.logs),[e.logs]),S=l.useMemo(()=>lk(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(()=>ck(e.logs),[e.logs]),I=l.useMemo(()=>dk(e.logs),[e.logs]),R=l.useMemo(()=>Ei(e.logs),[e.logs]);return l.useEffect(()=>{const k=M=>{const O=na(M);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(tS,{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(ak,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:!1,timeDisplayFormat:f}),t.jsx(RC,{turnGroups:R,viewMode:n,strip:s,slowResponseThresholdSeconds:r,timeDisplayFormat:f,cacheTrends:o,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),pk="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",mk="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function fk(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function hk(e){return e==="full"}function xk(e){return e==="raw"}function gk(e,n){const s=n>0;return{redacted:s,raw:s&&hk(e)}}function bk(e,n){const s=e[0],r=e[e.length-1];return s===void 0||r===void 0?null:Io(s.timestamp,r.timestamp,n)}function vk(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function yk(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 wk(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 jk(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 Sk(e,n){return`${Ie(e)} in / ${Ie(n)} out`}function Nk(e,n){if(e.length===0)return 0;if(n.length===0)return Ei(e).length;let s=0;for(const r of n)s+=Ei(r.logs).length;return s}function Ck({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 kk(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||kk(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 Tk({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 R=e[I];if(R===void 0)continue;const k=I+1,M=Pf(R);M!==null&&(m=M),M==="length"&&(d+=1),vk(R)&&(a+=1,f=k,h={logNumber:k,status:R.responseStatus,error:R.error??null}),R.responseStatus===null&&(i+=1),o>0&&R.elapsedMs!==null&&R.elapsedMs>=S&&(c+=1),R.inputTokens!==null&&(p+=R.inputTokens),R.outputTokens!==null&&(u+=R.outputTokens),R.elapsedMs!==null&&(g===null||R.elapsedMs>g)&&(g=R.elapsedMs,v=k);const O=R.inputTokens??0,$=R.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=Ck({stopReason:m,pending:i,lastFailureLogNumber:f}),A=_k({pending:i,failures:a,lengthStops:d,stopReason:m,lastFailure:h});return{status:N,statusLabel:C,modelLabel:yk(e),providerLabel:wk(e),requests:e.length,turns:Nk(e,n),failures:a,pending:i,slow:c,lengthStops:d,timeRange:bk(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":jk(g),slowestDetail:v===null?"Latency pending":`Request #${v}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${Sk(y,b)}`}}function Ek({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 Rk({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 Qs({...e}){return t.jsx(km,{"data-slot":"select",...e})}function vo({...e}){return t.jsx(Rm,{"data-slot":"select-value",...e})}function er({className:e,size:n="default",children:s,...r}){return t.jsxs(Tm,{"data-slot":"select-trigger","data-size":n,className:P("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(Mm,{asChild:!0,children:t.jsx(Ze,{className:"size-4 opacity-50"})})]})}function tr({className:e,children:n,position:s="popper",align:r="center",...o}){return t.jsx(Im,{children:t.jsxs(Pm,{"data-slot":"select-content",className:P("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(Mk,{}),t.jsx($m,{className:P("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(Ak,{})]})})}function it({className:e,children:n,...s}){return t.jsxs(qm,{"data-slot":"select-item",className:P("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(Wm,{children:t.jsx($e,{className:"size-4"})})}),t.jsx(Hm,{children:n})]})}function Mk({className:e,...n}){return t.jsx(Gm,{"data-slot":"select-scroll-up-button",className:P("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(tl,{className:"size-4"})})}function Ak({className:e,...n}){return t.jsx(Km,{"data-slot":"select-scroll-down-button",className:P("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Ze,{className:"size-4"})})}const Ik=pe(["critical","warning","notice"]),Pk=pe(["open"]),Lk=pe(["proxy","tool-schema","run","group"]),Zf=pe(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),Ok=pe(["log","session","run","group"]),Dk=pe(["anthropic","openai","unknown"]),zk=_({kind:Ok,id:x(),label:x(),href:x().nullable()}),$k=_({id:x(),fingerprint:x(),severity:Ik,category:Zf,source:Lk,status:Pk,title:x(),message:x(),count:T().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:V(Mt),sessionIds:V(x()),runIds:V(x()),groupIds:V(x()),provider:x().nullable(),model:x().nullable(),apiFormat:Dk.nullable(),evidence:V(zk),metadata:qe(x(),Xe)}),Fk=_({category:Zf,count:T().int().nonnegative()}),Qf=_({total:T().int().nonnegative(),open:T().int().nonnegative(),critical:T().int().nonnegative(),warning:T().int().nonnegative(),notice:T().int().nonnegative(),byCategory:V(Fk)}),Bk=_({alerts:V($k),total:T().int().nonnegative(),limit:T().int().positive(),summary:Qf}),Uk=8e3,qk=1e4;function Hk(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 Vk(e,n){const s=qt(n?Hk(e):null,r=>Be(r,Bk,qk));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 Wk(){const e=qt("/api/alerts/summary",n=>Be(n,Qf,Uk),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Ms="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",Gk=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function eh(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function Kk(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Hl(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 Yk(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 Jk(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function Xk(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function Zk(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return t.jsx(D1,{className:"size-3.5"});case"request-timeout":case"slow-response":return t.jsx(o0,{className:"size-3.5"});case"tool-schema":return t.jsx(yn,{className:"size-3.5"});case"group-incomplete":return t.jsx(kg,{className:"size-3.5"})}}function Mi(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 xt(e){return e.toLocaleString()}function th(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 Qk(e,n){const s={limit:100};return e!=="all"&&(s.severity=e),n!=="all"&&(s.category=n),s}function e3(e,n){if(n!==null){const s=e.find(r=>r.id===n);if(s!==void 0)return s}return e[0]??null}function Tr({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:P("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:xt(n)})]})}function Er({value:e,active:n,label:s,count:r,onClick:o}){return t.jsxs(Q,{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(_e,{variant:"outline",children:xt(r)}):null]})}function t3({category:e,active:n,count:s,onClick:r}){return t.jsxs(Q,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>r(e),className:"h-7 px-2",children:[Zk(e),Hl(e),t.jsx(_e,{variant:"outline",children:xt(s)})]})}function n3({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:P("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:P("size-2 rounded-full",Jk(a.severity))}),t.jsx("span",{className:P("text-xs font-semibold",Xk(a.severity)),children:eh(a.severity)}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Hl(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(_e,{variant:"outline",className:"shrink-0",children:["x",xt(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:th(a)}),t.jsx("span",{className:"shrink-0",children:Mi(a.lastSeenAt)})]})]},a.id)})})}function s3({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(_e,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):t.jsx(_e,{variant:"outline",asChild:!0,children:t.jsx("a",{href:s.href,onClick:n,children:s.label})},`${s.kind}:${s.id}`))})}function r3({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:P("border-b px-4 py-3",Yk(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(_e,{variant:"outline",children:eh(e.severity)}),t.jsx(_e,{variant:"outline",children:Kk(e.source)}),t.jsx(_e,{variant:"outline",children:Hl(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(_e,{variant:"outline",className:"shrink-0",children:[xt(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:th(e)}),t.jsx(un,{label:"Last seen",value:Mi(e.lastSeenAt)}),t.jsx(un,{label:"First seen",value:Mi(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(s3,{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":xt(e.logIds.length)}),t.jsx(un,{label:"Sessions",value:e.sessionIds.length===0?"n/a":xt(e.sessionIds.length)}),t.jsx(un,{label:"Runs",value:e.runIds.length===0?"n/a":xt(e.runIds.length)}),t.jsx(un,{label:"Groups",value:e.groupIds.length===0?"n/a":xt(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 o3(){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}=Wk(),u=l.useMemo(()=>Qk(s,o),[o,s]),{alerts:m,total:f,isLoading:h,error:g,mutate:v}=Vk(u,e),w=l.useMemo(()=>e3(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(Pt,{open:e,onOpenChange:n,children:[t.jsx(Es,{asChild:!0,children:t.jsxs(Q,{type:"button",variant:"ghost",size:"icon",className:Ms,"aria-label":"Alerts",title:"Alerts",children:[t.jsx(ro,{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:P("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:xt(y)}):null,t.jsx("span",{className:"sr-only",children:"Alerts"})]})}),t.jsxs(Lt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[t.jsxs(Dt,{children:[t.jsxs(zt,{className:"flex items-center gap-2 pr-8",children:[t.jsx(ro,{className:"size-5 text-status-danger"}),t.jsx("span",{children:"Alerts"}),t.jsx(_e,{variant:"outline",children:xt(y)})]}),t.jsx(ur,{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(Tr,{label:"Open",count:d?.open??0,tone:"neutral"}),t.jsx(Tr,{label:"Critical",count:b,tone:"critical"}),t.jsx(Tr,{label:"Warning",count:j,tone:"warning"}),t.jsx(Tr,{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(Er,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:r}),t.jsx(Er,{value:"critical",active:s==="critical",label:"Critical",count:b,onClick:r}),t.jsx(Er,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:r}),t.jsx(Er,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:r})]}),t.jsxs(Q,{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(Q,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>a("all"),className:"h-7 px-2",children:"All categories"}),Gk.map(C=>{const E=d?.byCategory.find(A=>A.category===C)?.count??0;return E===0?null:t.jsx(t3,{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:[xt(f)," matched"]}),t.jsx("span",{children:m.length<f?`${xt(m.length)} shown`:"Latest"})]}),t.jsx(n3,{alerts:m,selectedAlertId:w?.id??null,isLoading:h,error:g,onSelect:c})]}),t.jsx(r3,{alert:w,onNavigate:()=>n(!1)})]})]})]})}const a3=12e3;function i3(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function l3(e){const n=qt(i3(e),s=>Be(s,eg,a3));return{evidenceResponse:n.data??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}const c3=8e3;function d3(){const e=qt("/api/groups",n=>Be(n,Iu,c3));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const u3=3e3;function p3(e,n){return{id:(e?.id??0)+1,message:n.message,tone:n.tone??"error"}}function nh(){const[e,n]=l.useState(null),s=l.useCallback(o=>{n(a=>p3(a,o))},[]),r=l.useCallback(()=>{n(null)},[]);return l.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{n(null)},u3);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:s,dismissToast:r}}function sh({notice:e,onDismiss:n}){if(e===null)return null;const s=e.tone==="error",r=s?yn:Ks;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:P("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:P("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(ir,{className:"size-3.5"})})]},e.id)})}const Da=2e4;function m3(e,n){const s=`/api/groups/${encodeURIComponent(e)}`;return n?`${s}?deleteEvidence=1`:s}function f3(e){return"/api/groups"}function rh(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 h3(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 Vl(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 Wl(e){return e??"unknown"}function x3(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 sa(e){return e===null||e.trim().length===0?"-":e}function ht(e){return e.toLocaleString()}function Ai(e){return e==null?"-":e<1e3?`${ht(e)} ms`:`${(e/1e3).toFixed(1)} s`}function Ns(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 od(e){return e===null?"-":Ns(e)}function g3(e){const n=JSON.stringify(e),s=n===void 0?String(e):n;return s.length<=160?s:`${s.slice(0,157)}...`}function oh(...e){for(const n of e)if(n!==null&&n.trim().length>0)return n;return"-"}function b3(...e){for(const n of e)if(n!=null&&n.trim().length>0)return n;return null}function v3(e){const n=e.provider,s=e.model;return n!==null&&n.length>0&&s!==null&&s.length>0?`${n} / ${s}`:oh(n,s)}function y3(e,n){if(n!==null){const s=e.find(r=>r.id===n);if(s!==void 0)return s}return e[0]??null}function w3(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function j3(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function S3(e,n){return n!==null&&n.group.id===e.id?n.evidence:e.evidence}function N3(e,n,s){return n!==null&&n.group.id===e.id?n.summary:s!==null&&s.group.id===e.id?s.summary:null}function C3(e,n,s){return n!==null&&n.group.id===e.id?n.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function k3({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}=nh(),{groups:A,isLoading:I,error:R,mutate:k}=d3(),M=l.useMemo(()=>y3(A,r),[A,r]);l.useEffect(()=>{!n||r!==null&&A.some(L=>L.id===r)||o(A[0]?.id??null)},[A,n,r]);const O=M!==null&&p!==null&&p.group.id===M.id?p:null,{evidenceResponse:$,isLoading:K,error:ee,mutate:z}=l3(M),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(f3(!1),Ru,Da,{method:"DELETE"},L=>`Clear failed with status ${String(L.status)}`);u(null),o(null),await k(),await z(),C({message:`Cleared ${ht(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,z,C]),U=l.useCallback(async re=>{i(re.id),d(null);try{const L=await Be(`/api/groups/${encodeURIComponent(re.id)}/evidence`,tg,Da,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},J=>`Export failed with status ${String(J.status)}`);u(L),await k(),await z()}catch(L){d(L instanceof Error?L.message:String(L))}finally{i(null)}},[k,z]),Z=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(m3(re.id,h),Eu,Da,{method:"DELETE"},L=>`Delete failed with status ${String(L.status)}`),u(L=>L!==null&&L.group.id===re.id?null:L),o(L=>L===re.id?null:L),f(null),g(!1),await k(),await z()}catch(L){b(L instanceof Error?L.message:String(L))}finally{w(null)}}},[h,m,k,z]);return t.jsxs(Pt,{open:n,onOpenChange:s,children:[t.jsx(sh,{notice:N,onDismiss:E}),t.jsx(Es,{asChild:!0,children:t.jsxs(Q,{type:"button",variant:"ghost",size:e?"default":"icon",className:P(Ms,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(ac,{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(Lt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Dt,{children:t.jsxs(zt,{className:"flex items-center gap-2 pr-8",children:[t.jsx(ac,{className:"size-5 text-muted-foreground"}),t.jsx("span",{children:"Groups"}),t.jsx(_e,{variant:"outline",children:ht(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(Q,{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(Q,{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:M?.id??null,isLoading:I,error:R,onSelect:je}),t.jsx(T3,{group:M,deleteTarget:m,deleteEvidence:h,exportResult:O,evidenceResponse:$,evidenceLoading:K,evidenceError:ee,exportError:c,deleteError:y,exportingGroupId:a,deletingGroupId:v,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:Z,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=rh(a),c=n===a.id;return t.jsxs("button",{type:"button",onClick:()=>o(a.id),className:P("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(_e,{variant:"outline",className:Vl(a.status),children:Wl(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:Ns(a.updatedAt)})]})]},a.id)})})})}function T3({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=rh(e),y=N3(e,r,o),b=C3(e,r,o),j=S3(e,r),S=h3(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(_e,{variant:"outline",className:Vl(e.status),children:Wl(e.status)}),t.jsx(_e,{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:sa(e.project)}),t.jsxs("span",{children:["updated ",Ns(e.updatedAt)]})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Q,{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(Q,{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(ks,{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(E3,{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(R3,{report:b,loading:a,error:i,hasEvidence:j!==null}),t.jsx(M3,{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(A3,{rows:S})]})})}function E3({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:P("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(Q,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),t.jsxs(Q,{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:ht(n)})]})}function R3({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(_e,{variant:"outline",className:x3(e.status),children:e.status})]}),t.jsx(Q,{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($e,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function M3({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:Ns(e.exportedAt)})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(za,{label:"JSON",value:e.jsonPath}),t.jsx(za,{label:"Markdown",value:e.markdownPath}),t.jsx(za,{label:"HTML",value:e.htmlPath})]})]})}function za({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(Q,{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($e,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})}function A3({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(I3,{row:o,isExpanded:a,onToggleDetails:r}),t.jsx(P3,{row:o,isExpanded:a})]},o.member.id)})})]})})]})}function I3({row:e,isExpanded:n,onToggleDetails:s}){const r=e.member,o=e.exportMember?.session??null,a=w3(e),i=o?.inspectorPath??pu(r.sessionId),c=e.source!=="evidence",d=o?.requestCount??null,p=o?.errorCount??null,u=o?.tokenUsage.total??null,m=a?.firstChunkMs??null,f=oh(r.label,r.sessionId),h=b3(o?.clientUserAgent,a?.userAgent,r.agent),g=o?.clientProjectFolder??null,v=Pl({userAgent:h,conversationId:r.sessionId,clientProjectFolder:g}),w=ea(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(Q,{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(bt,{className:"size-3.5"})}),w!==null&&t.jsx(ta,{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(or,{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(_e,{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:sa(r.agent)})]}),t.jsx("td",{className:"max-w-52 px-3 py-2",children:t.jsx("span",{className:"block whitespace-normal leading-snug",children:v3(r)})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx(_e,{variant:"outline",className:Vl(r.status),children:Wl(r.status)})}),t.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ht(d)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:p===null?"-":ht(p)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:Ai(m)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ht(u)})]})}function P3({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:j3(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:Ns(s.addedAt)}),t.jsx(tt,{label:"Updated",value:Ns(s.updatedAt)}),t.jsx(tt,{label:"Session created",value:od(o?.createdAt??null)}),t.jsx(tt,{label:"Session updated",value:od(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:sa(o.runtimeMode)}),t.jsx(tt,{label:"Requests",value:ht(o.requestCount),mono:!0}),t.jsx(tt,{label:"Errors",value:ht(o.errorCount),mono:!0}),t.jsx(tt,{label:"Input tokens",value:ht(o.tokenUsage.input),mono:!0}),t.jsx(tt,{label:"Output tokens",value:ht(o.tokenUsage.output),mono:!0}),t.jsx(tt,{label:"Cache read",value:ht(o.tokenUsage.cacheRead),mono:!0}),t.jsx(tt,{label:"Total tokens",value:ht(o.tokenUsage.total),mono:!0})]}),t.jsx(L3,{logs:o?.latestLogs??[]}),t.jsx(O3,{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:P("truncate text-xs text-foreground",s?"font-mono":""),title:n,children:n})]})}function L3({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:[sa(s.model)," · ",s.apiFormat," · ",s.path]}),t.jsx("span",{className:"font-mono text-muted-foreground",children:Ai(s.firstChunkMs)}),t.jsx("span",{className:"font-mono text-muted-foreground",children:Ai(s.latencyMs)})]},s.id)})})]})}function O3({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=g3(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 D3=_({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()}),z3=_({scanId:x().uuid(),providers:V(D3),warnings:V(x()).optional()});_({scanId:x().uuid(),selectionIds:V(x().uuid()).min(1).max(100)});const $3=_({success:Ce().optional(),imported:T().optional(),message:x().optional(),errors:V(x()).optional()}),ad=2e4;function F3({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",z3,ad,{method:"POST"},M=>`Scan failed (${String(M.status)})`).then(M=>{if(N.current!==k)return;d(M.scanId),u(M.providers),f(M.warnings??[]);const O=new Set;M.providers.forEach(($,K)=>{$.alreadyExists||O.add(K)}),g(O)}).catch(M=>{N.current===k&&i(M instanceof Error?M.message:String(M))}).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(M=>{const O=new Set(M);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 M=C.current+1;C.current=M,w(!0),S(null),b(null),Be("/api/providers/import",$3,ad,{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===M&&(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===M&&S(O instanceof Error?O.message:String(O))}).finally(()=>{C.current===M&&w(!1)})},[p,c,h,s]),R=p.some(k=>!k.alreadyExists);return t.jsx(Pt,{open:e,onOpenChange:n,children:t.jsxs(Lt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(Dt,{children:[t.jsx(zt,{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,M)=>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(M),disabled:v,onChange:()=>A(M),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(ta,{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,M)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(tn,{className:"size-3"}),k]},M))}),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(Q,{variant:"outline",size:"sm",onClick:E,disabled:r,children:[t.jsx(Ue,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),t.jsxs(Q,{size:"sm",onClick:I,disabled:!R||h.size===0||v,children:[t.jsx(ks,{className:"size-3 mr-1"}),v?"Importing...":`Import Selected (${h.size})`]})]})]})})}const ah=_({id:x().min(1).max(ci),aliases:V(x().max(ci)).max(wn).optional().default([]),contextWindow:T().int().positive().optional(),outputLimit:T().int().positive().optional(),sourceUrl:x().optional()}),B3=_({name:x().min(1).optional(),aliases:V(x()).max(wn).optional().default([]),baseUrls:V(x()).max(wn).optional().default([]),models:V(ah).min(1).max(wn)});_({version:T().int().positive().optional(),updatedAt:x().optional(),providers:V(B3).max(wn).optional().default([]),models:V(ah).max(wn).optional().default([])});function id(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function U3(e){const n=e.models.filter(s=>s.trim()!=="");return n.length>0?n:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Gl(e,n){const s=id(n);return(e.modelMetadata??[]).find(o=>id(o.model)===s)??null}function q3(e){const n=U3(e);return n.length===0?!1:n.every(s=>{const r=Gl(e,s);return r!==null&&r.contextWindow!==void 0})}function H3(e,n){if(e===null)return null;for(const s of n){const r=Gl(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 nr(e){return Object.prototype.hasOwnProperty.call(e,"success")}function ra(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function jt(e){return e!==void 0&&e!==""}function rt(e){return e!==void 0&&e.trim()!==""}function Rr(e){return e!=null}function xs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function ih(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function lh(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 V3(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?xs(e.firstChunkMs):e.latencyMs!==void 0?xs(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?xs(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?ih(e.tokensPerSecond):null}function W3(e){return ra(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:nr(e)?e.success?{tone:"success",label:"Pass",metric:V3(e),hasDetails:!0}:{tone:"failure",label:lh(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function G3(e,n){if(n===void 0)return[];const s=[];return jt(e.anthropicBaseUrl)&&s.push(n.anthropic),jt(e.openaiBaseUrl)&&s.push(n.openaiChat),jt(e.openaiResponsesBaseUrl)&&s.push(n.openaiResponses),s}function K3(e,n){const s={total:0,passed:0,failed:0,testing:0};for(const r of G3(e,n))for(const o of[r.nonStreaming,r.streaming])ra(o)||(s.total+=1,nr(o)?o.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function ld(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 Y3({result:e}){const n=Rr(e.inputTokens)||Rr(e.outputTokens),s=Rr(e.cacheCreationInputTokens)||Rr(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:xs(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&t.jsx(An,{label:"First chunk",value:xs(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&t.jsx(An,{label:"Stream total",value:xs(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&t.jsx(An,{label:"Token rate",value:`${ih(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 J3({result:e}){const n=e.debug,s=n?.requestUrl,r=n?.requestMethod??"POST",o=ld(n?.requestHeaders),a=ld(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 X3({result:e,probeLabel:n,children:s}){const r=e.error?.message??"Connection failed";return t.jsxs(Pt,{children:[t.jsx(Es,{asChild:!0,children:s}),t.jsxs(Lt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[t.jsxs(Dt,{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(rr,{className:"size-4 text-status-success"}):t.jsx(tn,{className:"size-4 text-status-danger"}),t.jsx(zt,{className:"text-base",children:n})]}),t.jsx(ur,{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:lh(e.error?.type??"unknown")}),t.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:r})]}),t.jsx(Y3,{result:e}),t.jsx(J3,{result:e})]})]})]})}function Z3(e){const n="size-3 shrink-0";switch(e){case"timeout":return t.jsx(en,{className:n});case"network_unreachable":return t.jsx(Y1,{className:n});case"connection_refused":return t.jsx(X1,{className:n});case"auth_failed":return t.jsx(W0,{className:n});case"rate_limited":return t.jsx(nl,{className:n});case"server_error":return t.jsx(I1,{className:n});case"invalid_response":return t.jsx(Zg,{className:n});case"unknown":return t.jsx(tn,{className:n})}}const Q3={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 cd({result:e,probeLabel:n}){const s=W3(e),r=ra(e)?t.jsx(Hu,{className:"size-3 shrink-0"}):nr(e)?e.success?t.jsx(rr,{className:"size-3 shrink-0"}):Z3(e.error?.type??"unknown"):t.jsx(so,{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=P("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",Q3[s.tone]);return nr(e)&&s.hasDetails?t.jsx(X3,{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 dd({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(Hu,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e})]})}function $a({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(cd,{result:n.nonStreaming,probeLabel:`${e} non-stream`}):t.jsx(dd,{label:s?"Not tested":"Off"}),s&&n!==void 0?t.jsx(cd,{result:n.streaming,probeLabel:`${e} stream`}):t.jsx(dd,{label:s?"Not tested":"Off"})]})}function ch({provider:e,results:n}){const s=jt(e.anthropicBaseUrl),r=jt(e.openaiBaseUrl),o=jt(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($a,{label:"Anthropic",results:n?.anthropic}),r&&t.jsx($a,{label:"OpenAI Chat",results:n?.openaiChat}),o&&t.jsx($a,{label:"OpenAI Responses",results:n?.openaiResponses})]})})}function e4(e){const n={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])ra(s)||(n.total+=1,nr(s)?s.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function Fa({label:e,results:n}){const s=e4(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:P("rounded border px-1.5 py-0.5 text-[10px]",r),children:[e," ",o]})}function t4({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(bt,{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:[jt(e.anthropicBaseUrl)&&t.jsx(Fa,{label:"A",results:s.anthropic}),jt(e.openaiBaseUrl)&&t.jsx(Fa,{label:"Chat",results:s.openaiChat}),jt(e.openaiResponsesBaseUrl)&&t.jsx(Fa,{label:"Resp",results:s.openaiResponses})]})]}),r&&t.jsx("div",{className:"px-2 pb-3",children:t.jsx(ch,{provider:e,results:s})})]})}function n4({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(bt,{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(t4,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(p=>p===c?null:c)},c))})]})}function s4({provider:e,testResults:n,isTesting:s}){const r=jt(e.anthropicBaseUrl)||jt(e.openaiBaseUrl)||jt(e.openaiResponsesBaseUrl),o=K3(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(so,{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(rr,{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 r4={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function Ba(e){return e!==void 0&&e!==""}function Ua({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(rr,{className:"size-3"}),e]})}function o4({provider:e}){const n=Ba(e.anthropicBaseUrl),s=Ba(e.openaiBaseUrl),r=Ba(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(Ua,{label:"Anthropic"}),s&&t.jsx(Ua,{label:"OpenAI Chat"}),r&&t.jsx(Ua,{label:"OpenAI Responses"})]})}function a4(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 i4({provider:e,model:n}){const s=Gl(e,n),r=c4(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:fu(s.contextWindow)}),r!==null&&t.jsx(Rs,{children:t.jsxs(ut,{children:[t.jsx(pt,{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(mt,{children:r.title})]})})]})}function l4(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 c4(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 d4({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(r4).find(([b])=>e.name.toLowerCase().includes(b))?.[1],h=q3(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:a4(e)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(s4,{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(or,{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(o4,{provider:e}),n?.testedAt!==void 0&&t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(en,{className:"size-3"}),l4(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(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:p,children:[t.jsx(so,{className:`size-3 ${p?"animate-spin":""}`}),v]}),!g&&t.jsx(Q,{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(rr,{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(i4,{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(ch,{provider:e,results:n})]}),n!==void 0&&t.jsx(n4,{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(bt,{className:"size-3"}),"Details"]}),t.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&t.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:w,children:[t.jsx(so,{className:`size-3 ${w?"animate-spin":""}`}),w?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),t.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:w,children:[t.jsx(Vu,{className:"size-3"}),"Edit"]}),t.jsxs(Q,{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 gs="/v1/chat/completions",Ii="/v1/responses",u4="/v1/messages";function p4(e,n){const s=e.endsWith("/")?e.slice(0,-1):e,r=dh(n),o=n.indexOf("?"),a=o>=0?n.slice(o):"";return r!==""&&s.endsWith(r)?s+a:ph(s)&&uh(n)||s.endsWith("/v1")&&n.startsWith("/v1/")?s+n.slice(3):s+n}function m4(e,n,s={}){const r=e.trim().replace(/\/+$/,""),o=dh(n),a=p4(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."}):ph(r)&&uh(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."}),ud(o)&&h4(r)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),f4(o)&&x4(r)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),ud(o)&&g4(r,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function dh(e){return e.split("?")[0]??e}function uh(e){return e===gs||e.startsWith(`${gs}?`)||e.startsWith(`${gs}/`)}function f4(e){return e===gs||e.startsWith(`${gs}/`)}function ud(e){return e===Ii||e.startsWith(`${Ii}/`)}function h4(e){return e.toLowerCase().endsWith("/chat/completions")}function x4(e){return e.toLowerCase().endsWith("/responses")}function g4(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 ph(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 qa(e){return e!==void 0&&e.trim()!==""}function pd(e){const n=qa(e?.anthropicBaseUrl),s=qa(e?.openaiBaseUrl),r=qa(e?.openaiResponsesBaseUrl);return{anthropic:n,openai:s||r,openaiChat:s,openaiResponses:r}}function Ha(e,n,s){if(!e)return s?"":void 0;const r=n.trim();return r===""?void 0:r}const md=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],fd=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],Mr=u4,Ar=gs,Ir=Ii,b4={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"}},hd=["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"],xd=["qwen3.6-plus","qwen3.7-max"],gd=["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"],Pi="__unset__",yo="__custom__",mh=[{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 bd(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function fh(e,n){const s=bd(n);return e?.modelMetadata?.find(r=>bd(r.model)===s)??null}function hh(e){const n=Qr(e);if(n===null)return null;for(const s of mh)if(Qr(s.value)===n)return s.value;return null}function v4(e){return e.trim()===""?"unset":hh(e)!==null?"preset":"custom"}function y4(e){switch(e.contextWindowMode){case"unset":return Pi;case"custom":return yo;case"preset":return hh(e.contextWindow)??yo}}function Va(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 vd(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 yd(e,n){return n.map(s=>{const r=fh(e,s),o=r?.contextWindow!==void 0?tx(r.contextWindow):"";return{contextWindow:o,contextWindowMode:v4(o),outputLimit:r?.outputLimit?.toString()??""}})}function wd(e){const n=e.trim();if(n==="")return null;const s=Number(n);return!Number.isInteger(s)||s<=0?null:s}function rs(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 w4(e,n,s){const r=e.trim();return r===""?null:m4(r,n,{providerName:s})}function Wa({baseUrl:e,endpoint:n,providerName:s}){const r=w4(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 j4({provider:e,onSubmit:n,onCancel:s}){const r=pd(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(()=>yd(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,R]=l.useState(rs(e?.anthropicBaseUrl,Mr)),[k,M]=l.useState(rs(e?.openaiBaseUrl,Ar)),[O,$]=l.useState(rs(e?.openaiResponsesBaseUrl,Ir)),[K,ee]=l.useState(e?.apiDocsUrl??""),[z,H]=l.useState(e?.modelMetadataUrl??""),[te,U]=l.useState(e?.source),[Z,fe]=l.useState({}),[je,he]=l.useState(!1),[re,L]=l.useState(null),J=l.useRef([]);l.useEffect(()=>{if(re===null)return;const D=re;function Y(de){if(!(de.target instanceof Node))return;const Ne=J.current[D];Ne!=null&&!Ne.contains(de.target)&&L(null)}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[re]);const[Se,Te]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!1),Re=o.toLowerCase().includes("minimax"),Fe=o.toLowerCase().includes("alibaba"),ct=[...md,...fd].some(D=>o.toLowerCase().includes(D)),He=Re?hd:ct?gd:Fe?xd:[],Le=e?.modelMetadata?.some(D=>D.contextWindow!==void 0)??!1;function We(){wt(i).then(D=>{D&&(m(!0),setTimeout(()=>m(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),p(!1);const D=(e.models?.length??0)>0?e.models:[""];g(D),w(yd(e,D));const Y=pd(e);b(Y.anthropic),S(Y.openai),C(Y.openaiChat),A(Y.openaiResponses),R(rs(e.anthropicBaseUrl,Mr)),M(rs(e.openaiBaseUrl,Ar)),$(rs(e.openaiResponsesBaseUrl,Ir)),ee(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),U(e.source),Te(!1),le(!1),Pe(!1)}},[e]),l.useEffect(()=>{const D=o.toLowerCase();for(const[Y,de]of Object.entries(b4))if(D.includes(Y)){de.anthropicBaseUrl!==void 0&&!Se&&R(de.anthropicBaseUrl),de.openaiBaseUrl!==void 0&&!ge&&M(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([hd[0]??""]),Y==="alibaba"&&h.length===1&&h[0]===""&&g([xd[0]??""]),(md.includes(Y)||fd.includes(Y))&&h.length===1&&h[0]===""&&g([gd[0]??""]);break}},[o]);function Ye(){const D={};return o.trim()||(D.name="Name is required"),e===void 0&&!i.trim()&&(D.apiKey="API key is required"),(h.length===0||h.every(Y=>!Y.trim()))&&(D.models="At least one model is required"),!y&&!j&&(D.capabilities="Select at least one API capability"),j&&!N&&!E&&(D.openaiCapabilities="Select Chat Completions, Responses, or both"),y&&(I.trim()===""?D.anthropicBaseUrl="Anthropic base URL is required":Qe(I.trim())||(D.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?D.openaiBaseUrl="OpenAI Chat base URL is required":Qe(k.trim())||(D.openaiBaseUrl="Invalid URL format")),j&&E&&(O.trim()===""?D.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Qe(O.trim())||(D.openaiResponsesBaseUrl="Invalid URL format")),z.trim()&&!Qe(z.trim())&&(D.modelMetadataUrl="Invalid URL format"),v.forEach((Y,de)=>{const Ne=Qr(Y.contextWindow),F=wd(Y.outputLimit);Y.contextWindow.trim()!==""&&Ne===null&&(D[`modelMetadata.${de}.contextWindow`]="Context window must be a positive number, optionally using K or M"),Y.outputLimit.trim()!==""&&F===null&&(D[`modelMetadata.${de}.outputLimit`]="Output limit must be a positive integer"),Ne!==null&&F!==null&&F>Ne&&(D[`modelMetadata.${de}.outputLimit`]="Output limit should not exceed context window")}),fe(D),Object.keys(D).length===0}function Qe(D){try{return new URL(D),!0}catch{return!1}}function ot(D,Y){g(de=>{const Ne=[...de];return Ne[D]=Y,Ne})}function nt(D,Y){w(de=>{const Ne=[...de];return Ne[D]={...Ne[D]??In(),...Y},Ne})}function q(D,Y){switch(Y){case Pi:nt(D,{contextWindow:"",contextWindowMode:"unset"});return;case yo:{const de=v[D]??In();nt(D,{contextWindow:de.contextWindow,contextWindowMode:"custom"});return}default:nt(D,{contextWindow:Y,contextWindowMode:"preset"});return}}function se(D,Y){const de=v[D]??In(),Ne=Va(de.contextWindow);nt(D,{contextWindow:vd(Y,Ne.unit),contextWindowMode:"custom"})}function xe(D,Y){const de=v[D]??In(),Ne=Va(de.contextWindow);switch(Y){case"K":case"M":case"tokens":nt(D,{contextWindow:vd(Ne.amount,Y),contextWindowMode:"custom"});return;default:return}}function me(D){g(Y=>Y.filter((de,Ne)=>Ne!==D)),w(Y=>Y.filter((de,Ne)=>Ne!==D))}function we(){g(D=>[...D,""]),w(D=>[...D,In()])}function Oe(){const D=new Date().toISOString(),Y=[];return h.forEach((de,Ne)=>{const F=de.trim();if(F==="")return;const W=v[Ne]??In(),X=Qr(W.contextWindow),ne=wd(W.outputLimit);if(X===null&&ne===null)return;const Ee=fh(e,F);if(Ee!==null&&Ee.contextWindow===(X??void 0)&&Ee.outputLimit===(ne??void 0)){Y.push({...Ee,model:F});return}const ie={model:F,source:"manual",updatedAt:D};X!==null&&(ie.contextWindow=X),ne!==null&&(ie.outputLimit=ne),Y.push(ie)}),Y.length>0?Y:e?.modelMetadata!==void 0?[]:void 0}function ze(D){if(D.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:Ha(y,I,Y),openaiBaseUrl:Ha(j&&N,k,Y),openaiResponsesBaseUrl:Ha(j&&E,O,Y),apiDocsUrl:K.trim()||void 0,modelMetadataUrl:z.trim()||void 0,modelMetadata:Oe(),source:te})}finally{he(!1)}}return t.jsxs("form",{onSubmit:ze,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:D=>a(D.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"}),Z.name!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.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:D=>S(D.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:D=>C(D.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:D=>A(D.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),Z.openaiCapabilities!==void 0&&j&&t.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:Z.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:D=>b(D.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"})]})]})]}),Z.capabilities!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.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:D=>{Te(!0),R(D.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:Mr})]}),Z.anthropicBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.anthropicBaseUrl}),t.jsx(Wa,{baseUrl:I,endpoint:Mr,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:D=>{le(!0),M(D.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:Ar})]}),Z.openaiBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.openaiBaseUrl}),t.jsx(Wa,{baseUrl:k,endpoint:Ar,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:D=>{Pe(!0),$(D.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:Ir})]}),Z.openaiResponsesBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.openaiResponsesBaseUrl}),t.jsx(Wa,{baseUrl:O,endpoint:Ir,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:D=>U(D.target.value==="company"||D.target.value==="personal"?D.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:z,onChange:D=>H(D.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"}),Z.modelMetadataUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.modelMetadataUrl}),z.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&&z.trim()===""&&t.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),z.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:D=>c(D.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(D=>!D),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(y0,{className:"size-4"}):t.jsx($u,{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($e,{className:"size-4 text-status-success"}):t.jsx(St,{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."}),Z.apiKey!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.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((D,Y)=>{const de=v[Y]??In(),Ne=Z[`modelMetadata.${Y}.contextWindow`],F=Z[`modelMetadata.${Y}.outputLimit`],W=y4(de),X=Va(de.contextWindow);return t.jsxs("div",{ref:ne=>{J.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:D,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:()=>L(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),L(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(Qs,{value:W,onValueChange:ne=>q(Y,ne),children:[t.jsx(er,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(vo,{})}),t.jsxs(tr,{className:"max-h-64",children:[t.jsx(it,{value:Pi,children:"Not set"}),mh.map(ne=>t.jsxs(it,{value:ne.value,children:[ne.label," · ",ne.value]},ne.value)),t.jsx(it,{value:yo,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:X.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(Qs,{value:X.unit,onValueChange:ne=>xe(Y,ne),children:[t.jsx(er,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(vo,{})}),t.jsxs(tr,{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"}),Z.models!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:Z.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:D=>ee(D.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(Q,{type:"button",variant:"outline",onClick:s,disabled:je,children:"Cancel"}),t.jsx(Q,{type:"submit",disabled:je,children:je?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const S4=pe(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),N4=_({message:x(),type:S4,details:x().optional(),hint:x().optional()}),C4=_({type:pe(["text","thinking"]),text:x().optional(),thinking:x().optional()}),k4=_({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:qe(x(),x()).optional(),requestBody:x().optional(),responseStatus:T().optional(),responseStatusText:x().optional(),responseHeaders:qe(x(),x()).optional(),responseBody:x().optional()}),Pr=T().nullable().optional(),_4=_({success:Ce(),error:N4.optional(),model:x().optional(),inputTokens:Pr,outputTokens:Pr,cacheCreationInputTokens:Pr,cacheReadInputTokens:Pr,latencyMs:T().optional(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),content:V(C4).optional(),rawResponse:x().optional(),streaming:Ce().optional(),streamingChunks:_({chunks:V(xu),truncated:Ce().default(!1)}).optional(),requestHeaders:qe(x(),x()).optional(),debug:k4.optional()}),jd=Gt([_4,_({notConfigured:ae(!0)}),_({testing:ae(!0)})]),bn=_({nonStreaming:jd,streaming:jd});function wo(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const T4=_({anthropic:bn,openai:bn.optional(),openaiChat:bn.optional(),openaiResponses:bn.optional()}).transform(e=>{const n=e.openaiChat??e.openai??wo();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??wo()}}),E4=_({anthropic:bn,openai:bn.optional(),openaiChat:bn.optional(),openaiResponses:bn.optional(),models:qe(x(),T4).optional(),testedAt:x().optional()}).transform(e=>{const n=e.openaiChat??e.openai??wo();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??wo()}});function R4(){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 Sd(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 M4=_({providerConfig:x()}),A4=_({success:Ce().optional(),imported:T().optional(),message:x().optional(),errors:V(x()).optional()}),I4=_({provider:ao,imported:T(),matchedModels:V(x()),missingModels:V(x()),sourceUrl:x()}),Lr="Network error: could not reach the server. Is the proxy running?",P4=5e3,L4=5e3,Nd=15e3,O4=1e4,D4=2e4,z4=2e4,$4=3e4;function Ga(e,n){return(e?.length??0)>0?e:n&&e!==void 0?"":void 0}function Cd(e,n=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ga(e.anthropicBaseUrl,n),openaiBaseUrl:Ga(e.openaiBaseUrl,n),openaiResponsesBaseUrl:Ga(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 F4(e,n){const s=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,s)*n}async function B4(e,n){if(n.models!==void 0)try{await vn(`/api/providers/${e}/test/log`,L4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}function U4({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,R]=l.useState(null),[k,M]=l.useState(!1),[O,$]=l.useState(!1),[K,ee]=l.useState(null),[z,H]=l.useState("all"),[te,U]=l.useState(new Set),{providerTestTimeoutSeconds:Z}=Qi(),fe=l.useRef(null),je=l.useRef(null),he=e??[],re=l.useMemo(()=>{const q=z==="all"?he:he.filter(se=>se.source===z);return z==="all"?[...q].sort((se,xe)=>{const me={personal:0,company:1};return(me[se.source??""]??2)-(me[xe.source??""]??2)}):q},[he,z]),L=s??v,J=r??y,Se=o??j,Te=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",M4,P4);C(q.providerConfig)}catch{}})()},[]);const ge=l.useCallback(q=>{je.current!==null&&clearTimeout(je.current),R(q),fe.current?.scrollTo({top:fe.current.scrollHeight,behavior:"smooth"}),je.current=setTimeout(()=>{R(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,R4()),Pe(q,!0);const se=new AbortController,xe=he.find(ze=>ze.id===q),me=F4(xe,Z);let we=me;Te(q,we);const Oe=setInterval(()=>{we--,Te(q,we),we<=0&&(clearInterval(Oe),se.abort())},1e3);try{const ze=await Be(`/api/providers/${q}/test`,E4,me*1e3+1e3,{method:"POST",signal:se.signal},D=>`HTTP ${D.status}: ${D.statusText}`);ce(q,ze),await B4(q,ze)}catch(ze){const D=ze instanceof Error&&ze.name==="AbortError",Y=ze instanceof Ro;D||Y?ce(q,Sd("Request timed out","timeout")):ze instanceof Error&&ce(q,Sd(ze.message,"server_error"))}finally{clearInterval(Oe),Te(q,void 0),Pe(q,!1)}},[Z,he,Te,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`,I4,$4,{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:Lr),!1}finally{U(me=>{const we=new Set(me);return we.delete(q),we})}},[le,ge]);function ct(q){(async()=>{try{const se=await Be("/api/providers",ao,Nd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Cd(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:Lr)}})()}function He(q){m&&(async()=>{try{const se=await Be(`/api/providers/${m.id}`,ao,Nd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Cd(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:Lr)}})()}function Le(q){ee(q),$(!0)}function We(){const q=K;q!==null&&(async()=>{let se;try{se=await vn(`/api/providers/${q}`,O4,{method:"DELETE"})}catch{g(Lr);return}if(!se.ok){g(await nx(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,D4);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",z4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xe)}),we=await hu(me,A4);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(j4,{provider:m,onSubmit:m?He:ct,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(Q,{variant:"outline",size:"sm",onClick:()=>Qe(),className:"gap-1 hover:bg-muted",children:[t.jsx(ks,{className:"size-3"}),"Export"]}),t.jsxs(Q,{variant:"outline",size:"sm",onClick:ot,className:"gap-1 hover:bg-muted",children:[t.jsx(Yu,{className:"size-3"}),"Import"]}),t.jsx("input",{type:"file",ref:Ye,accept:".json",onChange:nt,style:{display:"none"}}),t.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>M(!0),className:"gap-1",children:[t.jsx(_1,{className:"size-3"}),"Scan"]}),t.jsxs(Q,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[t.jsx(ic,{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:()=>{wt(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($e,{className:"size-3 text-status-success"}):t.jsx(St,{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(Q,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[t.jsx(ic,{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 ${z===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(d4,{provider:q,testResults:L[q.id],isTesting:J.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(F3,{open:k,onOpenChange:M,onImportComplete:()=>{a!==void 0&&a()}}),t.jsx(Il,{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 q4=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function H4(){return t.jsx(zf,{"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:q4.map(e=>t.jsx(Zt,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function V4(){const[e,n]=l.useState(!1),[s,r]=l.useState("providers"),{providers:o,isLoading:a,mutate:i}=ll(),[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(Pt,{open:e,onOpenChange:n,children:[t.jsx(Es,{asChild:!0,children:t.jsxs(Q,{variant:"ghost",size:"icon",className:Ms,"aria-label":"Settings",title:"Settings",children:[t.jsx(L1,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Settings"})]})}),t.jsxs(Lt,{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(Dt,{children:t.jsx(zt,{children:"Settings"})}),t.jsxs(Df,{value:s,onValueChange:r,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[t.jsx(H4,{}),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(dt,{value:"providers",children:t.jsx(U4,{externalProviders:o,isLoading:a,externalTestResults:c,externalTestingProviders:p,externalTestingTimeLeft:m,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:v})}),t.jsx(dt,{value:"proxy",children:t.jsx(Q4,{})}),t.jsx(dt,{value:"storage",children:t.jsx(K4,{})}),t.jsx(dt,{value:"mcp",children:t.jsx(Z4,{})}),t.jsx(dt,{value:"onboarding",children:t.jsx(X4,{})})]})]})]})]})}const W4=_({kind:x(),root:x(),sensitivity:x(),cleanupBehavior:x(),fileCount:T(),bytes:T(),oldestModifiedAt:x().nullable(),newestModifiedAt:x().nullable()}),kd=_({memoryCount:T(),inventory:_({checkedAt:x(),totalFiles:T(),totalBytes:T(),artifacts:V(W4)}),policy:_({maxAgeMs:T(),maxTotalBytes:T()}),reclaimableBytes:T(),lastGc:_({checkedAt:x(),filesDeleted:T(),bytesDeleted:T(),errors:T(),beforeTotalBytes:T(),afterTotalBytes:T()}).nullable()}),_d=1e4;function Us(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 G4(e){return`${Math.round(e/1e3/60/60/24).toLocaleString()} days`}function K4(){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",kd,_d,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)=>{wt(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",kd,_d,{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(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{f()},disabled:i,children:i?"Running...":"Run GC now"}),t.jsx(Q,{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(Or,{label:"Persisted footprint",value:`${e.inventory.totalFiles.toLocaleString()} files / ${Us(e.inventory.totalBytes)}`,detail:`Checked ${new Date(e.inventory.checkedAt).toLocaleString()}`}),t.jsx(Or,{label:"Auto-reclaimable",value:Us(e.reclaimableBytes),detail:`Retention ${G4(e.policy.maxAgeMs)} / max ${Us(e.policy.maxTotalBytes)}`}),t.jsx(Or,{label:"In-memory logs",value:`${e.memoryCount.toLocaleString()} loaded`,detail:"Recent completed entries kept hot for the UI"}),t.jsx(Or,{label:"Last GC",value:e.lastGc===null?"Not run yet":`${e.lastGc.filesDeleted.toLocaleString()} files / ${Us(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(J4,{artifact:h,copiedId:d,onCopy:m},`${h.kind}:${h.root}`))]}),s!==null&&t.jsx("p",{className:"text-xs text-destructive",children:s})]})}function Y4(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 Or({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 J4({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:[Y4(e.cleanupBehavior)," · ",e.sensitivity]})]}),t.jsxs("div",{className:"text-right font-mono text-muted-foreground",children:[e.fileCount.toLocaleString()," files / ",Us(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(Kl,{id:r,label:"Root path",value:e.root,copiedId:n,onCopy:s})})]})}function Kl({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(Q,{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($e,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})]})}function X4(){const[e,n]=l.useState(null),[s,r]=l.useState(null);l.useEffect(()=>sl(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)=>{wt(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(Hn,{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(Kl,{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($e,{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($e,{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($e,{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($e,{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($e,{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($e,{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($e,{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 Z4(){const[e,n]=l.useState(null),[s,r]=l.useState(null);l.useEffect(()=>sl(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)=>{wt(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(Hn,{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(Kl,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function Q4(){const{strip:e,slowResponseThresholdSeconds:n,providerTestTimeoutSeconds:s,timeDisplayFormat:r,isLoading:o,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Qi(),[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:si,step:1,value:n,disabled:o||m,onChange:y=>{const b=Number(y.currentTarget.value);Number.isInteger(b)&&(b<0||b>si||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:ri,step:1,value:s,disabled:o||m,onChange:y=>{const b=Number(y.currentTarget.value);Number.isInteger(b)&&(b<1||b>ri||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=Pu.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 e_=pe(["installed","update-available","available","planned","unknown"]),t_=_({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:e_,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Ce()}),n_=_({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:V(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),s_=_({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Ce(),runnable:Ce()}),r_=_({checkedAt:x(),packages:V(t_),runnerPresets:V(n_),recipes:V(s_)}),xh=pe(["install","upgrade","help","runner-presets","recipe"]),gh="RUN_LOCAL_COMMAND",o_=_({action:xh,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:T().int().positive(),scope:x()}),a_=_({nonce:x().uuid(),phrase:ae(gh),expiresAt:x().datetime(),plan:o_}),Yl=_({confirmation:a_});_n("intent",[_({intent:ae("prepare")}),_({intent:ae("confirm"),nonce:x().uuid(),confirmation:ae(gh)})]);const i_=pe(["queued","running","succeeded","failed"]),bh=_({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:xh,status:i_,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:T().nullable(),error:x().nullable()}),jo=_({task:bh}),l_=_({tasks:V(bh)}),c_="https://registry.npmjs.org/@tonyclaw%2fagent-inspector/latest",d_=1e4,u_=1e3,Td="https://gitcode.com/TonyClaw/agent-inspector",Ed="/api/ecosystem/packages/inspector/upgrade",p_=_({version:x().min(1)});function Rd(e){if(e===void 0)return 0;const n=Number.parseInt(e,10);return Number.isFinite(n)?n:0}function m_(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=Rd(i[d])-Rd(c[d]);if(p!==0)return p}return r===void 0&&a!==void 0?1:r!==void 0&&a===void 0?-1:0}function f_({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(Ks,{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(Kg,{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 h_({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(c_,d_,{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 hu(y,p_);o(m_(b.version,oo.version)>0?{kind:"available",latestVersion:b.version}:{kind:"current",latestVersion:b.version})}catch(y){o({kind:"error",message:y instanceof Ro?"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)}`,jo,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,u_);return y(),()=>clearInterval(b)},[c]);const g=l.useCallback(async()=>{f(!0),u(null);try{const y=await Ke(Ed,Yl,{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(Ed,jo,{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(Pt,{open:n,onOpenChange:s,children:[t.jsx(Es,{asChild:!0,children:t.jsxs(Q,{variant:"ghost",size:"icon",className:Ms,"aria-label":"About Agent Inspector",title:"About Agent Inspector",children:[t.jsx(qu,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"About Agent Inspector"})]})}),t.jsxs(Lt,{className:"max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-xl overflow-y-auto p-4 sm:p-6",children:[t.jsx(Dt,{children:t.jsx(zt,{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(Fi,{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 ",oo.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(Q,{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(f_,{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:Td,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-primary hover:underline",children:["View release",t.jsx(or,{className:"size-3"})]}),t.jsxs(Q,{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(ks,{className:"size-3.5"}),w?"Upgrading...":"Upgrade now"]})]})]}),c!==null&&t.jsx(x_,{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(Dr,{label:"Package",value:"@tonyclaw/agent-inspector",mono:!0}),t.jsx(Dr,{label:"Release channel",value:"npm latest"}),t.jsx(Dr,{label:"License",value:"MIT License"}),t.jsx(Dr,{label:"Source",value:"AgentInspector",href:Td})]}),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(Il,{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 x_({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(Ks,{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 Dr({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(or,{className:"size-3 shrink-0"})]})]})}const g_=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:mg},{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:el},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:a1}];async function b_(e){return Ke(e,r_,void 0,n=>`Failed to load ecosystem packages: ${String(n.status)}`)}async function v_(e){return Ke(e,jo,void 0,n=>`Failed to load ecosystem task: ${String(n.status)}`)}async function y_(e){return Ke(e,l_,void 0,n=>`Failed to load ecosystem tasks: ${String(n.status)}`)}async function w_(e,n){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${n}`,r=await Ke(s,Yl,{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 j_(e){const n=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ke(n,Yl,{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 S_(e){return(await Ke(e.endpoint,jo,{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 N_(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 C_(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 k_(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 Hs(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 __(e){switch(e.status){case"queued":return"Queued";case"running":return`${Hs(e.action)} running`;case"succeeded":return`${Hs(e.action)} complete`;case"failed":return`${Hs(e.action)} failed`}}function vh(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 T_(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function E_({pkg:e,activeTask:n,onStartTask:s}){const r=T_(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(d1,{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(_e,{className:P("shrink-0",C_(e.state)),variant:"outline",children:N_(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:k_(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(Q,{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(ks,{className:"size-3.5"}),Hs(r)]}),t.jsxs(Q,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>s(e.id,"help"),children:[t.jsx(Hn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&t.jsxs(Q,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[t.jsx(el,{className:"size-3.5"}),"Presets"]})]})]})}function R_({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(Hn,{className:"size-4 text-white/55"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold",children:__(e)}),t.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),t.jsx(_e,{variant:"outline",className:P("shrink-0",vh(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 M_({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 A_(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 I_({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(Wu,{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(_e,{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 P_({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(Fu,{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(_e,{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(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>r(e),children:[n?t.jsx($e,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),n?"Copied":"Copy"]}),e.runnable&&t.jsxs(Q,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>o(e),children:[s?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Wu,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function L_({task:e,selected:n,onSelect:s}){const r=e.recipeId??Hs(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(Uu,{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(_e,{variant:"outline",className:P("shrink-0",vh(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(Q,{type:"button",size:"sm",variant:n?"secondary":"outline",onClick:()=>s(e),children:n?"Open":"View"})]})}function O_({pending:e,busy:n,onOpenChange:s,onConfirm:r}){const o=e?.confirmation.plan??null;return t.jsx(Pt,{open:e!==null,onOpenChange:s,children:t.jsxs(Lt,{className:"max-w-xl",children:[t.jsxs(Dt,{children:[t.jsx(zt,{children:"Confirm local command"}),t.jsx(ur,{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(Q,{type:"button",variant:"outline",disabled:n,onClick:()=>s(!1),children:"Cancel"}),t.jsxs(Q,{type:"button",variant:"secondary",disabled:n||o===null,onClick:r,children:[n?t.jsx(Ue,{className:"size-3.5 animate-spin"}):t.jsx(Hn,{className:"size-3.5"}),n?"Starting":"Confirm & Run"]})]})]})})}function D_({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",b_,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=qt(m===null?null:`/api/ecosystem/tasks/${m}`,v_,{refreshInterval:U=>{const Z=U?.task;return Z!==void 0&&(Z.status==="queued"||Z.status==="running")?900:0},revalidateOnFocus:!1}),N=qt(r?"/api/ecosystem/tasks":null,y_,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],E=j.data?.runnerPresets??[],A=j.data?.recipes??[],I=(N.data?.tasks??[]).slice(0,6),R=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=A_(e),M="npx @tonyclaw/eval-harness runner-presets",O=()=>{wt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{wt(M).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},K=U=>{wt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},ee=U=>{g(null),j_(U.id).then(Z=>{w(Z)}).catch(Z=>{g(Z instanceof Error?Z.message:"Failed to prepare ecosystem recipe")})},z=S.data?.task??null;l.useEffect(()=>{z!==null&&(N.mutate(),z.status==="succeeded"&&j.mutate())},[z,j,N]);const H=(U,Z)=>{g(null),w_(U,Z).then(fe=>{w(fe)}).catch(fe=>{g(fe instanceof Error?fe.message:"Failed to prepare ecosystem task")})},te=()=>{v!==null&&(g(null),b(!0),S_(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(Pt,{open:r,onOpenChange:o,children:[t.jsx(Es,{asChild:!0,children:t.jsxs(Q,{variant:"ghost",size:s?"default":"icon",className:P(Ms,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(Fu,{className:"size-4"}),t.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),t.jsxs(Lt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Dt,{children:t.jsxs(zt,{className:"flex items-center gap-2",children:[t.jsx(oi,{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(_e,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(R),"/",String(C.length)," packages"]})]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:g_.map(U=>t.jsx(M_,{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(_e,{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(Q,{size:"sm",variant:"secondary",onClick:O,children:[a?t.jsx($e,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),a?"Copied":"Copy"]}),t.jsxs(Q,{size:"sm",variant:"outline",onClick:$,children:[t.jsx(el,{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(oi,{className:"size-3.5"}),"copy-ready workflows"]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[A.map(U=>t.jsx(P_,{recipe:U,copied:p===U.id,running:z!==null&&z.recipeId===U.id&&(z.status==="queued"||z.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(Hn,{className:"size-3.5"}),M]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[E.map(U=>t.jsx(I_,{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(E_,{pkg:U,activeTask:z,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(L_,{task:U,selected:m===U.id,onSelect:Z=>{f(Z.id),S.mutate({task:Z},{revalidate:!0})}},U.id))})]}),t.jsx(R_,{task:z})]})]}),t.jsx(O_,{pending:v,busy:y,onOpenChange:U=>{!U&&!y&&w(null)},onConfirm:te})]})}function z_(e){return[...new Set(e.evidence.map(n=>n.logId).filter(n=>n!==null))]}const $_=[{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?"}],F_=4e3,Ka=12;function Md(){return{messages:[],question:"",error:null}}function B_(e){return e.filter(n=>n.content.trim().length>0).slice(-10).map(n=>({role:n.role,content:n.content.trim().slice(0,F_)}))}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 U_(e,n){const s=G(e,n);return Array.isArray(s)?s.filter(r=>typeof r=="string").slice(0,8):[]}function q_(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:U_(e,"matchedFields"),excerpt:at(e,"excerpt","snippet")??"No excerpt available."}}function Ya(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 Ad(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 Id(e){return Object.getOwnPropertyNames(e).map(n=>[n,G(e,n)])}function Pd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const n=[];for(const[s,r]of Id(e)){const o=Ad(r);if(o!==null){if(n.push({key:s,label:Ya(s),value:o}),n.length>=Ka)break;continue}if(!(r===null||typeof r!="object"||Array.isArray(r))){for(const[a,i]of Id(r)){const c=Ad(i);if(c===null)continue;const d=`${s}.${a}`;if(n.push({key:d,label:`${Ya(s)} ${Ya(a).toLowerCase()}`,value:c}),n.length>=Ka)break}if(n.length>=Ka)break}}return n}function H_(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(q_).filter(p=>p!==null).slice(0,12):[];return{answer:n,providerId:s,providerName:r,model:o,protocol:a,logCount:i,evidence:d,summaryMetrics:Pd(G(e,"summary")),queryMetrics:Pd(G(e,"queryStats"))}}const V_=l.lazy(()=>Kt(()=>import("./index-C93Za-A-.js"),__vite__mapDeps([10,1,2]),import.meta.url)),W_="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]",Ja=96*1024;function G_({text:e}){const[n,s]=l.useState(!1),r=e.length>Ja,o=r&&!n?e.slice(0,Ja):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 ",Ja.toLocaleString()," characters for fast rendering. The full response is preserved."]}),t.jsx("div",{className:W_,children:t.jsx(l.Suspense,{fallback:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:t.jsx(V_,{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 Ld="What looks abnormal, slow, or likely to hang?";function K_(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function Y_(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function J_(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 Od(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 X_({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 Z_({evidence:e}){const n=()=>{e.logId!==null&&Ss({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 Q_({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(G_,{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(X_,{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(Z_,{evidence:n},`${n.source}-${n.id}`))]})]})]})}function eT({message:e}){return e.role==="assistant"&&e.response!==null?t.jsx(Q_,{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 tT({currentSessionId:e,logCount:n,onResultChange:s}){const{providers:r}=ll(),o=l.useMemo(()=>J_(r.filter(K_)),[r]),[a,i]=l.useState(()=>({...Md(),question:Ld})),[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({...Md(),question:Ld}),s(null)},S=C=>{i(E=>({...E,question:C,error:null}))},N=()=>{if(!w)return;const C=v.trim(),E=B_(a.messages),A={id:Od("user"),role:"user",content:C,response:null};f(!0),i(R=>({...R,messages:[...R.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};sx("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(I)}).then(async R=>{const k=await R.text();if(!R.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(R.status)} ${k}`}));return}const M=JSON.parse(k),O=H_(M);if(O===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:Od("assistant"),role:"assistant",content:O.answer,response:O}]})),s({question:C,logIds:z_(O),reportedLogCount:O.logCount})}).catch(R=>{i(k=>({...k,error:R instanceof Error?R.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(Rg,{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(Gu,{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(Qs,{value:c,onValueChange:b,children:[t.jsx(er,{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(vo,{placeholder:"Provider"})}),t.jsxs(tr,{children:[t.jsx(it,{value:"__auto__",children:"Auto provider"}),o.map(C=>t.jsxs(it,{value:C.id,children:[C.name," / ",Y_(C)]},C.id))]})]}),t.jsxs(Qs,{value:p,onValueChange:u,children:[t.jsx(er,{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(vo,{placeholder:"Model"})}),t.jsxs(tr,{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:$_.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(oi,{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(eT,{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(M1,{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 nT(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:Dd(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:Dd(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return n}function Dd(e,n){return n===null||e===null?null:n>e?{direction:"up",delta:n-e}:n<e?{direction:"down",delta:e-n}:null}function yh(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function os(e,n,s){const r=yh(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 wh(e,n,s){switch(e){case"connecting":return{label:"Connecting",description:os(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:os(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:os(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:os(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:os(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:os(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 sT({state:e}){const n=wh(e.status,e,!1),s=yh(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:P("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:P("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 rT({state:e,hasLogs:n,onRetry:s,onStop:r}){const o=wh(e.status,e,n);return t.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:P("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:P("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(e0,{className:"size-3"}),"Stop retrying"]})]})]})}function oT(){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(Q,{type:"button",variant:"ghost",size:"icon",className:Ms,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:o,children:[e?t.jsx(X0,{className:"size-4"}):t.jsx(K0,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:a})]})}function aT({liveConnection:e,alertsAction:n,aboutAction:s,settingsAction:r}){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:Bi("/"),"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(Fi,{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",oo.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(sT,{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(oT,{}),n,r,s]})]})})}function iT(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function Jr({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,`${iT(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:P("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:P("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 jh(e){return e?"auto":"smooth"}function Sh(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function lT(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function Et(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 cT(e){return e===void 0||e.status==="live"?"empty":e.status}function dT(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 zd="agent-inspector.hierarchy.collapsedClients",$d="agent-inspector.hierarchy.collapsedProcesses";function So(e){return e.some(n=>n.responseStatus===null)}function Nh(e){return e.filter(n=>n.responseStatus===null).length}function Ch(e){for(const n of e){const s=n.userAgent;if(s!=null&&s!=="")return s}return null}function uT(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function kh(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function pT(e){return Pl({userAgent:Ch(e.logs),conversationId:e.conversationId,clientProjectFolder:kh(e.logs)})}function mT(e){if(e===null||e==="")return"Unknown client";const n=e.split(/[ /;]/)[0]??"";return n===""?"Unknown client":n}function fT(e,n){const s=ea(e);return s!==null?s:mT(n)}function No(e){return e===null||e===""?"unknown":String(e)}function hT(e,n,s){return e!=="unknown"?e:`unknown:${No(n)}:${No(s)}`}function xT(e,n){return`${No(e)}:${No(n)}`}function Fd(e){return[...e].sort((n,s)=>n.timestamp.localeCompare(s.timestamp))}function Bd(e){let n="";for(const s of e)s.timestamp>n&&(n=s.timestamp);return n}function Ud(e){return So(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 Xa(e){return[...e].sort((n,s)=>{const r=Ud(n.logs)-Ud(s.logs);if(r!==0)return r;const o=Bd(s.logs).localeCompare(Bd(n.logs));return o!==0?o:n.id.localeCompare(s.id)})}function gT(e){const n=new Map;for(const r of e){const o=Ch(r.logs),a=kh(r.logs),i=pT(r),c=hT(i,o,a);let d=n.get(c);d===void 0&&(d={id:c,client:i,label:fT(i,o),userAgent:o,processes:new Map,logs:[]},n.set(c,d)),d.logs.push(...r.logs);const p=uT(r.logs),u=`${c}:${xT(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=Xa([...r.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:Xa(a.sessions),logs:Fd(a.logs)})));s.push({id:r.id,client:r.client,label:r.label,userAgent:r.userAgent,processes:o,logs:Fd(r.logs)})}return Xa(s)}function Co(e){return e<=0?"0":Ie(e)}function _h(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 bT(e){let n=0;for(const s of e)n+=s.sessions.length;return n}function qd(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 Hd(e,n){try{window.localStorage.setItem(e,JSON.stringify([...n]))}catch{}}function Vd(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 vT(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&&!So(o.logs)&&n.add(o.id)}return n}function yT(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 ko({label:e,value:n,className:s}){return t.jsxs("span",{className:P("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 Th({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 wT({groups:e,...n}){const s=l.useMemo(()=>gT(e),[e]),[r,o]=l.useState(()=>new Set),[a,i]=l.useState(()=>vT(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const m=qd(zd),f=qd($d);m!==null&&o(m),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(Hd(zd,r),Hd($d,a))},[r,a,c]),l.useEffect(()=>{const m=new Set(s.filter(h=>So(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>So(g.logs)).map(g=>g.id)));o(h=>Vd(h,m)),i(h=>Vd(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(jT,{group:m,collapsed:r.has(m.id),collapsedProcessIds:a,onToggleClient:()=>p(m.id),onToggleProcess:u,conversationProps:n},m.id))})}function jT({group:e,collapsed:n,collapsedProcessIds:s,onToggleClient:r,onToggleProcess:o,conversationProps:a}){const i=_h(e.logs),c=bT(e.processes),d=e.logs.length,p=Nh(e.logs),u=p>0;return t.jsxs("section",{className:P("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(e1,{className:"size-4"})}):t.jsx(ta,{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:i5(e.client)}),u&&t.jsx(Th,{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(ko,{label:"IN",value:Co(i.inputTokens)}),t.jsx(ko,{label:"OUT",value:Co(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(bt,{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(ST,{group:m,collapsed:s.has(m.id),onToggle:()=>o(m.id),conversationProps:a},m.id))})]})}function ST({group:e,collapsed:n,onToggle:s,conversationProps:r}){const o=_h(e.logs),a=yT(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=Nh(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(f0,{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(Th,{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(O0,{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(ko,{label:"IN",value:Co(o.inputTokens)}),t.jsx(ko,{label:"OUT",value:Co(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(bt,{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(uk,{group:m,...r,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},m.id))})]})}const NT="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",CT=[{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 kT({onCancel:e,onExportRedacted:n,onConfirmRaw:s}){return t.jsxs(t.Fragment,{children:[t.jsxs(Dt,{children:[t.jsx(zt,{children:"Export unredacted logs?"}),t.jsx(ur,{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:CT.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(Q,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),t.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Export redacted instead"}),t.jsx(Q,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const _o="data-nav-id",_T="data-nav-action";function Wd(e){return Array.from(e.querySelectorAll(`[${_o}]`))}function Gd(e){return e instanceof HTMLElement}function TT(e,n){let s=e;for(;s!==null&&s!==n;){if(s.hasAttribute(_o))return s;s=s.parentElement}return e.hasAttribute(_o)?e:null}function Za(e){const n=e.getAttribute(_T);return n==="toggle"||n==="expand"||n==="collapse"?n:null}function $s(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Fs(e,n){return e[n]??null}function Eh(e){const n=e.tagName;return!!(n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable)}function Kd(e){const n=e.tagName;return n==="BUTTON"||n==="A"||Eh(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function ET(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function RT(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function zr(e,n){return e.key===n&&e.shiftKey}function MT(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(!Gd(p)||p!==d)return;const u=Wd(c),m=Fs(u,0);m!==null&&$s(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(!Gd(p)||Eh(p)||RT())return;const u=d.contains(p);if(u&&Kd(p)&&!p.hasAttribute(_o)||!u&&(!o||Kd(p)||ET(p)))return;const m=Wd(d);if(m.length===0)return;const f=TT(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"&&!zr(c,"W"))break;c.preventDefault();const v=h>0?h-1:h===-1?m.length-1:-1;if(v!==-1){const w=Fs(m,v);w!==null&&$s(w)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!zr(c,"S"))break;c.preventDefault();const v=h<m.length-1?h+1:h===-1?0:-1;if(v!==-1){const w=Fs(m,v);w!==null&&$s(w)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!zr(c,"A")||f===null)break;if(c.preventDefault(),Za(f)==="collapse")f.click();else if(h>0){const w=Fs(m,h-1);w!==null&&$s(w)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!zr(c,"D")||f===null)break;if(c.preventDefault(),Za(f)==="expand")f.click();else if(h<m.length-1){const w=Fs(m,h+1);w!==null&&$s(w)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Za(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 AT={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},IT={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"},PT={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"},Qa=12,$r=1,Yd=80,Jd=24;function LT(e){return e.length<=Jd?e:`${e.slice(0,Jd-3)}...`}function OT(e){const n=e.replace(/\s+/g," ").trim();return n.length<=Yd?n:`${n.slice(0,Yd)}...`}function Fr(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const DT=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,Qa),c=n.slice(Qa),d=c.reduce((w,y)=>w+y.size,0),p=c.length,u=Qa,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(Rs,{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($r,b),S=P("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",IT[w.role],h?PT[w.role]:""),N={width:`${j}%`},C=`${w.label}, ${Fr(b)}, ~${Ie(w.size)} tokens`;return t.jsxs(ut,{children:[t.jsx(pt,{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(mt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[t.jsxs("div",{className:"font-semibold",children:[w.label," - ",Fr(b)," - ~",Ie(w.size)," ","tokens"]}),t.jsx("div",{className:"text-muted-foreground",children:AT[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:OT(w.text)})]})]},`${w.path}-${y}`)}),f&&t.jsxs(ut,{children:[t.jsx(pt,{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($r,d/a*100)}%`},children:["... +",p]})}),t.jsxs(mt,{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($r,b);return t.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${w.label} - ${Fr(b)} - ~${Ie(w.size)} tokens`,children:[t.jsx("span",{className:"truncate font-mono text-foreground/80",children:LT(w.label)}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Fr(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($r,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"})]})})}),Rh=.75,Mh=.9,Li=8e3,zT=.35,Ah=40,Ih=160,$T=5,FT=8,BT=18,UT=6e4,qT=.7,Xd=3e3,HT=.3,Zd=160,VT=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),WT=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],GT=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],KT=[{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"]}],YT={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function JT(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 Ph(e,n){for(const s of n){const r=JT(G(e,s));if(r!==null)return r}return null}function XT(e){const n=G(e,"model");if(typeof n!="string")return null;const s=n.trim();return s===""?null:s}function ZT(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 QT(e,n,s=[]){const r=Ph(n,WT);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=H3(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 KT)if(ZT(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function eE(e){return e<0?0:e>1?1:e}function tE(e){return e===null?"unknown":e>=Mh?"danger":e>=Rh?"watch":"ok"}function nE(e,n){return e.filter(s=>s.role===n).reduce((s,r)=>s+r.size,0)}function sE(e,n){return["system","user","assistant","tool","tools"].map(r=>{const o=nE(e,r);return{role:r,label:YT[r],tokens:o,percent:n>0?o/n:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function Oi(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function rE(e){const n=e.replace(/\s+/g," ").trim();return n.length<=Zd?n:`${n.slice(0,Zd-3)}...`}function oE(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function aE(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function iE(e){const n=e.trim();return n.startsWith("{")||n.startsWith("[")}function lE(e){if(!iE(e))return null;try{return JSON.parse(e)}catch{return null}}function cE(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function dE(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 uE(e){const n=dE(e);return n===null?!1:VT.has(cE(n))}function pE(e){return e.map(n=>n.startsWith("[")?n:`.${n}`).join("").replace(/^\./,"")}function mE(e,n,s){const r=Ol(n);if(r<Ih)return null;const o=Ll(n);return o<Ah?null:{role:e.role,label:`${e.label} ${pE(s)}`,path:e.path,tokens:o,characters:r,text:n}}function Di({value:e,segment:n,path:s,depth:r,candidates:o}){if(!(o.length>=FT)&&!(r>$T)){if(typeof e=="string"){if(!uE(s))return;const a=mE(n,e,s);a!==null&&o.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Di({value:a,segment:n,path:[...s,`[${String(i)}]`],depth:r+1,candidates:o}));return}Dl(e)&&Object.entries(e).forEach(([a,i])=>Di({value:i,segment:n,path:[...s,a],depth:r+1,candidates:o}))}}function fE(e){const n=aE(e),s=lE(e.text);if(s===null)return[n];const r=[];Di({value:s,segment:e,path:[],depth:0,candidates:r});const o=Oi(e.text),a=new Set([o]),i=r.filter(c=>{const d=Oi(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[n,...i]}function hE(e){const n=new Map;for(const r of e){const o=fE(r);for(const a of o){if(a.tokens<Ah||a.characters<Ih)continue;const i=Oi(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:rE(o.text),firstLabel:o.label,segments:r.candidates.map(oE)})}return s.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function xE(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>=Li?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(n)} group${n===1?"":"s"}, ~${String(r)} repeated tokens.`}}function gE(e){return e.reduce((n,s)=>n+s.repeatedTokens,0)}function bE(e,n,s){const r=[],o=e.find(d=>d.role==="tools")??null;o!==null&&(o.tokens>=Li||o.percent>=zT&&o.tokens>=Xd)&&r.push({kind:"tool-schema",severity:o.tokens>=Li?"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>=Xd&&a.percent>=HT&&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>=BT&&(i>=UT||c>=qT)&&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 vE({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:gE(r)}}function yE({segments:e,inputTokens:n,parsed:s,model:r,providers:o=[]}){const a=e.reduce((C,E)=>C+E.size,0),i=r??XT(s),c=n??a,d=Ph(s,GT),p=QT(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:eE(m/p.tokens),v=sE(e,a),w=v[0]??null,y=e.filter(C=>C.role!=="tools").length,b=hE(e),j=xE(b),S=bE(v,a,y);j!==null&&S.unshift(j);const N=tE(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:vE({risk:N,contextWindow:p,diagnostics:S,duplicateGroups:b})}}const LR={watch:Rh,danger:Mh},Qd=new WeakMap;function wE(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 jE(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function SE(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function NE(e,n){const s=jE(e.rawRequestBody);if(s===null)return null;const o=_f(xo(e)).anatomySegments(s);if(o===null)return null;const a=yE({segments:o,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:n}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(SE);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 CE(e,n,s){const r=Qd.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=NE(e,n);return Qd.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 kE(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 eu(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function _E(e,n){const s=eu(n.latest.riskLevel)-eu(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 TE(e,n){return e.usagePercent===null||n.usagePercent===null?null:(n.usagePercent-e.usagePercent)*100}function EE(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 RE(e,n=[]){const s=EE(e),r=wE(n),o=new Map;for(const i of s){const c=CE(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:kE(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:TE(i.first,i.latest)})).sort(_E)}}function Dn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function ME(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 tu(e,n){return n.get(e.id)??e.id}function nu(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 AE(e){for(const n of e)if(n.userAgent!==null&&n.userAgent!==void 0&&n.userAgent!=="")return n.userAgent;return null}function IE(e,n){const s=e[0],r=e[e.length-1];return s===void 0||r===void 0?null:Io(s.timestamp,r.timestamp,n)}function PE(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 LE(e){switch(e){case"rolling":return t.jsx(lt,{className:"size-3 text-status-cool"});case"failed":return t.jsx(ro,{className:"size-3 text-status-danger"});case"watch":return t.jsx(Ku,{className:"size-3 text-status-watch"});case"clear":return t.jsx($e,{className:"size-3 text-status-success"})}}function OE(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function DE(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 as({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:P("mt-2 font-mono text-sm font-semibold",PE(o)),children:n}),t.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function zE({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(s0,{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(as,{label:"Status",value:e.statusLabel,detail:DE(e),icon:LE(e.status),tone:OE(e.status)}),t.jsx(as,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:t.jsx(I0,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),t.jsx(as,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:t.jsx(ro,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),t.jsx(as,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:t.jsx(Ku,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),t.jsx(as,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:t.jsx(nl,{className:"size-3 text-muted-foreground"})}),t.jsx(as,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Vs(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 $E(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function zi(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function FE(e,n){if(n===null)return null;const s=zi(e),r=zi(n);return r<=0||Math.abs(r-s)<.5?null:r}function BE(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 UE(e){const n=e.latest.contextWindow.tokens;return n===null?"Context window unknown":`Context window ${fu(n)}`}const qE=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Lh(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 ei(e,n){if(e===null)return null;const s=e.metadata[n];return s===void 0?null:Lh(s)}function HE(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 VE(e){const n=[];for(const s of qE){const r=e.metadata[s];if(r===void 0)continue;const o=Lh(r);o!==null&&n.push({key:s,value:o})}return n}function su({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=ei(a,"score"),c=ei(a,"decision"),d=ei(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:P("rounded border px-1.5 py-0.5 font-mono text-[10px]",HE(u.value)),children:u.label},u.label))})]}),s?t.jsx(tl,{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=VE(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:Dn(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 ",Dn(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 Br({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 ru({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:P("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:[Rk({logs:e,pagination:n}),n.isLoading&&e.length>0&&t.jsx("span",{className:"ml-2",children:"Loading..."})]}),n.loadProgress!==void 0&&t.jsx(Jr,{progress:n.loadProgress})]}),t.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[t.jsx(Br,{label:"Oldest",title:"Load the oldest logs in this session",icon:t.jsx(Bg,{className:"size-3.5"}),disabled:r||!n.hasOlder,onClick:n.onOldest}),t.jsx(Br,{label:"Older",title:"Load older logs",icon:t.jsx(Lg,{className:"size-3.5"}),disabled:r||!n.hasOlder,onClick:n.onOlder}),t.jsx(Br,{label:"Newer",title:"Load newer logs",icon:t.jsx(bt,{className:"size-3.5"}),disabled:r||!n.hasNewer,onClick:n.onNewer}),t.jsx(Br,{label:"Newest",title:"Load the newest logs in this session",icon:t.jsx(qg,{className:"size-3.5"}),disabled:r||!n.hasNewer,onClick:n.onNewest})]})]})}function WE(e){return`${e} ${e===1?"request":"requests"}`}function ou(e){return`#${String(e)}`}function au(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 GE(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 KE(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const YE=10,JE=80;function XE(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function ZE(e){const n=document.getElementById(`log-${String(e)}`);return n instanceof HTMLElement?(n.scrollIntoView({block:"center",behavior:jh(Sh())}),n.focus({preventScroll:!0}),XE(n),!0):!1}function Oh(e){Ss({logId:e,tab:"anatomy"});let n=0;const s=()=>{Ss({logId:e,tab:"anatomy"}),!ZE(e)&&(n+=1,n<YE&&window.setTimeout(s,JE))};window.setTimeout(s,0)}function QE({command:e}){const[n,s]=l.useState(!1),r=l.useCallback(()=>{wt(e).then(o=>{o&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return t.jsxs("div",{"data-command-example":"true",className:pk,children:[t.jsx("pre",{className:mk,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($e,{className:"size-4"}):t.jsx(St,{className:"size-4"})})]})}function ti({label:e,children:n,className:s}){return t.jsxs("section",{className:P("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 Ur({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 eR(){const{themeMode:e,setThemeMode:n}=Gb();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:P("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(U1,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("eye-care"),className:P("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($u,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("dark"),className:P("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(n1,{className:"size-3.5"})})]})}function tR({visible:e,onToggle:n}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return t.jsx("button",{type:"button",onClick:n,className:P("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(Fi,{className:P("size-4 transition-opacity",!e&&"opacity-45")})})}function nR({preference:e,resolvedScale:n,onChange:s}){const r=Qb(n),o=e==="auto"?`Auto (${r})`:`${e}%`;return t.jsxs(Qs,{value:e,onValueChange:a=>s(al(a)),children:[t.jsxs(er,{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(ug,{className:"size-3.5"}),t.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:r})]}),t.jsxs(tr,{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 Dh="agent-inspector.detailsPanelCollapsed",zh="agent-inspector.detailsPanelWidth",$h="agent-inspector.pet.visible",us=360,sR=288,rR=520;function Fh(e){return Math.min(Math.max(e,sR),rR)}function oR(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Dh);return e===null||e==="1"}catch{return!0}}function aR(){if(typeof window>"u")return us;try{const e=window.localStorage.getItem(zh);if(e===null)return us;const n=Number.parseInt(e,10);return Number.isFinite(n)?Fh(n):us}catch{return us}}function iR(){if(typeof window>"u")return!0;try{return window.localStorage.getItem($h)!=="0"}catch{return!0}}function iu({label:e,logId:n}){return t.jsxs("button",{type:"button",onClick:()=>Oh(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 ${ou(n)}`,children:[e," ",ou(n)]})}function lR({latestPercent:e,peakPercent:n,risk:s,onOpenContext:r}){const o=zi(e),a=FE(e,n),i=n===null?`Latest context window usage ${Vs(e)}`:`Latest context window usage ${Vs(e)}, peak ${Vs(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:P("block h-full rounded-full transition-[width]",BE(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 cR({summary:e}){const n=e.trendPercent,s=n===null||Math.abs(n)<.1?null:n>0?wg:hg,r=e.latest.diagnostics[0]??null,o=Vs(e.latest.usagePercent),a=Vs(e.peak.usagePercent),i=()=>{Oh(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:P("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",GE(e.latest.health.level)),children:KE(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:WE(e.requestCount)}),t.jsx("span",{children:UE(e)})]})]}),t.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[t.jsx(lR,{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:P("mt-0.5 font-mono",au(e.latest.riskLevel)),children:o}),t.jsx(iu,{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:P("mt-0.5 font-mono",au(e.peak.riskLevel)),children:a}),t.jsx(iu,{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:P("size-3",n!==null&&n>0?"text-amber-300":"text-cyan-300")}),$E(n)]}),t.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),t.jsxs("div",{className:"min-w-0 space-y-1.5",children:[t.jsx(DT,{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 dR({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(cR,{summary:n},n.model))})]})}function uR(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 pR({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(()=>IE(s,a),[s,a]),v=l.useMemo(()=>AE(s),[s]),w=l.useMemo(()=>uR(i),[i]),y=l.useCallback(()=>{n!==null&&wt(n).then(j=>{j&&(p(!0),setTimeout(()=>p(!1),2e3))})},[n]),b=l.useCallback(()=>{wt(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:Bi("/"),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(vg,{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:Dn(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($e,{className:"size-3"}):t.jsx(St,{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(tl,{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($e,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"})})]}),f&&t.jsx(dR,{summary:i})]})}function mR({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:R,totalOut:k}=l.useMemo(()=>nu(e),[e]),{providers:M}=ll(),{uiScalePreference:O,resolvedUiScale:$,setUiScalePreference:K}=sv(),[ee,z]=l.useState(null),[H,te]=l.useState(null),[U,Z]=l.useState(!1),[fe,je]=l.useState(!1),[he,re]=l.useState(null),[L,J]=l.useState(null),[Se,Te]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!0),[Re,Fe]=l.useState(us),[ct,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),ze=l.useRef(null),D=l.useRef(null),Y=l.useRef(0),de=l.useRef(null);MT(we,Oe,{pageWide:!0});const[Ne,F]=l.useState(null);l.useEffect(()=>sl(F),[]);const W=l.useCallback(()=>{Y.current+=1,D.current?.abort(),D.current=null,z(null),te(null)},[]);l.useEffect(()=>()=>{Y.current+=1,D.current?.abort(),D.current=null},[]),l.useEffect(()=>{Pe(oR()),Fe(aR()),We(!0)},[]),l.useEffect(()=>{Le&&window.localStorage.setItem(Dh,ce?"1":"0")},[ce,Le]),l.useEffect(()=>{if(Le)try{window.localStorage.setItem(zh,String(Re))}catch{}},[Le,Re]),l.useEffect(()=>{Qe(iR()),nt(!0)},[]),l.useEffect(()=>{if(ot)try{window.localStorage.setItem($h,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=`${Dn(I)} - ${ye} - Agent Inspector`},[e.length,I]);const X=l.useCallback(async ye=>{D.current?.abort();const Ge=new AbortController;D.current=Ge;const _t=Y.current+1;Y.current=_t,z(ye),te(null);try{const Xt=await Ub(e,ye,{signal:Ge.signal});if(Y.current!==_t)return;if(!Xt.ok){if(Xt.canceled===!0)return;p!==void 0?p({message:Xt.message,tone:"error"}):te(Xt.message)}}finally{Y.current===_t&&(D.current=null,z(null))}},[e,p]),ne=l.useCallback(ye=>{if(xk(ye)){Z(!0);return}X(ye)},[X]),Ee=l.useCallback(()=>{Z(!1),X("redacted")},[X]),ie=l.useCallback(()=>{Z(!1),X("raw")},[X]),oe=l.useCallback(()=>{ze.current?.click()},[]),ke=l.useCallback(ye=>{const Ge=ye.currentTarget.files?.[0];ye.currentTarget.value="",!(Ge===void 0||u===void 0)&&(je(!0),J(null),re(null),u(Ge).then(_t=>{const Xt=_t.skipped>0?`, skipped ${String(_t.skipped)}`:"",sc=`Imported ${String(_t.imported)} logs as ${_t.sessionId}${Xt}.`;p!==void 0?p({message:sc,tone:"success"}):re(sc)}).catch(_t=>{const Xt=_t instanceof Error?_t.message:"Failed to import logs";p!==void 0?p({message:Xt,tone:"error"}):J(Xt)}).finally(()=>{je(!1)}))},[u,p]);l.useEffect(()=>{W(),me(null),se(null)},[W,s,r]);const De=l.useCallback(()=>{W(),re(null),J(null),me(null),a()},[W,a]),Gn=l.useCallback(()=>{Te(!0)},[]),$t=l.useCallback(()=>{W(),re(null),J(null),me(null),i!==void 0&&(le(!0),i().then(()=>{Te(!1)}).catch(ye=>{const Ge=ye instanceof Error?ye.message:"Failed to delete stored logs";p!==void 0?p({message:Ge,tone:"error"}):J(Ge)}).finally(()=>{le(!1)}))},[W,i,p]),an=l.useCallback(()=>{c!==void 0&&(W(),re(null),J(null),me(null),c())},[W,c]),oa=l.useCallback(()=>{me(null)},[]),Kn=l.useCallback(()=>{Pe(ye=>!ye)},[]),aa=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(Fh(Ge.startWidth+Ge.startX-ye.clientX))},[]),yt=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(us)},[]),As=l.useCallback(()=>{Qe(ye=>!ye)},[]),st=l.useMemo(()=>q===null?null:new Set(q.logIds),[q]),kt=l.useMemo(()=>st===null?e:e.filter(ye=>st.has(ye.id)),[st,e]),Ft=l.useMemo(()=>sS(kt),[kt]),Xl=l.useMemo(()=>ME(Ft),[Ft]),ln=l.useMemo(()=>Ek({pinnedSessionId:I,selectedSession:s,sessions:n,logs:e}),[e,I,s,n]),Yn=ln?.logs??[],Is=ln!==null&&Yn.length>0,{totalIn:Zl,totalOut:Ql}=l.useMemo(()=>nu(Yn),[Yn]),Uh=l.useMemo(()=>RE(Yn,M),[Yn,M]),qh=l.useMemo(()=>nT(Ft),[Ft]),ia=l.useMemo(()=>jC(Ft),[Ft]),ec=gk(f,e.length),Hh=I!==void 0,Vh=e.length>0,Wh=i!==void 0&&(e.length>0||s!=="__all__"),Gh=s==="__all__"?"all sessions":"this session",Kh=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.",Yh=e.length===0?"Load":"Reload",la=Is&&ln!==null?Dn(ln.label):s==="__all__"?"All sessions":Dn(s),tc=cT(y),ca=dT(tc),Jh=l.useMemo(()=>Tk({logs:kt,conversationGroups:Ft,isLoading:w,timeDisplayFormat:v,slowResponseThresholdSeconds:g}),[kt,Ft,w,g,v]),Xh=l.useCallback(ye=>{const Ge=ia.get(ye.id);Ge!==void 0&&me([Ge,ye])},[ia]),nc=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(aT,{liveConnection:y,alertsAction:t.jsx(o3,{}),aboutAction:t.jsx(h_,{}),settingsAction:t.jsx(V4,{})}),t.jsxs("button",{type:"button",onClick:Kn,className:P("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(f1,{className:"size-3.5"}):t.jsx(p1,{className:"size-3.5"})]}),ot&&Ye&&t.jsx(Zr,{feature:"Inspector Pet",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(JS,{logs:e})})}),t.jsxs("div",{className:P("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",ct&&"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:Kn,"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:aa,onPointerMove:Me,onPointerUp:yt,onPointerCancel:yt,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(ti,{label:"View",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx(eR,{}),t.jsx(nR,{preference:O,resolvedScale:$,onChange:K})]})}),t.jsx(ti,{label:"Workspace",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(k3,{labelledTrigger:!0}),t.jsx(D_,{currentSessionId:nc,logCount:e.length,labelledTrigger:!0})]})})]}),t.jsxs(ti,{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:la,children:la}),t.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:Hh?"Pinned session":"Live Inspector data"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(Ur,{label:q===null?"Requests":"Results",value:kt.length}),t.jsx(Ur,{label:"Sessions",value:n.length}),t.jsx(Ur,{label:"Input",value:Ie(Is?Zl:R)}),t.jsx(Ur,{label:"Output",value:Ie(Is?Ql: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(Jr,{progress:N})})]}),Is&&ln!==null&&t.jsx(pR,{label:ln.label,sessionId:ln.sessionId,logs:Yn,totalIn:Zl,totalOut:Ql,timeDisplayFormat:v,contextSummary:Uh,showBackLink:ln.showBackLink}),Is&&I!==void 0&&E.length>0&&t.jsx(su,{memberships:E}),t.jsx("div",{className:"flex-1"}),t.jsx(tT,{currentSessionId:nc,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:la})]}),t.jsx(tR,{visible:Ye,onToggle:As}),u!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:ze,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(Yu,{className:"size-3.5"}),t.jsx("span",{children:"Import"})]})})]}),ec.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(ks,{className:"size-3.5"}),t.jsx("span",{children:"Export"})]})}),ec.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(S0,{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:P("size-3.5",w&&"animate-spin motion-reduce:animate-none")}),t.jsx("span",{children:Yh})]}),t.jsxs("button",{type:"button",onClick:De,disabled:!Vh,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:Gn,disabled:!Wh||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(Jr,{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(kt.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(ir,{className:"size-3"}),"All logs"]})]}),q===null&&t.jsx(ru,{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&&L!==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:L}),p===void 0&&he!==null&&L===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(rT,{state:y,hasLogs:e.length>0,onRetry:b,onStop:j})]}),t.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[t.jsx(zE,{stats:Jh}),q!==null&&kt.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:Dn(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(Jr,{progress:N})}),E.length>0&&t.jsx("div",{className:"text-left",children:t.jsx(su,{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:Bi("/"),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:ca.title}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:ca.description}),tc==="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."}),ca.showConnectionCommands&&Ne!==null&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-col items-center gap-2",children:fk(Ne).map(ye=>t.jsx(QE,{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(wT,{groups:Ft,viewMode:m,strip:h,slowResponseThresholdSeconds:g,cacheTrends:qh,onCompareWithPrevious:Xh,comparisonPredecessors:ia,onClearGroup:d,defaultExpanded:Ft.length===1,timeDisplayFormat:v})}),q===null&&t.jsx("div",{className:"mt-3",children:t.jsx(ru,{logs:e,pagination:S})})]})]})]})]}),t.jsx(Pt,{open:U,onOpenChange:Z,children:t.jsx(Lt,{className:NT,children:t.jsx(kT,{onCancel:()=>Z(!1),onExportRedacted:Ee,onConfirmRaw:ie})})}),t.jsx(Pt,{open:Se,onOpenChange:Te,children:t.jsxs(Lt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[t.jsxs(Dt,{children:[t.jsxs(zt,{children:["Delete ",Gh," history?"]}),t.jsx(ur,{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:Kh})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(Q,{type:"button",variant:"outline",size:"sm",disabled:ge,onClick:()=>Te(!1),children:"Cancel"}),t.jsx(Q,{type:"button",variant:"destructive",size:"sm",disabled:ge,onClick:$t,children:ge?"Deleting...":"Delete history"})]})]})}),xe!==null&&t.jsx(Zr,{feature:"Compare",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(YS,{left:xe[0],right:xe[1],leftDisplayNumber:tu(xe[0],Xl),rightDisplayNumber:tu(xe[1],Xl),onClose:oa})})})]})}function fR(e,n,s){return n==="__all__"&&s==="__all__"?e:e.filter(r=>!(n!=="__all__"&&r.sessionId!==n||s!=="__all__"&&r.model!==s))}function hR(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 lu(e,n){return n.retainIds?.has(e.id)===!0||n.retainSessionId!==void 0&&e.sessionId===n.retainSessionId}function cu(e,n){const s=e.reduce((a,i)=>a+(lu(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&&!lu(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 ni(e,n,s,r){if(s.length===0){const p=cu([...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=cu(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 xR(e){const n=new URLSearchParams({compact:"1"});e!==void 0&&n.set("sessionId",e);const s=rx();return s.ok?ox(s.runtime,`/api/logs/stream?${n.toString()}`):null}function gR(e){const n=xR(e);return n===null?null:new EventSource(n)}const bR=Gt([_({type:ae("init"),logs:V(Gs)}),_({type:ae("update"),log:Gs}),_({type:ae("progress"),logId:T().int().positive(),chunkBase64:x(),responseBytes:T().int().nonnegative(),responseStatus:T().int().nullable(),elapsedMs:T().int().nonnegative().nullable(),terminal:Ce()})]),vR=_({logs:V(Gs),total:T().int().nonnegative(),limit:T().int().positive(),hasOlder:Ce(),hasNewer:Ce(),oldestLogId:T().int().positive().nullable(),newestLogId:T().int().positive().nullable()}),yR=V(x()),du=_({success:Ce(),cleared:T().int().nonnegative(),logFilesRewritten:T().int().nonnegative().optional(),chunkFilesDeleted:T().int().nonnegative(),sessionArchiveLogsDeleted:T().int().nonnegative().optional()});function wR(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 qr(e){const n=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&n.add(s.sessionId);return[...n]}function jR(e){const n=new Set;for(const s of e)s.model!==null&&s.model!==""&&n.add(s.model);return[...n]}const SR=100,NR=12,CR=1800,Jl=100,To=500,Bh=200,$i=2e4,kR=1e4,_R=3e3,TR=1e4,ER=2e3;function RR(e,n,s=Jl){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 Ws(e,n,s=Jl){return Be(RR(e,n,s),vR,$i)}async function MR(e,n){const s=new Set;let r=await Ws(e,{kind:"oldest"},To);for(const a of r.logs)s.add(a.id);n(s.size,1);let o=1;for(;r.hasNewer&&r.newestLogId!==null&&o<Bh;){r=await Ws(e,{kind:"newer",afterLogId:r.newestLogId},To);for(const a of r.logs)s.add(a.id);o+=1,n(s.size,o)}return{ids:[...s],truncated:r.hasNewer}}async function AR(){try{return{deleted:(await Ke("/api/groups",Ru,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function OR({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}=nh(),[f,h]=l.useState(lT),[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),R=l.useRef(null),k=l.useRef(null),M=l.useRef(!0),O=l.useRef(null),$=l.useRef(0),K=l.useRef(null),ee=l.useRef(null),z=l.useRef(new Map),H=l.useRef([]),te=l.useRef(new Map),U=l.useRef(new Map),Z=l.useRef(new Map),fe=l.useRef(null),je=l.useCallback(()=>({recentLimit:ER,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)},[]),L=l.useCallback((F,W,X=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:$i,loadedLogs:X,loadedPages:ne})};ie(),ee.current=setInterval(ie,250)},[]),J=l.useCallback((F,W,X,ne)=>{const Ee=K.current;Ee===null||$.current!==W||N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:$i,loadedLogs:X,loadedPages:ne})},[]),Se=l.useMemo(()=>fR(n,r,a),[n,r,a]),Te=l.useMemo(()=>Pn(c,qr(n)),[n,c]),ge=l.useMemo(()=>jR(n),[n]),le=l.useCallback(()=>{Ke("/api/sessions",yR).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 X=ni(W,z.current,F,je());return z.current=X.index,X.logs})})},[je,A]),Pe=l.useCallback(F=>{const W=te.current.get(F.id),X=Z.current.get(F.id);H.current.push(W!==void 0&&F.responseText===null?{...F,responseText:W,responseTextBytes:X?.responseBytes??new TextEncoder().encode(W).byteLength,responseStatus:X?.responseStatus??F.responseStatus,elapsedMs:X?.elapsedMs??F.elapsedMs,totalStreamMs:X?.elapsedMs??F.totalStreamMs,streaming:!0,bodyContentMode:"full"}:F),fe.current===null&&(fe.current=setTimeout(ce,SR))},[ce]),Re=l.useCallback(F=>{const W=atob(F.chunkBase64),X=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(X,{stream:!F.terminal})}`;te.current.set(F.logId,ie),Z.current.set(F.logId,{responseBytes:F.responseBytes,responseStatus:F.responseStatus,elapsedMs:F.elapsedMs}),F.terminal&&U.current.delete(F.logId),s(oe=>{const ke=z.current.get(F.logId);if(ke===void 0)return oe;const De=oe[ke];if(De===void 0)return oe;const Gn=[...oe];return Gn[ke]={...De,responseText:ie,responseTextBytes:F.responseBytes,responseStatus:F.responseStatus??De.responseStatus,elapsedMs:F.elapsedMs??De.elapsedMs,totalStreamMs:F.elapsedMs??De.totalStreamMs,streaming:!0,bodyContentMode:"full"},Gn})},[]),Fe=l.useCallback(()=>{I.current&&I.current.close(),R.current!==null&&(clearTimeout(R.current),R.current=null),h(W=>Et(W,{type:"connect-requested"}));const F=gR(e);if(F===null){h(W=>Et(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 X=String(W.data),ne=JSON.parse(X),Ee=bR.safeParse(ne);if(!Ee.success){h(oe=>Et(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=ni(oe,z.current,ie.logs,je());return z.current=ke.index,ke.logs}),d(oe=>Pn(oe,qr(ie.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(oe=>Et(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=>Et(oe,{type:"message-received",at:Date.now()}));break}case"progress":{Re(ie),h(oe=>Et(oe,{type:"message-received",at:Date.now()}));break}}}catch{h(X=>Et(X,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),he("Failed to parse SSE data")}},F.onerror=()=>{const W=navigator.onLine;h(X=>Et(X,{type:"connection-lost",online:W,message:"The live stream disconnected."})),F.close(),!(!W||!M.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(X=>Et(X,{type:"stale-timeout"}))},TR)),R.current=setTimeout(Fe,_R))}},[Re,m,e,Pe,he]),ct=l.useCallback(()=>{M.current=!0,R.current!==null&&(clearTimeout(R.current),R.current=null),Fe()},[Fe]),He=l.useCallback(()=>{M.current=!1,I.current?.close(),I.current=null,R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(F=>Et(F,{type:"stop-retrying"}))},[]),Le=l.useCallback(F=>{if(e===void 0)return;const W=$.current+1;$.current=W,y(!0),j(null),L("Loading session logs",W),m(),Ws(e,F).then(X=>{if($.current!==W)return;const ne=X.logs;z.current=On(ne),s(ne),v(X),o(e),y(!1),j(null),re(),m()}).catch(X=>{if($.current!==W)return;y(!1),re();const ne=X instanceof Error?X.message:"Failed to load session logs";j(ne),he(ne)})},[m,e,he,L,re]),We=l.useCallback(F=>{const W=$.current+1;$.current=W,y(!0),j(null),L("Reloading full session",W),m(),(async()=>{const X=[];let ne=await Ws(F,{kind:"oldest"},To);X.push(...ne.logs),J("Reloading full session",W,X.length,1);let Ee=1;for(;ne.hasNewer&&ne.newestLogId!==null&&Ee<Bh;)ne=await Ws(F,{kind:"newer",afterLogId:ne.newestLogId},To),X.push(...ne.logs),Ee+=1,J("Reloading full session",W,X.length,Ee);$.current===W&&(s(ie=>{const oe=ni(ie,z.current,X,je());return z.current=oe.index,oe.logs}),d(ie=>Pn(ie,[F])),y(!1),j(null),re(),ne.hasNewer?u({message:`Loaded ${String(X.length)} logs for this session. More history is available.`,tone:"success"}):m())})().catch(X=>{if($.current!==W)return;y(!1),re();const ne=X instanceof Error?X.message:"Failed to reload session logs";j(ne),he(ne)})},[m,he,u,L,re,J]);l.useEffect(()=>{if(e===void 0){E([]);return}let F=!1;return Be("/api/groups",Iu,kR).then(W=>W.groups).then(W=>{F||W===null||E(wR(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,R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(X=>Et(X,{type:"browser-offline"}))},W=()=>{M.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),R.current!==null&&(clearTimeout(R.current),R.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),X=Number(W.replace(/^log-/,""));Number.isInteger(X)&&X>0&&Ss({logId:X,tab:"request"});let ne=!1,Ee=0,ie=null,oe=null;const ke=()=>{if(ne)return;const De=document.getElementById(W);if(De!==null){O.current=F,De.scrollIntoView({block:"center",behavior:jh(Sh())}),De instanceof HTMLElement&&(ie=De,De.setAttribute("data-deep-link-highlight","true"),oe=window.setTimeout(()=>{De.removeAttribute("data-deep-link-highlight")},CR),De.focus({preventScroll:!0}),De.getAttribute("data-nav-action")==="expand"&&De.click());return}Ee+=1,Ee<NR&&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=qr(n);re(),y(!1),z.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(X=>{const ne=X.filter(ie=>W.has(ie.id)),Ee=X.filter(ie=>!W.has(ie.id));return d(ie=>Pn(ie,qr(ne))),z.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__"){L("Deleting stored history",F);const oe=await Ke("/api/logs",du,{method:"DELETE"}),ke=await AR();if($.current!==F)return;s([]),z.current.clear(),v(null),d([]),E([]),y(!1),re();const De=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.${De}`,tone:ke.ok?"success":"error"});return}const W=r;L("Deleting session history",F);const X=await MR(W,(oe,ke)=>{J("Deleting session history",F,oe,ke)}),ne=new Set(X.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(De=>De.sessionId!==W);return z.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",du,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:Ee})});if($.current!==F)return;s(oe=>{const ke=oe.filter(De=>De.sessionId!==W);return z.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${X.truncated?". More history may remain.":"."}`,tone:X.truncated?"error":"success"})}finally{$.current===F&&(y(!1),re())}},[n,m,r,u,L,re,J]),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 X=await Ke("/api/logs/import",ng,{method:"POST",body:W});return s(ne=>{const Ee=new Set(X.logs.map(oe=>oe.id)),ie=hR(ne.filter(oe=>!Ee.has(oe.id)),X.logs);return z.current=On(ie),ie}),o(X.sessionId),i("__all__"),v(null),m(),X},[m]),{strip:se,captureMode:xe,slowResponseThresholdSeconds:me,timeDisplayFormat:we}=Qi(),Oe=xe,ze=l.useCallback(()=>{Le({kind:"oldest"})},[Le]),D=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??Jl,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ze,onOlder:Y,onNewer:de,onNewest:D}},[e,D,de,Y,ze,g,S,w]);return t.jsxs(t.Fragment,{children:[t.jsx(sh,{notice:p,onDismiss:m}),t.jsx(ab,{}),t.jsx(mR,{logs:Se,sessions:Te,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:ct,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 $,AT as A,_e as B,u0 as C,Pt as D,LR as E,Ze as F,be as G,ON as H,qu as I,PR as J,Ou as K,tN as L,Hu as M,DN as N,zN as O,OR as P,Hn as Q,S1 as R,DT as S,Df as T,ki as U,go as V,G_ as W,ir as X,e0 as Y,Ys as Z,G as _,nS as a,Ue as a0,xu as a1,GS as a2,$g as a3,ic as b,B as c,Vu as d,bt as e,$e as f,_f as g,St as h,Lt as i,Dt as j,zt as k,Gu as l,zf as m,Zt as n,dt as o,X0 as p,Rs as q,xo as r,ut as s,pt as t,ll as u,mt as v,Ss as w,Gs as x,yE as y,IT as z};
|