agent-session-inspector 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/VERSION +1 -1
  2. package/app/.next/BUILD_ID +1 -1
  3. package/app/.next/app-path-routes-manifest.json +1 -0
  4. package/app/.next/build-manifest.json +3 -3
  5. package/app/.next/prerender-manifest.json +3 -3
  6. package/app/.next/required-server-files.json +1 -1
  7. package/app/.next/routes-manifest.json +9 -0
  8. package/app/.next/server/app/_global-error.html +1 -1
  9. package/app/.next/server/app/_global-error.rsc +1 -1
  10. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  11. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  14. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/_not-found.html +1 -1
  16. package/app/.next/server/app/_not-found.rsc +2 -2
  17. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  19. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/app/.next/server/app/api/analytics/route.js +2 -1
  21. package/app/.next/server/app/api/analytics/route.js.nft.json +1 -1
  22. package/app/.next/server/app/api/logs/route.js +2 -1
  23. package/app/.next/server/app/api/logs/route.js.nft.json +1 -1
  24. package/app/.next/server/app/api/pricing/route.js +2 -1
  25. package/app/.next/server/app/api/pricing/route.js.nft.json +1 -1
  26. package/app/.next/server/app/api/providers/route.js +2 -1
  27. package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
  28. package/app/.next/server/app/api/search/route.js +3 -2
  29. package/app/.next/server/app/api/search/route.js.nft.json +1 -1
  30. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route/app-paths-manifest.json +3 -0
  31. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route/build-manifest.json +12 -0
  32. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route/server-reference-manifest.json +4 -0
  33. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route.js +8 -0
  34. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route.js.map +5 -0
  35. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route.js.nft.json +1 -0
  36. package/app/.next/server/app/api/sessions/[provider]/[id]/record/route_client-reference-manifest.js +3 -0
  37. package/app/.next/server/app/api/sessions/[provider]/[id]/reveal/route.js +2 -1
  38. package/app/.next/server/app/api/sessions/[provider]/[id]/reveal/route.js.nft.json +1 -1
  39. package/app/.next/server/app/api/sessions/[provider]/[id]/route.js +2 -1
  40. package/app/.next/server/app/api/sessions/[provider]/[id]/route.js.nft.json +1 -1
  41. package/app/.next/server/app/api/sessions/route.js +2 -1
  42. package/app/.next/server/app/api/sessions/route.js.nft.json +1 -1
  43. package/app/.next/server/app/index.html +1 -1
  44. package/app/.next/server/app/index.rsc +3 -3
  45. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  46. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  47. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  48. package/app/.next/server/app/page.js.nft.json +1 -1
  49. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/sessions/[provider]/[id]/page.js.nft.json +1 -1
  51. package/app/.next/server/app/sessions/[provider]/[id]/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app-paths-manifest.json +1 -0
  53. package/app/.next/server/chunks/1oeh_server_app_api_sessions_[provider]_[id]_record_route_actions_13lvgh0.js +3 -0
  54. package/app/.next/server/chunks/[externals]__0xll52b._.js +3 -0
  55. package/app/.next/server/chunks/[root-of-the-server]__014br-h._.js +3 -0
  56. package/app/.next/server/chunks/[root-of-the-server]__03bee2l._.js +3 -0
  57. package/app/.next/server/chunks/[root-of-the-server]__093lyxv._.js +3 -0
  58. package/app/.next/server/chunks/[root-of-the-server]__0co499t._.js +3 -0
  59. package/app/.next/server/chunks/[root-of-the-server]__0ne74op._.js +3 -0
  60. package/app/.next/server/chunks/[root-of-the-server]__0p_hyq8._.js +3 -0
  61. package/app/.next/server/chunks/[root-of-the-server]__0ryrg2h._.js +3 -0
  62. package/app/.next/server/chunks/[root-of-the-server]__0uv5tnc._.js +3 -0
  63. package/app/.next/server/chunks/[root-of-the-server]__0yxic1z._.js +3 -3
  64. package/app/.next/server/chunks/[root-of-the-server]__1lfc-ga._.js +3 -0
  65. package/app/.next/server/chunks/[root-of-the-server]__1n_sepq._.js +3 -0
  66. package/app/.next/server/chunks/ssr/_0o294sf._.js +1 -1
  67. package/app/.next/server/chunks/ssr/_0wfo2z0._.js +1 -1
  68. package/app/.next/server/chunks/ssr/src_app_sessions_[provider]_[id]_page_tsx_0uf635h._.js +3 -3
  69. package/app/.next/server/middleware-build-manifest.js +3 -3
  70. package/app/.next/server/pages/404.html +1 -1
  71. package/app/.next/server/pages/500.html +1 -1
  72. package/app/.next/server/server-reference-manifest.js +1 -1
  73. package/app/.next/server/server-reference-manifest.json +1 -1
  74. package/app/.next/static/chunks/1lmw5sxsr57p6.css +1 -0
  75. package/app/.next/static/chunks/{33valh9_p24ah.js → 1nuneih_2_kul.js} +1 -1
  76. package/app/.next/static/chunks/21ckxredfe3pr.js +6 -0
  77. package/app/package.json +1 -1
  78. package/app/server.js +1 -1
  79. package/cli/cli.mjs +159 -52
  80. package/package.json +1 -1
  81. package/app/.next/server/chunks/[root-of-the-server]__0dyq0rc._.js +0 -3
  82. package/app/.next/server/chunks/[root-of-the-server]__0kgkqhn._.js +0 -3
  83. package/app/.next/server/chunks/[root-of-the-server]__10p8y9z._.js +0 -3
  84. package/app/.next/server/chunks/[root-of-the-server]__1cceere._.js +0 -3
  85. package/app/.next/server/chunks/[root-of-the-server]__1eclfq8._.js +0 -3
  86. package/app/.next/server/chunks/[root-of-the-server]__1lz20wm._.js +0 -3
  87. package/app/.next/server/chunks/[root-of-the-server]__1zdh1mi._.js +0 -3
  88. package/app/.next/server/chunks/[root-of-the-server]__20epvou._.js +0 -3
  89. package/app/.next/static/chunks/0slbmtcht4v2w.css +0 -1
  90. package/app/.next/static/chunks/279fmcw99x0e9.js +0 -6
  91. package/app/AGENTS.md +0 -9
  92. package/app/CLAUDE.md +0 -1
  93. package/app/CONTRIBUTING.md +0 -90
  94. package/app/Dockerfile +0 -34
  95. package/app/LICENSE +0 -21
  96. package/app/README.md +0 -369
  97. package/app/bin/agent-session-inspector.mjs +0 -185
  98. package/app/components.json +0 -25
  99. package/app/docs/screenshots/analytics-dark.png +0 -0
  100. package/app/docs/screenshots/analytics.png +0 -0
  101. package/app/docs/screenshots/request-table.png +0 -0
  102. package/app/docs/screenshots/session-overview-dark.png +0 -0
  103. package/app/docs/screenshots/session-overview.png +0 -0
  104. package/app/docs/screenshots/sessions-dark.png +0 -0
  105. package/app/docs/screenshots/sessions.png +0 -0
  106. package/app/docs/screenshots/timeline-dark.png +0 -0
  107. package/app/docs/screenshots/timeline.png +0 -0
  108. package/app/docs/screenshots/token-optimizer-dark.png +0 -0
  109. package/app/docs/screenshots/token-optimizer.png +0 -0
  110. package/app/docs/social-preview.png +0 -0
  111. package/app/eslint.config.mjs +0 -20
  112. package/app/install.sh +0 -85
  113. package/app/next.config.ts +0 -17
  114. package/app/pnpm-lock.yaml +0 -7031
  115. package/app/pnpm-workspace.yaml +0 -3
  116. package/app/postcss.config.mjs +0 -7
  117. package/app/scripts/build-cli.mjs +0 -26
  118. package/app/scripts/demo-data.mjs +0 -335
  119. package/app/scripts/deploy-docker.sh +0 -71
  120. package/app/scripts/package-release.sh +0 -86
  121. package/app/tsconfig.json +0 -34
  122. /package/app/.next/static/{ji6govOHS2spXukBPOyFL → muuOFZsnyOfIG_5aUuqFV}/_buildManifest.js +0 -0
  123. /package/app/.next/static/{ji6govOHS2spXukBPOyFL → muuOFZsnyOfIG_5aUuqFV}/_clientMiddlewareManifest.js +0 -0
  124. /package/app/.next/static/{ji6govOHS2spXukBPOyFL → muuOFZsnyOfIG_5aUuqFV}/_ssgManifest.js +0 -0
@@ -1,8 +1,8 @@
1
- module.exports=[75136,a=>{"use strict";var b=a.i(38742),c=a.i(73895),d=a.i(24687),e=a.i(37303),f=a.i(70627);let g=(0,f.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),h=(0,f.default)("bookmark",[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]]),i=(0,f.default)("circle-dollar-sign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]),j=(0,f.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),k=(0,f.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);var l=a.i(35789);let m=(0,f.default)("flask-conical",[["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"}]]),n=(0,f.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);var o=a.i(22598),p=a.i(99570),q=a.i(75083),r=a.i(69876),s=a.i(64151),t=a.i(19608),u=a.i(59561),v=a.i(27936),w=a.i(31049),x=a.i(35540),y=a.i(34597);let z=(0,f.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),A=(0,f.default)("arrow-down-narrow-wide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]),B=(0,f.default)("arrow-up-narrow-wide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]),C=(0,f.default)("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);var D=a.i(12650),D=D,E=a.i(80995);let F=(0,f.default)("chevrons-down-up",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]),G=(0,f.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),H=(0,f.default)("circle-x",[["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"}]]),I=(0,f.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);var J=a.i(89560);let K=(0,f.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),L=(0,f.default)("list-filter",[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]),M=(0,f.default)("radio",[["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"}]]),N=(0,f.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),O=(0,f.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var P=a.i(61055),Q=a.i(86304),R=a.i(73221),S=a.i(85259),T=a.i(96538),U=a.i(16543),V=a.i(45646);function W(a){let b=[],c=[],d=new Map,e=new Map,f=new Map,g=0,h=0,i=0,j=0,k=null;for(let l of a){if(!0===l.data.inherited){"number"==typeof l.data.costUSD&&(i+=l.data.costUSD);continue}if("user.message"===l.type){j+=1,k={turn:j,prompt:"string"==typeof l.data.content?l.data.content:void 0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k),d.set(l.id,k),e.set(l.id,j);continue}k&&e.set(l.id,k.turn),k&&l.type.startsWith("session.compaction")&&(k.compacted=!0);let a=l.data.costUSD,m="number"==typeof a&&a>0,n=Array.isArray(l.data.costLines)?l.data.costLines:[];if(m||k){for(let a of(k||(k={turn:0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k)),n))!function(a,b){let c=a.find(a=>a.model===b.model&&a.kind===b.kind&&a.rate===b.rate);c?(c.tokens+=b.tokens,null!==c.usd&&null!==b.usd&&(c.usd+=b.usd)):a.push({...b})}(k.lines,a);n.length>0&&c.push(function(a,b,c,d,e){let f=(...a)=>b.reduce((b,c)=>a.includes(c.kind)?b+c.tokens:b,0),g=(...a)=>b.reduce((b,c)=>a.includes(c.kind)&&null!==c.usd?(b??0)+c.usd:b,null),h=f("input"),i=f("cacheWrite","cacheWrite1h"),j=f("cacheRead");return{n:c,turn:d,eventId:a.id,timestamp:a.timestamp,models:[...new Set(b.map(a=>a.model))],inputTokens:h,cacheWriteTokens:i,cacheReadTokens:j,outputTokens:f("output"),contextTokens:h+i+j,usd:{input:g("input"),cacheWrite:g("cacheWrite","cacheWrite1h"),cacheRead:g("cacheRead"),output:g("output")},costUSD:e}}(l,n,c.length+1,k.turn,m?a:null)),m&&(h+=a,k.costUSD+=a,k.requests+=1,k.totalUSD=h,f.set(l.id,h),g=Math.max(g,a))}}let l=b.findIndex(a=>a.costUSD>0);return{turns:-1===l?[]:b.slice(l),requests:c,turnByPrompt:d,turnOf:e,runningUSD:f,maxEventUSD:g,totalUSD:h,inheritedUSD:i}}var X=a.i(90075),Y=a.i(3541),Z=a.i(87105),$=a.i(68114);let _={"session.start":{label:"Session Start",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"session.shutdown":{label:"Session Shutdown",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"session.resume":{label:"Session Resume",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"user.message":{label:"User Message",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"assistant.message":{label:"Assistant",dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400"},"assistant.turn_start":{label:"Turn Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"assistant.turn_end":{label:"Turn End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"tool.execution_start":{label:"Tool Start",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"tool.execution_complete":{label:"Tool Done",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"external_tool.requested":{label:"External Tool Request",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"external_tool.completed":{label:"External Tool Done",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"permission.requested":{label:"Permission",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"permission.completed":{label:"Permission Done",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"hook.start":{label:"Hook Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"hook.end":{label:"Hook End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"session.auto_mode_resolved":{label:"Auto Mode",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.binary_asset":{label:"Binary Asset",dotCls:"bg-rose-100 border-rose-400 dark:bg-rose-900/60 dark:border-rose-700",typeCls:"text-rose-700 dark:text-rose-400"},"session.usage_checkpoint":{label:"Usage Checkpoint",dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400"},"subagent.deselected":{label:"Subagent Deselected",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"session.model_change":{label:"Model Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_start":{label:"Compaction Start",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_complete":{label:"Compaction Complete",dotCls:"bg-purple-100 border-purple-400 dark:bg-purple-900/60 dark:border-purple-700",typeCls:"text-purple-700 dark:text-purple-400"},"system.message":{label:"System",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"assistant.thinking":{label:"Thinking",dotCls:"bg-indigo-100 border-indigo-400 dark:bg-indigo-900/60 dark:border-indigo-700",typeCls:"text-indigo-700 dark:text-indigo-400"},"session.error":{label:"Error",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"context.attachment":{label:"Attachment",dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400"},"file.patch_applied":{label:"Patch Applied",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"web.search":{label:"Web Search",dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400"},"session.turn_context":{label:"Turn Context",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.world_state":{label:"World State",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.mode_change":{label:"Mode Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.turn_aborted":{label:"Turn Aborted",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"session.rollback":{label:"Rollback",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"subagent.activity":{label:"Subagent",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"session.plan_changed":{label:"Plan Changed",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"system.notification":{label:"Notification",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"subagent.session_start":{label:"Subagent Start",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"subagent.message":{label:"Subagent Message",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"}},aa={label:"Event",dotCls:"bg-muted border-border",typeCls:"text-muted-foreground",chipCls:"border-border bg-muted text-muted-foreground"},ab={session:{dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400",chipCls:"border-fuchsia-300 bg-fuchsia-100 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/50 dark:text-fuchsia-300"},user:{dotCls:"bg-pink-100 border-pink-400 dark:bg-pink-900/60 dark:border-pink-700",typeCls:"text-pink-700 dark:text-pink-400",chipCls:"border-pink-300 bg-pink-100 text-pink-800 dark:border-pink-800 dark:bg-pink-900/50 dark:text-pink-300"},assistant:{dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400",chipCls:"border-sky-300 bg-sky-100 text-sky-800 dark:border-sky-800 dark:bg-sky-900/50 dark:text-sky-300"},tool:{dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400",chipCls:"border-amber-300 bg-amber-100 text-amber-800 dark:border-amber-800 dark:bg-amber-900/50 dark:text-amber-300"},external_tool:{dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400",chipCls:"border-lime-300 bg-lime-100 text-lime-800 dark:border-lime-800 dark:bg-lime-900/50 dark:text-lime-300"},permission:{dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400",chipCls:"border-red-300 bg-red-100 text-red-800 dark:border-red-800 dark:bg-red-900/50 dark:text-red-300"},hook:{dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400",chipCls:"border-teal-300 bg-teal-100 text-teal-800 dark:border-teal-800 dark:bg-teal-900/50 dark:text-teal-300"},system:{dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400",chipCls:"border-slate-300 bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300"},subagent:{dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400",chipCls:"border-zinc-300 bg-zinc-100 text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/60 dark:text-zinc-300"},context:{dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400",chipCls:"border-stone-300 bg-stone-100 text-stone-800 dark:border-stone-700 dark:bg-stone-900/60 dark:text-stone-300"},file:{dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400",chipCls:"border-emerald-300 bg-emerald-100 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-300"},web:{dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400",chipCls:"border-blue-300 bg-blue-100 text-blue-800 dark:border-blue-800 dark:bg-blue-900/50 dark:text-blue-300"}},ac={"session.start":"Session initialization event. Captures the runtime context and selected model when a session begins.","session.resume":"Session resumed from previous state. Indicates context reload and continuation.","session.shutdown":"Session end summary. Usually includes usage, token totals, premium requests, and API timing.","session.auto_mode_resolved":"Auto-mode model selection result. Shows predicted task profile and chosen model settings.","session.binary_asset":"Binary payload captured in the session (typically screenshots/images). Can consume significant context/storage.","session.usage_checkpoint":"Interim usage accounting snapshot (AIU/premium usage/cache state) while session is active.","session.model_change":"Model configuration switched during the session (model/effort/context tier).","session.compaction_start":"Context compaction started. Conversation is being summarized/compressed to reduce token load.","session.compaction_complete":"Compaction finished, with success/failure metadata and request identifiers.","user.message":"User input message that drives the next assistant turn.","assistant.message":"Assistant output message, optionally with model/tool-request and token metadata.","assistant.turn_start":"Start of a single assistant reasoning/execution turn.","assistant.turn_end":"End of the assistant turn after reasoning/tools/output.","tool.execution_start":"A local tool invocation started with tool name and arguments.","tool.execution_complete":"A local tool invocation completed with status and result payload.","external_tool.requested":"Request sent to an external tool bridge/service.","external_tool.completed":"External tool request lifecycle completed.","permission.requested":"Runtime requested user permission for an action (e.g., file/system/network).","permission.completed":"Permission flow resolved (approved/denied).","hook.start":"Lifecycle hook execution started (for example, prompt submission hooks).","hook.end":"Lifecycle hook execution completed with success/failure state.","subagent.deselected":"Subagent focus was cleared and control returned to the main agent context.","system.message":"System-level instruction/context block injected into the conversation runtime.","assistant.thinking":"Extended reasoning the model produced before answering. Billed as output tokens.","session.error":"API or transport error. Each retry re-sends the full request context.","context.attachment":"Context the runtime injected automatically: file snapshots, reminders, tool or skill listings.","file.patch_applied":"A patch the agent applied to the workspace, with the files it touched.","web.search":"Web search issued by the model; results are added to the conversation context.","session.turn_context":"Per-turn runtime configuration: model, effort, sandbox and approval policy.","session.world_state":"Snapshot of the workspace the runtime handed to the model.","session.mode_change":"Interaction or permission mode switched during the session.","session.turn_aborted":"The turn was interrupted before it completed.","session.rollback":"Conversation was rolled back by a number of turns.","subagent.activity":"Activity reported by a subagent working under the main agent.","subagent.message":"Message passed between agents.","subagent.session_start":"A subagent thread started inside this session.","session.plan_changed":"The agent created or updated its working plan.","system.notification":"Runtime notification injected into the conversation, such as a background shell finishing."};function ad(a){return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ae(a){return new Date(a).toLocaleDateString([],{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function af(a,b){return new Date(b).getTime()-new Date(a).getTime()}function ag(a){let[b,...c]=a.split(".");return{category:b||"unknown",subCategory:c.join(".")||"general"}}function ah(a){return!!a&&!1===a.data.success&&(aX.has(a.type)||"file.patch_applied"===a.type)}function ai(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function aj({data:a}){let d=a.content||"",[e,f]=(0,c.useState)(!1),g=d.slice(0,300),h=d.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[e?d:g,h&&!e&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>f(!e),className:"h-auto px-0 font-normal text-violet-600 dark:text-violet-400 mt-1",children:e?"Show less":`Show more (${d.length} chars)`})]})}function ak({data:a}){let d=a.content||"",e=a.toolRequests||[],f=a.model,g=a.outputTokens,[h,i]=(0,c.useState)(!1),j=d.slice(0,400),k=d.length>400;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:f}),void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()}),(0,b.jsx)("span",{className:"opacity-60",children:"tokens"})]})]}),d&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[h?d:j,k&&!h&&"..."]}),k&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:"h-auto px-0 font-normal text-sky-600 dark:text-sky-400 mt-1",children:h?"Show less":`Show more (${d.length} chars)`})]}),e.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-amber-100 border border-amber-300 dark:bg-amber-900/50 dark:border-amber-800 rounded-sm text-xs text-amber-800 dark:text-amber-300 font-mono",children:["🔧 ",a.name]},c))})]})}function al({data:a,type:d}){let e=a.toolName,f=a.arguments,g=a.result,h=a.success,[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!1);return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"font-mono text-amber-700 dark:text-amber-300 font-semibold",children:e}),"tool.execution_complete"===d&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium ${h?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400":"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400"}`,children:h?"success":"failed"})]}),f&&Object.keys(f).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>j(!i),className:"h-auto px-0 font-normal text-amber-600 dark:text-amber-500",children:[i?"▼":"▶"," Arguments"]}),i&&(0,b.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded-sm text-xs text-foreground overflow-auto max-h-48 font-mono border border-border",children:JSON.stringify(f,null,2)})]}),g&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>l(!k),className:"h-auto px-0 font-normal text-amber-600 dark:text-amber-500",children:[k?"▼":"▶"," Result"]}),k&&(0,b.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded-sm text-xs text-foreground overflow-auto max-h-48 font-mono border border-border",children:JSON.stringify(g,null,2)})]})]})}function am({data:a}){let c=a.tokenDetails,d=a.totalApiDurationMs,e=a.totalPremiumRequests,f=a.shutdownType,g=c?.input?.tokenCount,h=c?.output?.tokenCount,i=c?.cache_read?.tokenCount;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(Q.Badge,{variant:"outline",className:"text-xs",children:f}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:e})," premium req"]}),void 0!==d&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsxs)("span",{className:"font-semibold text-foreground",children:[(d/1e3).toFixed(1),"s"]})," API"]})]}),(void 0!==g||void 0!==h)&&(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-cyan-100 border border-cyan-300 dark:bg-cyan-950 dark:border-cyan-800 rounded-full text-xs text-cyan-700 dark:text-cyan-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"in"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()})]}),void 0!==h&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:h.toLocaleString()})]}),void 0!==i&&i>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-teal-100 border border-teal-300 dark:bg-teal-950 dark:border-teal-800 rounded-full text-xs text-teal-700 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"cache"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:i.toLocaleString()})]})]})]})}function an({data:a}){let d=a.role,e=a.interactionId,f=a.content||"",[g,h]=(0,c.useState)(!1),i=f.slice(0,420),j=f.length>420;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs border border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300 font-mono",children:d}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",e]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-slate-200/80 dark:border-slate-800/80 bg-background/70 px-3 py-2",children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"System Prompt"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-72 font-mono",children:[g?f:i,j&&!g&&"..."]})]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>h(!g),className:"h-auto px-0 font-normal text-slate-700 dark:text-slate-300",children:g?"Show less":`Show full system prompt (${f.length.toLocaleString()} chars)`})]})}function ao({data:a,type:d}){let e=a.hookType,f=a.hookInvocationId,g=a.success,h=a.input,i=h?.prompt,[j,k]=(0,c.useState)(!1),l=(i||"").slice(0,300),m=(i||"").length>300;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[e&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:e}),"hook.end"===d&&void 0!==g&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium border ${g?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:g?"success":"failed"}),f&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:f})]}),"hook.start"===d&&i&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Prompt Preview"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-44 font-mono",children:[j?i:l,m&&!j&&"..."]}),m&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>k(!j),className:"h-auto px-0 font-normal text-cyan-700 dark:text-cyan-300 mt-1",children:j?"Show less":`Show more (${i.length.toLocaleString()} chars)`})]})]})}function ap({data:a}){let c=a.chosenModel,d=a.reasoningBucket,e=a.predictedLabel,f=a.confidence,g=a.candidateModels||[],h=a.categoryScores;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(Q.Badge,{className:"text-xs font-mono bg-fuchsia-100 text-fuchsia-800 border border-fuchsia-300 dark:bg-fuchsia-900/50 dark:text-fuchsia-300 dark:border-fuchsia-800",children:c}),d&&(0,b.jsxs)(Q.Badge,{variant:"outline",className:"text-xs font-mono",children:["reasoning: ",d]}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["label: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]}),"number"==typeof f&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["confidence: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[Math.round(100*f),"%"]})]})]}),g.length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Candidate Models"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:g.slice(0,8).map((a,c)=>(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm border border-fuchsia-300 bg-fuchsia-100/70 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/40 dark:text-fuchsia-300 text-xs font-mono",children:String(a)},c))})]}),h&&Object.keys(h).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Category Scores"}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5",children:Object.entries(h).slice(0,6).map(([a,c])=>(0,b.jsxs)("div",{className:"text-xs border border-fuchsia-200 bg-fuchsia-50/70 dark:border-fuchsia-900/80 dark:bg-fuchsia-950/25 rounded-sm px-2 py-1 flex items-center justify-between gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(c)})]},a))})]})]})}function aq({data:a,type:d}){let e=a.requestId,f=a.toolName,g=a.toolCallId,h=a.workingDirectory,i=a.arguments,[j,k]=(0,c.useState)(!1);return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"external_tool.requested"===d?"bg-lime-100 text-lime-800 border-lime-300 dark:bg-lime-900/60 dark:text-lime-300 dark:border-lime-800":"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/60 dark:text-emerald-300 dark:border-emerald-800"}`,children:"external_tool.requested"===d?"requested":"completed"}),f&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:f}),g&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:g})]}),e&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["request: ",e]}),"external_tool.requested"===d&&h&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cwd: ",(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:h})]}),"external_tool.requested"===d&&i&&Object.keys(i).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>k(!j),className:"h-auto px-0 font-normal text-lime-700 dark:text-lime-400",children:[j?"▼":"▶"," Arguments"]}),j&&(0,b.jsx)("pre",{className:"mt-1 p-2 bg-background/70 rounded-sm text-xs text-foreground overflow-auto max-h-40 font-mono border border-lime-200 dark:border-lime-800 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:JSON.stringify(i,null,2)})]})]})}function ar({data:a}){let c=a.assetId,d=a.type,e=a.mimeType,f=a.byteLength,g=a.data;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:d}),e&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:e})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["size: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[f.toLocaleString()," bytes"]})]}),g&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["payload: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[g.length.toLocaleString()," chars"]})]})]}),c&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["asset: ",c]})]})}function as({data:a}){let c=a.usage,d=a.contextWindow,e=a.totalNanoAiu,f=a.totalPremiumRequests,g=a.modelCacheState,h="number"==typeof e?e/1e9:void 0;return(0,b.jsxs)("div",{className:"space-y-2",children:[c&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[[["in",c.inputTokens],["cached",c.cachedInputTokens],["out",c.outputTokens],["reasoning",c.reasoningTokens]].filter(([,a])=>"number"==typeof a&&a>0).map(([a,c])=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-teal-300 bg-teal-100 px-2 py-0.5 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:a}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:ai(c)})]},a)),d&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["window ",ai(d)]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==h&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["total AIU: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(h)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["premium req: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f})]})]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cache state entries: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:g.length})]})]})}function at({data:a}){let c=a.previousModel,d=a.newModel,e=a.reasoningEffort,f=a.contextTier;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"text-sm text-foreground",children:[(0,b.jsx)("span",{className:"font-mono",children:c||"unknown"}),(0,b.jsx)("span",{className:"mx-2 text-muted-foreground",children:"→"}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:d||"unknown"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-xs",children:[(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["effort: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e??"default"})]}),(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["context: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f??"default"})]})]})]})}function au({data:a}){let c=a.model,d=a.systemTokens,e=a.conversationTokens,f=a.toolDefinitionsTokens,g=[d,e,f].filter(a=>"number"==typeof a).reduce((a,b)=>a+b,0);return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:c}),g>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["total: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(g)})," tokens"]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-xs",children:[void 0!==d&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["system: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(d)})]}),void 0!==e&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["convo: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(e)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["tools: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(f)})]})]})]})}function av({data:a}){let c=a.success,d=a.error,e=a.statusCode,f=a.requestId,g=a.serviceRequestId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:c?"success":"failed"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["status: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]})]}),d&&(0,b.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 bg-red-100/70 dark:bg-red-950/30 border border-red-200 dark:border-red-900 rounded-sm px-2 py-1.5 font-mono whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:d}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["requestId: ",f]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["serviceRequestId: ",g]})]})}function aw(){return(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:"Active subagent context was cleared and focus returned to the main agent."})}function ax({data:a,type:c}){let d=a.model,e=a.turnId,f=a.interactionId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"assistant.turn_start"===c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-slate-100 text-slate-700 border-slate-300 dark:bg-slate-900/60 dark:text-slate-300 dark:border-slate-700"}`,children:"assistant.turn_start"===c?"turn started":"turn finished"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["turn: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(e)})]}),d&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:d})]}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",f]})]})}function ay({data:a}){let d=a.content||"",e=a.charLength??d.length,[f,g]=(0,c.useState)(!1),h=d.slice(0,400),i=d.length>400;return d?(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:["Reasoning · ",e.toLocaleString()," chars"]}),(0,b.jsxs)("div",{className:"text-sm italic leading-relaxed text-muted-foreground whitespace-pre-wrap",children:[f?d:h,i&&!f&&"…"]}),i&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>g(!f),className:"h-auto px-0 font-normal text-indigo-600 dark:text-indigo-400",children:f?"Show less":`Show more (${e.toLocaleString()} chars)`})]}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reasoning was recorded but its content is encrypted in the transcript."})}function az({data:a}){let c=a.message||"Error",d=a.detail;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-destructive",children:c}),d&&d!==c&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d})]})}function aA({items:a,label:d}){let[e,f]=(0,c.useState)(!1);if(0===a.length)return null;let g=e?a:a.slice(0,12);return(0,b.jsxs)("div",{className:"space-y-1",children:[d&&(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:[a.length," ",d]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-1",children:[g.map(a=>(0,b.jsx)("span",{className:"max-w-full truncate rounded-sm border border-border bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-foreground/80",title:a,children:a},a)),!e&&a.length>g.length&&(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>f(!0),className:"text-[11px] font-normal text-muted-foreground",children:["+",a.length-g.length," more"]})]})]})}function aB({text:a,charLength:d,limit:e=400,mono:f=!0,accentCls:g="text-muted-foreground"}){let[h,i]=(0,c.useState)(!1);if(!a)return null;let j=a.length>e,k=d??a.length;return(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("pre",{className:(0,$.cn)("max-h-72 overflow-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-foreground/80",f&&"font-mono"),children:[h?a:a.slice(0,e),!h&&j&&"…"]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:(0,$.cn)("h-auto px-0 font-normal",g),children:h?"Show less":`Show more (${k.toLocaleString()} chars)`})]})}function aC({data:a}){let c=a.attachmentType||"attachment",d=a.label||c,e=a.subject,f=a.items??[],g=a.itemsLabel,h=a.charLength??0,i=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs",children:d}),(0,b.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:c}),h>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["~",Math.round(h/4).toLocaleString()," tokens"]})]}),e&&(0,b.jsx)("p",{className:"break-all font-mono text-xs text-foreground/80",children:e}),(0,b.jsx)(aA,{items:f,label:g}),(0,b.jsx)(aB,{text:i,charLength:h,accentCls:"text-stone-600 dark:text-stone-400"})]})}function aD({data:a}){let c=a.success,d=a.changes||[],e=a.stdout||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:`rounded-sm px-1.5 py-0.5 text-xs font-medium ${!1===c?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400"}`,children:!1===c?"failed":"applied"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," file",1===d.length?"":"s"]})]}),d.length>0&&(0,b.jsx)("ul",{className:"space-y-1",children:d.slice(0,12).map(a=>(0,b.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm border border-emerald-300 bg-emerald-100/70 px-1 font-mono text-[10px] uppercase text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300",children:a.type}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",title:a.file,children:a.file})]},a.file))}),e&&(0,b.jsx)("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:e})]})}function aE({data:a}){let c=a.query||"",d=a.resultCount;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm text-foreground",children:c}),void 0!==d&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[d," result",1===d?"":"s"," returned"]})]})}function aF({facts:a}){let c=a.filter(([,a])=>null!=a&&""!==a);return 0===c.length?null:(0,b.jsx)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:c.map(([a,c])=>(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-sm border border-border bg-muted/40 px-2 py-1 text-xs",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",title:String(c),children:String(c)})]},a))})}function aG({data:a}){let c=a.mode||"unknown";return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Mode set to"}),(0,b.jsx)(Q.Badge,{variant:"secondary",className:"font-mono",children:c})]})}function aH({data:a}){let c=a.sandboxPolicy,d=a.approvalPolicy,e=c?.writable_roots??[];return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aF,{facts:[["model",a.model],["effort",a.effort],["personality",a.personality],["sandbox",c?.type],["network",c?.network_access===!0?"enabled":"restricted"],["approval",d?Object.keys(d)[0]:void 0],["cwd",a.cwd]]}),e.length>0&&(0,b.jsx)(aA,{items:e,label:"writable roots"})]})}function aI({data:a}){let c=a.sections??[],d=a.content||"",e=a.charLength??0;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)(aF,{facts:[["cwd",a.cwd],["shell",a.shell],["date",a.currentDate],["timezone",a.timezone],["snapshot",!0===a.full?"full":"delta"],["size",e?`${e.toLocaleString()} chars`:void 0]]}),(0,b.jsx)(aA,{items:c,label:"state sections"}),(0,b.jsx)(aB,{text:d,charLength:e})]})}function aJ({data:a,type:c}){return"subagent.session_start"===c?(0,b.jsx)(aF,{facts:[["agent",a.agentNickname],["path",a.agentPath],["thread",a.sessionId],["parent",a.parentThreadId],["cwd",a.cwd]]}):"subagent.activity"===c?(0,b.jsx)(aF,{facts:[["activity",a.kind],["path",a.agentPath],["thread",a.agentThreadId]]}):(0,b.jsx)(aO,{data:a})}function aK({data:a}){let c=a.durationMs;return(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm bg-orange-100 px-1.5 py-0.5 font-medium text-orange-800 dark:bg-orange-900/60 dark:text-orange-300",children:a.reason??"aborted"}),void 0!==c&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["after"," ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[(c/1e3).toFixed(1),"s"]})]}),void 0!==a.turnId&&(0,b.jsxs)("span",{className:"font-mono text-muted-foreground",children:["turn ",String(a.turnId)]})]})}function aL({data:a}){let c=a.turns;return(0,b.jsxs)("p",{className:"text-sm text-foreground",children:["Conversation rolled back"," ",(0,b.jsx)("span",{className:"font-semibold",children:c??"?"})," turn",1===c?"":"s","."]})}function aM({data:a}){return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Plan"}),(0,b.jsx)(Q.Badge,{variant:"secondary",className:"font-mono",children:a.operation??"changed"})]})}function aN({data:a}){let c=a.kind,d=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aF,{facts:[["kind",c?.type],["shell",c?.shellId],["exit code",c?.exitCode],["description",c?.description]]}),(0,b.jsx)(aB,{text:d,mono:!1})]})}function aO({data:a}){let[d,e]=(0,c.useState)(!1),f=JSON.stringify(a,null,2),g=f.slice(0,300),h=f.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("pre",{className:"text-xs text-muted-foreground font-mono whitespace-pre-wrap",children:[d?f:g,h&&!d&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>e(!d),className:"h-auto px-0 font-normal text-muted-foreground hover:text-foreground mt-1",children:d?"Collapse":"Expand"})]})}function aP(a,b=150){let c=String(a??"").replace(/\s+/g," ").trim();return c.length>b?`${c.slice(0,b)}…`:c}function aQ(a){if(!a)return"";for(let b of["command","cmd","input","script","filePath","file_path","notebook_path","path","pattern","query","description","url","prompt"])if(a[b])return`${b}: ${aP(a[b],90)}`;return Object.keys(a).length?aP(JSON.stringify(a),90):"(no args)"}let aR=a=>"string"==typeof a&&a.length>0?a.replace(/\n$/,"").split("\n").length:0,aS=new Set(["user.message","assistant.message","assistant.thinking"]);function aT({event:a,prevTimestamp:d,expandAll:e,parallel:f=!1,target:g=!1,merged:h=!1,result:i,runningUSD:j,costShare:k=0,turn:l}){let m,n,o,q,r,t,u=_[a.type]||aa,v=d?af(d,a.timestamp):null,[w,x]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)({nonce:0,open:aS.has(a.type)||g}),D=e&&e.nonce!==A.nonce?"open"===e.mode:A.open,F=function(a){let b=a.data,c=_[a.type]?.label??ag(a.type).subCategory;switch(a.type){case"user.message":return{label:"User",preview:aP(b.content)};case"assistant.message":{let a=b.toolRequests??[],c=aP(b.content);if(c)return{label:"Assistant",preview:c};if(a.length)return{label:"Assistant",preview:`requests ${a.map(a=>a.name).filter(Boolean).join(", ")}`};return{label:"Assistant",preview:"(no text)"}}case"assistant.turn_start":case"assistant.turn_end":{let c=b.turnId;return{label:"assistant.turn_start"===a.type?"Turn start":"Turn end",preview:[void 0!==c?`turn ${c}`:"",b.model].filter(Boolean).join(" · ")}}case"tool.execution_start":return{label:b.toolName||"Tool",preview:aQ(b.arguments),delta:function(a){if(!a)return null;let b=[a.input,a.patch,a.command].find(a=>"string"==typeof a&&a.includes("*** Begin Patch"));if(b){let a=0,c=0;for(let d of b.split("\n"))d.startsWith("+")&&!d.startsWith("+++")?a+=1:d.startsWith("-")&&!d.startsWith("---")&&(c+=1);return{added:a,removed:c}}let c=Array.isArray(a.edits)?a.edits:[a],d=0,e=0,f=!1;for(let a of c){let b=a.new_string??a.new_str??a.content??a.file_text,c=a.old_string??a.old_str;("string"==typeof b||"string"==typeof c)&&(f=!0,d+=aR(b),e+=aR(c))}return f?{added:d,removed:e}:null}(b.arguments)};case"tool.execution_complete":return{label:b.toolName||"Tool",preview:!1===b.success?"failed":"completed"};case"external_tool.requested":case"external_tool.completed":return{label:b.toolName||"External tool",preview:"external_tool.requested"===a.type?aQ(b.arguments):"completed"};case"session.start":case"session.resume":{let c=b.context;return{label:"session.start"===a.type?"Session start":"Session resume",preview:[c?.branch?`branch ${c.branch}`:"",b.selectedModel?`model ${b.selectedModel}`:""].filter(Boolean).join(" · ")}}case"session.shutdown":return{label:"Shutdown",preview:[b.shutdownType,void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:""].filter(Boolean).join(" · ")};case"session.auto_mode_resolved":return{label:"Auto mode",preview:[b.chosenModel,b.predictedLabel?`label ${b.predictedLabel}`:""].filter(Boolean).join(" · ")};case"session.binary_asset":return{label:"Binary asset",preview:[b.mimeType,"number"==typeof b.byteLength?`${(b.byteLength/1024).toFixed(0)} KB`:""].filter(Boolean).join(" · ")};case"session.usage_checkpoint":{let a=b.usage;if(a)return{label:"Usage checkpoint",preview:`in ${ai(a.inputTokens??0)} \xb7 out ${ai(a.outputTokens??0)}`};return{label:"Usage checkpoint",preview:void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:"usage snapshot"}}case"session.model_change":return{label:"Model change",preview:`${b.previousModel??"unknown"} → ${b.newModel??"unknown"}`};case"session.compaction_start":return{label:"Compaction",preview:`started \xb7 ${b.model??""}`.trim()};case"session.compaction_complete":return{label:"Compaction",preview:b.success?"completed":`failed${b.error?`: ${aP(b.error,80)}`:""}`};case"system.message":{let a=b.charLength||String(b.content??"").length;return{label:"System",preview:`${b.role??"system"} \xb7 ${a.toLocaleString()} chars`}}case"hook.start":case"hook.end":{let c=b.input;if("hook.end"===a.type)return{label:b.hookType||"Hook",preview:!1===b.success?"failed":"success"};return{label:b.hookType||"Hook",preview:aP(c?.prompt,90)||"started"}}case"permission.requested":{let a=b.permissionRequest;return{label:"Permission",preview:[a?.kind,aP(a?.intention,90)].filter(Boolean).join(" · ")}}case"permission.completed":{let a=b.result;return{label:"Permission",preview:a?.kind??"resolved"}}case"subagent.deselected":return{label:"Subagent",preview:"focus returned to main agent"};case"subagent.activity":return{label:"Subagent",preview:[b.kind,b.agentPath].filter(Boolean).join(" · ")};case"subagent.session_start":return{label:"Subagent start",preview:[b.agentNickname,b.agentPath,b.cwd].filter(Boolean).join(" · ")};case"session.plan_changed":return{label:"Plan",preview:String(b.operation??"changed")};case"system.notification":{let a=b.kind;return{label:"Notification",preview:[a?.type,a?.description].filter(Boolean).join(" · ")||aP(b.content,90)}}case"assistant.thinking":{let a=aP(b.content),c=b.charLength??0;return{label:"Thinking",preview:a||(c?`${c.toLocaleString()} chars (encrypted)`:"reasoning")}}case"session.error":return{label:"Error",preview:aP(b.detail||b.message,90)};case"context.attachment":{let a=b.charLength??0,c=b.itemCount??0,d=b.subject||(c?`${c} ${b.itemsLabel??"items"}`:"")||aP(b.content,70);return{label:b.label||"Attachment",preview:[d,a?`${a.toLocaleString()} chars`:""].filter(Boolean).join(" · ")}}case"file.patch_applied":{let a=b.changes??[],c=a[0]?.file.split("/").pop();return{label:"Patch",preview:a.length>1?`${a.length} files \xb7 ${c}, …`:c??(!1===b.success?"failed":"applied")}}case"web.search":return{label:"Web search",preview:aP(b.query,90)};case"session.turn_context":return{label:"Turn context",preview:[b.model,b.effort?`effort ${b.effort}`:""].filter(Boolean).join(" · ")};case"session.world_state":let d;return{label:"World state",preview:(d=(b.sections??[]).length,[!0===b.full?"full snapshot":"delta",`${d} section${1===d?"":"s"}`,`${(b.charLength??0).toLocaleString()} chars`].join(" · "))};case"session.mode_change":return{label:"Mode",preview:String(b.mode??"changed")};case"session.turn_aborted":return{label:"Turn aborted",preview:[b.reason,b.durationMs?`${Math.round(b.durationMs/1e3)}s`:""].filter(Boolean).join(" · ")};case"session.rollback":return{label:"Rollback",preview:`${b.turns??"?"} turn(s)`};default:return{label:c,preview:aP(JSON.stringify(b),90)}}}(a),G=(n=(m=a.data).tokenDetails,o=m.sessionTotals,q=m.usageSummary,r=("number"==typeof m.inputTokens?m.inputTokens:0)||(n?.input?.tokenCount??0)||(q?.inputTokens??0)||(o?.inputTokens??0),t=("number"==typeof m.outputTokens?m.outputTokens:0)||(n?.output?.tokenCount??0)||(q?.outputTokens??0)||(o?.outputTokens??0),0===r&&0===t?null:{input:r,output:t}),H="number"==typeof a.data.costUSD?a.data.costUSD:null,I=ag(a.type),L=ab[I.category]??u,M=ac[a.type]??`Event in "${I.category}" category with "${I.subCategory}" sub-category.`,N=function(){if(h)return(0,b.jsx)(al,{data:i?{...a.data,result:i.data.result,success:i.data.success}:a.data,type:i?"tool.execution_complete":"tool.execution_start"});switch(a.type){case"user.message":return(0,b.jsx)(aj,{data:a.data});case"assistant.message":return(0,b.jsx)(ak,{data:a.data});case"assistant.turn_start":return(0,b.jsx)(ax,{data:a.data,type:"assistant.turn_start"});case"assistant.turn_end":return(0,b.jsx)(ax,{data:a.data,type:"assistant.turn_end"});case"tool.execution_start":case"tool.execution_complete":return(0,b.jsx)(al,{data:a.data,type:a.type});case"external_tool.requested":return(0,b.jsx)(aq,{data:a.data,type:"external_tool.requested"});case"external_tool.completed":return(0,b.jsx)(aq,{data:a.data,type:"external_tool.completed"});case"session.shutdown":return(0,b.jsx)(am,{data:a.data});case"session.start":case"session.resume":{let c=a.data.context;return(0,b.jsx)("div",{className:"text-xs text-muted-foreground space-y-1",children:c&&(0,b.jsxs)("div",{children:["Branch: ",(0,b.jsx)("span",{className:"text-foreground",children:c.branch})," · ","Model: ",(0,b.jsx)("span",{className:"text-foreground",children:a.data.selectedModel})]})})}case"hook.start":return(0,b.jsx)(ao,{data:a.data,type:"hook.start"});case"hook.end":return(0,b.jsx)(ao,{data:a.data,type:"hook.end"});case"session.auto_mode_resolved":return(0,b.jsx)(ap,{data:a.data});case"session.binary_asset":return(0,b.jsx)(ar,{data:a.data});case"session.usage_checkpoint":return(0,b.jsx)(as,{data:a.data});case"subagent.deselected":return(0,b.jsx)(aw,{});case"session.model_change":return(0,b.jsx)(at,{data:a.data});case"session.compaction_start":return(0,b.jsx)(au,{data:a.data});case"session.compaction_complete":return(0,b.jsx)(av,{data:a.data});case"system.message":return(0,b.jsx)(an,{data:a.data});case"assistant.thinking":return(0,b.jsx)(ay,{data:a.data});case"session.error":return(0,b.jsx)(az,{data:a.data});case"context.attachment":return(0,b.jsx)(aC,{data:a.data});case"file.patch_applied":return(0,b.jsx)(aD,{data:a.data});case"web.search":return(0,b.jsx)(aE,{data:a.data});case"session.mode_change":return(0,b.jsx)(aG,{data:a.data});case"session.turn_context":return(0,b.jsx)(aH,{data:a.data});case"session.world_state":return(0,b.jsx)(aI,{data:a.data});case"subagent.session_start":case"subagent.activity":case"subagent.message":return(0,b.jsx)(aJ,{data:a.data,type:a.type});case"session.turn_aborted":return(0,b.jsx)(aK,{data:a.data});case"session.rollback":return(0,b.jsx)(aL,{data:a.data});case"session.plan_changed":return(0,b.jsx)(aM,{data:a.data});case"system.notification":return(0,b.jsx)(aN,{data:a.data});case"permission.requested":{let c=a.data.permissionRequest;return c?(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-orange-600 dark:text-orange-400 font-medium",children:c.kind})," ",c.intention]}):null}case"permission.completed":{let c=a.data.result;return c?(0,b.jsx)("div",{className:"text-xs",children:(0,b.jsx)("span",{className:"approved"===c.kind?"text-emerald-600 dark:text-emerald-400":"text-destructive",children:c.kind})}):null}default:return(0,b.jsx)(aO,{data:a.data})}}(),O=JSON.stringify(h&&i?[a,i]:a,null,2),P=i?.data.success===!1,Q=i?af(a.timestamp,i.timestamp):null,R=!!N;return(0,b.jsxs)("div",{"data-event-id":a.id,className:"relative scroll-mt-40 border-l-2 border-border pb-1.5 pl-6 last:border-l-transparent",children:[(0,b.jsx)("span",{className:`absolute -left-[5px] top-3 size-2 rounded-full border border-background ${L.dotCls}`,"aria-hidden":!0}),(0,b.jsxs)("div",{className:(0,$.cn)("relative overflow-hidden rounded-lg border border-border bg-card",f&&"border-l-2 border-l-amber-400 dark:border-l-amber-600",g&&"ring-2 ring-brand/60"),children:[k>0&&(0,b.jsx)("span",{className:"pointer-events-none absolute inset-y-0 left-0 w-[3px] bg-emerald-500",style:{opacity:Math.max(.12,k)},"aria-hidden":!0}),(0,b.jsxs)("button",{type:"button","data-event-row":!0,onClick:()=>{let a;return a=!D,B({nonce:e?.nonce??0,open:a})},"aria-expanded":D,className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",D&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:`max-w-[9rem] shrink-0 truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] font-semibold ${L.chipCls??u.typeCls}`,title:F.label,children:F.label}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground/90",children:F.preview}),F.delta&&(0,b.jsxs)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums",title:"Lines written and replaced by this call",children:[(0,b.jsxs)("span",{className:"text-emerald-700 dark:text-emerald-400",children:["+",F.delta.added]}),F.delta.removed>0&&(0,b.jsxs)("span",{className:"ml-1 text-red-700 dark:text-red-400",children:["−",F.delta.removed]})]}),h&&(0,b.jsx)("span",{className:(0,$.cn)("shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[11px] tabular-nums",P?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-muted text-muted-foreground"),title:i?P?"The call failed":"Time from the call to its result":"No result was recorded for this call",children:i?P?"failed":null!==Q&&Q>=1e3?`${(Q/1e3).toFixed(1)}s`:"done":"no result"}),G&&(0,b.jsxs)("span",{className:"hidden shrink-0 items-center gap-1.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline-flex",title:`${G.input.toLocaleString()} input tokens \xb7 ${G.output.toLocaleString()} output tokens`,children:[G.input>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(T.InputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"in"})," ",ai(G.input)]}),G.output>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(T.OutputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"out"})," ",ai(G.output)]})]}),null!==H&&H>0&&(0,b.jsx)("span",{className:(0,$.cn)("hidden shrink-0 font-mono text-[11px] tabular-nums sm:inline",!0===a.data.inherited?"text-muted-foreground line-through decoration-muted-foreground/50":"text-emerald-700 dark:text-emerald-400"),title:!0===a.data.inherited?"Estimated cost of this request in the forked session it was copied from; not part of this session's cost":"Estimated cost of this request at API list prices",children:(0,X.formatCost)(H)}),void 0!==j&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground md:inline",title:"Estimated cost of the session up to and including this request",children:["Σ ",(0,X.formatCost)(j)]}),l&&l.costUSD>0&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-emerald-700 dark:text-emerald-400 sm:inline",title:`Estimated cost of the ${l.requests} ${1===l.requests?"request":"requests"} made to answer this prompt; ${(0,X.formatCost)(l.totalUSD)} for the session by the end of the turn`,children:["turn ",(0,X.formatCost)(l.costUSD)]}),null!==v&&v>5e3&&(0,b.jsxs)("span",{className:"hidden shrink-0 rounded-sm bg-muted px-1.5 py-0.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline",title:"Gap since the previous event",children:["+",v>6e4?`${(v/6e4).toFixed(1)}m`:`${(v/1e3).toFixed(1)}s`]}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground",title:`${ae(a.timestamp)}, ${ad(a.timestamp)}`,children:ad(a.timestamp)})]}),D&&(0,b.jsxs)("div",{className:"border-t border-border",children:[R?(0,b.jsx)("div",{className:"px-3 py-2.5",children:N}):(0,b.jsx)("p",{className:"px-3 py-2.5 text-xs text-muted-foreground",children:"No structured detail for this event — see the raw event below."}),(0,b.jsxs)("div",{className:"flex items-center gap-1 border-t border-border bg-muted/30 px-2 py-1.5",children:[(0,b.jsx)("span",{className:"mr-auto truncate pl-1 font-mono text-[11px] text-muted-foreground",children:h&&i?`${a.type} + ${i.type}`:a.type}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>z(!y),"aria-expanded":y,className:"text-muted-foreground",children:[(0,b.jsx)(J.Info,{className:"size-3.5","aria-hidden":!0}),"About"]}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>x(!w),"aria-expanded":w,className:"text-muted-foreground",children:[(0,b.jsx)(C,{className:"size-3.5","aria-hidden":!0}),w?"Hide raw":"Raw"]}),(0,b.jsx)(s.CopyButton,{value:()=>{let b=new URL(window.location.href);return b.search="",b.searchParams.set("event",a.id),b.toString()},label:"Copy a link to this event",icon:K,children:"Link"}),(0,b.jsx)(s.CopyButton,{value:O,label:"Copy raw JSON",children:"Copy"})]}),y&&(0,b.jsx)("div",{className:"border-t border-border bg-muted/40 px-3 py-2 text-xs leading-relaxed text-muted-foreground",children:M}),w&&(0,b.jsxs)("div",{className:"border-t border-border px-3 py-2.5",children:[(0,b.jsx)("p",{className:"mb-1.5 text-[11px] uppercase tracking-wide text-muted-foreground",children:"Raw event"}),(0,b.jsx)("pre",{className:"max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:O})]})]})]})]})}function aU(a){return ab[a]?.chipCls||"border-border bg-muted text-muted-foreground"}let aV=new Set(["system.message","context.attachment","session.world_state"]),aW=new Set(["tool.execution_start","external_tool.requested"]),aX=new Set(["tool.execution_complete","external_tool.completed"]),aY=new Set(["user.message","assistant.thinking","assistant.message"]),aZ=["normal","compact","focused"];function a$(a){let b=Array.from(document.querySelectorAll("[data-event-row]")),c=b.indexOf(document.activeElement),d=-1===c?Math.max(0,b.findIndex(a=>a.getBoundingClientRect().top>160)):Math.min(b.length-1,Math.max(0,c+a));b[d]?.focus({preventScroll:!0}),b[d]?.scrollIntoView({block:"center"})}function a_(a){let{category:b}=ag(a);return aU(b)}function a0({events:a,focusRequest:e,targetEventId:f,forkParentHref:g,live:h=!1,onLiveChange:i,running:j=!1}){let k=(0,c.useMemo)(()=>{if(!f||a.some(a=>a.id===f))return f;let b=f.lastIndexOf(":");if(-1===b)return f;let c=f.slice(0,b+1);return a.findLast(a=>a.id.startsWith(c))?.id??f},[a,f]),l=(0,c.useMemo)(()=>{let b=a.findLast(a=>!0===a.data.inherited);return g&&b?`${g}?event=${encodeURIComponent(b.id)}`:void 0},[a,g]),[m,n]=(0,Z.useQueryParam)("mode","normal"),[o,q]=(0,c.useState)(aZ.includes(m)?m:"normal");(0,c.useEffect)(()=>n(o),[o,n]);let[r,s]=(0,c.useState)("asc"),[t,u]=(0,c.useState)([]),[v,w]=(0,c.useState)([]),[x,y]=(0,c.useState)(""),[C,E]=(0,c.useState)(!0),[J,K]=(0,c.useState)(!1),[Q,R]=(0,c.useState)(!1),[T,X]=(0,c.useState)(!1),_=(0,c.useRef)(null),[aa,ab]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=_.current;if(!a)return;let b=getComputedStyle(document.documentElement),c=parseFloat(b.getPropertyValue("--cv-topbar-h"))+parseFloat(b.getPropertyValue("--cv-tabbar-h")),d=new IntersectionObserver(([a])=>ab(!a.isIntersecting&&a.boundingClientRect.top<c),{rootMargin:`-${c}px 0px 0px 0px`});return d.observe(a),()=>d.disconnect()},[]);let ac=(0,c.useRef)(null),[ad,af]=(0,c.useState)(0);(0,c.useEffect)(()=>{let a=ac.current;if(!a)return;let b=new ResizeObserver(()=>af(a.offsetHeight));return b.observe(a),()=>b.disconnect()},[]);let[ai,aj]=(0,c.useState)(null),ak=(0,c.useMemo)(()=>a.map(a=>{let b=ag(a.type);return{...a,category:b.category,subCategory:b.subCategory,subKey:`${b.category}.${b.subCategory}`}}),[a]),al=(0,c.useMemo)(()=>W(a),[a]),am=(0,c.useMemo)(()=>{let b=new Set,c=null,d=()=>{c&&b.add(c),c=null};for(let e of a)"user.message"===e.type?(d(),b.add(e.id)):"assistant.message"===e.type&&String(e.data.content??"").trim()&&(c=e.id);return d(),b},[a]),an=(0,c.useMemo)(()=>{let b=new Map,c=new Set,d=[];for(let e of a)if(aW.has(e.type))d.push(e);else if(aX.has(e.type)){let a=e.data.toolCallId,f=d.findIndex(b=>a?b.data.toolCallId===a:!b.data.toolCallId&&b.data.toolName===e.data.toolName);if(-1===f)continue;b.set(d[f].id,e),c.add(e.id),d.splice(f,1)}return{results:b,consumed:c}},[a]),ao=(0,c.useMemo)(()=>{let b=new Map,c=[],d=()=>{if(c.length>1){let a={key:c[0].id,size:c.length};for(let d of c)b.set(d.id,a)}c=[]};for(let b of a)aW.has(b.type)?c.push(b):d();return d(),b},[a]),ap=(0,c.useMemo)(()=>"normal"===o?ak:ak.filter(a=>"focused"===o?am.has(a.id):!an.consumed.has(a.id)&&(aW.has(a.type)||aX.has(a.type)||aY.has(a.type)&&("assistant.message"!==a.type||String(a.data.content??"").trim()))),[ak,o,am,an]),aq=(0,c.useMemo)(()=>ap.some(a=>aV.has(a.type)),[ap]),ar=(0,c.useMemo)(()=>ap.filter(a=>C||!aV.has(a.type)),[ap,C]),as=(0,c.useMemo)(()=>{let a=new Map;for(let b of ar){let c=a.get(b.category)??{count:0,typeCounts:new Map};c.count+=1,c.typeCounts.set(b.type,(c.typeCounts.get(b.type)||0)+1),a.set(b.category,c)}return Array.from(a.entries()).map(([a,b])=>{let c=Array.from(b.typeCounts.entries()).sort((a,b)=>b[1]-a[1]||a[0].localeCompare(b[0]))[0]?.[0];return{category:a,count:b.count,representativeType:c}}).sort((a,b)=>b.count-a.count||a.category.localeCompare(b.category))},[ar]),at=(0,c.useMemo)(()=>t.filter(a=>as.some(b=>b.category===a)),[t,as]),au=(0,c.useMemo)(()=>{if(0===at.length)return[];let a=new Set(at),b=new Map;for(let c of ar){if(!a.has(c.category))continue;let d=b.get(c.subKey);d?d.count+=1:b.set(c.subKey,{category:c.category,subCategory:c.subCategory,count:1})}return Array.from(b.values()).sort((a,b)=>b.count-a.count||a.subCategory.localeCompare(b.subCategory))},[ar,at]),av=(0,c.useMemo)(()=>{let a=new Set(au.map(a=>`${a.category}.${a.subCategory}`));return v.filter(b=>a.has(b))},[v,au]),[aw,ax]=(0,c.useState)(null);e&&e!==aw&&(ax(e),u(e.categories??[]),w(e.subKeys??[]),y(e.search??""),R(e.failures??!1),((e.categories??[]).includes("system")||(e.subKeys??[]).includes("system.message"))&&E(!0),q("normal"),X(!0));let ay=(0,c.useMemo)(()=>{let a=new Set(at),b=new Set(av),c=x.toLowerCase().split(/\s+/).filter(Boolean),d=ar.filter(d=>{if(a.size>0&&!a.has(d.category)||b.size>0&&!b.has(d.subKey)||J&&!function(a){let b=a.data,c=b.outputTokens;if("number"==typeof c&&c>0)return!0;let d=b.inputTokens;if("number"==typeof d&&d>0)return!0;let e=b.cacheReadTokens;if("number"==typeof e&&e>0)return!0;let f=b.tokenDetails;if(f){let a=f.input?.tokenCount??0,b=f.output?.tokenCount??0,c=f.cache_read?.tokenCount??0;if(a>0||b>0||c>0)return!0}return!1}(d)||Q&&!ah(d)&&!ah(an.results.get(d.id)))return!1;if(c.length>0){let a="compact"===o?an.results.get(d.id):void 0,b=(JSON.stringify(d)+(a?JSON.stringify(a):"")).toLowerCase();return c.every(a=>b.includes(a))}return!0});return"desc"===r?d.reverse():d},[ar,at,av,J,Q,x,o,an,r]),az=`${at.join()}|${av.join()}|${x}|${C}|${J}|${Q}|${o}|${r}`,[aA,aB]=(0,c.useState)({key:az,count:150}),aC=k?ay.findIndex(a=>a.id===k):-1,aD=Math.max(aA.key===az?aA.count:150,aC+1),aE=a=>aB({key:az,count:a}),aF=h&&"asc"===r,aG=(0,c.useMemo)(()=>aF?ay.slice(-aD):ay.slice(0,aD),[ay,aD,aF]);(0,c.useEffect)(()=>{if(!aF)return;let a=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight}));return()=>cancelAnimationFrame(a)},[aF,a.length]),(0,c.useEffect)(()=>{k&&document.querySelector(`[data-event-id="${CSS.escape(k)}"]`)?.scrollIntoView({block:"center"})},[k,-1!==aC]),(0,Y.useHotkeys)({f:()=>q(a=>aZ[(aZ.indexOf(a)+1)%aZ.length]),o:()=>s(a=>"asc"===a?"desc":"asc"),l:i&&(()=>i(!h)),e:()=>aj({nonce:Date.now(),mode:"open"}),E:()=>aj({nonce:Date.now(),mode:"closed"}),j:()=>a$(1),k:()=>a$(-1)});let aH=(0,c.useMemo)(()=>{let a=[];return aG.forEach((b,c)=>{let d=new Date(b.timestamp).toLocaleDateString([],{month:"short",day:"numeric"}),e=al.turnOf.get(b.id),f=!0===b.data.inherited,g=a[a.length-1];g&&g.date===d&&g.turn===e&&g.inherited===f?g.events.push(b):a.push({date:d,fullDate:ae(b.timestamp),turn:e,inherited:f,start:c,events:[b]})}),a},[aG,al]),aI=at.length+av.length+ +!!J+ +!!Q+(aq&&!C?1:0),aJ=aI+ +!!x;function aK(){u([]),w([]),y(""),K(!1),R(!1),E(!0),q("normal")}let aL=ay.length-aG.length,aM=aL>0&&(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6",children:[(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",aF?"the last ":"",aG.length.toLocaleString()," of ",ay.length.toLocaleString()," matching events"]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>aE(aD+150),children:["Load ",Math.min(150,aL)," ",aF?"earlier":"more"]}),(0,b.jsx)(p.Button,{variant:"ghost",size:"sm",onClick:()=>aE(ay.length),className:"text-muted-foreground",children:"Show all"})]})]});return(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("div",{ref:_,"aria-hidden":!0}),(0,b.jsxs)("div",{ref:ac,className:(0,$.cn)("sticky top-[calc(var(--cv-topbar-h)+var(--cv-tabbar-h))] z-10 -mx-4 border-b bg-background/90 px-4 pt-1 pb-2.5 backdrop-blur transition-colors supports-[backdrop-filter]:bg-background/75 sm:-mx-6 sm:px-6",aa?"border-border":"border-transparent"),children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(U.SearchInput,{value:x,onChange:y,shortcut:!0,placeholder:"Search events…","aria-label":"Search events",className:"w-full sm:w-56"}),(0,b.jsx)(V.Segmented,{label:"Transcript view",size:"default",value:o,onChange:q,options:[{value:"normal",label:"Normal"},{value:"compact",label:"Compact"},{value:"focused",label:"Focused"}]}),(0,b.jsxs)(p.Button,{variant:"outline",onClick:()=>X(a=>!a),"aria-expanded":T,className:(0,$.cn)(aI>0?"border-foreground/25 bg-muted":"text-muted-foreground"),children:[(0,b.jsx)(O,{className:"size-3.5","aria-hidden":!0}),"Filters",aI>0&&(0,b.jsx)("span",{className:"rounded-sm bg-foreground/10 px-1 tabular-nums",children:aI}),(0,b.jsx)(D.default,{className:(0,$.cn)("size-3.5 transition-transform",T&&"rotate-180"),"aria-hidden":!0})]}),aJ>0&&(0,b.jsxs)(p.Button,{variant:"ghost",onClick:aK,className:"text-muted-foreground",children:[(0,b.jsx)(P.X,{className:"size-3.5","aria-hidden":!0}),"Clear"]}),(0,b.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[i&&(0,b.jsx)(a1,{active:h,onClick:()=>i(!h),icon:M,label:"Follow live",title:j?"Follow the session: keep the newest events in view (l)":"Watch for new events and keep the newest in view (l)",pulse:j,iconOnly:!0}),(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>s("asc"===r?"desc":"asc"),"aria-label":"asc"===r?"Show newest first":"Show oldest first",className:"text-muted-foreground",children:"asc"===r?(0,b.jsx)(A,{className:"size-3.5","aria-hidden":!0}):(0,b.jsx)(B,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsxs)(S.TooltipContent,{children:["asc"===r?"Oldest first":"Newest first"," (o)"]})]}),(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>aj({nonce:Date.now(),mode:"open"}),"aria-label":"Expand all events",className:"text-muted-foreground",children:(0,b.jsx)(G,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(S.TooltipContent,{children:"Expand all"})]}),(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>aj({nonce:Date.now(),mode:"closed"}),"aria-label":"Collapse all events",className:"text-muted-foreground",children:(0,b.jsx)(F,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(S.TooltipContent,{children:"Collapse all"})]}),(0,b.jsx)("span",{className:"ml-1 text-xs tabular-nums text-muted-foreground",children:ay.length===a.length?`${a.length} events`:`${ay.length} of ${a.length} events`})]})]}),T&&(0,b.jsxs)("div",{className:"mt-2.5 space-y-2 border-t border-border pt-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[aq&&(0,b.jsx)(a1,{active:!C,onClick:()=>E(!C),icon:I,label:"Hide context",title:"Hide system prompts, auto-attached context and world-state snapshots"}),(0,b.jsx)(a1,{active:J,onClick:()=>K(!J),icon:L,label:"Token events",title:"Show only events that report token usage"}),(0,b.jsx)(a1,{active:Q,onClick:()=>R(!Q),icon:H,label:"Failures",title:"Show only tool calls that failed"})]}),(0,b.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:as.map(({category:a,count:c,representativeType:d})=>{let e=at.includes(a);return(0,b.jsxs)("button",{type:"button","aria-pressed":e,onClick:()=>u(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a]),className:(0,$.cn)("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",d?a_(d):aU(a),e?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[(0,b.jsx)("span",{children:a}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:c})]},a)})}),at.length>0&&au.length>0&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,b.jsx)("span",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Sub-type"}),au.map(({category:a,subCategory:c,count:d})=>{let e=`${a}.${c}`,f=av.includes(e);return(0,b.jsxs)("button",{type:"button","aria-pressed":f,title:e,onClick:()=>w(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e]),className:(0,$.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",a_(e),f?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[at.length>1&&(0,b.jsxs)("span",{className:"opacity-70",children:[a,":"]}),(0,b.jsx)("span",{children:c}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:d})]},e)})]})]})]}),(0,b.jsxs)("div",{className:"pr-2",children:[aF&&aM,aH.map(a=>(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:"absolute inset-x-0 top-[27px] h-px bg-border","aria-hidden":!0}),(0,b.jsx)("div",{className:"pointer-events-none sticky z-[5] flex justify-center py-4",style:{top:`calc(var(--cv-topbar-h) + var(--cv-tabbar-h) + ${ad}px - 0.5rem)`},children:(0,b.jsxs)("span",{className:"pointer-events-auto rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground shadow-sm",title:a.inherited?`${a.fullDate} \xb7 history copied from the forked session; its cost was billed there and is not part of this session`:void 0===a.turn?a.fullDate:`${a.fullDate} \xb7 prompt ${a.turn} and everything the agent did to answer it`,children:[a.date,a.inherited&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),"Inherited",l&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)(d.default,{href:l,title:"Open the session this one was forked from, at the last event it copied",className:"inline-flex items-center gap-0.5 text-foreground underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["Open fork point",(0,b.jsx)(z,{className:"size-3","aria-hidden":!0})]})]})]}),void 0!==a.turn&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)("span",{className:"text-foreground",children:["Turn ",a.turn]})]})]})}),a.events.map((d,e)=>{let f=ao.get(d.id),g=a.start+e,h=aG["asc"===r?g-1:g+1],i=f&&ao.get(aG[g-1]?.id)!==f;return(0,b.jsxs)(c.Fragment,{children:[i&&(0,b.jsxs)("div",{className:"border-l-2 border-border pb-1 pl-6 font-mono text-[11px] text-amber-700 dark:text-amber-400",children:["parallel · ",f.size," calls"]}),(0,b.jsx)(aT,{event:d,prevTimestamp:h?.timestamp,expandAll:ai,parallel:!!f,target:d.id===k,merged:"compact"===o&&aW.has(d.type),result:"compact"===o?an.results.get(d.id):void 0,runningUSD:al.runningUSD.get(d.id),costShare:al.runningUSD.has(d.id)&&"number"==typeof d.data.costUSD?d.data.costUSD/al.maxEventUSD:0,turn:al.turnByPrompt.get(d.id)})]},d.id)})]},`${a.date}|${a.inherited?"inherited":a.turn}`)),!aF&&aM,0===ay.length&&(0,b.jsxs)("div",{className:"mt-4 flex flex-col items-center gap-2 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,b.jsx)(N,{className:"size-5","aria-hidden":!0})}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No events match your filters"}),(0,b.jsxs)("p",{className:"max-w-sm text-xs text-muted-foreground",children:[a.length.toLocaleString()," events are recorded in this session."]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:aK,className:"mt-2",children:"Clear filters"})]})]})]})}function a1({active:a,onClick:c,icon:d,label:e,title:f,pulse:g=!1,iconOnly:h=!1}){return(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsxs)(R.Toggle,{variant:"outline",pressed:a,onPressedChange:c,"aria-label":h?e:void 0,className:(0,$.cn)("relative gap-1.5 text-muted-foreground aria-pressed:border-foreground/25 aria-pressed:text-foreground",h&&"px-0 aria-pressed:border-emerald-500/60 aria-pressed:text-emerald-600 dark:aria-pressed:text-emerald-400"),children:[(0,b.jsx)(d,{className:"size-3.5","aria-hidden":!0}),!h&&e,g&&(0,b.jsx)("span",{className:(0,$.cn)("size-1.5 animate-pulse rounded-full bg-emerald-500",h&&"absolute top-1 right-1"),"aria-hidden":!0})]})}),(0,b.jsx)(S.TooltipContent,{children:f})]})}var a2=a.i(6015),a3=a.i(56979),a4=a.i(14574);let a5={input:"Uncached input",cacheWrite:"Cache write",cacheWrite1h:"Cache write (1h)",cacheRead:"Cache read",output:"Output"},a6=[["Uncached input","new prompt text the model had not seen before."],["Cache write","context stored so later requests can reuse it. A 1-hour cache costs more to write than the default."],["Cache read","stored context reused at a discount. The whole conversation is re-sent on every request, so this grows fastest in long sessions."],["Output","the model's replies, tool calls and reasoning."]];function a7(a){return`$${a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4})}`}function a8({cost:a,totalLabel:d}){let e=a.byModel.length>1,f=a.unpricedModels.length>0;return(0,b.jsx)("div",{className:"overflow-hidden rounded-lg border border-border",children:(0,b.jsxs)(a2.Table,{className:"text-xs",children:[(0,b.jsx)(a2.TableHeader,{children:(0,b.jsxs)(a2.TableRow,{className:"bg-muted/60 hover:bg-muted/60",children:[(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-muted-foreground",children:"Token type"}),(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Tokens"}),(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Rate / 1M"}),(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Cost"})]})}),(0,b.jsx)(a2.TableBody,{className:"tabular-nums",children:a.byModel.map(d=>(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(a2.TableRow,{className:"bg-muted/30 hover:bg-muted/30",children:[(0,b.jsx)(a2.TableHead,{colSpan:3,scope:"rowgroup",className:"h-auto px-3 py-1.5 font-mono font-semibold",children:d.model}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono font-semibold text-foreground",children:e&&null!==d.costUSD&&(0,X.formatCost)(d.costUSD)})]}),a.lines.filter(a=>a.model===d.model).map(a=>(0,b.jsxs)(a2.TableRow,{className:"border-border/60",children:[(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-foreground",children:a5[a.kind]}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:null===a.rate?"—":a7(a.rate)}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono text-foreground",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,X.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},d.model))}),(0,b.jsx)(a2.TableFooter,{className:"bg-muted/60",children:(0,b.jsxs)(a2.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(a2.TableHead,{colSpan:3,scope:"row",className:"h-auto px-3 py-2 font-semibold",children:d}),(0,b.jsxs)(a2.TableCell,{className:"px-3 py-2 text-right font-mono font-bold tabular-nums text-foreground",children:[(0,X.formatCost)(a.totalUSD),f&&"+"]})]})})]})})}function a9({cost:a,open:d,onOpenChange:e}){let f,g=a.unpricedModels.length>0,h=(f=Object.entries(a.prices).map(([a,b])=>{let c=(b??[{input:0,output:0}]).map(a=>` ${JSON.stringify(a).replace(/([{,:])/g,"$1 ").replace("}"," }")}`).join(",\n");return` ${JSON.stringify(a)}: [
1
+ module.exports=[75136,a=>{"use strict";var b=a.i(38742),c=a.i(73895),d=a.i(24687),e=a.i(37303),f=a.i(70627);let g=(0,f.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),h=(0,f.default)("bookmark",[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]]),i=(0,f.default)("circle-dollar-sign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]),j=(0,f.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),k=(0,f.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);var l=a.i(35789);let m=(0,f.default)("flask-conical",[["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"}]]),n=(0,f.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);var o=a.i(22598),p=a.i(99570),q=a.i(75083),r=a.i(69876),s=a.i(64151),t=a.i(19608),u=a.i(59561),v=a.i(27936),w=a.i(31049),x=a.i(35540),y=a.i(34597),z=a.i(1442);let A=(0,f.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),B=(0,f.default)("arrow-down-narrow-wide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]),C=(0,f.default)("arrow-up-narrow-wide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]),D=(0,f.default)("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);var E=a.i(12650),E=E,F=a.i(80995);let G=(0,f.default)("chevrons-down-up",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]),H=(0,f.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),I=(0,f.default)("circle-x",[["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"}]]),J=(0,f.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);var K=a.i(89560);let L=(0,f.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),M=(0,f.default)("list-filter",[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]),N=(0,f.default)("radio",[["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"}]]),O=(0,f.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),P=(0,f.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var Q=a.i(61055),R=a.i(86304),S=a.i(73221),T=a.i(85259),U=a.i(96538),V=a.i(16543),W=a.i(45646);function X(a){let b=[],c=[],d=new Map,e=new Map,f=new Map,g=0,h=0,i=0,j=0,k=null;for(let l of a){if(!0===l.data.inherited){"number"==typeof l.data.costUSD&&(i+=l.data.costUSD);continue}if("user.message"===l.type){j+=1,k={turn:j,prompt:"string"==typeof l.data.content?l.data.content:void 0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k),d.set(l.id,k),e.set(l.id,j);continue}k&&e.set(l.id,k.turn),k&&l.type.startsWith("session.compaction")&&(k.compacted=!0);let a=l.data.costUSD,m="number"==typeof a&&a>0,n=Array.isArray(l.data.costLines)?l.data.costLines:[];if(m||k){for(let a of(k||(k={turn:0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k)),n))!function(a,b){let c=a.find(a=>a.model===b.model&&a.kind===b.kind&&a.rate===b.rate);c?(c.tokens+=b.tokens,null!==c.usd&&null!==b.usd&&(c.usd+=b.usd)):a.push({...b})}(k.lines,a);n.length>0&&c.push(function(a,b,c,d,e){let f=(...a)=>b.reduce((b,c)=>a.includes(c.kind)?b+c.tokens:b,0),g=(...a)=>b.reduce((b,c)=>a.includes(c.kind)&&null!==c.usd?(b??0)+c.usd:b,null),h=f("input"),i=f("cacheWrite","cacheWrite1h"),j=f("cacheRead");return{n:c,turn:d,eventId:a.id,timestamp:a.timestamp,models:[...new Set(b.map(a=>a.model))],inputTokens:h,cacheWriteTokens:i,cacheReadTokens:j,outputTokens:f("output"),contextTokens:h+i+j,usd:{input:g("input"),cacheWrite:g("cacheWrite","cacheWrite1h"),cacheRead:g("cacheRead"),output:g("output")},costUSD:e}}(l,n,c.length+1,k.turn,m?a:null)),m&&(h+=a,k.costUSD+=a,k.requests+=1,k.totalUSD=h,f.set(l.id,h),g=Math.max(g,a))}}let l=b.findIndex(a=>a.costUSD>0);return{turns:-1===l?[]:b.slice(l),requests:c,turnByPrompt:d,turnOf:e,runningUSD:f,maxEventUSD:g,totalUSD:h,inheritedUSD:i}}var Y=a.i(90075),Z=a.i(3541),$=a.i(87105),_=a.i(68114);let aa={"session.start":{label:"Session Start",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"session.shutdown":{label:"Session Shutdown",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"session.resume":{label:"Session Resume",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"user.message":{label:"User Message",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"assistant.message":{label:"Assistant",dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400"},"assistant.turn_start":{label:"Turn Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"assistant.turn_end":{label:"Turn End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"tool.execution_start":{label:"Tool Start",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"tool.execution_complete":{label:"Tool Done",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"external_tool.requested":{label:"External Tool Request",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"external_tool.completed":{label:"External Tool Done",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"permission.requested":{label:"Permission",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"permission.completed":{label:"Permission Done",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"hook.start":{label:"Hook Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"hook.end":{label:"Hook End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"session.auto_mode_resolved":{label:"Auto Mode",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.binary_asset":{label:"Binary Asset",dotCls:"bg-rose-100 border-rose-400 dark:bg-rose-900/60 dark:border-rose-700",typeCls:"text-rose-700 dark:text-rose-400"},"session.usage_checkpoint":{label:"Usage Checkpoint",dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400"},"subagent.deselected":{label:"Subagent Deselected",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"session.model_change":{label:"Model Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_start":{label:"Compaction Start",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_complete":{label:"Compaction Complete",dotCls:"bg-purple-100 border-purple-400 dark:bg-purple-900/60 dark:border-purple-700",typeCls:"text-purple-700 dark:text-purple-400"},"system.message":{label:"System",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"assistant.thinking":{label:"Thinking",dotCls:"bg-indigo-100 border-indigo-400 dark:bg-indigo-900/60 dark:border-indigo-700",typeCls:"text-indigo-700 dark:text-indigo-400"},"session.error":{label:"Error",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"context.attachment":{label:"Attachment",dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400"},"file.patch_applied":{label:"Patch Applied",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"web.search":{label:"Web Search",dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400"},"session.turn_context":{label:"Turn Context",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.world_state":{label:"World State",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.mode_change":{label:"Mode Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.turn_aborted":{label:"Turn Aborted",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"session.rollback":{label:"Rollback",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"subagent.activity":{label:"Subagent",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"session.plan_changed":{label:"Plan Changed",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"system.notification":{label:"Notification",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"subagent.session_start":{label:"Subagent Start",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"subagent.message":{label:"Subagent Message",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"}},ab={label:"Event",dotCls:"bg-muted border-border",typeCls:"text-muted-foreground",chipCls:"border-border bg-muted text-muted-foreground"},ac={session:{dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400",chipCls:"border-fuchsia-300 bg-fuchsia-100 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/50 dark:text-fuchsia-300"},user:{dotCls:"bg-pink-100 border-pink-400 dark:bg-pink-900/60 dark:border-pink-700",typeCls:"text-pink-700 dark:text-pink-400",chipCls:"border-pink-300 bg-pink-100 text-pink-800 dark:border-pink-800 dark:bg-pink-900/50 dark:text-pink-300"},assistant:{dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400",chipCls:"border-sky-300 bg-sky-100 text-sky-800 dark:border-sky-800 dark:bg-sky-900/50 dark:text-sky-300"},tool:{dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400",chipCls:"border-amber-300 bg-amber-100 text-amber-800 dark:border-amber-800 dark:bg-amber-900/50 dark:text-amber-300"},external_tool:{dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400",chipCls:"border-lime-300 bg-lime-100 text-lime-800 dark:border-lime-800 dark:bg-lime-900/50 dark:text-lime-300"},permission:{dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400",chipCls:"border-red-300 bg-red-100 text-red-800 dark:border-red-800 dark:bg-red-900/50 dark:text-red-300"},hook:{dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400",chipCls:"border-teal-300 bg-teal-100 text-teal-800 dark:border-teal-800 dark:bg-teal-900/50 dark:text-teal-300"},system:{dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400",chipCls:"border-slate-300 bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300"},subagent:{dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400",chipCls:"border-zinc-300 bg-zinc-100 text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/60 dark:text-zinc-300"},context:{dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400",chipCls:"border-stone-300 bg-stone-100 text-stone-800 dark:border-stone-700 dark:bg-stone-900/60 dark:text-stone-300"},file:{dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400",chipCls:"border-emerald-300 bg-emerald-100 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-300"},web:{dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400",chipCls:"border-blue-300 bg-blue-100 text-blue-800 dark:border-blue-800 dark:bg-blue-900/50 dark:text-blue-300"}},ad={"session.start":"Session initialization event. Captures the runtime context and selected model when a session begins.","session.resume":"Session resumed from previous state. Indicates context reload and continuation.","session.shutdown":"Session end summary. Usually includes usage, token totals, premium requests, and API timing.","session.auto_mode_resolved":"Auto-mode model selection result. Shows predicted task profile and chosen model settings.","session.binary_asset":"Binary payload captured in the session (typically screenshots/images). Can consume significant context/storage.","session.usage_checkpoint":"Interim usage accounting snapshot (AIU/premium usage/cache state) while session is active.","session.model_change":"Model configuration switched during the session (model/effort/context tier).","session.compaction_start":"Context compaction started. Conversation is being summarized/compressed to reduce token load.","session.compaction_complete":"Compaction finished, with success/failure metadata and request identifiers.","user.message":"User input message that drives the next assistant turn.","assistant.message":"Assistant output message, optionally with model/tool-request and token metadata.","assistant.turn_start":"Start of a single assistant reasoning/execution turn.","assistant.turn_end":"End of the assistant turn after reasoning/tools/output.","tool.execution_start":"A local tool invocation started with tool name and arguments.","tool.execution_complete":"A local tool invocation completed with status and result payload.","external_tool.requested":"Request sent to an external tool bridge/service.","external_tool.completed":"External tool request lifecycle completed.","permission.requested":"Runtime requested user permission for an action (e.g., file/system/network).","permission.completed":"Permission flow resolved (approved/denied).","hook.start":"Lifecycle hook execution started (for example, prompt submission hooks).","hook.end":"Lifecycle hook execution completed with success/failure state.","subagent.deselected":"Subagent focus was cleared and control returned to the main agent context.","system.message":"System-level instruction/context block injected into the conversation runtime.","assistant.thinking":"Extended reasoning the model produced before answering. Billed as output tokens.","session.error":"API or transport error. Each retry re-sends the full request context.","context.attachment":"Context the runtime injected automatically: file snapshots, reminders, tool or skill listings.","file.patch_applied":"A patch the agent applied to the workspace, with the files it touched.","web.search":"Web search issued by the model; results are added to the conversation context.","session.turn_context":"Per-turn runtime configuration: model, effort, sandbox and approval policy.","session.world_state":"Snapshot of the workspace the runtime handed to the model.","session.mode_change":"Interaction or permission mode switched during the session.","session.turn_aborted":"The turn was interrupted before it completed.","session.rollback":"Conversation was rolled back by a number of turns.","subagent.activity":"Activity reported by a subagent working under the main agent.","subagent.message":"Message passed between agents.","subagent.session_start":"A subagent thread started inside this session.","session.plan_changed":"The agent created or updated its working plan.","system.notification":"Runtime notification injected into the conversation, such as a background shell finishing."};function ae(a){return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function af(a){return new Date(a).toLocaleDateString([],{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function ag(a,b){return new Date(b).getTime()-new Date(a).getTime()}function ah(a){let[b,...c]=a.split(".");return{category:b||"unknown",subCategory:c.join(".")||"general"}}function ai(a){return!!a&&!1===a.data.success&&(a3.has(a.type)||"file.patch_applied"===a.type)}function aj(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function ak({data:a}){let d=a.content||"",[e,f]=(0,c.useState)(!1),g=d.slice(0,300),h=d.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[e?d:g,h&&!e&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>f(!e),className:"h-auto px-0 font-normal text-violet-600 dark:text-violet-400 mt-1",children:e?"Show less":`Show more (${d.length} chars)`})]})}function al({data:a}){let d=a.content||"",e=a.toolRequests||[],f=a.model,g=a.outputTokens,[h,i]=(0,c.useState)(!1),j=d.slice(0,400),k=d.length>400;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:f}),void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()}),(0,b.jsx)("span",{className:"opacity-60",children:"tokens"})]})]}),d&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[h?d:j,k&&!h&&"..."]}),k&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:"h-auto px-0 font-normal text-sky-600 dark:text-sky-400 mt-1",children:h?"Show less":`Show more (${d.length} chars)`})]}),e.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-amber-100 border border-amber-300 dark:bg-amber-900/50 dark:border-amber-800 rounded-sm text-xs text-amber-800 dark:text-amber-300 font-mono",children:["🔧 ",a.name]},c))})]})}function am(a){return`${a.toLocaleString()} chars \xb7 ~${aj(Math.round(a/4))} tokens`}let an="max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-sm border border-border bg-muted p-2 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]";function ao({label:a,note:c,copyValue:d}){return(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs text-amber-600 dark:text-amber-500",children:a}),c&&(0,b.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:c}),(0,b.jsx)(s.CopyButton,{value:d,label:`Copy ${a.toLowerCase()}`,className:"-my-1"})]})}function ap({args:a,chars:c}){let d=Object.entries(a);if(0===d.length)return null;let e=c??JSON.stringify(a).length;return(0,b.jsxs)("div",{children:[(0,b.jsx)(ao,{label:"Arguments",note:am(e),copyValue:JSON.stringify(a,null,2)}),(0,b.jsx)("dl",{className:"mt-1 space-y-1.5",children:d.map(([a,c])=>{let d="string"==typeof c?c:JSON.stringify(c,null,2)??"",e=d.includes("\n")||d.length>100;return(0,b.jsxs)("div",{className:e?"space-y-0.5":"flex items-baseline gap-2",children:[(0,b.jsx)("dt",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"min-w-0",children:e?(0,b.jsx)("pre",{className:an,children:d}):(0,b.jsx)("span",{className:"break-words font-mono text-xs text-foreground [overflow-wrap:anywhere]",children:d})})]},a)})})]})}function aq({result:a,chars:d,truncated:e}){let[f,g]=(0,c.useState)(!1),h="string"==typeof a.content?a.content:"",i=a.images??[],j=i.reduce((a,b)=>a+(b.bytes??0),0),k=d??h.length,l=[k>0?am(k):0===i.length?"empty":null,"json"===a.format?"JSON":null,i.length>0?`${i.length} image${1===i.length?"":"s"}${j>0?` (${(0,Y.formatBytes)(j)})`:""}`:null].filter(Boolean).join(" · ");return(0,b.jsxs)("div",{children:[(0,b.jsx)(ao,{label:"Result",note:l,copyValue:h}),(0,b.jsxs)("div",{className:"mt-1 space-y-1.5",children:[h&&(0,b.jsx)("pre",{className:an,children:h}),e&&(0,b.jsxs)("p",{className:"text-[11px] text-amber-700 dark:text-amber-400",children:["Showing the first ",h.length.toLocaleString()," of ",k.toLocaleString()," chars. The whole result is in the original record, under Raw."]}),i.map((a,c)=>(0,b.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Image ",c+1,": ",a.mediaType??"unknown type",a.bytes?`, ${(0,Y.formatBytes)(a.bytes)}`:""," (not loaded)"]},c)),a.detail&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>g(!f),"aria-expanded":f,className:"h-auto px-0 font-normal text-muted-foreground",children:[f?"▼":"▶"," Detail"]}),f&&(0,b.jsx)("pre",{className:(0,_.cn)(an,"mt-1"),children:a.detail})]})]})]})}function ar({data:a,type:c}){let d=a.toolName,e=a.arguments,f=a.result,g=a.success;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"font-mono text-amber-700 dark:text-amber-300 font-semibold",children:d}),"tool.execution_complete"===c&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium ${g?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400":"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400"}`,children:g?"success":"failed"})]}),e&&"object"==typeof e&&(0,b.jsx)(ap,{args:e,chars:a.argumentChars}),f&&(0,b.jsx)(aq,{result:f,chars:a.resultChars,truncated:!0===a.truncated})]})}function as({data:a}){let c=a.tokenDetails,d=a.totalApiDurationMs,e=a.totalPremiumRequests,f=a.shutdownType,g=c?.input?.tokenCount,h=c?.output?.tokenCount,i=c?.cache_read?.tokenCount;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(R.Badge,{variant:"outline",className:"text-xs",children:f}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:e})," premium req"]}),void 0!==d&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsxs)("span",{className:"font-semibold text-foreground",children:[(d/1e3).toFixed(1),"s"]})," API"]})]}),(void 0!==g||void 0!==h)&&(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-cyan-100 border border-cyan-300 dark:bg-cyan-950 dark:border-cyan-800 rounded-full text-xs text-cyan-700 dark:text-cyan-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"in"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()})]}),void 0!==h&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:h.toLocaleString()})]}),void 0!==i&&i>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-teal-100 border border-teal-300 dark:bg-teal-950 dark:border-teal-800 rounded-full text-xs text-teal-700 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"cache"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:i.toLocaleString()})]})]})]})}function at({data:a}){let d=a.role,e=a.interactionId,f=a.content||"",[g,h]=(0,c.useState)(!1),i=f.slice(0,420),j=f.length>420;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs border border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300 font-mono",children:d}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",e]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-slate-200/80 dark:border-slate-800/80 bg-background/70 px-3 py-2",children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"System Prompt"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-72 font-mono",children:[g?f:i,j&&!g&&"..."]})]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>h(!g),className:"h-auto px-0 font-normal text-slate-700 dark:text-slate-300",children:g?"Show less":`Show full system prompt (${f.length.toLocaleString()} chars)`})]})}function au({data:a,type:d}){let e=a.hookType,f=a.hookInvocationId,g=a.success,h=a.input,i=h?.prompt,[j,k]=(0,c.useState)(!1),l=(i||"").slice(0,300),m=(i||"").length>300;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[e&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:e}),"hook.end"===d&&void 0!==g&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium border ${g?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:g?"success":"failed"}),f&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:f})]}),"hook.start"===d&&i&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Prompt Preview"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-44 font-mono",children:[j?i:l,m&&!j&&"..."]}),m&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>k(!j),className:"h-auto px-0 font-normal text-cyan-700 dark:text-cyan-300 mt-1",children:j?"Show less":`Show more (${i.length.toLocaleString()} chars)`})]})]})}function av({data:a}){let c=a.chosenModel,d=a.reasoningBucket,e=a.predictedLabel,f=a.confidence,g=a.candidateModels||[],h=a.categoryScores;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(R.Badge,{className:"text-xs font-mono bg-fuchsia-100 text-fuchsia-800 border border-fuchsia-300 dark:bg-fuchsia-900/50 dark:text-fuchsia-300 dark:border-fuchsia-800",children:c}),d&&(0,b.jsxs)(R.Badge,{variant:"outline",className:"text-xs font-mono",children:["reasoning: ",d]}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["label: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]}),"number"==typeof f&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["confidence: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[Math.round(100*f),"%"]})]})]}),g.length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Candidate Models"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:g.slice(0,8).map((a,c)=>(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm border border-fuchsia-300 bg-fuchsia-100/70 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/40 dark:text-fuchsia-300 text-xs font-mono",children:String(a)},c))})]}),h&&Object.keys(h).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Category Scores"}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5",children:Object.entries(h).slice(0,6).map(([a,c])=>(0,b.jsxs)("div",{className:"text-xs border border-fuchsia-200 bg-fuchsia-50/70 dark:border-fuchsia-900/80 dark:bg-fuchsia-950/25 rounded-sm px-2 py-1 flex items-center justify-between gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(c)})]},a))})]})]})}function aw({data:a,type:c}){let d=a.requestId,e=a.toolName,f=a.toolCallId,g=a.workingDirectory,h=a.arguments,i=a.result;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"external_tool.requested"===c?"bg-lime-100 text-lime-800 border-lime-300 dark:bg-lime-900/60 dark:text-lime-300 dark:border-lime-800":"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/60 dark:text-emerald-300 dark:border-emerald-800"}`,children:"external_tool.requested"===c?"requested":"completed"}),e&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:e}),f&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:f})]}),d&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["request: ",d]}),"external_tool.requested"===c&&g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cwd: ",(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:g})]}),h&&"object"==typeof h&&(0,b.jsx)(ap,{args:h,chars:a.argumentChars}),"external_tool.completed"===c&&i&&(0,b.jsx)(aq,{result:i,chars:a.resultChars,truncated:!0===a.truncated})]})}function ax({data:a}){let c=a.assetId,d=a.type,e=a.mimeType,f=a.byteLength,g=a.data;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:d}),e&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:e})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["size: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[f.toLocaleString()," bytes"]})]}),g&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["payload: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[g.length.toLocaleString()," chars"]})]})]}),c&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["asset: ",c]})]})}function ay({data:a}){let c=a.usage,d=a.contextWindow,e=a.totalNanoAiu,f=a.totalPremiumRequests,g=a.modelCacheState,h="number"==typeof e?e/1e9:void 0;return(0,b.jsxs)("div",{className:"space-y-2",children:[c&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[[["in",c.inputTokens],["cached",c.cachedInputTokens],["out",c.outputTokens],["reasoning",c.reasoningTokens]].filter(([,a])=>"number"==typeof a&&a>0).map(([a,c])=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-teal-300 bg-teal-100 px-2 py-0.5 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:a}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:aj(c)})]},a)),d&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["window ",aj(d)]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==h&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["total AIU: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aj(h)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["premium req: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f})]})]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cache state entries: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:g.length})]})]})}function az({data:a}){let c=a.previousModel,d=a.newModel,e=a.reasoningEffort,f=a.contextTier;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"text-sm text-foreground",children:[(0,b.jsx)("span",{className:"font-mono",children:c||"unknown"}),(0,b.jsx)("span",{className:"mx-2 text-muted-foreground",children:"→"}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:d||"unknown"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-xs",children:[(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["effort: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e??"default"})]}),(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["context: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f??"default"})]})]})]})}function aA({data:a}){let c=a.model,d=a.systemTokens,e=a.conversationTokens,f=a.toolDefinitionsTokens,g=[d,e,f].filter(a=>"number"==typeof a).reduce((a,b)=>a+b,0);return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:c}),g>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["total: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aj(g)})," tokens"]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-xs",children:[void 0!==d&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["system: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aj(d)})]}),void 0!==e&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["convo: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aj(e)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["tools: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aj(f)})]})]})]})}function aB({data:a}){let c=a.success,d=a.error,e=a.statusCode,f=a.requestId,g=a.serviceRequestId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:c?"success":"failed"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["status: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]})]}),d&&(0,b.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 bg-red-100/70 dark:bg-red-950/30 border border-red-200 dark:border-red-900 rounded-sm px-2 py-1.5 font-mono whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:d}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["requestId: ",f]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["serviceRequestId: ",g]})]})}function aC(){return(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:"Active subagent context was cleared and focus returned to the main agent."})}function aD({data:a,type:c}){let d=a.model,e=a.turnId,f=a.interactionId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"assistant.turn_start"===c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-slate-100 text-slate-700 border-slate-300 dark:bg-slate-900/60 dark:text-slate-300 dark:border-slate-700"}`,children:"assistant.turn_start"===c?"turn started":"turn finished"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["turn: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(e)})]}),d&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:d})]}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",f]})]})}function aE({data:a}){let d=a.content||"",e=a.charLength??d.length,[f,g]=(0,c.useState)(!1),h=d.slice(0,400),i=d.length>400;return d?(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:["Reasoning · ",e.toLocaleString()," chars"]}),(0,b.jsxs)("div",{className:"text-sm italic leading-relaxed text-muted-foreground whitespace-pre-wrap",children:[f?d:h,i&&!f&&"…"]}),i&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>g(!f),className:"h-auto px-0 font-normal text-indigo-600 dark:text-indigo-400",children:f?"Show less":`Show more (${e.toLocaleString()} chars)`})]}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reasoning was recorded but its content is encrypted in the transcript."})}function aF({data:a}){let c=a.message||"Error",d=a.detail;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-destructive",children:c}),d&&d!==c&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d})]})}function aG({items:a,label:d}){let[e,f]=(0,c.useState)(!1);if(0===a.length)return null;let g=e?a:a.slice(0,12);return(0,b.jsxs)("div",{className:"space-y-1",children:[d&&(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:[a.length," ",d]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-1",children:[g.map(a=>(0,b.jsx)("span",{className:"max-w-full truncate rounded-sm border border-border bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-foreground/80",title:a,children:a},a)),!e&&a.length>g.length&&(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>f(!0),className:"text-[11px] font-normal text-muted-foreground",children:["+",a.length-g.length," more"]})]})]})}function aH({text:a,charLength:d,limit:e=400,mono:f=!0,accentCls:g="text-muted-foreground"}){let[h,i]=(0,c.useState)(!1);if(!a)return null;let j=a.length>e,k=d??a.length;return(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("pre",{className:(0,_.cn)("max-h-72 overflow-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-foreground/80",f&&"font-mono"),children:[h?a:a.slice(0,e),!h&&j&&"…"]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:(0,_.cn)("h-auto px-0 font-normal",g),children:h?"Show less":`Show more (${k.toLocaleString()} chars)`})]})}function aI({data:a}){let c=a.attachmentType||"attachment",d=a.label||c,e=a.subject,f=a.items??[],g=a.itemsLabel,h=a.charLength??0,i=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs",children:d}),(0,b.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:c}),h>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["~",Math.round(h/4).toLocaleString()," tokens"]})]}),e&&(0,b.jsx)("p",{className:"break-all font-mono text-xs text-foreground/80",children:e}),(0,b.jsx)(aG,{items:f,label:g}),(0,b.jsx)(aH,{text:i,charLength:h,accentCls:"text-stone-600 dark:text-stone-400"})]})}function aJ({data:a}){let c=a.success,d=a.changes||[],e=a.stdout||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:`rounded-sm px-1.5 py-0.5 text-xs font-medium ${!1===c?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400"}`,children:!1===c?"failed":"applied"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," file",1===d.length?"":"s"]})]}),d.length>0&&(0,b.jsx)("ul",{className:"space-y-1",children:d.slice(0,12).map(a=>(0,b.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm border border-emerald-300 bg-emerald-100/70 px-1 font-mono text-[10px] uppercase text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300",children:a.type}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",title:a.file,children:a.file})]},a.file))}),e&&(0,b.jsx)("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:e})]})}function aK({data:a}){let c=a.query||"",d=a.resultCount;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm text-foreground",children:c}),void 0!==d&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[d," result",1===d?"":"s"," returned"]})]})}function aL({facts:a}){let c=a.filter(([,a])=>null!=a&&""!==a);return 0===c.length?null:(0,b.jsx)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:c.map(([a,c])=>(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-sm border border-border bg-muted/40 px-2 py-1 text-xs",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",title:String(c),children:String(c)})]},a))})}function aM({data:a}){let c=a.mode||"unknown";return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Mode set to"}),(0,b.jsx)(R.Badge,{variant:"secondary",className:"font-mono",children:c})]})}function aN({data:a}){let c=a.sandboxPolicy,d=a.approvalPolicy,e=c?.writable_roots??[];return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aL,{facts:[["model",a.model],["effort",a.effort],["personality",a.personality],["sandbox",c?.type],["network",c?.network_access===!0?"enabled":"restricted"],["approval",d?Object.keys(d)[0]:void 0],["cwd",a.cwd]]}),e.length>0&&(0,b.jsx)(aG,{items:e,label:"writable roots"})]})}function aO({data:a}){let c=a.sections??[],d=a.content||"",e=a.charLength??0;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)(aL,{facts:[["cwd",a.cwd],["shell",a.shell],["date",a.currentDate],["timezone",a.timezone],["snapshot",!0===a.full?"full":"delta"],["size",e?`${e.toLocaleString()} chars`:void 0]]}),(0,b.jsx)(aG,{items:c,label:"state sections"}),(0,b.jsx)(aH,{text:d,charLength:e})]})}function aP({data:a,type:c}){return"subagent.session_start"===c?(0,b.jsx)(aL,{facts:[["agent",a.agentNickname],["path",a.agentPath],["thread",a.sessionId],["parent",a.parentThreadId],["cwd",a.cwd]]}):"subagent.activity"===c?(0,b.jsx)(aL,{facts:[["activity",a.kind],["path",a.agentPath],["thread",a.agentThreadId]]}):(0,b.jsx)(aU,{data:a})}function aQ({data:a}){let c=a.durationMs;return(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm bg-orange-100 px-1.5 py-0.5 font-medium text-orange-800 dark:bg-orange-900/60 dark:text-orange-300",children:a.reason??"aborted"}),void 0!==c&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["after"," ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[(c/1e3).toFixed(1),"s"]})]}),void 0!==a.turnId&&(0,b.jsxs)("span",{className:"font-mono text-muted-foreground",children:["turn ",String(a.turnId)]})]})}function aR({data:a}){let c=a.turns;return(0,b.jsxs)("p",{className:"text-sm text-foreground",children:["Conversation rolled back"," ",(0,b.jsx)("span",{className:"font-semibold",children:c??"?"})," turn",1===c?"":"s","."]})}function aS({data:a}){return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Plan"}),(0,b.jsx)(R.Badge,{variant:"secondary",className:"font-mono",children:a.operation??"changed"})]})}function aT({data:a}){let c=a.kind,d=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aL,{facts:[["kind",c?.type],["shell",c?.shellId],["exit code",c?.exitCode],["description",c?.description]]}),(0,b.jsx)(aH,{text:d,mono:!1})]})}function aU({data:a}){let[d,e]=(0,c.useState)(!1),f=JSON.stringify(a,null,2),g=f.slice(0,300),h=f.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("pre",{className:"text-xs text-muted-foreground font-mono whitespace-pre-wrap",children:[d?f:g,h&&!d&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>e(!d),className:"h-auto px-0 font-normal text-muted-foreground hover:text-foreground mt-1",children:d?"Collapse":"Expand"})]})}function aV(a,b=150){let c=String(a??"").replace(/\s+/g," ").trim();return c.length>b?`${c.slice(0,b)}…`:c}function aW(a){if(!a)return"";for(let b of["command","cmd","input","script","filePath","file_path","notebook_path","path","pattern","query","description","url","prompt"])if(a[b])return`${b}: ${aV(a[b],90)}`;return Object.keys(a).length?aV(JSON.stringify(a),90):"(no args)"}let aX=a=>"string"==typeof a&&a.length>0?a.replace(/\n$/,"").split("\n").length:0;function aY(a){let b="number"==typeof a.resultChars?a.resultChars:0;return b>0?`${aj(b)} chars`:""}let aZ=new Set(["user.message","assistant.message","assistant.thinking"]);function a$({sources:a}){let d=(0,z.useParams)(),[e,f]=(0,c.useState)({status:"idle"});if(0===a.length||!d.provider||!d.id)return null;async function g(){f({status:"loading"});try{let b=encodeURIComponent(decodeURIComponent(d.id??"")),c=await Promise.all(a.map(async a=>{let c=await fetch(`/api/sessions/${d.provider}/${b}/record?source=${encodeURIComponent(a)}`);if(!c.ok)throw Error(String(c.status));return(await c.json()).record}));f({status:"loaded",text:JSON.stringify(1===c.length?c[0]:c,null,2)})}catch{f({status:"failed"})}}return(0,b.jsxs)("div",{className:"mt-2.5",children:[(0,b.jsxs)("div",{className:"mb-1.5 flex items-center gap-2",children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Original record"}),"loaded"===e.status?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[e.text.length.toLocaleString()," chars"]}),(0,b.jsx)(s.CopyButton,{value:e.text,label:"Copy the original record",className:"-my-1"})]}):(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:g,disabled:"loading"===e.status,className:"h-auto px-0 font-normal",children:"loading"===e.status?"Loading…":"Load from transcript"}),"failed"===e.status&&(0,b.jsx)("span",{className:"text-[11px] text-destructive",children:"Could not read the record."})]}),"loaded"===e.status&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("pre",{className:"max-h-96 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:e.text.slice(0,2e5)}),e.text.length>2e5&&(0,b.jsxs)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Showing the first ",2e5.toLocaleString()," chars; Copy takes the whole record."]})]})]})}function a_({event:a,prevTimestamp:d,expandAll:e,parallel:f=!1,target:g=!1,merged:h=!1,result:i,runningUSD:j,costShare:k=0,turn:l}){let m,n,o,q,r,t,u=aa[a.type]||ab,v=d?ag(d,a.timestamp):null,[w,x]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)({nonce:0,open:aZ.has(a.type)||g}),C=e&&e.nonce!==A.nonce?"open"===e.mode:A.open,E=function(a){let b=a.data,c=aa[a.type]?.label??ah(a.type).subCategory;switch(a.type){case"user.message":return{label:"User",preview:aV(b.content)};case"assistant.message":{let a=b.toolRequests??[],c=aV(b.content);if(c)return{label:"Assistant",preview:c};if(a.length)return{label:"Assistant",preview:`requests ${a.map(a=>a.name).filter(Boolean).join(", ")}`};return{label:"Assistant",preview:"(no text)"}}case"assistant.turn_start":case"assistant.turn_end":{let c=b.turnId;return{label:"assistant.turn_start"===a.type?"Turn start":"Turn end",preview:[void 0!==c?`turn ${c}`:"",b.model].filter(Boolean).join(" · ")}}case"tool.execution_start":return{label:b.toolName||"Tool",preview:aW(b.arguments),delta:function(a){if(!a)return null;let b=[a.input,a.patch,a.command].find(a=>"string"==typeof a&&a.includes("*** Begin Patch"));if(b){let a=0,c=0;for(let d of b.split("\n"))d.startsWith("+")&&!d.startsWith("+++")?a+=1:d.startsWith("-")&&!d.startsWith("---")&&(c+=1);return{added:a,removed:c}}let c=Array.isArray(a.edits)?a.edits:[a],d=0,e=0,f=!1;for(let a of c){let b=a.new_string??a.new_str??a.content??a.file_text,c=a.old_string??a.old_str;("string"==typeof b||"string"==typeof c)&&(f=!0,d+=aX(b),e+=aX(c))}return f?{added:d,removed:e}:null}(b.arguments)};case"tool.execution_complete":return{label:b.toolName||"Tool",preview:[!1===b.success?"failed":"completed",aY(b)].filter(Boolean).join(" · ")};case"external_tool.requested":case"external_tool.completed":return{label:b.toolName||"External tool",preview:"external_tool.requested"===a.type?aW(b.arguments):["completed",aY(b)].filter(Boolean).join(" · ")};case"session.start":case"session.resume":{let c=b.context;return{label:"session.start"===a.type?"Session start":"Session resume",preview:[c?.branch?`branch ${c.branch}`:"",b.selectedModel?`model ${b.selectedModel}`:""].filter(Boolean).join(" · ")}}case"session.shutdown":return{label:"Shutdown",preview:[b.shutdownType,void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:""].filter(Boolean).join(" · ")};case"session.auto_mode_resolved":return{label:"Auto mode",preview:[b.chosenModel,b.predictedLabel?`label ${b.predictedLabel}`:""].filter(Boolean).join(" · ")};case"session.binary_asset":return{label:"Binary asset",preview:[b.mimeType,"number"==typeof b.byteLength?`${(b.byteLength/1024).toFixed(0)} KB`:""].filter(Boolean).join(" · ")};case"session.usage_checkpoint":{let a=b.usage;if(a)return{label:"Usage checkpoint",preview:`in ${aj(a.inputTokens??0)} \xb7 out ${aj(a.outputTokens??0)}`};return{label:"Usage checkpoint",preview:void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:"usage snapshot"}}case"session.model_change":return{label:"Model change",preview:`${b.previousModel??"unknown"} → ${b.newModel??"unknown"}`};case"session.compaction_start":return{label:"Compaction",preview:`started \xb7 ${b.model??""}`.trim()};case"session.compaction_complete":return{label:"Compaction",preview:b.success?"completed":`failed${b.error?`: ${aV(b.error,80)}`:""}`};case"system.message":{let a=b.charLength||String(b.content??"").length;return{label:"System",preview:`${b.role??"system"} \xb7 ${a.toLocaleString()} chars`}}case"hook.start":case"hook.end":{let c=b.input;if("hook.end"===a.type)return{label:b.hookType||"Hook",preview:!1===b.success?"failed":"success"};return{label:b.hookType||"Hook",preview:aV(c?.prompt,90)||"started"}}case"permission.requested":{let a=b.permissionRequest;return{label:"Permission",preview:[a?.kind,aV(a?.intention,90)].filter(Boolean).join(" · ")}}case"permission.completed":{let a=b.result;return{label:"Permission",preview:a?.kind??"resolved"}}case"subagent.deselected":return{label:"Subagent",preview:"focus returned to main agent"};case"subagent.activity":return{label:"Subagent",preview:[b.kind,b.agentPath].filter(Boolean).join(" · ")};case"subagent.session_start":return{label:"Subagent start",preview:[b.agentNickname,b.agentPath,b.cwd].filter(Boolean).join(" · ")};case"session.plan_changed":return{label:"Plan",preview:String(b.operation??"changed")};case"system.notification":{let a=b.kind;return{label:"Notification",preview:[a?.type,a?.description].filter(Boolean).join(" · ")||aV(b.content,90)}}case"assistant.thinking":{let a=aV(b.content),c=b.charLength??0;return{label:"Thinking",preview:a||(c?`${c.toLocaleString()} chars (encrypted)`:"reasoning")}}case"session.error":return{label:"Error",preview:aV(b.detail||b.message,90)};case"context.attachment":{let a=b.charLength??0,c=b.itemCount??0,d=b.subject||(c?`${c} ${b.itemsLabel??"items"}`:"")||aV(b.content,70);return{label:b.label||"Attachment",preview:[d,a?`${a.toLocaleString()} chars`:""].filter(Boolean).join(" · ")}}case"file.patch_applied":{let a=b.changes??[],c=a[0]?.file.split("/").pop();return{label:"Patch",preview:a.length>1?`${a.length} files \xb7 ${c}, …`:c??(!1===b.success?"failed":"applied")}}case"web.search":return{label:"Web search",preview:aV(b.query,90)};case"session.turn_context":return{label:"Turn context",preview:[b.model,b.effort?`effort ${b.effort}`:""].filter(Boolean).join(" · ")};case"session.world_state":let d;return{label:"World state",preview:(d=(b.sections??[]).length,[!0===b.full?"full snapshot":"delta",`${d} section${1===d?"":"s"}`,`${(b.charLength??0).toLocaleString()} chars`].join(" · "))};case"session.mode_change":return{label:"Mode",preview:String(b.mode??"changed")};case"session.turn_aborted":return{label:"Turn aborted",preview:[b.reason,b.durationMs?`${Math.round(b.durationMs/1e3)}s`:""].filter(Boolean).join(" · ")};case"session.rollback":return{label:"Rollback",preview:`${b.turns??"?"} turn(s)`};default:return{label:c,preview:aV(JSON.stringify(b),90)}}}(a),G=(n=(m=a.data).tokenDetails,o=m.sessionTotals,q=m.usageSummary,r=("number"==typeof m.inputTokens?m.inputTokens:0)||(n?.input?.tokenCount??0)||(q?.inputTokens??0)||(o?.inputTokens??0),t=("number"==typeof m.outputTokens?m.outputTokens:0)||(n?.output?.tokenCount??0)||(q?.outputTokens??0)||(o?.outputTokens??0),0===r&&0===t?null:{input:r,output:t}),H="number"==typeof a.data.costUSD?a.data.costUSD:null,I=ah(a.type),J=ac[I.category]??u,M=ad[a.type]??`Event in "${I.category}" category with "${I.subCategory}" sub-category.`,N=function(){if(h)return(0,b.jsx)(ar,{data:i?{...a.data,result:i.data.result,success:i.data.success,resultChars:i.data.resultChars,truncated:i.data.truncated}:a.data,type:i?"tool.execution_complete":"tool.execution_start"});switch(a.type){case"user.message":return(0,b.jsx)(ak,{data:a.data});case"assistant.message":return(0,b.jsx)(al,{data:a.data});case"assistant.turn_start":return(0,b.jsx)(aD,{data:a.data,type:"assistant.turn_start"});case"assistant.turn_end":return(0,b.jsx)(aD,{data:a.data,type:"assistant.turn_end"});case"tool.execution_start":case"tool.execution_complete":return(0,b.jsx)(ar,{data:a.data,type:a.type});case"external_tool.requested":return(0,b.jsx)(aw,{data:a.data,type:"external_tool.requested"});case"external_tool.completed":return(0,b.jsx)(aw,{data:a.data,type:"external_tool.completed"});case"session.shutdown":return(0,b.jsx)(as,{data:a.data});case"session.start":case"session.resume":{let c=a.data.context;return(0,b.jsx)("div",{className:"text-xs text-muted-foreground space-y-1",children:c&&(0,b.jsxs)("div",{children:["Branch: ",(0,b.jsx)("span",{className:"text-foreground",children:c.branch})," · ","Model: ",(0,b.jsx)("span",{className:"text-foreground",children:a.data.selectedModel})]})})}case"hook.start":return(0,b.jsx)(au,{data:a.data,type:"hook.start"});case"hook.end":return(0,b.jsx)(au,{data:a.data,type:"hook.end"});case"session.auto_mode_resolved":return(0,b.jsx)(av,{data:a.data});case"session.binary_asset":return(0,b.jsx)(ax,{data:a.data});case"session.usage_checkpoint":return(0,b.jsx)(ay,{data:a.data});case"subagent.deselected":return(0,b.jsx)(aC,{});case"session.model_change":return(0,b.jsx)(az,{data:a.data});case"session.compaction_start":return(0,b.jsx)(aA,{data:a.data});case"session.compaction_complete":return(0,b.jsx)(aB,{data:a.data});case"system.message":return(0,b.jsx)(at,{data:a.data});case"assistant.thinking":return(0,b.jsx)(aE,{data:a.data});case"session.error":return(0,b.jsx)(aF,{data:a.data});case"context.attachment":return(0,b.jsx)(aI,{data:a.data});case"file.patch_applied":return(0,b.jsx)(aJ,{data:a.data});case"web.search":return(0,b.jsx)(aK,{data:a.data});case"session.mode_change":return(0,b.jsx)(aM,{data:a.data});case"session.turn_context":return(0,b.jsx)(aN,{data:a.data});case"session.world_state":return(0,b.jsx)(aO,{data:a.data});case"subagent.session_start":case"subagent.activity":case"subagent.message":return(0,b.jsx)(aP,{data:a.data,type:a.type});case"session.turn_aborted":return(0,b.jsx)(aQ,{data:a.data});case"session.rollback":return(0,b.jsx)(aR,{data:a.data});case"session.plan_changed":return(0,b.jsx)(aS,{data:a.data});case"system.notification":return(0,b.jsx)(aT,{data:a.data});case"permission.requested":{let c=a.data.permissionRequest;return c?(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-orange-600 dark:text-orange-400 font-medium",children:c.kind})," ",c.intention]}):null}case"permission.completed":{let c=a.data.result;return c?(0,b.jsx)("div",{className:"text-xs",children:(0,b.jsx)("span",{className:"approved"===c.kind?"text-emerald-600 dark:text-emerald-400":"text-destructive",children:c.kind})}):null}default:return(0,b.jsx)(aU,{data:a.data})}}(),O=JSON.stringify(h&&i?[a,i]:a,null,2),P=[...new Set([a.source,h?i?.source:void 0])].filter(a=>"string"==typeof a),Q=i?.data.success===!1,R=i?ag(a.timestamp,i.timestamp):null,S=!!N;return(0,b.jsxs)("div",{"data-event-id":a.id,className:"relative scroll-mt-40 border-l-2 border-border pb-1.5 pl-6 last:border-l-transparent",children:[(0,b.jsx)("span",{className:`absolute -left-[5px] top-3 size-2 rounded-full border border-background ${J.dotCls}`,"aria-hidden":!0}),(0,b.jsxs)("div",{className:(0,_.cn)("relative overflow-hidden rounded-lg border border-border bg-card",f&&"border-l-2 border-l-amber-400 dark:border-l-amber-600",g&&"ring-2 ring-brand/60"),children:[k>0&&(0,b.jsx)("span",{className:"pointer-events-none absolute inset-y-0 left-0 w-[3px] bg-emerald-500",style:{opacity:Math.max(.12,k)},"aria-hidden":!0}),(0,b.jsxs)("button",{type:"button","data-event-row":!0,onClick:()=>{let a;return a=!C,B({nonce:e?.nonce??0,open:a})},"aria-expanded":C,className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,_.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",C&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:`max-w-[9rem] shrink-0 truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] font-semibold ${J.chipCls??u.typeCls}`,title:E.label,children:E.label}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground/90",children:E.preview}),E.delta&&(0,b.jsxs)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums",title:"Lines written and replaced by this call",children:[(0,b.jsxs)("span",{className:"text-emerald-700 dark:text-emerald-400",children:["+",E.delta.added]}),E.delta.removed>0&&(0,b.jsxs)("span",{className:"ml-1 text-red-700 dark:text-red-400",children:["−",E.delta.removed]})]}),h&&i&&aY(i.data)&&(0,b.jsx)("span",{className:(0,_.cn)("hidden shrink-0 font-mono text-[11px] tabular-nums md:inline",i.data.resultChars>=2e4?"text-amber-700 dark:text-amber-400":"text-muted-foreground"),title:`The result is ${am(i.data.resultChars)}`,children:aY(i.data)}),h&&(0,b.jsx)("span",{className:(0,_.cn)("shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[11px] tabular-nums",Q?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-muted text-muted-foreground"),title:i?Q?"The call failed":"Time from the call to its result":"No result was recorded for this call",children:i?Q?"failed":null!==R&&R>=1e3?`${(R/1e3).toFixed(1)}s`:"done":"no result"}),G&&(0,b.jsxs)("span",{className:"hidden shrink-0 items-center gap-1.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline-flex",title:`${G.input.toLocaleString()} input tokens \xb7 ${G.output.toLocaleString()} output tokens`,children:[G.input>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(U.InputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"in"})," ",aj(G.input)]}),G.output>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(U.OutputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"out"})," ",aj(G.output)]})]}),null!==H&&H>0&&(0,b.jsx)("span",{className:(0,_.cn)("hidden shrink-0 font-mono text-[11px] tabular-nums sm:inline",!0===a.data.inherited?"text-muted-foreground line-through decoration-muted-foreground/50":"text-emerald-700 dark:text-emerald-400"),title:!0===a.data.inherited?"Estimated cost of this request in the forked session it was copied from; not part of this session's cost":"Estimated cost of this request at API list prices",children:(0,Y.formatCost)(H)}),void 0!==j&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground md:inline",title:"Estimated cost of the session up to and including this request",children:["Σ ",(0,Y.formatCost)(j)]}),l&&l.costUSD>0&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-emerald-700 dark:text-emerald-400 sm:inline",title:`Estimated cost of the ${l.requests} ${1===l.requests?"request":"requests"} made to answer this prompt; ${(0,Y.formatCost)(l.totalUSD)} for the session by the end of the turn`,children:["turn ",(0,Y.formatCost)(l.costUSD)]}),null!==v&&v>5e3&&(0,b.jsxs)("span",{className:"hidden shrink-0 rounded-sm bg-muted px-1.5 py-0.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline",title:"Gap since the previous event",children:["+",v>6e4?`${(v/6e4).toFixed(1)}m`:`${(v/1e3).toFixed(1)}s`]}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground",title:`${af(a.timestamp)}, ${ae(a.timestamp)}`,children:ae(a.timestamp)})]}),C&&(0,b.jsxs)("div",{className:"border-t border-border",children:[S?(0,b.jsx)("div",{className:"px-3 py-2.5",children:N}):(0,b.jsx)("p",{className:"px-3 py-2.5 text-xs text-muted-foreground",children:"No structured detail for this event — see the raw event below."}),(0,b.jsxs)("div",{className:"flex items-center gap-1 border-t border-border bg-muted/30 px-2 py-1.5",children:[(0,b.jsx)("span",{className:"mr-auto truncate pl-1 font-mono text-[11px] text-muted-foreground",children:h&&i?`${a.type} + ${i.type}`:a.type}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>z(!y),"aria-expanded":y,className:"text-muted-foreground",children:[(0,b.jsx)(K.Info,{className:"size-3.5","aria-hidden":!0}),"About"]}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>x(!w),"aria-expanded":w,className:"text-muted-foreground",children:[(0,b.jsx)(D,{className:"size-3.5","aria-hidden":!0}),w?"Hide raw":"Raw"]}),(0,b.jsx)(s.CopyButton,{value:()=>{let b=new URL(window.location.href);return b.search="",b.searchParams.set("event",a.id),b.toString()},label:"Copy a link to this event",icon:L,children:"Link"}),(0,b.jsx)(s.CopyButton,{value:O,label:"Copy raw JSON",children:"Copy"})]}),y&&(0,b.jsx)("div",{className:"border-t border-border bg-muted/40 px-3 py-2 text-xs leading-relaxed text-muted-foreground",children:M}),w&&(0,b.jsxs)("div",{className:"border-t border-border px-3 py-2.5",children:[(0,b.jsx)("p",{className:"mb-1.5 text-[11px] uppercase tracking-wide text-muted-foreground",children:"Raw event"}),(0,b.jsx)("pre",{className:"max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:O}),(0,b.jsx)(a$,{sources:P})]})]})]})]})}function a0(a){return ac[a]?.chipCls||"border-border bg-muted text-muted-foreground"}let a1=new Set(["system.message","context.attachment","session.world_state"]),a2=new Set(["tool.execution_start","external_tool.requested"]),a3=new Set(["tool.execution_complete","external_tool.completed"]),a4=new Set(["user.message","assistant.thinking","assistant.message"]),a5=["normal","compact","focused"];function a6(a){let b=Array.from(document.querySelectorAll("[data-event-row]")),c=b.indexOf(document.activeElement),d=-1===c?Math.max(0,b.findIndex(a=>a.getBoundingClientRect().top>160)):Math.min(b.length-1,Math.max(0,c+a));b[d]?.focus({preventScroll:!0}),b[d]?.scrollIntoView({block:"center"})}function a7(a){let{category:b}=ah(a);return a0(b)}function a8({events:a,focusRequest:e,targetEventId:f,forkParentHref:g,live:h=!1,onLiveChange:i,running:j=!1}){let k=(0,c.useMemo)(()=>{if(!f||a.some(a=>a.id===f))return f;let b=f.lastIndexOf(":");if(-1===b)return f;let c=f.slice(0,b+1);return a.findLast(a=>a.id.startsWith(c))?.id??f},[a,f]),l=(0,c.useMemo)(()=>{let b=a.findLast(a=>!0===a.data.inherited);return g&&b?`${g}?event=${encodeURIComponent(b.id)}`:void 0},[a,g]),[m,n]=(0,$.useQueryParam)("mode","normal"),[o,q]=(0,c.useState)(a5.includes(m)?m:"normal");(0,c.useEffect)(()=>n(o),[o,n]);let[r,s]=(0,c.useState)("asc"),[t,u]=(0,c.useState)([]),[v,w]=(0,c.useState)([]),[x,y]=(0,c.useState)(""),[z,D]=(0,c.useState)(!0),[F,K]=(0,c.useState)(!1),[L,R]=(0,c.useState)(!1),[S,U]=(0,c.useState)(!1),Y=(0,c.useRef)(null),[aa,ab]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=Y.current;if(!a)return;let b=getComputedStyle(document.documentElement),c=parseFloat(b.getPropertyValue("--cv-topbar-h"))+parseFloat(b.getPropertyValue("--cv-tabbar-h")),d=new IntersectionObserver(([a])=>ab(!a.isIntersecting&&a.boundingClientRect.top<c),{rootMargin:`-${c}px 0px 0px 0px`});return d.observe(a),()=>d.disconnect()},[]);let ac=(0,c.useRef)(null),[ad,ae]=(0,c.useState)(0);(0,c.useEffect)(()=>{let a=ac.current;if(!a)return;let b=new ResizeObserver(()=>ae(a.offsetHeight));return b.observe(a),()=>b.disconnect()},[]);let[ag,aj]=(0,c.useState)(null),ak=(0,c.useMemo)(()=>a.map(a=>{let b=ah(a.type);return{...a,category:b.category,subCategory:b.subCategory,subKey:`${b.category}.${b.subCategory}`}}),[a]),al=(0,c.useMemo)(()=>X(a),[a]),am=(0,c.useMemo)(()=>{let b=new Set,c=null,d=()=>{c&&b.add(c),c=null};for(let e of a)"user.message"===e.type?(d(),b.add(e.id)):"assistant.message"===e.type&&String(e.data.content??"").trim()&&(c=e.id);return d(),b},[a]),an=(0,c.useMemo)(()=>{let b=new Map,c=new Set,d=[];for(let e of a)if(a2.has(e.type))d.push(e);else if(a3.has(e.type)){let a=e.data.toolCallId,f=d.findIndex(b=>a?b.data.toolCallId===a:!b.data.toolCallId&&b.data.toolName===e.data.toolName);if(-1===f)continue;b.set(d[f].id,e),c.add(e.id),d.splice(f,1)}return{results:b,consumed:c}},[a]),ao=(0,c.useMemo)(()=>{let b=new Map,c=[],d=()=>{if(c.length>1){let a={key:c[0].id,size:c.length};for(let d of c)b.set(d.id,a)}c=[]};for(let b of a)a2.has(b.type)?c.push(b):d();return d(),b},[a]),ap=(0,c.useMemo)(()=>"normal"===o?ak:ak.filter(a=>"focused"===o?am.has(a.id):!an.consumed.has(a.id)&&(a2.has(a.type)||a3.has(a.type)||a4.has(a.type)&&("assistant.message"!==a.type||String(a.data.content??"").trim()))),[ak,o,am,an]),aq=(0,c.useMemo)(()=>ap.some(a=>a1.has(a.type)),[ap]),ar=(0,c.useMemo)(()=>ap.filter(a=>z||!a1.has(a.type)),[ap,z]),as=(0,c.useMemo)(()=>{let a=new Map;for(let b of ar){let c=a.get(b.category)??{count:0,typeCounts:new Map};c.count+=1,c.typeCounts.set(b.type,(c.typeCounts.get(b.type)||0)+1),a.set(b.category,c)}return Array.from(a.entries()).map(([a,b])=>{let c=Array.from(b.typeCounts.entries()).sort((a,b)=>b[1]-a[1]||a[0].localeCompare(b[0]))[0]?.[0];return{category:a,count:b.count,representativeType:c}}).sort((a,b)=>b.count-a.count||a.category.localeCompare(b.category))},[ar]),at=(0,c.useMemo)(()=>t.filter(a=>as.some(b=>b.category===a)),[t,as]),au=(0,c.useMemo)(()=>{if(0===at.length)return[];let a=new Set(at),b=new Map;for(let c of ar){if(!a.has(c.category))continue;let d=b.get(c.subKey);d?d.count+=1:b.set(c.subKey,{category:c.category,subCategory:c.subCategory,count:1})}return Array.from(b.values()).sort((a,b)=>b.count-a.count||a.subCategory.localeCompare(b.subCategory))},[ar,at]),av=(0,c.useMemo)(()=>{let a=new Set(au.map(a=>`${a.category}.${a.subCategory}`));return v.filter(b=>a.has(b))},[v,au]),[aw,ax]=(0,c.useState)(null);e&&e!==aw&&(ax(e),u(e.categories??[]),w(e.subKeys??[]),y(e.search??""),R(e.failures??!1),((e.categories??[]).includes("system")||(e.subKeys??[]).includes("system.message"))&&D(!0),q("normal"),U(!0));let ay=(0,c.useMemo)(()=>{let a=new Set(at),b=new Set(av),c=x.toLowerCase().split(/\s+/).filter(Boolean),d=ar.filter(d=>{if(a.size>0&&!a.has(d.category)||b.size>0&&!b.has(d.subKey)||F&&!function(a){let b=a.data,c=b.outputTokens;if("number"==typeof c&&c>0)return!0;let d=b.inputTokens;if("number"==typeof d&&d>0)return!0;let e=b.cacheReadTokens;if("number"==typeof e&&e>0)return!0;let f=b.tokenDetails;if(f){let a=f.input?.tokenCount??0,b=f.output?.tokenCount??0,c=f.cache_read?.tokenCount??0;if(a>0||b>0||c>0)return!0}return!1}(d)||L&&!ai(d)&&!ai(an.results.get(d.id)))return!1;if(c.length>0){let a="compact"===o?an.results.get(d.id):void 0,b=(JSON.stringify(d)+(a?JSON.stringify(a):"")).toLowerCase();return c.every(a=>b.includes(a))}return!0});return"desc"===r?d.reverse():d},[ar,at,av,F,L,x,o,an,r]),az=`${at.join()}|${av.join()}|${x}|${z}|${F}|${L}|${o}|${r}`,[aA,aB]=(0,c.useState)({key:az,count:150}),aC=k?ay.findIndex(a=>a.id===k):-1,aD=Math.max(aA.key===az?aA.count:150,aC+1),aE=a=>aB({key:az,count:a}),aF=h&&"asc"===r,aG=(0,c.useMemo)(()=>aF?ay.slice(-aD):ay.slice(0,aD),[ay,aD,aF]);(0,c.useEffect)(()=>{if(!aF)return;let a=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight}));return()=>cancelAnimationFrame(a)},[aF,a.length]),(0,c.useEffect)(()=>{k&&document.querySelector(`[data-event-id="${CSS.escape(k)}"]`)?.scrollIntoView({block:"center"})},[k,-1!==aC]),(0,Z.useHotkeys)({f:()=>q(a=>a5[(a5.indexOf(a)+1)%a5.length]),o:()=>s(a=>"asc"===a?"desc":"asc"),l:i&&(()=>i(!h)),e:()=>aj({nonce:Date.now(),mode:"open"}),E:()=>aj({nonce:Date.now(),mode:"closed"}),j:()=>a6(1),k:()=>a6(-1)});let aH=(0,c.useMemo)(()=>{let a=[];return aG.forEach((b,c)=>{let d=new Date(b.timestamp).toLocaleDateString([],{month:"short",day:"numeric"}),e=al.turnOf.get(b.id),f=!0===b.data.inherited,g=a[a.length-1];g&&g.date===d&&g.turn===e&&g.inherited===f?g.events.push(b):a.push({date:d,fullDate:af(b.timestamp),turn:e,inherited:f,start:c,events:[b]})}),a},[aG,al]),aI=at.length+av.length+ +!!F+ +!!L+(aq&&!z?1:0),aJ=aI+ +!!x;function aK(){u([]),w([]),y(""),K(!1),R(!1),D(!0),q("normal")}let aL=ay.length-aG.length,aM=aL>0&&(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6",children:[(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",aF?"the last ":"",aG.length.toLocaleString()," of ",ay.length.toLocaleString()," matching events"]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>aE(aD+150),children:["Load ",Math.min(150,aL)," ",aF?"earlier":"more"]}),(0,b.jsx)(p.Button,{variant:"ghost",size:"sm",onClick:()=>aE(ay.length),className:"text-muted-foreground",children:"Show all"})]})]});return(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("div",{ref:Y,"aria-hidden":!0}),(0,b.jsxs)("div",{ref:ac,className:(0,_.cn)("sticky top-[calc(var(--cv-topbar-h)+var(--cv-tabbar-h))] z-10 -mx-4 border-b bg-background/90 px-4 pt-1 pb-2.5 backdrop-blur transition-colors supports-[backdrop-filter]:bg-background/75 sm:-mx-6 sm:px-6",aa?"border-border":"border-transparent"),children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(V.SearchInput,{value:x,onChange:y,shortcut:!0,placeholder:"Search events…","aria-label":"Search events",className:"w-full sm:w-56"}),(0,b.jsx)(W.Segmented,{label:"Transcript view",size:"default",value:o,onChange:q,options:[{value:"normal",label:"Normal"},{value:"compact",label:"Compact"},{value:"focused",label:"Focused"}]}),(0,b.jsxs)(p.Button,{variant:"outline",onClick:()=>U(a=>!a),"aria-expanded":S,className:(0,_.cn)(aI>0?"border-foreground/25 bg-muted":"text-muted-foreground"),children:[(0,b.jsx)(P,{className:"size-3.5","aria-hidden":!0}),"Filters",aI>0&&(0,b.jsx)("span",{className:"rounded-sm bg-foreground/10 px-1 tabular-nums",children:aI}),(0,b.jsx)(E.default,{className:(0,_.cn)("size-3.5 transition-transform",S&&"rotate-180"),"aria-hidden":!0})]}),aJ>0&&(0,b.jsxs)(p.Button,{variant:"ghost",onClick:aK,className:"text-muted-foreground",children:[(0,b.jsx)(Q.X,{className:"size-3.5","aria-hidden":!0}),"Clear"]}),(0,b.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[i&&(0,b.jsx)(a9,{active:h,onClick:()=>i(!h),icon:N,label:"Follow live",title:j?"Follow the session: keep the newest events in view (l)":"Watch for new events and keep the newest in view (l)",pulse:j,iconOnly:!0}),(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>s("asc"===r?"desc":"asc"),"aria-label":"asc"===r?"Show newest first":"Show oldest first",className:"text-muted-foreground",children:"asc"===r?(0,b.jsx)(B,{className:"size-3.5","aria-hidden":!0}):(0,b.jsx)(C,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsxs)(T.TooltipContent,{children:["asc"===r?"Oldest first":"Newest first"," (o)"]})]}),(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>aj({nonce:Date.now(),mode:"open"}),"aria-label":"Expand all events",className:"text-muted-foreground",children:(0,b.jsx)(H,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(T.TooltipContent,{children:"Expand all"})]}),(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>aj({nonce:Date.now(),mode:"closed"}),"aria-label":"Collapse all events",className:"text-muted-foreground",children:(0,b.jsx)(G,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(T.TooltipContent,{children:"Collapse all"})]}),(0,b.jsx)("span",{className:"ml-1 text-xs tabular-nums text-muted-foreground",children:ay.length===a.length?`${a.length} events`:`${ay.length} of ${a.length} events`})]})]}),S&&(0,b.jsxs)("div",{className:"mt-2.5 space-y-2 border-t border-border pt-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[aq&&(0,b.jsx)(a9,{active:!z,onClick:()=>D(!z),icon:J,label:"Hide context",title:"Hide system prompts, auto-attached context and world-state snapshots"}),(0,b.jsx)(a9,{active:F,onClick:()=>K(!F),icon:M,label:"Token events",title:"Show only events that report token usage"}),(0,b.jsx)(a9,{active:L,onClick:()=>R(!L),icon:I,label:"Failures",title:"Show only tool calls that failed"})]}),(0,b.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:as.map(({category:a,count:c,representativeType:d})=>{let e=at.includes(a);return(0,b.jsxs)("button",{type:"button","aria-pressed":e,onClick:()=>u(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a]),className:(0,_.cn)("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",d?a7(d):a0(a),e?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[(0,b.jsx)("span",{children:a}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:c})]},a)})}),at.length>0&&au.length>0&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,b.jsx)("span",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Sub-type"}),au.map(({category:a,subCategory:c,count:d})=>{let e=`${a}.${c}`,f=av.includes(e);return(0,b.jsxs)("button",{type:"button","aria-pressed":f,title:e,onClick:()=>w(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e]),className:(0,_.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",a7(e),f?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[at.length>1&&(0,b.jsxs)("span",{className:"opacity-70",children:[a,":"]}),(0,b.jsx)("span",{children:c}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:d})]},e)})]})]})]}),(0,b.jsxs)("div",{className:"pr-2",children:[aF&&aM,aH.map(a=>(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:"absolute inset-x-0 top-[27px] h-px bg-border","aria-hidden":!0}),(0,b.jsx)("div",{className:"pointer-events-none sticky z-[5] flex justify-center py-4",style:{top:`calc(var(--cv-topbar-h) + var(--cv-tabbar-h) + ${ad}px - 0.5rem)`},children:(0,b.jsxs)("span",{className:"pointer-events-auto rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground shadow-sm",title:a.inherited?`${a.fullDate} \xb7 history copied from the forked session; its cost was billed there and is not part of this session`:void 0===a.turn?a.fullDate:`${a.fullDate} \xb7 prompt ${a.turn} and everything the agent did to answer it`,children:[a.date,a.inherited&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),"Inherited",l&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)(d.default,{href:l,title:"Open the session this one was forked from, at the last event it copied",className:"inline-flex items-center gap-0.5 text-foreground underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["Open fork point",(0,b.jsx)(A,{className:"size-3","aria-hidden":!0})]})]})]}),void 0!==a.turn&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)("span",{className:"text-foreground",children:["Turn ",a.turn]})]})]})}),a.events.map((d,e)=>{let f=ao.get(d.id),g=a.start+e,h=aG["asc"===r?g-1:g+1],i=f&&ao.get(aG[g-1]?.id)!==f;return(0,b.jsxs)(c.Fragment,{children:[i&&(0,b.jsxs)("div",{className:"border-l-2 border-border pb-1 pl-6 font-mono text-[11px] text-amber-700 dark:text-amber-400",children:["parallel · ",f.size," calls"]}),(0,b.jsx)(a_,{event:d,prevTimestamp:h?.timestamp,expandAll:ag,parallel:!!f,target:d.id===k,merged:"compact"===o&&a2.has(d.type),result:"compact"===o?an.results.get(d.id):void 0,runningUSD:al.runningUSD.get(d.id),costShare:al.runningUSD.has(d.id)&&"number"==typeof d.data.costUSD?d.data.costUSD/al.maxEventUSD:0,turn:al.turnByPrompt.get(d.id)})]},d.id)})]},`${a.date}|${a.inherited?"inherited":a.turn}`)),!aF&&aM,0===ay.length&&(0,b.jsxs)("div",{className:"mt-4 flex flex-col items-center gap-2 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,b.jsx)(O,{className:"size-5","aria-hidden":!0})}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No events match your filters"}),(0,b.jsxs)("p",{className:"max-w-sm text-xs text-muted-foreground",children:[a.length.toLocaleString()," events are recorded in this session."]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:aK,className:"mt-2",children:"Clear filters"})]})]})]})}function a9({active:a,onClick:c,icon:d,label:e,title:f,pulse:g=!1,iconOnly:h=!1}){return(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsxs)(S.Toggle,{variant:"outline",pressed:a,onPressedChange:c,"aria-label":h?e:void 0,className:(0,_.cn)("relative gap-1.5 text-muted-foreground aria-pressed:border-foreground/25 aria-pressed:text-foreground",h&&"px-0 aria-pressed:border-emerald-500/60 aria-pressed:text-emerald-600 dark:aria-pressed:text-emerald-400"),children:[(0,b.jsx)(d,{className:"size-3.5","aria-hidden":!0}),!h&&e,g&&(0,b.jsx)("span",{className:(0,_.cn)("size-1.5 animate-pulse rounded-full bg-emerald-500",h&&"absolute top-1 right-1"),"aria-hidden":!0})]})}),(0,b.jsx)(T.TooltipContent,{children:f})]})}var ba=a.i(6015),bb=a.i(56979),bc=a.i(14574);let bd={input:"Uncached input",cacheWrite:"Cache write",cacheWrite1h:"Cache write (1h)",cacheRead:"Cache read",output:"Output"},be=[["Uncached input","new prompt text the model had not seen before."],["Cache write","context stored so later requests can reuse it. A 1-hour cache costs more to write than the default."],["Cache read","stored context reused at a discount. The whole conversation is re-sent on every request, so this grows fastest in long sessions."],["Output","the model's replies, tool calls and reasoning."]];function bf(a){return`$${a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4})}`}function bg({cost:a,totalLabel:d}){let e=a.byModel.length>1,f=a.unpricedModels.length>0;return(0,b.jsx)("div",{className:"overflow-hidden rounded-lg border border-border",children:(0,b.jsxs)(ba.Table,{className:"text-xs",children:[(0,b.jsx)(ba.TableHeader,{children:(0,b.jsxs)(ba.TableRow,{className:"bg-muted/60 hover:bg-muted/60",children:[(0,b.jsx)(ba.TableHead,{className:"h-8 px-3 text-muted-foreground",children:"Token type"}),(0,b.jsx)(ba.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Tokens"}),(0,b.jsx)(ba.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Rate / 1M"}),(0,b.jsx)(ba.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Cost"})]})}),(0,b.jsx)(ba.TableBody,{className:"tabular-nums",children:a.byModel.map(d=>(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(ba.TableRow,{className:"bg-muted/30 hover:bg-muted/30",children:[(0,b.jsx)(ba.TableHead,{colSpan:3,scope:"rowgroup",className:"h-auto px-3 py-1.5 font-mono font-semibold",children:d.model}),(0,b.jsx)(ba.TableCell,{className:"px-3 py-1.5 text-right font-mono font-semibold text-foreground",children:e&&null!==d.costUSD&&(0,Y.formatCost)(d.costUSD)})]}),a.lines.filter(a=>a.model===d.model).map(a=>(0,b.jsxs)(ba.TableRow,{className:"border-border/60",children:[(0,b.jsx)(ba.TableCell,{className:"px-3 py-1.5 text-foreground",children:bd[a.kind]}),(0,b.jsx)(ba.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)(ba.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:null===a.rate?"—":bf(a.rate)}),(0,b.jsx)(ba.TableCell,{className:"px-3 py-1.5 text-right font-mono text-foreground",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,Y.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},d.model))}),(0,b.jsx)(ba.TableFooter,{className:"bg-muted/60",children:(0,b.jsxs)(ba.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(ba.TableHead,{colSpan:3,scope:"row",className:"h-auto px-3 py-2 font-semibold",children:d}),(0,b.jsxs)(ba.TableCell,{className:"px-3 py-2 text-right font-mono font-bold tabular-nums text-foreground",children:[(0,Y.formatCost)(a.totalUSD),f&&"+"]})]})})]})})}function bh({cost:a,open:d,onOpenChange:e}){let f,g=a.unpricedModels.length>0,h=(f=Object.entries(a.prices).map(([a,b])=>{let c=(b??[{input:0,output:0}]).map(a=>` ${JSON.stringify(a).replace(/([{,:])/g,"$1 ").replace("}"," }")}`).join(",\n");return` ${JSON.stringify(a)}: [
2
2
  ${c}
3
3
  ]`}),`{
4
4
  ${f.join(",\n")}
5
- }`),[i,j]=(0,c.useState)(g);return(0,b.jsx)(a4.Dialog,{open:d,onOpenChange:e,children:(0,b.jsxs)(a4.DialogContent,{className:"sm:max-w-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(a4.DialogTitle,{children:"How this cost is estimated"}),(0,b.jsx)(a4.DialogDescription,{children:"This is what the session’s tokens would cost on the pay-per-token API at list prices. It is not a bill: on a subscription or a request-based plan you pay your plan price, however many tokens a session uses."})]}),(0,b.jsx)(a8,{cost:a,totalLabel:a.inherited?"This session":"Total"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Each row is tokens ÷ 1,000,000 × rate, using the list price on the day of the request.",g&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out."]})]}),a.inherited&&(0,b.jsxs)("div",{className:"space-y-2 border-t border-border pt-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Inherited from the forked session"}),(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"This session is a fork, so it opens with a copy of its parent’s history. Those requests were made, and are counted, in the parent session; they are listed here for reference and are not part of this session’s cost or of any usage total."})]}),(0,b.jsx)(a8,{cost:a.inherited,totalLabel:"Inherited"})]}),(0,b.jsx)("dl",{className:"space-y-1.5 border-t border-border pt-3 text-xs leading-relaxed text-muted-foreground",children:a6.map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("dt",{className:"inline font-medium text-foreground",children:[a,": "]}),(0,b.jsx)("dd",{className:"inline",children:c})]},a))}),(0,b.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border bg-card text-xs",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>j(!i),"aria-expanded":i,"aria-controls":"cost-dialog-prices",className:"flex w-full items-center gap-2 px-3 py-2 text-left font-medium text-foreground transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),"aria-hidden":!0}),g?"Add the missing price":"Change these prices"]}),(0,b.jsxs)("div",{id:"cost-dialog-prices",hidden:!i,className:"space-y-2 border-t border-border px-3 py-3 leading-relaxed text-muted-foreground",children:[(0,b.jsxs)("p",{children:["Save the block below as"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:a.overridePath})," ","and edit the numbers. It replaces the bundled price for the models it lists and takes effect on the next page load."]}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("pre",{className:"overflow-x-auto rounded-lg border border-border bg-muted/50 p-3 pr-10 font-mono text-[11px] leading-relaxed text-foreground",children:h}),(0,b.jsx)(s.CopyButton,{value:h,label:"Copy pricing.json",className:"absolute top-1.5 right-1.5"})]}),(0,b.jsxs)("ul",{className:"list-disc space-y-1 pl-4",children:[(0,b.jsx)("li",{children:"All prices are US dollars per million tokens."}),(0,b.jsxs)("li",{children:[(0,b.jsx)("code",{className:"font-mono text-foreground",children:"input"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"output"})," are required. ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheRead"}),","," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","are optional: the first two fall back to the input price, and ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","to ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"}),"."," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"fast"})," multiplies every price for requests made in a faster, premium speed tier."]}),(0,b.jsxs)("li",{children:["To record a price change, add a second entry with"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:'"from": "YYYY-MM-DD"'}),". Requests before that day keep the old price."]})]})]})]})]})})}let ba=Object.keys(a5);function bb({events:a,partial:d,onOpenEvent:e}){let{turns:f,totalUSD:g,inheritedUSD:h}=(0,c.useMemo)(()=>W(a),[a]),[i,j]=(0,c.useState)(null);if(f.length<2||g<=0)return null;let k=null!==i&&i<f.length?i:null,l=(0,a3.niceCeil)(Math.max(...f.map(a=>a.costUSD))),m=(0,a3.niceCeil)(g),n=f.reduce((a,b)=>b.costUSD>a.costUSD?b:a),o=a=>`${Math.round(a/g*100)}%`,p=a=>0===a?"Before the first prompt":`Turn ${a}`,q=Math.floor((f.length-1)/2),r=null===k?null:f[k],s=r?[...new Set(r.lines.map(a=>a.model))]:[],t=null===k?0:(k+.5)/f.length*100,u=f.reduce((a,b,c)=>`${a} H${c+.5} V${100-b.totalUSD/m*100}`,"M0,100")+` H${f.length}`;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Cost by turn",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"a turn is one prompt and everything the agent did to answer it"})]})}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-right text-[10px] leading-none tabular-nums text-emerald-700 dark:text-emerald-400",children:[(0,b.jsx)("span",{children:(0,X.formatCost)(l)}),(0,b.jsx)("span",{children:(0,X.formatCost)(l/2)}),(0,b.jsx)("span",{children:"$0"})]}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:(0,$.cn)("relative flex h-40 items-end border-b border-border",f.length>80?"gap-0":"gap-[2px]"),onMouseLeave:()=>j(null),children:[(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-dashed border-border"}),(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-dashed border-border"}),f.map((a,c)=>(0,b.jsxs)("button",{type:"button",onMouseEnter:()=>j(c),onFocus:()=>j(c),onBlur:()=>j(null),onClick:()=>e(a.eventId),"aria-label":`${p(a.turn)}: ${(0,X.formatCost)(a.costUSD)}, ${(0,X.formatCost)(a.totalUSD)} so far. Open in the timeline.`,className:(0,$.cn)("relative flex h-full min-w-0 flex-1 cursor-pointer flex-col justify-end focus-visible:outline-2 focus-visible:outline-ring",null!==k&&k!==c&&"opacity-50"),children:[a.compacted&&(0,b.jsx)("span",{className:"absolute top-1 left-1/2 size-1.5 -translate-x-1/2 rotate-45 bg-amber-500","aria-hidden":!0}),(0,b.jsx)("span",{className:"w-full rounded-t-[3px] bg-emerald-500/60 dark:bg-emerald-500/50",style:{height:`${a.costUSD/l*100}%`,minHeight:2*(a.costUSD>0)}})]},a.eventId)),(0,b.jsx)("svg",{className:"pointer-events-none absolute inset-0 size-full overflow-visible text-foreground",viewBox:`0 0 ${f.length} 100`,preserveAspectRatio:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:u,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})}),r&&(0,b.jsxs)("div",{role:"status",className:"pointer-events-none absolute top-full z-20 mt-2 w-80 max-w-full rounded-lg border border-border bg-popover p-3 text-xs text-popover-foreground shadow-lg",style:{left:`${t}%`,transform:`translateX(-${t}%)`},children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3 tabular-nums",children:[(0,b.jsxs)("span",{className:"font-semibold",children:[p(r.turn)," · ",(0,X.formatCost)(r.costUSD)]}),(0,b.jsxs)("span",{className:"text-muted-foreground",children:[o(r.costUSD)," of the session"]})]}),(0,b.jsx)("p",{className:"mt-0.5 truncate text-muted-foreground",children:(0,X.firstLine)(r.prompt)??"Requests made before the first prompt."}),(0,b.jsxs)("table",{className:"mt-2 w-full border-t border-border tabular-nums",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-[10px] text-muted-foreground",children:[(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-left font-normal",children:"Token type"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Tokens"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Rate / 1M"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Cost"})]})}),(0,b.jsx)("tbody",{children:s.map(a=>(0,b.jsxs)(c.Fragment,{children:[s.length>1&&(0,b.jsx)("tr",{children:(0,b.jsx)("th",{colSpan:4,scope:"rowgroup",className:"max-w-0 truncate pt-1.5 text-left font-mono font-semibold",children:a})}),r.lines.filter(b=>b.model===a).sort((a,b)=>ba.indexOf(a.kind)-ba.indexOf(b.kind)).map(a=>(0,b.jsxs)("tr",{children:[(0,b.jsx)("td",{className:"py-0.5",children:a5[a.kind]}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono text-muted-foreground",children:null===a.rate?"—":a7(a.rate)}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,X.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},a))})]}),(0,b.jsxs)("p",{className:"mt-2 border-t border-border pt-1.5 tabular-nums text-muted-foreground",children:[1===s.length&&(0,b.jsxs)("span",{className:"font-mono",children:[s[0]," · "]}),r.requests," ",1===r.requests?"request":"requests"," ·"," ",(0,X.formatCost)(r.totalUSD)," so far",r.compacted&&" · context compacted"]})]})]}),(0,b.jsxs)("div",{className:"mt-1.5 flex justify-between text-[10px] text-muted-foreground",children:[(0,b.jsx)("span",{children:p(f[0].turn)}),f.length>4&&(0,b.jsx)("span",{children:f[q].turn}),(0,b.jsx)("span",{children:f[f.length-1].turn})]})]}),(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-[10px] leading-none tabular-nums text-muted-foreground",children:[(0,b.jsx)("span",{children:(0,X.formatCost)(m)}),(0,b.jsx)("span",{children:(0,X.formatCost)(m/2)}),(0,b.jsx)("span",{children:"$0"})]})]}),(0,b.jsxs)("div",{className:"mt-3 space-y-1 text-xs",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[(0,b.jsxs)("span",{className:"font-medium tabular-nums",children:["Whole session · ",(0,X.formatCost)(g),d&&"+"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-2.5 rounded-[3px] bg-emerald-500/60","aria-hidden":!0}),"cost of the turn (left axis)"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"w-3 border-t-2 border-foreground","aria-hidden":!0}),"running total (right axis)"]}),f.some(a=>a.compacted)&&(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-1.5 rotate-45 bg-amber-500","aria-hidden":!0}),"context compacted"]})]}),(0,b.jsxs)("p",{className:"truncate text-muted-foreground",children:[p(n.turn)," cost the most: ",(0,X.formatCost)(n.costUSD),","," ",o(n.costUSD)," of the session. Hover a bar for its tokens and prices; click it to open the turn in the timeline."]}),h>0&&(0,b.jsxs)("p",{className:"text-muted-foreground",children:["Not charted: ",(0,X.formatCost)(h)," of history copied from the forked session, shown as Inherited in the timeline. The parent session was billed for it."]})]})]})}let bc=[{key:"input",label:"Uncached input"},{key:"cacheWrite",label:"Cache write"},{key:"cacheRead",label:"Cache read"},{key:"output",label:"Output"}],bd=["Context",...bc.map(a=>a.label),"Cost"];function be(a){return{input:a.inputTokens,cacheWrite:a.cacheWriteTokens,cacheRead:a.cacheReadTokens,output:a.outputTokens}}function bf(a){let b={tokens:{input:0,cacheWrite:0,cacheRead:0,output:0},usd:{input:null,cacheWrite:null,cacheRead:null,output:null},costUSD:null};for(let c of a){let a=be(c);for(let{key:d}of bc){b.tokens[d]+=a[d];let e=c.usd[d];null!==e&&(b.usd[d]=(b.usd[d]??0)+e)}null!==c.costUSD&&(b.costUSD=(b.costUSD??0)+c.costUSD)}return b}function bg(a){return a>=.01?(0,X.formatCost)(a):a<1e-4?"<$0.0001":`$${a.toFixed(4)}`}function bh({tokens:a,usd:c,unit:d,sticky:e}){return bc.map(({key:f,label:g})=>{let h=a[f],i=c[f],j=null===i?"no price":bg(i);return(0,b.jsx)(a2.TableCell,{className:(0,$.cn)("py-1.5 pr-0 pl-3 text-right",e),title:h>0?`${g}: ${h.toLocaleString()} tokens, ${j}`:void 0,children:0===h?"—":"tokens"===d?(0,X.formatTokens)(h):null===i?(0,b.jsx)("span",{className:"font-sans",children:"no price"}):bg(i)},f)})}function bi({value:a,max:c}){return(0,b.jsxs)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",title:a.toLocaleString(),children:[(0,X.formatTokens)(a)??"—",(0,b.jsx)("span",{className:"mt-0.5 block h-0.5 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:(0,b.jsx)("span",{className:"block h-full rounded-full bg-emerald-500/70",style:{width:`${c>0?a/c*100:0}%`}})})]})}let bj="sticky top-0 z-10 bg-card shadow-[inset_0_-1px_0_var(--border)]",bk="sticky bottom-0 z-10 bg-card shadow-[inset_0_1px_0_var(--border)]";function bl({value:a,className:c}){return(0,b.jsx)(a2.TableCell,{className:(0,$.cn)("py-1.5 pr-0 pl-3 text-right text-foreground",c),children:null===a?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,X.formatCost)(a)})}function bm({events:a,onOpenEvent:d}){let{requests:e,turns:f}=(0,c.useMemo)(()=>W(a),[a]),[g,h]=(0,c.useState)({allOpen:null,flipped:new Set}),[i,j]=(0,c.useState)("tokens"),k=(0,c.useMemo)(()=>{let a=new Map;for(let b of e){let c=a.get(b.turn);c?c.push(b):a.set(b.turn,[b])}let b=new Map(f.map(a=>[a.turn,a.prompt]));return[...a].map(([a,c])=>({turn:a,rows:c,prompt:b.get(a),totals:bf(c)}))},[e,f]);if(e.length<2)return null;let l=g.allOpen??e.length<=60,m=a=>l!==g.flipped.has(a),n=Math.max(...e.map(a=>a.contextTokens)),o=bf(e),q=new Set(e.flatMap(a=>a.models)).size>1,r=o.tokens.cacheRead>0,s=k.some(a=>m(a.turn)),t=null!==o.costUSD;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-2 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Requests",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"every call to the model, grouped by turn"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t&&(0,b.jsx)(V.Segmented,{label:"Show each token class as",value:i,onChange:j,options:[{value:"tokens",label:"Tokens"},{value:"cost",label:"Cost"}]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:()=>h({allOpen:!s,flipped:new Set}),children:s?"Collapse all":"Expand all"})]})]}),(0,b.jsxs)("p",{className:"mb-3 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:["Each tool round is its own request, and every request sends the whole conversation again."," ",(0,b.jsx)("span",{className:"text-foreground",children:"Context"})," is what one request sent: cache read (already stored), cache write (new since the last request, stored for the next) and uncached input. A turn row adds up its requests, so its cache read is the context multiplied by the number of requests, not the size of the context."]}),(0,b.jsx)("div",{className:"[&>[data-slot=table-container]]:max-h-[70vh] [&>[data-slot=table-container]]:overflow-y-auto",children:(0,b.jsxs)(a2.Table,{className:"min-w-[47rem] table-fixed text-xs",children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{}),bd.map(a=>(0,b.jsx)("col",{className:"Cost"===a?"w-20":"Uncached input"===a?"w-28":"w-24"},a))]}),(0,b.jsx)(a2.TableHeader,{children:(0,b.jsxs)(a2.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(a2.TableHead,{className:(0,$.cn)("h-8 px-0 text-muted-foreground",bj),children:"Turn / request"}),bd.map(a=>(0,b.jsx)(a2.TableHead,{className:(0,$.cn)("h-8 pr-0 pl-3 text-right text-muted-foreground",bj),children:a},a))]})}),(0,b.jsx)(a2.TableBody,{className:"font-mono tabular-nums",children:k.map(({turn:a,rows:f,prompt:g,totals:j})=>{let k=m(a),l=f[f.length-1];return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(a2.TableRow,{className:"border-border/60 bg-muted/40 font-semibold hover:bg-muted/60",children:[(0,b.jsx)(a2.TableCell,{className:"truncate px-0 py-1.5 font-sans",children:(0,b.jsxs)("button",{type:"button",onClick:()=>h(({allOpen:b,flipped:c})=>{let d=new Set(c);return d.delete(a)||d.add(a),{allOpen:b,flipped:d}}),"aria-expanded":k,className:"flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-left text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-3.5 shrink-0 transition-transform",k&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:"shrink-0",children:0===a?"Before the first prompt":`Turn ${a}`}),(0,b.jsxs)("span",{className:"shrink-0 font-normal tabular-nums text-muted-foreground",children:[f.length," ",1===f.length?"request":"requests"]}),(0,b.jsx)("span",{className:"min-w-0 truncate font-normal text-muted-foreground",children:(0,X.firstLine)(g)})]})}),(0,b.jsx)(bi,{value:l.contextTokens,max:n}),(0,b.jsx)(bh,{tokens:j.tokens,usd:j.usd,unit:i}),(0,b.jsx)(bl,{value:j.costUSD})]}),k&&f.map(a=>{let c=e[a.n-2],f=r&&void 0!==c&&a.cacheReadTokens<c.contextTokens/2&&a.inputTokens+a.cacheWriteTokens>a.cacheReadTokens;return(0,b.jsxs)(a2.TableRow,{className:"group border-border/60 text-muted-foreground",children:[(0,b.jsxs)(a2.TableCell,{className:"truncate py-1.5 pr-0 pl-5",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>d(a.eventId),"aria-label":`Request ${a.n}: open in the timeline`,title:"Open in the timeline",className:"inline-flex cursor-pointer items-center gap-1 rounded-sm text-foreground underline-offset-2 hover:text-brand hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["#",a.n,(0,b.jsx)(z,{className:"size-3 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100","aria-hidden":!0})]}),q&&(0,b.jsx)("span",{className:"ml-2",children:a.models.join(", ")}),f&&(0,b.jsx)("span",{className:"ml-2 rounded-sm bg-amber-500/15 px-1.5 py-0.5 font-sans text-[10px] text-amber-700 dark:text-amber-400",title:"Little of the context came from the cache, so it was sent and stored again at the higher rate. This follows a compaction, a change to the early context, or a pause longer than the cache lifetime.",children:"cache miss"})]}),(0,b.jsx)(bi,{value:a.contextTokens,max:n}),(0,b.jsx)(bh,{tokens:be(a),usd:a.usd,unit:i}),(0,b.jsx)(bl,{value:a.costUSD})]},a.eventId)})]},a)})}),(0,b.jsx)(a2.TableFooter,{className:"bg-transparent font-mono tabular-nums",children:(0,b.jsxs)(a2.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsxs)(a2.TableCell,{className:(0,$.cn)("truncate px-0 py-1.5 font-sans text-foreground",bk),children:["Whole session",(0,b.jsxs)("span",{className:"ml-1.5 font-normal text-muted-foreground",children:[e.length," requests, context peaked at ",(0,X.formatTokens)(n)]})]}),(0,b.jsx)(a2.TableCell,{className:(0,$.cn)("py-1.5 pr-0 pl-3",bk)}),(0,b.jsx)(bh,{tokens:o.tokens,usd:o.usd,unit:i,sticky:bk}),(0,b.jsx)(bl,{value:o.costUSD,className:(0,$.cn)("font-semibold",bk)})]})})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground",children:["Click a request number to open it in the timeline. Hover a value for its exact token count and cost",t&&", or switch the columns between tokens and cost","."]})]})}function bn({cost:a}){let[d,e]=(0,c.useState)(!1);if(0===a.byModel.length)return null;let f=[{label:"Output",note:"replies + reasoning",usd:a.breakdown.output,bar:"bg-sky-400 dark:bg-sky-500"},{label:"Cache writes",note:"new context stored",usd:a.breakdown.cacheWrite,bar:"bg-amber-400 dark:bg-amber-500"},{label:"Cache reads",note:"context re-sent each turn",usd:a.breakdown.cacheRead,bar:"bg-emerald-400 dark:bg-emerald-500"},{label:"Uncached input",usd:a.breakdown.input,bar:"bg-red-400 dark:bg-red-500"}].filter(a=>a.usd>0),g=a.byModel.reduce((a,b)=>a+b.cacheReadTokens,0),h=a.byModel.reduce((a,b)=>a+b.inputTokens+b.cacheWriteTokens+b.cacheReadTokens,0),i=a.unpricedModels.length>0;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Estimated cost"}),(0,b.jsxs)("span",{className:"font-mono text-lg font-bold tabular-nums text-foreground",children:[(0,X.formatCost)(a.totalUSD),i&&"+"]})]}),a.totalUSD>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:c,usd:d,bar:e})=>(0,b.jsx)("div",{className:e,style:{width:`${d/a.totalUSD*100}%`}},c))}),(0,b.jsx)("div",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:f.map(({label:c,note:d,usd:e,bar:f})=>(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:(0,$.cn)("size-2 shrink-0 rounded-full",f),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:[c,d&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",d,")"]})]}),(0,b.jsx)("span",{className:"font-mono font-semibold tabular-nums text-foreground",children:(0,X.formatCost)(e)}),(0,b.jsxs)("span",{className:"w-9 text-right tabular-nums text-muted-foreground",children:[Math.round(e/a.totalUSD*100),"%"]})]},c))})]}),(0,b.jsx)("div",{className:"mt-4 border-t border-border pt-1.5",children:(0,b.jsxs)(a2.Table,{className:"text-xs",children:[(0,b.jsx)(a2.TableHeader,{children:(0,b.jsx)(a2.TableRow,{className:"hover:bg-transparent",children:["Model","Input","Cache write","Cache read","Output","Cost"].map((a,c)=>(0,b.jsx)(a2.TableHead,{className:(0,$.cn)("h-8 px-0 text-muted-foreground",c>0&&"pl-3 text-right"),children:a},a))})}),(0,b.jsx)(a2.TableBody,{className:"font-mono tabular-nums",children:a.byModel.map(a=>(0,b.jsxs)(a2.TableRow,{className:"border-border/60",children:[(0,b.jsx)(a2.TableCell,{className:"px-0 py-1.5 text-foreground",children:a.model}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.inputTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.cacheWriteTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.cacheReadTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.outputTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right font-semibold text-foreground",children:null===a.costUSD?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,X.formatCost)(a.costUSD)})]},a.model))})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:[h>0&&g>0&&(0,b.jsxs)(b.Fragment,{children:[Math.round(g/h*100),"% of input was served from cache."," "]}),"API-equivalent estimate at list prices on the day of each request, not a bill: subscription and request-based plans charge differently."," ",(0,b.jsx)(p.Button,{variant:"link",onClick:()=>e(!0),"aria-haspopup":"dialog",className:"inline h-auto rounded-sm p-0 text-xs text-foreground underline underline-offset-2 hover:text-brand",children:"See the rates and arithmetic"}),i&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out; add one in"," ",(0,b.jsx)("code",{className:"font-mono",children:"~/.agent-session-inspector/pricing.json"}),"."]})]}),(0,b.jsx)(a9,{cost:a,open:d,onOpenChange:e})]})}function bo({cost:a,events:c,onOpenEvent:d}){return 0===a.byModel.length?(0,b.jsx)("p",{className:"rounded-xl border border-border bg-card p-5 text-xs text-muted-foreground",children:"This session recorded no token usage, so there is nothing to price."}):(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)(bn,{cost:a}),(0,b.jsx)(bb,{events:c,partial:a.unpricedModels.length>0,onOpenEvent:d}),(0,b.jsx)(bm,{events:c,onOpenEvent:d})]})}var bp=a.i(90892);let bq=/(?<!<)<<(?!<)-?\s*(['"]?)([A-Za-z_]\w*)\1/g,br=/^__heredoc_(\d+)__$/,bs=new Set(["sudo","command","env","time","nohup","exec","xargs"]),bt=/^(ba|z|da)?sh$/,bu=/^(python[\d.]*|node|bun|deno)$/,bv=a=>a.startsWith("-");function bw(a,b=/^-[a-zA-Z]*[ef]$|^--(expression|file)$/){let c=[],d=!1;for(let e=0;e<a.length;e++)b.test(a[e])?(d=!0,e++):bv(a[e])||""===a[e]||c.push(a[e]);return{files:c,scripted:d}}let bx=String.raw`(?:(['"\`])([^'"\`\n]+)\1|([A-Za-z_$][\w$]*))`,by=[RegExp(String.raw`\bopen\(\s*${bx}\s*,\s*(?:mode\s*=\s*)?['"](?=[^'"]*[wax+])[rwaxbt+]+['"]`,"g"),RegExp(String.raw`\bPath\(\s*${bx}\s*\)\s*\.write_(?:text|bytes)\(`,"g"),RegExp(String.raw`\b(?:write|append)File(?:Sync)?\(\s*${bx}`,"g")],bz=/^(\/dev\/|\/tmp\/|\/private\/tmp\/|\/var\/folders\/|\/private\/var\/folders\/)/,bA=a=>""!==a&&"-"!==a&&!/[$`*?{}]/.test(a)&&!a.startsWith("~")&&!bz.test(a);function bB(a,b){if(b.startsWith("/")||!a)return b.replace(/^(\.\/)+/,"");let c=a.split("/");for(let a of b.split("/"))".."===a?c.pop():"."!==a&&""!==a&&c.push(a);return c.join("/")}let bC=["file_path","filePath","notebook_path","path","target_file"],bD=/^(edit|write|multiedit|notebookedit|update|create|patch|apply_patch|replace|search_replace|str_replace\w*|(copilot_)?(write|edit|create|replace|insert)\w*(file|string|edit|notebook)\w*)$/i,bE=/^(bash|sh|zsh|shell|exec|exec_command|shell_command|local_shell|terminal|run_in_terminal|run_terminal_cmd|run_terminal_command\w*|run_shell_command|run_command|execute_command|container\.exec)$/i,bF=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm,bG=a=>[...new Set([...a.matchAll(bF)].map(a=>a[1].trim()))];function bH(a,b){let c=new Set;for(let b of a)"file.patch_applied"===b.type&&b.data.callId&&c.add(b.data.callId);let d=[],e={turn:0,timestamp:a[0]?.timestamp??"",files:[],edits:0},f=0,g=(a,b,c)=>{0===e.files.length&&d.push(e),e.edits++;let f=e.files.find(a=>a.path===b);f?(f.count++,f.tools.includes(c)||f.tools.push(c)):e.files.push({path:b,count:1,tools:[c],eventId:a.id})};for(let d of a)if("user.message"===d.type)e={turn:++f,prompt:"string"==typeof d.data.content?d.data.content:void 0,promptEventId:d.id,timestamp:d.timestamp,files:[],edits:0};else if("file.patch_applied"===d.type){if(!1===d.data.success)continue;for(let a of d.data.changes??[])a?.file&&g(d,a.file,"patch")}else if("tool.execution_start"===d.type){let a=function(a){let b=a.toolName??a.name;return"string"==typeof b?b:""}(d.data);if(c.has(d.data.toolCallId))continue;for(let c of bD.test(a)?function(a){let b=a.arguments,c=b&&"object"==typeof b?b:{};for(let a of bC){let b=c[a];if("string"==typeof b&&b)return[b]}let d="string"==typeof b?b:c.input??c.patch??c.patchText;return"string"!=typeof d?[]:bG(d)}(d.data):bE.test(a)?function(a,b){let c=function(a){let b=a.arguments;if("string"==typeof b)return b;let c=b&&"object"==typeof b?b:{},d=c.command??c.cmd??c.script??c.input;return"string"==typeof d?d:Array.isArray(d)&&d.every(a=>"string"==typeof a)?/^-l?c$/.test(d[1]??"")&&3===d.length?d[2]:d.join(" "):void 0}(a);if(!c)return[];let d=bG(c);return d.length>0?d:function a(b,c){let{shell:d,bodies:e}=function(a){let b=[],c=[],d=a.split("\n");for(let a=0;a<d.length;a++){let e=[];for(let f of(b.push(d[a].replace(bq,(a,b,d)=>(e.push(d),`<<__heredoc_${c.length+e.length-1}__`))),e)){let b=[];for(;++a<d.length&&d[a].trim()!==f;)b.push(d[a]);c.push(b.join("\n"))}}return{shell:b.join("\n"),bodies:c}}(b),f=new Set,g=c?.replace(/\/+$/,""),h=a=>{if(!bA(a))return;let b=bB(g,a);bz.test(b)||f.add(b)};for(let{words:b,writes:c,inputs:i}of function(a){let b=[],c={words:[],writes:[],inputs:[]},d=null,e="words",f=()=>{null!==d&&(c[e].push(d),d=null,e="words")},g=()=>{f(),(c.words.length>0||c.writes.length>0)&&b.push(c),c={words:[],writes:[],inputs:[]},e="words"};for(let b=0;b<a.length;b++){let c=a[b];if("\\"===c)"\n"!==a[++b]&&(d=(d??"")+(a[b]??""));else if("'"===c){let c=a.indexOf("'",b+1),e=c<0?a.length:c;d=(d??"")+a.slice(b+1,e),b=e}else if('"'===c){let c="";for(b++;b<a.length&&'"'!==a[b];b++)"\\"===a[b]&&b+1<a.length&&b++,c+=a[b];d=(d??"")+c}else if(" "===c||" "===c)f();else if("#"===c&&null===d)for(;b+1<a.length&&"\n"!==a[b+1];)b++;else if("&"===c&&">"===a[b+1])f();else if("\n"===c||";"===c||"|"===c||"&"===c||"("===c||")"===c)g();else if(">"===c){if(null!==d&&/^\d+$/.test(d)?d=null:f(),(">"===a[b+1]||"|"===a[b+1])&&b++,"&"===a[b+1]){b++;let c=/^[\d-]+/.exec(a.slice(b+1));if(c){b+=c[0].length;continue}}e="writes"}else if("<"===c){for(f();"<"===a[b+1]||"-"===a[b+1];)b++;e="inputs"}else d=(d??"")+c}return g(),b}(d)){let d=0;for(;d<b.length&&(/^\w+=/.test(b[d])||bs.has(b[d]));)d++;let j=b[d]?.split("/").pop()??"",k=b.slice(d+1),l=i.flatMap(a=>e[Number(br.exec(a)?.[1])]??[]);if("cd"===j)k[0]&&bA(k[0])&&(k[0].startsWith("/")||g)&&(g=bB(g,k[0]));else if(bt.test(j)){let b=k.findIndex(a=>/^-[a-zA-Z]*c$/.test(a));for(let c of b>=0?[k[b+1]??""]:l)a(c,g).forEach(a=>f.add(a))}else if(bu.test(j))for(let a of[...k,...l])(function(a){let b=[];for(let c of by)for(let d of a.matchAll(c)){let c=d[2]??function(a,b,c){let d,e=b.replace(/\$/g,"\\$"),f=RegExp(String.raw`(?<![\w$.])${e}\s*=\s*(['"])([^'"\n]+)\1`,"g");for(let b of a.slice(0,c).matchAll(f))d=b[2];return d}(a,d[3],d.index);c&&b.push({index:d.index,path:c})}return b.sort((a,b)=>a.index-b.index).map(a=>a.path)})(a).forEach(h);else(function(a,b){"git"===a&&("mv"===b[0]||"rm"===b[0])&&(a=b[0],b=b.slice(1));let c=b.some(a=>/^-[a-zA-Z]*[rR]/.test(a)||"--recursive"===a);switch(a){case"tee":case"touch":case"mv":return bw(b).files;case"sed":case"gsed":{if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)||a.startsWith("--in-place")))return[];let{files:a,scripted:c}=bw(b);return c?a:a.slice(1)}case"perl":if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)))return[];return bw(b,/^-[a-zA-Z]*e$/).files;case"rm":return c?[]:bw(b).files;case"cp":return c?[]:bw(b).files.slice(-1);default:return[]}})(j,k).forEach(h);c.forEach(h)}return[...f]}(c,b)}(d.data,b):[])g(d,c,a)}return d}let bI=(a,b)=>`${a.toLocaleString()} ${b}${1===a?"":"s"}`;function bJ({events:a,cwd:d,onOpenEvent:e}){let[f,g]=(0,c.useState)(""),h=(0,c.useMemo)(()=>bH(a,d),[a,d]),i=f.trim().toLowerCase(),j=(0,c.useMemo)(()=>i?h.map(a=>({...a,files:a.files.filter(a=>a.path.toLowerCase().includes(i))})).filter(a=>a.files.length>0):h,[h,i]);if(0===h.length)return(0,b.jsx)(bp.EmptyState,{icon:k,title:"No file edits",description:"Files appear here, grouped by prompt, when the agent writes, edits or patches one, or changes one from the shell."});let l=d?`${d.replace(/[\\/]+$/,"")}/`:null,m=new Set(h.flatMap(a=>a.files.map(a=>a.path))).size,n=h.reduce((a,b)=>a+b.edits,0);return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[m>8&&(0,b.jsx)(U.SearchInput,{value:f,onChange:g,placeholder:"Filter files…","aria-label":"Filter edited files",className:"w-full max-w-sm"}),(0,b.jsxs)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[bI(m,"file")," · ",bI(n,"edit")," · ",bI(h.length,"turn")]})]}),j.map(a=>(0,b.jsxs)("section",{className:"overflow-hidden rounded-xl border border-border bg-card",children:[(0,b.jsxs)("header",{className:"flex items-baseline gap-3 border-b border-border bg-muted/40 px-3 py-2",children:[(0,b.jsx)("span",{className:"shrink-0 text-xs font-medium tabular-nums text-muted-foreground",children:a.turn>0?`Turn ${a.turn}`:"Start"}),a.promptEventId?(0,b.jsx)("button",{type:"button",onClick:()=>e(a.promptEventId),title:"Open this prompt in the timeline",className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(0,X.firstLine)(a.prompt)??"Prompt"}):(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-muted-foreground",children:"Before the first prompt"}),(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[bI(a.files.length,"file")," · ",(0,X.formatDateTime)(a.timestamp)]})]}),(0,b.jsx)("ul",{children:a.files.map(a=>{let c;return(0,b.jsxs)("li",{className:"group flex items-center gap-3 border-b border-border/60 px-3 py-2 text-sm last:border-b-0 hover:bg-muted/50",children:[(0,b.jsx)("button",{type:"button",onClick:()=>e(a.eventId),title:`${a.path}
6
- Open the edit in the timeline`,className:"min-w-0 flex-1 truncate rounded-sm text-left font-mono text-[13px] hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(c=a.path,l&&c.startsWith(l)?c.slice(l.length):c)}),(0,b.jsx)("span",{className:"opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:(0,b.jsx)(s.CopyButton,{value:a.path,label:"Copy path"})}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:a.tools.join(", ")}),(0,b.jsx)("span",{className:"w-8 shrink-0 text-right text-xs tabular-nums text-muted-foreground",children:a.count>1?`\xd7${a.count}`:""})]},a.path)})})]},a.promptEventId??"start")),0===j.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No files match “",f,"”"]})]})}var bK=a.i(73946);let bL=(0,f.default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]),bM=(0,f.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);var bN=a.i(21732);let bO=(0,f.default)("folder-open",[["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"}]]),bP=(0,f.default)("folder-search",[["path",{d:"M10.7 20H4a2 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.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);var bQ=a.i(44264),bR=a.i(14300),bS=a.i(84213);let bT=(0,f.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var bU=a.i(89065),bV=a.i(63167),bW=a.i(27855);function bX({health:a,open:c,onOpenChange:d,onFocus:e}){return(0,b.jsx)(a4.Dialog,{open:c,onOpenChange:d,children:(0,b.jsxs)(a4.DialogContent,{children:[(0,b.jsx)(a4.DialogTitle,{children:"Session health"}),(0,b.jsx)(a4.DialogDescription,{children:"A rule-based score read straight off the transcript. It measures how smoothly the session ran, not whether the result was any good."}),(0,b.jsxs)("div",{className:"flex items-center gap-4",children:[(0,b.jsx)(bV.GradeBadge,{grade:a.grade,className:"h-12 min-w-12 rounded-lg text-2xl"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,b.jsx)("span",{className:"text-2xl font-bold leading-none tabular-nums",children:a.score}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"/ 100"}),(0,b.jsx)("span",{className:"ml-auto text-xs font-medium",children:bW.OUTCOME_LABELS[a.outcome]})]}),(0,b.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,$.cn)("h-full rounded-full",bW.GRADE_STYLES[a.grade].bar),style:{width:`${a.score}%`}})})]})]}),0===a.signals.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(bU.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsxs)("p",{className:"text-sm",children:["Nothing went wrong. ",bW.OUTCOME_NOTES[a.outcome]]})]}):(0,b.jsx)("ul",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:a.signals.map(c=>{let f=bW.SIGNAL_INFO[c.id];return(0,b.jsxs)("li",{className:"px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:"outcome"===c.id?bW.OUTCOME_LABELS[a.outcome]:f.label}),(0,b.jsxs)("span",{className:"shrink-0 font-mono text-xs font-semibold tabular-nums text-red-600 dark:text-red-400",children:["−",c.penalty]})]}),(0,b.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:[f.describe(c,a)," ",f.advice]}),f.focus&&e&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{d(!1),f.focus&&e(f.focus)},children:["View related events",(0,b.jsx)(bT,{"data-icon":"inline-end","aria-hidden":!0})]})]},c.id)})}),(0,b.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Every session starts at 100 and loses points for each signal above. 90 and up is an A, 80 a B, 70 a C, 60 a D; anything lower is an F.",a.toolResults>0&&0===a.toolFailures&&(0,b.jsxs)(b.Fragment,{children:[" All ",a.toolResults.toLocaleString()," tool results succeeded."]})]})]})})}var bY=a.i(80153),bZ=a.i(75775);function b$(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function b_({meta:a}){let[d,e]=(0,c.useState)(!1);async function f(){try{let b=await fetch(`/api/sessions/${a.provider}/${encodeURIComponent(a.id)}/reveal`,{method:"POST"});e(!b.ok)}catch{e(!0)}}return(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:f,className:(0,$.cn)("text-muted-foreground",d&&"text-destructive"),children:[(0,b.jsx)(bP,{className:"size-3.5","aria-hidden":!0}),"Reveal"]})}),(0,b.jsx)(S.TooltipContent,{children:d?"Could not open a file manager here. Copy the path instead.":"Show this session's files in the file manager"})]})}function b0({meta:a,storagePath:e,revealable:f=!1,stats:g,cost:h,context:i,activeMs:j,running:k=!1,onFocusEvents:l}){let m=(0,X.firstLine)(a.name),n=a.title??m,o=a.title?m:void 0,[p,q]=(0,c.useState)(!1),[r,t]=(0,c.useState)(!1),u=a.health,v=(0,bY.providerStyle)(a.provider),w=(0,bZ.resumeCommand)(a),x=g?.totalInputTokens??0,y=g?.totalOutputTokens??0,z=g?.totalCacheReadTokens??0,A=x+y+z;return(0,b.jsx)("div",{className:"border-b border-border bg-card/40",children:(0,b.jsxs)("div",{className:"mx-auto max-w-6xl px-4 py-5 sm:px-6",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("h1",{className:"text-lg font-bold leading-tight text-foreground sm:text-xl",children:n??(0,b.jsx)("span",{className:"font-normal italic text-muted-foreground",children:"Unnamed session"})}),o&&(0,b.jsx)("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:o}),(0,b.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs text-muted-foreground",children:a.id}),(0,b.jsx)(s.CopyButton,{value:a.id,label:"Copy session id"}),w&&(0,b.jsx)(s.CopyButton,{value:w,label:"Copy the command that resumes this session in a terminal",icon:bR.Terminal,className:"ml-1",children:"Resume"}),e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s.CopyButton,{value:e,label:`Copy where this session is stored: ${e}`,icon:bO,children:"Path"}),f&&(0,b.jsx)(b_,{meta:a})]})]})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[k&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-300 bg-emerald-50 px-2.5 py-0.5 text-xs font-medium text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300",children:[(0,b.jsx)("span",{className:"size-1.5 animate-pulse rounded-full bg-emerald-500","aria-hidden":!0}),"Running"]}),(0,b.jsxs)("span",{className:(0,$.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",v.badgeCls),children:[(0,b.jsx)("span",{className:(0,$.cn)("size-1.5 rounded-full",v.dotCls),"aria-hidden":!0}),v.label]}),a.model&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"font-mono",children:a.model}),a.client_name&&(0,b.jsx)(Q.Badge,{variant:"secondary",children:a.client_name}),a.host_type&&(0,b.jsx)(Q.Badge,{variant:"outline",children:a.host_type})]})]}),(0,b.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground",children:[a.project&&(0,b.jsxs)(d.default,{href:`/?tab=sessions&project=${encodeURIComponent(a.project)}`,title:a.projectPath,className:"inline-flex min-w-0 items-center gap-1.5 rounded-sm hover:text-foreground hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(bN.FolderGit2,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-medium text-foreground/80",children:a.project})]}),a.repository&&(0,b.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)(bM,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",children:a.repository})]}),a.branch&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bQ.GitBranch,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"font-mono",children:a.branch})]}),a.created_at&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bK.CalendarDays,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,X.formatFullDateTime)(a.created_at)]}),a.updated_at&&(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bL,{className:"size-3.5 opacity-70","aria-hidden":!0}),"Updated ",(0,X.timeAgo)(a.updated_at)]})}),(0,b.jsx)(S.TooltipContent,{children:(0,X.formatFullDateTime)(a.updated_at)})]})]}),g&&(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsxs)(bS.StatCardGrid,{children:[(0,b.jsx)(bS.StatCard,{label:"Events",value:g.eventCount.toLocaleString(),sub:"recorded in session"}),(0,b.jsx)(bS.StatCard,{label:"Messages",value:(g.totalUserMessages+g.totalAssistantMessages).toLocaleString(),sub:`${g.totalUserMessages} user \xb7 ${g.totalAssistantMessages} assistant`}),(0,b.jsx)(bS.StatCard,{label:"Tool calls",value:g.totalToolCalls.toLocaleString(),sub:"local + external"}),(0,b.jsx)(bS.StatCard,{label:"Total tokens",value:A>0?b$(A):"—",sub:"in + out + cache",accent:!0}),i&&(0,b.jsx)(bS.StatCard,{label:"Context",value:b$(i.latest),sub:i.peak>i.latest?`sent by the last request \xb7 peak ${b$(i.peak)}`:"sent by the last request"}),h&&(h.inherited||h.byModel.some(a=>null!==a.costUSD))&&(0,b.jsx)(bS.StatCard,{label:"Est. cost",value:`${(0,X.formatCost)(h.totalUSD)}${h.unpricedModels.length>0?"+":""}`,sub:h.unpricedModels.length>0?`excludes ${h.unpricedModels.join(", ")}`:h.inherited?`+ ${(0,X.formatCost)(h.inherited.totalUSD)} inherited`:"at API list prices",onClick:()=>q(!0)}),u&&(0,b.jsx)(bS.StatCard,{label:"Health",value:(0,bW.healthSummary)(u),sub:u.signals.length>0?`${bW.OUTCOME_LABELS[u.outcome].toLowerCase()} \xb7 ${u.signals.length} signal${1===u.signals.length?"":"s"}`:bW.OUTCOME_LABELS[u.outcome].toLowerCase(),onClick:()=>t(!0)}),x>0&&(0,b.jsx)(bS.StatCard,{label:"Input tokens",value:b$(x),sub:"fresh input"}),y>0&&(0,b.jsx)(bS.StatCard,{label:"Output tokens",value:b$(y),sub:"generated"}),z>0&&(0,b.jsx)(bS.StatCard,{label:"Cache reads",value:b$(z),sub:"reused context"}),g.totalPremiumRequests>0&&(0,b.jsx)(bS.StatCard,{label:"Premium req",value:g.totalPremiumRequests.toLocaleString(),sub:"billed requests"}),g.totalApiDurationMs>0&&(0,b.jsx)(bS.StatCard,{label:"API time",value:(0,X.formatDuration)(g.totalApiDurationMs),sub:"waiting on the model"}),null!=j&&j>0&&(0,b.jsx)(bS.StatCard,{label:"Time span",value:(0,X.formatDuration)(j),sub:"first to last event"})]}),h&&(0,b.jsx)(a9,{cost:h,open:p,onOpenChange:q}),u&&(0,b.jsx)(bX,{health:u,open:r,onOpenChange:t,onFocus:l})]})]})})}var b1=a.i(24848),b2=a.i(66535),b2=b2,b3=a.i(4888);let b4={high:{label:"High impact",Icon:b2.default,card:"border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/30",icon:"text-red-600 dark:text-red-400"},medium:{label:"Medium impact",Icon:b2.default,card:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/30",icon:"text-amber-600 dark:text-amber-400"},low:{label:"Info",Icon:J.Info,card:"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/30",icon:"text-emerald-600 dark:text-emerald-400"}},b5=["high","medium","low"];function b6({analysis:a,stats:c,eventTypeCounts:d,onFocusHint:e}){let f=[{label:"System context",note:"agent managed",chars:a.systemContextChars,bar:"bg-red-400 dark:bg-red-500",text:"text-red-700 dark:text-red-400"},{label:"Tool results",chars:a.toolResultChars,bar:"bg-amber-400 dark:bg-amber-500",text:"text-amber-700 dark:text-amber-400"},{label:"Assistant replies",chars:a.assistantChars,bar:"bg-sky-400 dark:bg-sky-500",text:"text-sky-700 dark:text-sky-400"}],g=f.reduce((a,b)=>a+b.chars,0),h=b5.flatMap(b=>a.hints.filter(a=>a.severity===b));return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("section",{children:[(0,b.jsxs)("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,b.jsx)(n,{className:"size-4 text-brand","aria-hidden":!0}),"Optimization hints",h.length>0&&(0,b.jsx)("span",{className:"rounded-sm bg-muted px-1.5 text-xs font-normal tabular-nums text-muted-foreground",children:h.length})]}),0===h.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(bU.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm text-foreground",children:"No issues detected in this session’s context usage."})]}):(0,b.jsx)("div",{className:"space-y-3",children:h.map(a=>{let c=b4[a.severity];return(0,b.jsx)("article",{className:(0,$.cn)("rounded-xl border p-4",c.card),children:(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)(c.Icon,{className:(0,$.cn)("mt-0.5 size-4 shrink-0",c.icon),"aria-hidden":!0}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a.category}),(0,b.jsx)("span",{className:"sr-only",children:c.label}),a.saving&&(0,b.jsxs)("span",{className:"rounded-sm border border-border bg-background px-1.5 py-0.5 font-mono text-xs text-foreground",children:["save ~",a.saving]})]}),(0,b.jsx)("p",{className:"mt-0.5 text-sm font-semibold text-foreground",children:a.title}),(0,b.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:a.description}),a.focus&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>a.focus&&e(a.focus),className:"mt-2.5",children:["View related events",(0,b.jsx)(bT,{"data-icon":"inline-end","aria-hidden":!0})]})]})]})},`${a.category}-${a.title}`)})})]}),(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h2",{className:"mb-4 text-sm font-semibold text-foreground",children:"Context usage breakdown"}),0===g?(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"No measurable context recorded for this session."}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:a,chars:c,bar:d})=>(0,b.jsx)("div",{className:d,style:{width:`${c/g*100}%`}},a))}),(0,b.jsx)("div",{className:"space-y-2.5",children:f.map(({label:a,note:c,chars:d,bar:e,text:f})=>{let h=Math.round(d/g*100);return(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)("div",{className:"flex w-36 shrink-0 items-center gap-2 sm:w-60",children:[(0,b.jsx)("span",{className:(0,$.cn)("size-2 shrink-0 rounded-full",e),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"truncate text-xs text-foreground",children:[a,c&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",c,")"]})]})]}),(0,b.jsx)("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,$.cn)("h-full rounded-full",e),style:{width:`${h}%`}})}),(0,b.jsxs)("span",{className:(0,$.cn)("w-20 text-right font-mono text-xs font-semibold tabular-nums",f),children:[(d/1e3).toFixed(0),"K chars"]}),(0,b.jsxs)("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[h,"%"]})]},a)})})]}),(0,b.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3 border-t border-border pt-4 sm:grid-cols-4",children:[{label:"Output tokens",value:c.totalOutputTokens>0?`${(c.totalOutputTokens/1e3).toFixed(1)}K`:"—"},{label:"Input tokens",value:c.totalInputTokens>0?`${(c.totalInputTokens/1e3).toFixed(1)}K`:"N/A (active)"},{label:"Compactions",value:String(a.compactionCount)},{label:"Hook events",value:String(a.hookEventCount)}].map(({label:a,value:c})=>(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("div",{className:"font-mono text-base font-bold tabular-nums text-foreground",children:c}),(0,b.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]},a))})]}),(0,b.jsxs)("section",{className:"grid gap-4 md:grid-cols-2",children:[(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Tool usage"}),(0,b.jsx)(b3.BarList,{items:a.topToolsByCount.map(({name:a,count:b})=>({name:a,value:b})),color:"bg-chart-3",emptyLabel:"No tool calls recorded."})]}),(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Event types"}),(0,b.jsx)(b3.BarList,{items:d,color:"bg-brand-2",limit:10,emptyLabel:"No events recorded."})]})]})]})}function b7({checkpoints:a}){let[d,e]=(0,c.useState)(new Set);return 0===a.length?(0,b.jsx)(bp.EmptyState,{icon:h,title:"No checkpoints",description:"Copilot CLI writes checkpoint files when it summarizes progress. Claude Code and Codex sessions have none."}):(0,b.jsx)("div",{className:"space-y-2",children:a.map(a=>{let c=d.has(a.name);return(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>{var b;return b=a.name,void e(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},"aria-expanded":c,className:"flex w-full items-center gap-3 bg-muted/60 px-4 py-3 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-4 shrink-0 text-muted-foreground transition-transform",c&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)(l.FileText,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-sm font-medium text-foreground",children:a.name}),a.content&&(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[a.content.length.toLocaleString()," chars"]})]}),c&&(a.content?(0,b.jsxs)("div",{className:"border-t border-border",children:[(0,b.jsx)("div",{className:"flex justify-end border-b border-border bg-background px-2 py-1",children:(0,b.jsx)(s.CopyButton,{value:a.content,label:"Copy checkpoint"})}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:a.content})})]}):(0,b.jsx)("p",{className:"border-t border-border p-4 text-sm text-muted-foreground",children:"Empty file"}))]},a.name)})})}function b8({paths:a,kind:d}){let[e,f]=(0,c.useState)(""),g=e.trim().toLowerCase(),h=g?a.filter(a=>a.toLowerCase().includes(g)):a,i="research"===d?m:l.FileText;return 0===a.length?(0,b.jsx)(bp.EmptyState,{icon:i,title:"research"===d?"No research files":"No files",description:"research"===d?"Research notes appear here when the agent saves its findings.":"No files recorded. Copilot lists its workspace files here; Claude Code and Codex list the files the session edited."}):(0,b.jsxs)("div",{className:"space-y-2",children:[a.length>8&&(0,b.jsx)(U.SearchInput,{value:e,onChange:f,placeholder:"Filter paths…","aria-label":"Filter paths",className:"w-full max-w-sm"}),h.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-sm transition-colors hover:bg-muted/50",children:[(0,b.jsx)(i,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:a}),(0,b.jsx)(s.CopyButton,{value:a,label:"Copy path"})]},a)),0===h.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No paths match “",e,"”"]})]})}let b9=["events","checkpoints","files","edits","research","workspace","cost","optimizer"];function ca({value:a}){return(0,b.jsx)("span",{className:"ml-1 rounded-sm bg-foreground/10 px-1.5 text-[11px] tabular-nums",children:a})}function cb({provider:a,id:f}){let[z,A]=(0,Z.useTabParam)(b9,"events"),[B,C]=(0,c.useState)(null),[D,E]=(0,c.useState)(!0),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(null),[J]=(0,Z.useQueryParam)("q",""),K=(0,c.useMemo)(()=>J?{nonce:0,search:J}:null,[J]),[L,M]=(0,c.useState)(J);J!==L&&(M(J),I(null));let[N,O]=(0,Z.useQueryParam)("event",""),[P,Q]=(0,c.useState)(0),R=(0,c.useRef)(null),S=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let b=!1;return(async()=>{try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`),d=c.ok?(await c.json()).revision:null,e=await fetch(`/api/sessions/${a}/${f}`);if(!e.ok)throw Error("Request failed");let g=await e.json();if(!g?.meta)throw Error("Not found");b||(R.current=d,S.current=!0,C(g))}catch{b||S.current||G("This session could not be loaded. It may have been removed.")}finally{b||E(!1)}})(),()=>{b=!0}},[a,f,P]);let[T,U]=(0,c.useState)(!1),V=(0,bZ.isRunning)(B?.meta.updated_at),[,Y]=(0,c.useState)(0),$=null!==B&&(T||V),_=B?.meta.updated_at;(0,c.useEffect)(()=>{if(!$)return;let b=!1,c=window.setInterval(async()=>{if(!document.hidden)try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`);if(!c.ok||b)return;let d=(await c.json()).revision;if(b)return;d!==R.current?Q(a=>a+1):(0,bZ.isRunning)(_)||Y(a=>a+1)}catch{}},3e3);return()=>{b=!0,window.clearInterval(c)}},[$,a,f,_]);let aa=(0,c.useMemo)(()=>{let a=new Map;for(let b of B?.events??[])a.set(b.type,(a.get(b.type)??0)+1);return Array.from(a,([a,b])=>({name:a,value:b}))},[B]),ab=(0,c.useMemo)(()=>{let{requests:a}=W(B?.events??[]);if(!(a.length<2))return{latest:a[a.length-1].contextTokens,peak:Math.max(...a.map(a=>a.contextTokens))}},[B]),ac=(0,c.useMemo)(()=>bH(B?.events??[],B?.meta.cwd).reduce((a,b)=>a+b.edits,0),[B]),ad=(0,c.useMemo)(()=>{let a=B?.events??[];if(a.length<2)return null;let b=a.map(a=>new Date(a.timestamp).getTime()).filter(a=>Number.isFinite(a));return b.length<2?null:Math.max(...b)-Math.min(...b)},[B]);function ae(a){A("events"),I({nonce:Date.now(),...a})}let[af,ag]=(0,c.useState)(null);function ah(a){O(a),A("events"),ag({eventId:a,nonce:Date.now()})}(0,c.useEffect)(()=>{if(!af||"events"!==z)return;let a=requestAnimationFrame(()=>document.querySelector(`[data-event-id="${CSS.escape(af.eventId)}"]`)?.scrollIntoView({block:"center"}));return()=>cancelAnimationFrame(a)},[af,z]);let ai="checkpoints"===z&&B?.checkpoints.length===0||"research"===z&&B?.research.length===0?"events":z,aj=B?B.meta.title??(0,X.firstLine)(B.meta.name)??B.meta.id:f;return(0,b.jsxs)("div",{className:"min-h-screen bg-background text-foreground",children:[(0,b.jsx)("div",{className:"sticky top-0 z-30 border-b border-border bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/70",children:(0,b.jsxs)("div",{className:"mx-auto flex h-[var(--cv-topbar-h)] max-w-6xl items-center gap-3 px-4 sm:px-6",children:[(0,b.jsx)(b1.SidebarTrigger,{className:"-ml-2 shrink-0"}),(0,b.jsxs)(p.Button,{variant:"ghost",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),className:"text-muted-foreground",children:[(0,b.jsx)(g,{"aria-hidden":!0}),(0,b.jsx)("span",{className:"hidden sm:inline",children:"Sessions"})]}),(0,b.jsx)("span",{className:"text-muted-foreground/50","aria-hidden":!0,children:"/"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:aj}),(0,b.jsx)(w.SearchTrigger,{className:"shrink-0"}),(0,b.jsx)(b1.ShortcutsTrigger,{className:"hidden shrink-0 sm:inline-flex"}),(0,b.jsx)(v.PalettePicker,{className:"shrink-0"}),(0,b.jsx)(x.ThemeToggle,{className:"shrink-0"}),(0,b.jsx)(y.AboutDialog,{className:"shrink-0"})]})}),D?(0,b.jsxs)("div",{className:"mx-auto max-w-6xl space-y-4 px-4 py-8 sm:px-6",children:[(0,b.jsx)(u.Skeleton,{className:"h-7 w-2/3"}),(0,b.jsx)(u.Skeleton,{className:"h-4 w-1/3"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 pt-2",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-11 w-24"},c))}),(0,b.jsx)(u.Skeleton,{className:"h-9 w-96"}),(0,b.jsx)("div",{className:"space-y-3 pt-4",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-20 w-full"},c))})]}):F||!B?(0,b.jsx)("div",{className:"mx-auto max-w-6xl px-4 py-16 sm:px-6",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)(e.AlertTriangle,{className:"size-6 text-destructive","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Session unavailable"}),(0,b.jsx)("p",{className:"max-w-sm text-xs text-muted-foreground",children:F}),(0,b.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:function(){E(!0),G(null),Q(a=>a+1)},children:"Retry"}),(0,b.jsx)(p.Button,{size:"sm",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),children:"Back to sessions"})]})]})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(b0,{meta:B.meta,storagePath:B.storagePath,revealable:B.revealable,stats:B.stats,cost:B.cost,context:ab,activeMs:ad,running:V,onFocusEvents:ae}),(0,b.jsx)("main",{id:"main",className:"mx-auto max-w-6xl px-4 pt-2 pb-5 sm:px-6",children:(0,b.jsxs)(q.Tabs,{value:ai,onValueChange:A,className:"gap-0",children:[(0,b.jsx)("div",{className:"sticky top-[var(--cv-topbar-h)] z-20 -mx-4 overflow-x-auto scrollbar-none bg-background/85 px-4 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:-mx-6 sm:px-6",children:(0,b.jsxs)(q.TabsList,{className:"w-max",children:[(0,b.jsxs)(q.TabsTrigger,{value:"events",className:"px-3",children:[(0,b.jsx)(o.Zap,{className:"size-4","aria-hidden":!0}),"Events",(0,b.jsx)(ca,{value:B.events.length})]}),B.checkpoints.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"checkpoints",className:"px-3",children:[(0,b.jsx)(h,{className:"size-4","aria-hidden":!0}),"Checkpoints",(0,b.jsx)(ca,{value:B.checkpoints.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"files",className:"px-3",children:[(0,b.jsx)(l.FileText,{className:"size-4","aria-hidden":!0}),"Files",(0,b.jsx)(ca,{value:B.files.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"edits",className:"px-3",children:[(0,b.jsx)(k,{className:"size-4","aria-hidden":!0}),"Edits",(0,b.jsx)(ca,{value:ac})]}),B.research.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"research",className:"px-3",children:[(0,b.jsx)(m,{className:"size-4","aria-hidden":!0}),"Research",(0,b.jsx)(ca,{value:B.research.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"workspace",className:"px-3",children:[(0,b.jsx)(j,{className:"size-4","aria-hidden":!0}),"Metadata"]}),(0,b.jsxs)(q.TabsTrigger,{value:"cost",className:"px-3",children:[(0,b.jsx)(i,{className:"size-4","aria-hidden":!0}),"Cost"]}),(0,b.jsxs)(q.TabsTrigger,{value:"optimizer",className:"px-3",children:[(0,b.jsx)(n,{className:"size-4","aria-hidden":!0}),"Token Optimizer",B.tokenAnalysis?.hints.some(a=>"high"===a.severity)&&(0,b.jsx)("span",{className:"ml-1 inline-flex size-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white",title:"High-impact hints",children:B.tokenAnalysis.hints.filter(a=>"high"===a.severity).length})]})]})}),(0,b.jsx)(q.TabsContent,{value:"events",children:(0,b.jsx)(a0,{events:B.events,focusRequest:H??K,targetEventId:N||void 0,forkParentHref:B.meta.forkedFrom?`/sessions/${a}/${encodeURIComponent(B.meta.forkedFrom)}`:void 0,live:T,onLiveChange:U,running:V})}),(0,b.jsx)(q.TabsContent,{value:"checkpoints",className:"pt-2",children:(0,b.jsx)(b7,{checkpoints:B.checkpoints})}),(0,b.jsx)(q.TabsContent,{value:"files",className:"pt-2",children:(0,b.jsx)(b8,{paths:B.files,kind:"file"})}),(0,b.jsx)(q.TabsContent,{value:"edits",className:"pt-2",children:(0,b.jsx)(bJ,{events:B.events,cwd:B.meta.cwd,onOpenEvent:ah})}),(0,b.jsx)(q.TabsContent,{value:"research",className:"pt-2",children:(0,b.jsx)(b8,{paths:B.research,kind:"research"})}),(0,b.jsx)(q.TabsContent,{value:"workspace",className:"pt-2",children:(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2",children:[(0,b.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:B.rawMeta.name}),B.rawMeta.content&&(0,b.jsx)(s.CopyButton,{value:B.rawMeta.content,label:`Copy ${B.rawMeta.name}`,className:"ml-auto"})]}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:B.rawMeta.content||"No session metadata found"})})]})}),(0,b.jsx)(q.TabsContent,{value:"cost",className:"pt-2",children:(0,b.jsx)(bo,{cost:B.cost,events:B.events,onOpenEvent:ah})}),(0,b.jsx)(q.TabsContent,{value:"optimizer",className:"pt-2",children:(0,b.jsx)(b6,{analysis:B.tokenAnalysis,stats:B.stats,eventTypeCounts:aa,onFocusHint:ae})})]})})]}),(0,b.jsx)(t.ScrollToTop,{})]})}a.s(["default",0,function(a){let{provider:d,id:e}=(0,c.use)(a.params);return(0,b.jsx)(c.Suspense,{children:(0,b.jsx)(cb,{provider:d,id:e},`${d}/${e}`)})}],75136)}];
5
+ }`),[i,j]=(0,c.useState)(g);return(0,b.jsx)(bc.Dialog,{open:d,onOpenChange:e,children:(0,b.jsxs)(bc.DialogContent,{className:"sm:max-w-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(bc.DialogTitle,{children:"How this cost is estimated"}),(0,b.jsx)(bc.DialogDescription,{children:"This is what the session’s tokens would cost on the pay-per-token API at list prices. It is not a bill: on a subscription or a request-based plan you pay your plan price, however many tokens a session uses."})]}),(0,b.jsx)(bg,{cost:a,totalLabel:a.inherited?"This session":"Total"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Each row is tokens ÷ 1,000,000 × rate, using the list price on the day of the request.",g&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out."]})]}),a.inherited&&(0,b.jsxs)("div",{className:"space-y-2 border-t border-border pt-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Inherited from the forked session"}),(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"This session is a fork, so it opens with a copy of its parent’s history. Those requests were made, and are counted, in the parent session; they are listed here for reference and are not part of this session’s cost or of any usage total."})]}),(0,b.jsx)(bg,{cost:a.inherited,totalLabel:"Inherited"})]}),(0,b.jsx)("dl",{className:"space-y-1.5 border-t border-border pt-3 text-xs leading-relaxed text-muted-foreground",children:be.map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("dt",{className:"inline font-medium text-foreground",children:[a,": "]}),(0,b.jsx)("dd",{className:"inline",children:c})]},a))}),(0,b.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border bg-card text-xs",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>j(!i),"aria-expanded":i,"aria-controls":"cost-dialog-prices",className:"flex w-full items-center gap-2 px-3 py-2 text-left font-medium text-foreground transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,_.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),"aria-hidden":!0}),g?"Add the missing price":"Change these prices"]}),(0,b.jsxs)("div",{id:"cost-dialog-prices",hidden:!i,className:"space-y-2 border-t border-border px-3 py-3 leading-relaxed text-muted-foreground",children:[(0,b.jsxs)("p",{children:["Save the block below as"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:a.overridePath})," ","and edit the numbers. It replaces the bundled price for the models it lists and takes effect on the next page load."]}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("pre",{className:"overflow-x-auto rounded-lg border border-border bg-muted/50 p-3 pr-10 font-mono text-[11px] leading-relaxed text-foreground",children:h}),(0,b.jsx)(s.CopyButton,{value:h,label:"Copy pricing.json",className:"absolute top-1.5 right-1.5"})]}),(0,b.jsxs)("ul",{className:"list-disc space-y-1 pl-4",children:[(0,b.jsx)("li",{children:"All prices are US dollars per million tokens."}),(0,b.jsxs)("li",{children:[(0,b.jsx)("code",{className:"font-mono text-foreground",children:"input"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"output"})," are required. ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheRead"}),","," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","are optional: the first two fall back to the input price, and ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","to ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"}),"."," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"fast"})," multiplies every price for requests made in a faster, premium speed tier."]}),(0,b.jsxs)("li",{children:["To record a price change, add a second entry with"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:'"from": "YYYY-MM-DD"'}),". Requests before that day keep the old price."]})]})]})]})]})})}let bi=Object.keys(bd);function bj({events:a,partial:d,onOpenEvent:e}){let{turns:f,totalUSD:g,inheritedUSD:h}=(0,c.useMemo)(()=>X(a),[a]),[i,j]=(0,c.useState)(null);if(f.length<2||g<=0)return null;let k=null!==i&&i<f.length?i:null,l=(0,bb.niceCeil)(Math.max(...f.map(a=>a.costUSD))),m=(0,bb.niceCeil)(g),n=f.reduce((a,b)=>b.costUSD>a.costUSD?b:a),o=a=>`${Math.round(a/g*100)}%`,p=a=>0===a?"Before the first prompt":`Turn ${a}`,q=Math.floor((f.length-1)/2),r=null===k?null:f[k],s=r?[...new Set(r.lines.map(a=>a.model))]:[],t=null===k?0:(k+.5)/f.length*100,u=f.reduce((a,b,c)=>`${a} H${c+.5} V${100-b.totalUSD/m*100}`,"M0,100")+` H${f.length}`;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Cost by turn",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"a turn is one prompt and everything the agent did to answer it"})]})}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-right text-[10px] leading-none tabular-nums text-emerald-700 dark:text-emerald-400",children:[(0,b.jsx)("span",{children:(0,Y.formatCost)(l)}),(0,b.jsx)("span",{children:(0,Y.formatCost)(l/2)}),(0,b.jsx)("span",{children:"$0"})]}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:(0,_.cn)("relative flex h-40 items-end border-b border-border",f.length>80?"gap-0":"gap-[2px]"),onMouseLeave:()=>j(null),children:[(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-dashed border-border"}),(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-dashed border-border"}),f.map((a,c)=>(0,b.jsxs)("button",{type:"button",onMouseEnter:()=>j(c),onFocus:()=>j(c),onBlur:()=>j(null),onClick:()=>e(a.eventId),"aria-label":`${p(a.turn)}: ${(0,Y.formatCost)(a.costUSD)}, ${(0,Y.formatCost)(a.totalUSD)} so far. Open in the timeline.`,className:(0,_.cn)("relative flex h-full min-w-0 flex-1 cursor-pointer flex-col justify-end focus-visible:outline-2 focus-visible:outline-ring",null!==k&&k!==c&&"opacity-50"),children:[a.compacted&&(0,b.jsx)("span",{className:"absolute top-1 left-1/2 size-1.5 -translate-x-1/2 rotate-45 bg-amber-500","aria-hidden":!0}),(0,b.jsx)("span",{className:"w-full rounded-t-[3px] bg-emerald-500/60 dark:bg-emerald-500/50",style:{height:`${a.costUSD/l*100}%`,minHeight:2*(a.costUSD>0)}})]},a.eventId)),(0,b.jsx)("svg",{className:"pointer-events-none absolute inset-0 size-full overflow-visible text-foreground",viewBox:`0 0 ${f.length} 100`,preserveAspectRatio:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:u,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})}),r&&(0,b.jsxs)("div",{role:"status",className:"pointer-events-none absolute top-full z-20 mt-2 w-80 max-w-full rounded-lg border border-border bg-popover p-3 text-xs text-popover-foreground shadow-lg",style:{left:`${t}%`,transform:`translateX(-${t}%)`},children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3 tabular-nums",children:[(0,b.jsxs)("span",{className:"font-semibold",children:[p(r.turn)," · ",(0,Y.formatCost)(r.costUSD)]}),(0,b.jsxs)("span",{className:"text-muted-foreground",children:[o(r.costUSD)," of the session"]})]}),(0,b.jsx)("p",{className:"mt-0.5 truncate text-muted-foreground",children:(0,Y.firstLine)(r.prompt)??"Requests made before the first prompt."}),(0,b.jsxs)("table",{className:"mt-2 w-full border-t border-border tabular-nums",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-[10px] text-muted-foreground",children:[(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-left font-normal",children:"Token type"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Tokens"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Rate / 1M"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Cost"})]})}),(0,b.jsx)("tbody",{children:s.map(a=>(0,b.jsxs)(c.Fragment,{children:[s.length>1&&(0,b.jsx)("tr",{children:(0,b.jsx)("th",{colSpan:4,scope:"rowgroup",className:"max-w-0 truncate pt-1.5 text-left font-mono font-semibold",children:a})}),r.lines.filter(b=>b.model===a).sort((a,b)=>bi.indexOf(a.kind)-bi.indexOf(b.kind)).map(a=>(0,b.jsxs)("tr",{children:[(0,b.jsx)("td",{className:"py-0.5",children:bd[a.kind]}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono text-muted-foreground",children:null===a.rate?"—":bf(a.rate)}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,Y.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},a))})]}),(0,b.jsxs)("p",{className:"mt-2 border-t border-border pt-1.5 tabular-nums text-muted-foreground",children:[1===s.length&&(0,b.jsxs)("span",{className:"font-mono",children:[s[0]," · "]}),r.requests," ",1===r.requests?"request":"requests"," ·"," ",(0,Y.formatCost)(r.totalUSD)," so far",r.compacted&&" · context compacted"]})]})]}),(0,b.jsxs)("div",{className:"mt-1.5 flex justify-between text-[10px] text-muted-foreground",children:[(0,b.jsx)("span",{children:p(f[0].turn)}),f.length>4&&(0,b.jsx)("span",{children:f[q].turn}),(0,b.jsx)("span",{children:f[f.length-1].turn})]})]}),(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-[10px] leading-none tabular-nums text-muted-foreground",children:[(0,b.jsx)("span",{children:(0,Y.formatCost)(m)}),(0,b.jsx)("span",{children:(0,Y.formatCost)(m/2)}),(0,b.jsx)("span",{children:"$0"})]})]}),(0,b.jsxs)("div",{className:"mt-3 space-y-1 text-xs",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[(0,b.jsxs)("span",{className:"font-medium tabular-nums",children:["Whole session · ",(0,Y.formatCost)(g),d&&"+"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-2.5 rounded-[3px] bg-emerald-500/60","aria-hidden":!0}),"cost of the turn (left axis)"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"w-3 border-t-2 border-foreground","aria-hidden":!0}),"running total (right axis)"]}),f.some(a=>a.compacted)&&(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-1.5 rotate-45 bg-amber-500","aria-hidden":!0}),"context compacted"]})]}),(0,b.jsxs)("p",{className:"truncate text-muted-foreground",children:[p(n.turn)," cost the most: ",(0,Y.formatCost)(n.costUSD),","," ",o(n.costUSD)," of the session. Hover a bar for its tokens and prices; click it to open the turn in the timeline."]}),h>0&&(0,b.jsxs)("p",{className:"text-muted-foreground",children:["Not charted: ",(0,Y.formatCost)(h)," of history copied from the forked session, shown as Inherited in the timeline. The parent session was billed for it."]})]})]})}let bk=[{key:"input",label:"Uncached input"},{key:"cacheWrite",label:"Cache write"},{key:"cacheRead",label:"Cache read"},{key:"output",label:"Output"}],bl=["Context",...bk.map(a=>a.label),"Cost"];function bm(a){return{input:a.inputTokens,cacheWrite:a.cacheWriteTokens,cacheRead:a.cacheReadTokens,output:a.outputTokens}}function bn(a){let b={tokens:{input:0,cacheWrite:0,cacheRead:0,output:0},usd:{input:null,cacheWrite:null,cacheRead:null,output:null},costUSD:null};for(let c of a){let a=bm(c);for(let{key:d}of bk){b.tokens[d]+=a[d];let e=c.usd[d];null!==e&&(b.usd[d]=(b.usd[d]??0)+e)}null!==c.costUSD&&(b.costUSD=(b.costUSD??0)+c.costUSD)}return b}function bo(a){return a>=.01?(0,Y.formatCost)(a):a<1e-4?"<$0.0001":`$${a.toFixed(4)}`}function bp({tokens:a,usd:c,unit:d,sticky:e}){return bk.map(({key:f,label:g})=>{let h=a[f],i=c[f],j=null===i?"no price":bo(i);return(0,b.jsx)(ba.TableCell,{className:(0,_.cn)("py-1.5 pr-0 pl-3 text-right",e),title:h>0?`${g}: ${h.toLocaleString()} tokens, ${j}`:void 0,children:0===h?"—":"tokens"===d?(0,Y.formatTokens)(h):null===i?(0,b.jsx)("span",{className:"font-sans",children:"no price"}):bo(i)},f)})}function bq({value:a,max:c}){return(0,b.jsxs)(ba.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",title:a.toLocaleString(),children:[(0,Y.formatTokens)(a)??"—",(0,b.jsx)("span",{className:"mt-0.5 block h-0.5 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:(0,b.jsx)("span",{className:"block h-full rounded-full bg-emerald-500/70",style:{width:`${c>0?a/c*100:0}%`}})})]})}let br="sticky top-0 z-10 bg-card shadow-[inset_0_-1px_0_var(--border)]",bs="sticky bottom-0 z-10 bg-card shadow-[inset_0_1px_0_var(--border)]";function bt({value:a,className:c}){return(0,b.jsx)(ba.TableCell,{className:(0,_.cn)("py-1.5 pr-0 pl-3 text-right text-foreground",c),children:null===a?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,Y.formatCost)(a)})}function bu({events:a,onOpenEvent:d}){let{requests:e,turns:f}=(0,c.useMemo)(()=>X(a),[a]),[g,h]=(0,c.useState)({allOpen:null,flipped:new Set}),[i,j]=(0,c.useState)("tokens"),k=(0,c.useMemo)(()=>{let a=new Map;for(let b of e){let c=a.get(b.turn);c?c.push(b):a.set(b.turn,[b])}let b=new Map(f.map(a=>[a.turn,a.prompt]));return[...a].map(([a,c])=>({turn:a,rows:c,prompt:b.get(a),totals:bn(c)}))},[e,f]);if(e.length<2)return null;let l=g.allOpen??e.length<=60,m=a=>l!==g.flipped.has(a),n=Math.max(...e.map(a=>a.contextTokens)),o=bn(e),q=new Set(e.flatMap(a=>a.models)).size>1,r=o.tokens.cacheRead>0,s=k.some(a=>m(a.turn)),t=null!==o.costUSD;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-2 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Requests",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"every call to the model, grouped by turn"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t&&(0,b.jsx)(W.Segmented,{label:"Show each token class as",value:i,onChange:j,options:[{value:"tokens",label:"Tokens"},{value:"cost",label:"Cost"}]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:()=>h({allOpen:!s,flipped:new Set}),children:s?"Collapse all":"Expand all"})]})]}),(0,b.jsxs)("p",{className:"mb-3 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:["Each tool round is its own request, and every request sends the whole conversation again."," ",(0,b.jsx)("span",{className:"text-foreground",children:"Context"})," is what one request sent: cache read (already stored), cache write (new since the last request, stored for the next) and uncached input. A turn row adds up its requests, so its cache read is the context multiplied by the number of requests, not the size of the context."]}),(0,b.jsx)("div",{className:"[&>[data-slot=table-container]]:max-h-[70vh] [&>[data-slot=table-container]]:overflow-y-auto",children:(0,b.jsxs)(ba.Table,{className:"min-w-[47rem] table-fixed text-xs",children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{}),bl.map(a=>(0,b.jsx)("col",{className:"Cost"===a?"w-20":"Uncached input"===a?"w-28":"w-24"},a))]}),(0,b.jsx)(ba.TableHeader,{children:(0,b.jsxs)(ba.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(ba.TableHead,{className:(0,_.cn)("h-8 px-0 text-muted-foreground",br),children:"Turn / request"}),bl.map(a=>(0,b.jsx)(ba.TableHead,{className:(0,_.cn)("h-8 pr-0 pl-3 text-right text-muted-foreground",br),children:a},a))]})}),(0,b.jsx)(ba.TableBody,{className:"font-mono tabular-nums",children:k.map(({turn:a,rows:f,prompt:g,totals:j})=>{let k=m(a),l=f[f.length-1];return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(ba.TableRow,{className:"border-border/60 bg-muted/40 font-semibold hover:bg-muted/60",children:[(0,b.jsx)(ba.TableCell,{className:"truncate px-0 py-1.5 font-sans",children:(0,b.jsxs)("button",{type:"button",onClick:()=>h(({allOpen:b,flipped:c})=>{let d=new Set(c);return d.delete(a)||d.add(a),{allOpen:b,flipped:d}}),"aria-expanded":k,className:"flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-left text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,_.cn)("size-3.5 shrink-0 transition-transform",k&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:"shrink-0",children:0===a?"Before the first prompt":`Turn ${a}`}),(0,b.jsxs)("span",{className:"shrink-0 font-normal tabular-nums text-muted-foreground",children:[f.length," ",1===f.length?"request":"requests"]}),(0,b.jsx)("span",{className:"min-w-0 truncate font-normal text-muted-foreground",children:(0,Y.firstLine)(g)})]})}),(0,b.jsx)(bq,{value:l.contextTokens,max:n}),(0,b.jsx)(bp,{tokens:j.tokens,usd:j.usd,unit:i}),(0,b.jsx)(bt,{value:j.costUSD})]}),k&&f.map(a=>{let c=e[a.n-2],f=r&&void 0!==c&&a.cacheReadTokens<c.contextTokens/2&&a.inputTokens+a.cacheWriteTokens>a.cacheReadTokens;return(0,b.jsxs)(ba.TableRow,{className:"group border-border/60 text-muted-foreground",children:[(0,b.jsxs)(ba.TableCell,{className:"truncate py-1.5 pr-0 pl-5",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>d(a.eventId),"aria-label":`Request ${a.n}: open in the timeline`,title:"Open in the timeline",className:"inline-flex cursor-pointer items-center gap-1 rounded-sm text-foreground underline-offset-2 hover:text-brand hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["#",a.n,(0,b.jsx)(A,{className:"size-3 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100","aria-hidden":!0})]}),q&&(0,b.jsx)("span",{className:"ml-2",children:a.models.join(", ")}),f&&(0,b.jsx)("span",{className:"ml-2 rounded-sm bg-amber-500/15 px-1.5 py-0.5 font-sans text-[10px] text-amber-700 dark:text-amber-400",title:"Little of the context came from the cache, so it was sent and stored again at the higher rate. This follows a compaction, a change to the early context, or a pause longer than the cache lifetime.",children:"cache miss"})]}),(0,b.jsx)(bq,{value:a.contextTokens,max:n}),(0,b.jsx)(bp,{tokens:bm(a),usd:a.usd,unit:i}),(0,b.jsx)(bt,{value:a.costUSD})]},a.eventId)})]},a)})}),(0,b.jsx)(ba.TableFooter,{className:"bg-transparent font-mono tabular-nums",children:(0,b.jsxs)(ba.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsxs)(ba.TableCell,{className:(0,_.cn)("truncate px-0 py-1.5 font-sans text-foreground",bs),children:["Whole session",(0,b.jsxs)("span",{className:"ml-1.5 font-normal text-muted-foreground",children:[e.length," requests, context peaked at ",(0,Y.formatTokens)(n)]})]}),(0,b.jsx)(ba.TableCell,{className:(0,_.cn)("py-1.5 pr-0 pl-3",bs)}),(0,b.jsx)(bp,{tokens:o.tokens,usd:o.usd,unit:i,sticky:bs}),(0,b.jsx)(bt,{value:o.costUSD,className:(0,_.cn)("font-semibold",bs)})]})})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground",children:["Click a request number to open it in the timeline. Hover a value for its exact token count and cost",t&&", or switch the columns between tokens and cost","."]})]})}function bv({cost:a}){let[d,e]=(0,c.useState)(!1);if(0===a.byModel.length)return null;let f=[{label:"Output",note:"replies + reasoning",usd:a.breakdown.output,bar:"bg-sky-400 dark:bg-sky-500"},{label:"Cache writes",note:"new context stored",usd:a.breakdown.cacheWrite,bar:"bg-amber-400 dark:bg-amber-500"},{label:"Cache reads",note:"context re-sent each turn",usd:a.breakdown.cacheRead,bar:"bg-emerald-400 dark:bg-emerald-500"},{label:"Uncached input",usd:a.breakdown.input,bar:"bg-red-400 dark:bg-red-500"}].filter(a=>a.usd>0),g=a.byModel.reduce((a,b)=>a+b.cacheReadTokens,0),h=a.byModel.reduce((a,b)=>a+b.inputTokens+b.cacheWriteTokens+b.cacheReadTokens,0),i=a.unpricedModels.length>0;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Estimated cost"}),(0,b.jsxs)("span",{className:"font-mono text-lg font-bold tabular-nums text-foreground",children:[(0,Y.formatCost)(a.totalUSD),i&&"+"]})]}),a.totalUSD>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:c,usd:d,bar:e})=>(0,b.jsx)("div",{className:e,style:{width:`${d/a.totalUSD*100}%`}},c))}),(0,b.jsx)("div",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:f.map(({label:c,note:d,usd:e,bar:f})=>(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:(0,_.cn)("size-2 shrink-0 rounded-full",f),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:[c,d&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",d,")"]})]}),(0,b.jsx)("span",{className:"font-mono font-semibold tabular-nums text-foreground",children:(0,Y.formatCost)(e)}),(0,b.jsxs)("span",{className:"w-9 text-right tabular-nums text-muted-foreground",children:[Math.round(e/a.totalUSD*100),"%"]})]},c))})]}),(0,b.jsx)("div",{className:"mt-4 border-t border-border pt-1.5",children:(0,b.jsxs)(ba.Table,{className:"text-xs",children:[(0,b.jsx)(ba.TableHeader,{children:(0,b.jsx)(ba.TableRow,{className:"hover:bg-transparent",children:["Model","Input","Cache write","Cache read","Output","Cost"].map((a,c)=>(0,b.jsx)(ba.TableHead,{className:(0,_.cn)("h-8 px-0 text-muted-foreground",c>0&&"pl-3 text-right"),children:a},a))})}),(0,b.jsx)(ba.TableBody,{className:"font-mono tabular-nums",children:a.byModel.map(a=>(0,b.jsxs)(ba.TableRow,{className:"border-border/60",children:[(0,b.jsx)(ba.TableCell,{className:"px-0 py-1.5 text-foreground",children:a.model}),(0,b.jsx)(ba.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,Y.formatTokens)(a.inputTokens)??"—"}),(0,b.jsx)(ba.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,Y.formatTokens)(a.cacheWriteTokens)??"—"}),(0,b.jsx)(ba.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,Y.formatTokens)(a.cacheReadTokens)??"—"}),(0,b.jsx)(ba.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,Y.formatTokens)(a.outputTokens)??"—"}),(0,b.jsx)(ba.TableCell,{className:"py-1.5 pr-0 pl-3 text-right font-semibold text-foreground",children:null===a.costUSD?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,Y.formatCost)(a.costUSD)})]},a.model))})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:[h>0&&g>0&&(0,b.jsxs)(b.Fragment,{children:[Math.round(g/h*100),"% of input was served from cache."," "]}),"API-equivalent estimate at list prices on the day of each request, not a bill: subscription and request-based plans charge differently."," ",(0,b.jsx)(p.Button,{variant:"link",onClick:()=>e(!0),"aria-haspopup":"dialog",className:"inline h-auto rounded-sm p-0 text-xs text-foreground underline underline-offset-2 hover:text-brand",children:"See the rates and arithmetic"}),i&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out; add one in"," ",(0,b.jsx)("code",{className:"font-mono",children:"~/.agent-session-inspector/pricing.json"}),"."]})]}),(0,b.jsx)(bh,{cost:a,open:d,onOpenChange:e})]})}function bw({cost:a,events:c,onOpenEvent:d}){return 0===a.byModel.length?(0,b.jsx)("p",{className:"rounded-xl border border-border bg-card p-5 text-xs text-muted-foreground",children:"This session recorded no token usage, so there is nothing to price."}):(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)(bv,{cost:a}),(0,b.jsx)(bj,{events:c,partial:a.unpricedModels.length>0,onOpenEvent:d}),(0,b.jsx)(bu,{events:c,onOpenEvent:d})]})}var bx=a.i(90892);let by=/(?<!<)<<(?!<)-?\s*(['"]?)([A-Za-z_]\w*)\1/g,bz=/^__heredoc_(\d+)__$/,bA=new Set(["sudo","command","env","time","nohup","exec","xargs"]),bB=/^(ba|z|da)?sh$/,bC=/^(python[\d.]*|node|bun|deno)$/,bD=a=>a.startsWith("-");function bE(a,b=/^-[a-zA-Z]*[ef]$|^--(expression|file)$/){let c=[],d=!1;for(let e=0;e<a.length;e++)b.test(a[e])?(d=!0,e++):bD(a[e])||""===a[e]||c.push(a[e]);return{files:c,scripted:d}}let bF=String.raw`(?:(['"\`])([^'"\`\n]+)\1|([A-Za-z_$][\w$]*))`,bG=[RegExp(String.raw`\bopen\(\s*${bF}\s*,\s*(?:mode\s*=\s*)?['"](?=[^'"]*[wax+])[rwaxbt+]+['"]`,"g"),RegExp(String.raw`\bPath\(\s*${bF}\s*\)\s*\.write_(?:text|bytes)\(`,"g"),RegExp(String.raw`\b(?:write|append)File(?:Sync)?\(\s*${bF}`,"g")],bH=/^(\/dev\/|\/tmp\/|\/private\/tmp\/|\/var\/folders\/|\/private\/var\/folders\/)/,bI=a=>""!==a&&"-"!==a&&!/[$`*?{}]/.test(a)&&!a.startsWith("~")&&!bH.test(a);function bJ(a,b){if(b.startsWith("/")||!a)return b.replace(/^(\.\/)+/,"");let c=a.split("/");for(let a of b.split("/"))".."===a?c.pop():"."!==a&&""!==a&&c.push(a);return c.join("/")}let bK=["file_path","filePath","notebook_path","path","target_file"],bL=/^(edit|write|multiedit|notebookedit|update|create|patch|apply_patch|replace|search_replace|str_replace\w*|(copilot_)?(write|edit|create|replace|insert)\w*(file|string|edit|notebook)\w*)$/i,bM=/^(bash|sh|zsh|shell|exec|exec_command|shell_command|local_shell|terminal|run_in_terminal|run_terminal_cmd|run_terminal_command\w*|run_shell_command|run_command|execute_command|container\.exec)$/i,bN=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm,bO=a=>[...new Set([...a.matchAll(bN)].map(a=>a[1].trim()))];function bP(a,b){let c=new Set;for(let b of a)"file.patch_applied"===b.type&&b.data.callId&&c.add(b.data.callId);let d=[],e={turn:0,timestamp:a[0]?.timestamp??"",files:[],edits:0},f=0,g=(a,b,c)=>{0===e.files.length&&d.push(e),e.edits++;let f=e.files.find(a=>a.path===b);f?(f.count++,f.tools.includes(c)||f.tools.push(c)):e.files.push({path:b,count:1,tools:[c],eventId:a.id})};for(let d of a)if("user.message"===d.type)e={turn:++f,prompt:"string"==typeof d.data.content?d.data.content:void 0,promptEventId:d.id,timestamp:d.timestamp,files:[],edits:0};else if("file.patch_applied"===d.type){if(!1===d.data.success)continue;for(let a of d.data.changes??[])a?.file&&g(d,a.file,"patch")}else if("tool.execution_start"===d.type){let a=function(a){let b=a.toolName??a.name;return"string"==typeof b?b:""}(d.data);if(c.has(d.data.toolCallId))continue;for(let c of bL.test(a)?function(a){let b=a.arguments,c=b&&"object"==typeof b?b:{};for(let a of bK){let b=c[a];if("string"==typeof b&&b)return[b]}let d="string"==typeof b?b:c.input??c.patch??c.patchText;return"string"!=typeof d?[]:bO(d)}(d.data):bM.test(a)?function(a,b){let c=function(a){let b=a.arguments;if("string"==typeof b)return b;let c=b&&"object"==typeof b?b:{},d=c.command??c.cmd??c.script??c.input;return"string"==typeof d?d:Array.isArray(d)&&d.every(a=>"string"==typeof a)?/^-l?c$/.test(d[1]??"")&&3===d.length?d[2]:d.join(" "):void 0}(a);if(!c)return[];let d=bO(c);return d.length>0?d:function a(b,c){let{shell:d,bodies:e}=function(a){let b=[],c=[],d=a.split("\n");for(let a=0;a<d.length;a++){let e=[];for(let f of(b.push(d[a].replace(by,(a,b,d)=>(e.push(d),`<<__heredoc_${c.length+e.length-1}__`))),e)){let b=[];for(;++a<d.length&&d[a].trim()!==f;)b.push(d[a]);c.push(b.join("\n"))}}return{shell:b.join("\n"),bodies:c}}(b),f=new Set,g=c?.replace(/\/+$/,""),h=a=>{if(!bI(a))return;let b=bJ(g,a);bH.test(b)||f.add(b)};for(let{words:b,writes:c,inputs:i}of function(a){let b=[],c={words:[],writes:[],inputs:[]},d=null,e="words",f=()=>{null!==d&&(c[e].push(d),d=null,e="words")},g=()=>{f(),(c.words.length>0||c.writes.length>0)&&b.push(c),c={words:[],writes:[],inputs:[]},e="words"};for(let b=0;b<a.length;b++){let c=a[b];if("\\"===c)"\n"!==a[++b]&&(d=(d??"")+(a[b]??""));else if("'"===c){let c=a.indexOf("'",b+1),e=c<0?a.length:c;d=(d??"")+a.slice(b+1,e),b=e}else if('"'===c){let c="";for(b++;b<a.length&&'"'!==a[b];b++)"\\"===a[b]&&b+1<a.length&&b++,c+=a[b];d=(d??"")+c}else if(" "===c||" "===c)f();else if("#"===c&&null===d)for(;b+1<a.length&&"\n"!==a[b+1];)b++;else if("&"===c&&">"===a[b+1])f();else if("\n"===c||";"===c||"|"===c||"&"===c||"("===c||")"===c)g();else if(">"===c){if(null!==d&&/^\d+$/.test(d)?d=null:f(),(">"===a[b+1]||"|"===a[b+1])&&b++,"&"===a[b+1]){b++;let c=/^[\d-]+/.exec(a.slice(b+1));if(c){b+=c[0].length;continue}}e="writes"}else if("<"===c){for(f();"<"===a[b+1]||"-"===a[b+1];)b++;e="inputs"}else d=(d??"")+c}return g(),b}(d)){let d=0;for(;d<b.length&&(/^\w+=/.test(b[d])||bA.has(b[d]));)d++;let j=b[d]?.split("/").pop()??"",k=b.slice(d+1),l=i.flatMap(a=>e[Number(bz.exec(a)?.[1])]??[]);if("cd"===j)k[0]&&bI(k[0])&&(k[0].startsWith("/")||g)&&(g=bJ(g,k[0]));else if(bB.test(j)){let b=k.findIndex(a=>/^-[a-zA-Z]*c$/.test(a));for(let c of b>=0?[k[b+1]??""]:l)a(c,g).forEach(a=>f.add(a))}else if(bC.test(j))for(let a of[...k,...l])(function(a){let b=[];for(let c of bG)for(let d of a.matchAll(c)){let c=d[2]??function(a,b,c){let d,e=b.replace(/\$/g,"\\$"),f=RegExp(String.raw`(?<![\w$.])${e}\s*=\s*(['"])([^'"\n]+)\1`,"g");for(let b of a.slice(0,c).matchAll(f))d=b[2];return d}(a,d[3],d.index);c&&b.push({index:d.index,path:c})}return b.sort((a,b)=>a.index-b.index).map(a=>a.path)})(a).forEach(h);else(function(a,b){"git"===a&&("mv"===b[0]||"rm"===b[0])&&(a=b[0],b=b.slice(1));let c=b.some(a=>/^-[a-zA-Z]*[rR]/.test(a)||"--recursive"===a);switch(a){case"tee":case"touch":case"mv":return bE(b).files;case"sed":case"gsed":{if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)||a.startsWith("--in-place")))return[];let{files:a,scripted:c}=bE(b);return c?a:a.slice(1)}case"perl":if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)))return[];return bE(b,/^-[a-zA-Z]*e$/).files;case"rm":return c?[]:bE(b).files;case"cp":return c?[]:bE(b).files.slice(-1);default:return[]}})(j,k).forEach(h);c.forEach(h)}return[...f]}(c,b)}(d.data,b):[])g(d,c,a)}return d}let bQ=(a,b)=>`${a.toLocaleString()} ${b}${1===a?"":"s"}`;function bR({events:a,cwd:d,onOpenEvent:e}){let[f,g]=(0,c.useState)(""),h=(0,c.useMemo)(()=>bP(a,d),[a,d]),i=f.trim().toLowerCase(),j=(0,c.useMemo)(()=>i?h.map(a=>({...a,files:a.files.filter(a=>a.path.toLowerCase().includes(i))})).filter(a=>a.files.length>0):h,[h,i]);if(0===h.length)return(0,b.jsx)(bx.EmptyState,{icon:k,title:"No file edits",description:"Files appear here, grouped by prompt, when the agent writes, edits or patches one, or changes one from the shell."});let l=d?`${d.replace(/[\\/]+$/,"")}/`:null,m=new Set(h.flatMap(a=>a.files.map(a=>a.path))).size,n=h.reduce((a,b)=>a+b.edits,0);return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[m>8&&(0,b.jsx)(V.SearchInput,{value:f,onChange:g,placeholder:"Filter files…","aria-label":"Filter edited files",className:"w-full max-w-sm"}),(0,b.jsxs)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[bQ(m,"file")," · ",bQ(n,"edit")," · ",bQ(h.length,"turn")]})]}),j.map(a=>(0,b.jsxs)("section",{className:"overflow-hidden rounded-xl border border-border bg-card",children:[(0,b.jsxs)("header",{className:"flex items-baseline gap-3 border-b border-border bg-muted/40 px-3 py-2",children:[(0,b.jsx)("span",{className:"shrink-0 text-xs font-medium tabular-nums text-muted-foreground",children:a.turn>0?`Turn ${a.turn}`:"Start"}),a.promptEventId?(0,b.jsx)("button",{type:"button",onClick:()=>e(a.promptEventId),title:"Open this prompt in the timeline",className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(0,Y.firstLine)(a.prompt)??"Prompt"}):(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-muted-foreground",children:"Before the first prompt"}),(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[bQ(a.files.length,"file")," · ",(0,Y.formatDateTime)(a.timestamp)]})]}),(0,b.jsx)("ul",{children:a.files.map(a=>{let c;return(0,b.jsxs)("li",{className:"group flex items-center gap-3 border-b border-border/60 px-3 py-2 text-sm last:border-b-0 hover:bg-muted/50",children:[(0,b.jsx)("button",{type:"button",onClick:()=>e(a.eventId),title:`${a.path}
6
+ Open the edit in the timeline`,className:"min-w-0 flex-1 truncate rounded-sm text-left font-mono text-[13px] hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(c=a.path,l&&c.startsWith(l)?c.slice(l.length):c)}),(0,b.jsx)("span",{className:"opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:(0,b.jsx)(s.CopyButton,{value:a.path,label:"Copy path"})}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:a.tools.join(", ")}),(0,b.jsx)("span",{className:"w-8 shrink-0 text-right text-xs tabular-nums text-muted-foreground",children:a.count>1?`\xd7${a.count}`:""})]},a.path)})})]},a.promptEventId??"start")),0===j.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No files match “",f,"”"]})]})}var bS=a.i(73946);let bT=(0,f.default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]),bU=(0,f.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);var bV=a.i(21732);let bW=(0,f.default)("folder-open",[["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"}]]),bX=(0,f.default)("folder-search",[["path",{d:"M10.7 20H4a2 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.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);var bY=a.i(44264),bZ=a.i(14300),b$=a.i(84213);let b_=(0,f.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var b0=a.i(89065),b1=a.i(63167),b2=a.i(27855);function b3({health:a,open:c,onOpenChange:d,onFocus:e}){return(0,b.jsx)(bc.Dialog,{open:c,onOpenChange:d,children:(0,b.jsxs)(bc.DialogContent,{children:[(0,b.jsx)(bc.DialogTitle,{children:"Session health"}),(0,b.jsx)(bc.DialogDescription,{children:"A rule-based score read straight off the transcript. It measures how smoothly the session ran, not whether the result was any good."}),(0,b.jsxs)("div",{className:"flex items-center gap-4",children:[(0,b.jsx)(b1.GradeBadge,{grade:a.grade,className:"h-12 min-w-12 rounded-lg text-2xl"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,b.jsx)("span",{className:"text-2xl font-bold leading-none tabular-nums",children:a.score}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"/ 100"}),(0,b.jsx)("span",{className:"ml-auto text-xs font-medium",children:b2.OUTCOME_LABELS[a.outcome]})]}),(0,b.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,_.cn)("h-full rounded-full",b2.GRADE_STYLES[a.grade].bar),style:{width:`${a.score}%`}})})]})]}),0===a.signals.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(b0.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsxs)("p",{className:"text-sm",children:["Nothing went wrong. ",b2.OUTCOME_NOTES[a.outcome]]})]}):(0,b.jsx)("ul",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:a.signals.map(c=>{let f=b2.SIGNAL_INFO[c.id];return(0,b.jsxs)("li",{className:"px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:"outcome"===c.id?b2.OUTCOME_LABELS[a.outcome]:f.label}),(0,b.jsxs)("span",{className:"shrink-0 font-mono text-xs font-semibold tabular-nums text-red-600 dark:text-red-400",children:["−",c.penalty]})]}),(0,b.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:[f.describe(c,a)," ",f.advice]}),f.focus&&e&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{d(!1),f.focus&&e(f.focus)},children:["View related events",(0,b.jsx)(b_,{"data-icon":"inline-end","aria-hidden":!0})]})]},c.id)})}),(0,b.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Every session starts at 100 and loses points for each signal above. 90 and up is an A, 80 a B, 70 a C, 60 a D; anything lower is an F.",a.toolResults>0&&0===a.toolFailures&&(0,b.jsxs)(b.Fragment,{children:[" All ",a.toolResults.toLocaleString()," tool results succeeded."]})]})]})})}var b4=a.i(80153),b5=a.i(75775);function b6(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function b7({meta:a}){let[d,e]=(0,c.useState)(!1);async function f(){try{let b=await fetch(`/api/sessions/${a.provider}/${encodeURIComponent(a.id)}/reveal`,{method:"POST"});e(!b.ok)}catch{e(!0)}}return(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:f,className:(0,_.cn)("text-muted-foreground",d&&"text-destructive"),children:[(0,b.jsx)(bX,{className:"size-3.5","aria-hidden":!0}),"Reveal"]})}),(0,b.jsx)(T.TooltipContent,{children:d?"Could not open a file manager here. Copy the path instead.":"Show this session's files in the file manager"})]})}function b8({meta:a,storagePath:e,revealable:f=!1,stats:g,cost:h,context:i,activeMs:j,running:k=!1,onFocusEvents:l}){let m=(0,Y.firstLine)(a.name),n=a.title??m,o=a.title?m:void 0,[p,q]=(0,c.useState)(!1),[r,t]=(0,c.useState)(!1),u=a.health,v=(0,b4.providerStyle)(a.provider),w=(0,b5.resumeCommand)(a),x=g?.totalInputTokens??0,y=g?.totalOutputTokens??0,z=g?.totalCacheReadTokens??0,A=x+y+z;return(0,b.jsx)("div",{className:"border-b border-border bg-card/40",children:(0,b.jsxs)("div",{className:"mx-auto max-w-6xl px-4 py-5 sm:px-6",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("h1",{className:"text-lg font-bold leading-tight text-foreground sm:text-xl",children:n??(0,b.jsx)("span",{className:"font-normal italic text-muted-foreground",children:"Unnamed session"})}),o&&(0,b.jsx)("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:o}),(0,b.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs text-muted-foreground",children:a.id}),(0,b.jsx)(s.CopyButton,{value:a.id,label:"Copy session id"}),w&&(0,b.jsx)(s.CopyButton,{value:w,label:"Copy the command that resumes this session in a terminal",icon:bZ.Terminal,className:"ml-1",children:"Resume"}),e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s.CopyButton,{value:e,label:`Copy where this session is stored: ${e}`,icon:bW,children:"Path"}),f&&(0,b.jsx)(b7,{meta:a})]})]})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[k&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-300 bg-emerald-50 px-2.5 py-0.5 text-xs font-medium text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300",children:[(0,b.jsx)("span",{className:"size-1.5 animate-pulse rounded-full bg-emerald-500","aria-hidden":!0}),"Running"]}),(0,b.jsxs)("span",{className:(0,_.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",v.badgeCls),children:[(0,b.jsx)("span",{className:(0,_.cn)("size-1.5 rounded-full",v.dotCls),"aria-hidden":!0}),v.label]}),a.model&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"font-mono",children:a.model}),a.client_name&&(0,b.jsx)(R.Badge,{variant:"secondary",children:a.client_name}),a.host_type&&(0,b.jsx)(R.Badge,{variant:"outline",children:a.host_type})]})]}),(0,b.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground",children:[a.project&&(0,b.jsxs)(d.default,{href:`/?tab=sessions&project=${encodeURIComponent(a.project)}`,title:a.projectPath,className:"inline-flex min-w-0 items-center gap-1.5 rounded-sm hover:text-foreground hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(bV.FolderGit2,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-medium text-foreground/80",children:a.project})]}),a.repository&&(0,b.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)(bU,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",children:a.repository})]}),a.branch&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bY.GitBranch,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"font-mono",children:a.branch})]}),a.created_at&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bS.CalendarDays,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,Y.formatFullDateTime)(a.created_at)]}),a.updated_at&&(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bT,{className:"size-3.5 opacity-70","aria-hidden":!0}),"Updated ",(0,Y.timeAgo)(a.updated_at)]})}),(0,b.jsx)(T.TooltipContent,{children:(0,Y.formatFullDateTime)(a.updated_at)})]})]}),g&&(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsxs)(b$.StatCardGrid,{children:[(0,b.jsx)(b$.StatCard,{label:"Events",value:g.eventCount.toLocaleString(),sub:"recorded in session"}),(0,b.jsx)(b$.StatCard,{label:"Messages",value:(g.totalUserMessages+g.totalAssistantMessages).toLocaleString(),sub:`${g.totalUserMessages} user \xb7 ${g.totalAssistantMessages} assistant`}),(0,b.jsx)(b$.StatCard,{label:"Tool calls",value:g.totalToolCalls.toLocaleString(),sub:"local + external"}),(0,b.jsx)(b$.StatCard,{label:"Total tokens",value:A>0?b6(A):"—",sub:"in + out + cache",accent:!0}),i&&(0,b.jsx)(b$.StatCard,{label:"Context",value:b6(i.latest),sub:i.peak>i.latest?`sent by the last request \xb7 peak ${b6(i.peak)}`:"sent by the last request"}),h&&(h.inherited||h.byModel.some(a=>null!==a.costUSD))&&(0,b.jsx)(b$.StatCard,{label:"Est. cost",value:`${(0,Y.formatCost)(h.totalUSD)}${h.unpricedModels.length>0?"+":""}`,sub:h.unpricedModels.length>0?`excludes ${h.unpricedModels.join(", ")}`:h.inherited?`+ ${(0,Y.formatCost)(h.inherited.totalUSD)} inherited`:"at API list prices",onClick:()=>q(!0)}),u&&(0,b.jsx)(b$.StatCard,{label:"Health",value:(0,b2.healthSummary)(u),sub:u.signals.length>0?`${b2.OUTCOME_LABELS[u.outcome].toLowerCase()} \xb7 ${u.signals.length} signal${1===u.signals.length?"":"s"}`:b2.OUTCOME_LABELS[u.outcome].toLowerCase(),onClick:()=>t(!0)}),x>0&&(0,b.jsx)(b$.StatCard,{label:"Input tokens",value:b6(x),sub:"fresh input"}),y>0&&(0,b.jsx)(b$.StatCard,{label:"Output tokens",value:b6(y),sub:"generated"}),z>0&&(0,b.jsx)(b$.StatCard,{label:"Cache reads",value:b6(z),sub:"reused context"}),g.totalPremiumRequests>0&&(0,b.jsx)(b$.StatCard,{label:"Premium req",value:g.totalPremiumRequests.toLocaleString(),sub:"billed requests"}),g.totalApiDurationMs>0&&(0,b.jsx)(b$.StatCard,{label:"API time",value:(0,Y.formatDuration)(g.totalApiDurationMs),sub:"waiting on the model"}),null!=j&&j>0&&(0,b.jsx)(b$.StatCard,{label:"Time span",value:(0,Y.formatDuration)(j),sub:"first to last event"})]}),h&&(0,b.jsx)(bh,{cost:h,open:p,onOpenChange:q}),u&&(0,b.jsx)(b3,{health:u,open:r,onOpenChange:t,onFocus:l})]})]})})}var b9=a.i(24848),ca=a.i(66535),ca=ca,cb=a.i(4888);let cc={high:{label:"High impact",Icon:ca.default,card:"border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/30",icon:"text-red-600 dark:text-red-400"},medium:{label:"Medium impact",Icon:ca.default,card:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/30",icon:"text-amber-600 dark:text-amber-400"},low:{label:"Info",Icon:K.Info,card:"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/30",icon:"text-emerald-600 dark:text-emerald-400"}},cd=["high","medium","low"];function ce({analysis:a,stats:c,eventTypeCounts:d,onFocusHint:e}){let f=[{label:"System context",note:"agent managed",chars:a.systemContextChars,bar:"bg-red-400 dark:bg-red-500",text:"text-red-700 dark:text-red-400"},{label:"Tool results",chars:a.toolResultChars,bar:"bg-amber-400 dark:bg-amber-500",text:"text-amber-700 dark:text-amber-400"},{label:"Assistant replies",chars:a.assistantChars,bar:"bg-sky-400 dark:bg-sky-500",text:"text-sky-700 dark:text-sky-400"}],g=f.reduce((a,b)=>a+b.chars,0),h=cd.flatMap(b=>a.hints.filter(a=>a.severity===b));return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("section",{children:[(0,b.jsxs)("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,b.jsx)(n,{className:"size-4 text-brand","aria-hidden":!0}),"Optimization hints",h.length>0&&(0,b.jsx)("span",{className:"rounded-sm bg-muted px-1.5 text-xs font-normal tabular-nums text-muted-foreground",children:h.length})]}),0===h.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(b0.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm text-foreground",children:"No issues detected in this session’s context usage."})]}):(0,b.jsx)("div",{className:"space-y-3",children:h.map(a=>{let c=cc[a.severity];return(0,b.jsx)("article",{className:(0,_.cn)("rounded-xl border p-4",c.card),children:(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)(c.Icon,{className:(0,_.cn)("mt-0.5 size-4 shrink-0",c.icon),"aria-hidden":!0}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a.category}),(0,b.jsx)("span",{className:"sr-only",children:c.label}),a.saving&&(0,b.jsxs)("span",{className:"rounded-sm border border-border bg-background px-1.5 py-0.5 font-mono text-xs text-foreground",children:["save ~",a.saving]})]}),(0,b.jsx)("p",{className:"mt-0.5 text-sm font-semibold text-foreground",children:a.title}),(0,b.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:a.description}),a.focus&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>a.focus&&e(a.focus),className:"mt-2.5",children:["View related events",(0,b.jsx)(b_,{"data-icon":"inline-end","aria-hidden":!0})]})]})]})},`${a.category}-${a.title}`)})})]}),(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h2",{className:"mb-4 text-sm font-semibold text-foreground",children:"Context usage breakdown"}),0===g?(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"No measurable context recorded for this session."}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:a,chars:c,bar:d})=>(0,b.jsx)("div",{className:d,style:{width:`${c/g*100}%`}},a))}),(0,b.jsx)("div",{className:"space-y-2.5",children:f.map(({label:a,note:c,chars:d,bar:e,text:f})=>{let h=Math.round(d/g*100);return(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)("div",{className:"flex w-36 shrink-0 items-center gap-2 sm:w-60",children:[(0,b.jsx)("span",{className:(0,_.cn)("size-2 shrink-0 rounded-full",e),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"truncate text-xs text-foreground",children:[a,c&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",c,")"]})]})]}),(0,b.jsx)("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,_.cn)("h-full rounded-full",e),style:{width:`${h}%`}})}),(0,b.jsxs)("span",{className:(0,_.cn)("w-20 text-right font-mono text-xs font-semibold tabular-nums",f),children:[(d/1e3).toFixed(0),"K chars"]}),(0,b.jsxs)("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[h,"%"]})]},a)})})]}),(0,b.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3 border-t border-border pt-4 sm:grid-cols-4",children:[{label:"Output tokens",value:c.totalOutputTokens>0?`${(c.totalOutputTokens/1e3).toFixed(1)}K`:"—"},{label:"Input tokens",value:c.totalInputTokens>0?`${(c.totalInputTokens/1e3).toFixed(1)}K`:"N/A (active)"},{label:"Compactions",value:String(a.compactionCount)},{label:"Hook events",value:String(a.hookEventCount)}].map(({label:a,value:c})=>(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("div",{className:"font-mono text-base font-bold tabular-nums text-foreground",children:c}),(0,b.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]},a))})]}),(0,b.jsxs)("section",{className:"grid gap-4 md:grid-cols-2",children:[(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Tool usage"}),(0,b.jsx)(cb.BarList,{items:a.topToolsByCount.map(({name:a,count:b})=>({name:a,value:b})),color:"bg-chart-3",emptyLabel:"No tool calls recorded."})]}),(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Event types"}),(0,b.jsx)(cb.BarList,{items:d,color:"bg-brand-2",limit:10,emptyLabel:"No events recorded."})]})]})]})}function cf({checkpoints:a}){let[d,e]=(0,c.useState)(new Set);return 0===a.length?(0,b.jsx)(bx.EmptyState,{icon:h,title:"No checkpoints",description:"Copilot CLI writes checkpoint files when it summarizes progress. Claude Code and Codex sessions have none."}):(0,b.jsx)("div",{className:"space-y-2",children:a.map(a=>{let c=d.has(a.name);return(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>{var b;return b=a.name,void e(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},"aria-expanded":c,className:"flex w-full items-center gap-3 bg-muted/60 px-4 py-3 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,_.cn)("size-4 shrink-0 text-muted-foreground transition-transform",c&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)(l.FileText,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-sm font-medium text-foreground",children:a.name}),a.content&&(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[a.content.length.toLocaleString()," chars"]})]}),c&&(a.content?(0,b.jsxs)("div",{className:"border-t border-border",children:[(0,b.jsx)("div",{className:"flex justify-end border-b border-border bg-background px-2 py-1",children:(0,b.jsx)(s.CopyButton,{value:a.content,label:"Copy checkpoint"})}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:a.content})})]}):(0,b.jsx)("p",{className:"border-t border-border p-4 text-sm text-muted-foreground",children:"Empty file"}))]},a.name)})})}function cg({paths:a,kind:d}){let[e,f]=(0,c.useState)(""),g=e.trim().toLowerCase(),h=g?a.filter(a=>a.toLowerCase().includes(g)):a,i="research"===d?m:l.FileText;return 0===a.length?(0,b.jsx)(bx.EmptyState,{icon:i,title:"research"===d?"No research files":"No files",description:"research"===d?"Research notes appear here when the agent saves its findings.":"No files recorded. Copilot lists its workspace files here; Claude Code and Codex list the files the session edited."}):(0,b.jsxs)("div",{className:"space-y-2",children:[a.length>8&&(0,b.jsx)(V.SearchInput,{value:e,onChange:f,placeholder:"Filter paths…","aria-label":"Filter paths",className:"w-full max-w-sm"}),h.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-sm transition-colors hover:bg-muted/50",children:[(0,b.jsx)(i,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:a}),(0,b.jsx)(s.CopyButton,{value:a,label:"Copy path"})]},a)),0===h.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No paths match “",e,"”"]})]})}let ch=["events","checkpoints","files","edits","research","workspace","cost","optimizer"];function ci({value:a}){return(0,b.jsx)("span",{className:"ml-1 rounded-sm bg-foreground/10 px-1.5 text-[11px] tabular-nums",children:a})}function cj({provider:a,id:f}){let[z,A]=(0,$.useTabParam)(ch,"events"),[B,C]=(0,c.useState)(null),[D,E]=(0,c.useState)(!0),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(null),[J]=(0,$.useQueryParam)("q",""),K=(0,c.useMemo)(()=>J?{nonce:0,search:J}:null,[J]),[L,M]=(0,c.useState)(J);J!==L&&(M(J),I(null));let[N,O]=(0,$.useQueryParam)("event",""),[P,Q]=(0,c.useState)(0),R=(0,c.useRef)(null),S=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let b=!1;return(async()=>{try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`),d=c.ok?(await c.json()).revision:null,e=await fetch(`/api/sessions/${a}/${f}`);if(!e.ok)throw Error("Request failed");let g=await e.json();if(!g?.meta)throw Error("Not found");b||(R.current=d,S.current=!0,C(g))}catch{b||S.current||G("This session could not be loaded. It may have been removed.")}finally{b||E(!1)}})(),()=>{b=!0}},[a,f,P]);let[T,U]=(0,c.useState)(!1),V=(0,b5.isRunning)(B?.meta.updated_at),[,W]=(0,c.useState)(0),Z=null!==B&&(T||V),_=B?.meta.updated_at;(0,c.useEffect)(()=>{if(!Z)return;let b=!1,c=window.setInterval(async()=>{if(!document.hidden)try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`);if(!c.ok||b)return;let d=(await c.json()).revision;if(b)return;d!==R.current?Q(a=>a+1):(0,b5.isRunning)(_)||W(a=>a+1)}catch{}},3e3);return()=>{b=!0,window.clearInterval(c)}},[Z,a,f,_]);let aa=(0,c.useMemo)(()=>{let a=new Map;for(let b of B?.events??[])a.set(b.type,(a.get(b.type)??0)+1);return Array.from(a,([a,b])=>({name:a,value:b}))},[B]),ab=(0,c.useMemo)(()=>{let{requests:a}=X(B?.events??[]);if(!(a.length<2))return{latest:a[a.length-1].contextTokens,peak:Math.max(...a.map(a=>a.contextTokens))}},[B]),ac=(0,c.useMemo)(()=>bP(B?.events??[],B?.meta.cwd).reduce((a,b)=>a+b.edits,0),[B]),ad=(0,c.useMemo)(()=>{let a=B?.events??[];if(a.length<2)return null;let b=a.map(a=>new Date(a.timestamp).getTime()).filter(a=>Number.isFinite(a));return b.length<2?null:Math.max(...b)-Math.min(...b)},[B]);function ae(a){A("events"),I({nonce:Date.now(),...a})}let[af,ag]=(0,c.useState)(null);function ah(a){O(a),A("events"),ag({eventId:a,nonce:Date.now()})}(0,c.useEffect)(()=>{if(!af||"events"!==z)return;let a=requestAnimationFrame(()=>document.querySelector(`[data-event-id="${CSS.escape(af.eventId)}"]`)?.scrollIntoView({block:"center"}));return()=>cancelAnimationFrame(a)},[af,z]);let ai="checkpoints"===z&&B?.checkpoints.length===0||"research"===z&&B?.research.length===0?"events":z,aj=B?B.meta.title??(0,Y.firstLine)(B.meta.name)??B.meta.id:f;return(0,b.jsxs)("div",{className:"min-h-screen bg-background text-foreground",children:[(0,b.jsx)("div",{className:"sticky top-0 z-30 border-b border-border bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/70",children:(0,b.jsxs)("div",{className:"mx-auto flex h-[var(--cv-topbar-h)] max-w-6xl items-center gap-3 px-4 sm:px-6",children:[(0,b.jsx)(b9.SidebarTrigger,{className:"-ml-2 shrink-0"}),(0,b.jsxs)(p.Button,{variant:"ghost",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),className:"text-muted-foreground",children:[(0,b.jsx)(g,{"aria-hidden":!0}),(0,b.jsx)("span",{className:"hidden sm:inline",children:"Sessions"})]}),(0,b.jsx)("span",{className:"text-muted-foreground/50","aria-hidden":!0,children:"/"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:aj}),(0,b.jsx)(w.SearchTrigger,{className:"shrink-0"}),(0,b.jsx)(b9.ShortcutsTrigger,{className:"hidden shrink-0 sm:inline-flex"}),(0,b.jsx)(v.PalettePicker,{className:"shrink-0"}),(0,b.jsx)(x.ThemeToggle,{className:"shrink-0"}),(0,b.jsx)(y.AboutDialog,{className:"shrink-0"})]})}),D?(0,b.jsxs)("div",{className:"mx-auto max-w-6xl space-y-4 px-4 py-8 sm:px-6",children:[(0,b.jsx)(u.Skeleton,{className:"h-7 w-2/3"}),(0,b.jsx)(u.Skeleton,{className:"h-4 w-1/3"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 pt-2",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-11 w-24"},c))}),(0,b.jsx)(u.Skeleton,{className:"h-9 w-96"}),(0,b.jsx)("div",{className:"space-y-3 pt-4",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-20 w-full"},c))})]}):F||!B?(0,b.jsx)("div",{className:"mx-auto max-w-6xl px-4 py-16 sm:px-6",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)(e.AlertTriangle,{className:"size-6 text-destructive","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Session unavailable"}),(0,b.jsx)("p",{className:"max-w-sm text-xs text-muted-foreground",children:F}),(0,b.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:function(){E(!0),G(null),Q(a=>a+1)},children:"Retry"}),(0,b.jsx)(p.Button,{size:"sm",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),children:"Back to sessions"})]})]})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(b8,{meta:B.meta,storagePath:B.storagePath,revealable:B.revealable,stats:B.stats,cost:B.cost,context:ab,activeMs:ad,running:V,onFocusEvents:ae}),(0,b.jsx)("main",{id:"main",className:"mx-auto max-w-6xl px-4 pt-2 pb-5 sm:px-6",children:(0,b.jsxs)(q.Tabs,{value:ai,onValueChange:A,className:"gap-0",children:[(0,b.jsx)("div",{className:"sticky top-[var(--cv-topbar-h)] z-20 -mx-4 overflow-x-auto scrollbar-none bg-background/85 px-4 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:-mx-6 sm:px-6",children:(0,b.jsxs)(q.TabsList,{className:"w-max",children:[(0,b.jsxs)(q.TabsTrigger,{value:"events",className:"px-3",children:[(0,b.jsx)(o.Zap,{className:"size-4","aria-hidden":!0}),"Events",(0,b.jsx)(ci,{value:B.events.length})]}),B.checkpoints.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"checkpoints",className:"px-3",children:[(0,b.jsx)(h,{className:"size-4","aria-hidden":!0}),"Checkpoints",(0,b.jsx)(ci,{value:B.checkpoints.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"files",className:"px-3",children:[(0,b.jsx)(l.FileText,{className:"size-4","aria-hidden":!0}),"Files",(0,b.jsx)(ci,{value:B.files.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"edits",className:"px-3",children:[(0,b.jsx)(k,{className:"size-4","aria-hidden":!0}),"Edits",(0,b.jsx)(ci,{value:ac})]}),B.research.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"research",className:"px-3",children:[(0,b.jsx)(m,{className:"size-4","aria-hidden":!0}),"Research",(0,b.jsx)(ci,{value:B.research.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"workspace",className:"px-3",children:[(0,b.jsx)(j,{className:"size-4","aria-hidden":!0}),"Metadata"]}),(0,b.jsxs)(q.TabsTrigger,{value:"cost",className:"px-3",children:[(0,b.jsx)(i,{className:"size-4","aria-hidden":!0}),"Cost"]}),(0,b.jsxs)(q.TabsTrigger,{value:"optimizer",className:"px-3",children:[(0,b.jsx)(n,{className:"size-4","aria-hidden":!0}),"Token Optimizer",B.tokenAnalysis?.hints.some(a=>"high"===a.severity)&&(0,b.jsx)("span",{className:"ml-1 inline-flex size-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white",title:"High-impact hints",children:B.tokenAnalysis.hints.filter(a=>"high"===a.severity).length})]})]})}),(0,b.jsx)(q.TabsContent,{value:"events",children:(0,b.jsx)(a8,{events:B.events,focusRequest:H??K,targetEventId:N||void 0,forkParentHref:B.meta.forkedFrom?`/sessions/${a}/${encodeURIComponent(B.meta.forkedFrom)}`:void 0,live:T,onLiveChange:U,running:V})}),(0,b.jsx)(q.TabsContent,{value:"checkpoints",className:"pt-2",children:(0,b.jsx)(cf,{checkpoints:B.checkpoints})}),(0,b.jsx)(q.TabsContent,{value:"files",className:"pt-2",children:(0,b.jsx)(cg,{paths:B.files,kind:"file"})}),(0,b.jsx)(q.TabsContent,{value:"edits",className:"pt-2",children:(0,b.jsx)(bR,{events:B.events,cwd:B.meta.cwd,onOpenEvent:ah})}),(0,b.jsx)(q.TabsContent,{value:"research",className:"pt-2",children:(0,b.jsx)(cg,{paths:B.research,kind:"research"})}),(0,b.jsx)(q.TabsContent,{value:"workspace",className:"pt-2",children:(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2",children:[(0,b.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:B.rawMeta.name}),B.rawMeta.content&&(0,b.jsx)(s.CopyButton,{value:B.rawMeta.content,label:`Copy ${B.rawMeta.name}`,className:"ml-auto"})]}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:B.rawMeta.content||"No session metadata found"})})]})}),(0,b.jsx)(q.TabsContent,{value:"cost",className:"pt-2",children:(0,b.jsx)(bw,{cost:B.cost,events:B.events,onOpenEvent:ah})}),(0,b.jsx)(q.TabsContent,{value:"optimizer",className:"pt-2",children:(0,b.jsx)(ce,{analysis:B.tokenAnalysis,stats:B.stats,eventTypeCounts:aa,onFocusHint:ae})})]})})]}),(0,b.jsx)(t.ScrollToTop,{})]})}a.s(["default",0,function(a){let{provider:d,id:e}=(0,c.use)(a.params);return(0,b.jsx)(c.Suspense,{children:(0,b.jsx)(cj,{provider:d,id:e},`${d}/${e}`)})}],75136)}];
7
7
 
8
8
  //# sourceMappingURL=src_app_sessions_%5Bprovider%5D_%5Bid%5D_page_tsx_0uf635h._.js.map