agent-relay-server 0.53.0 → 0.54.0

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 (131) hide show
  1. package/docs/openapi.json +1 -1
  2. package/package.json +1 -1
  3. package/public/assets/{PlanGraphPanel-C81um9s6.js → PlanGraphPanel-CQ0CH7e9.js} +2 -2
  4. package/public/assets/{PlanGraphPanel-C81um9s6.js.map → PlanGraphPanel-CQ0CH7e9.js.map} +1 -1
  5. package/public/assets/{activity-DwVgT07D.js → activity-CxnH-3Zt.js} +2 -2
  6. package/public/assets/{activity-DwVgT07D.js.map → activity-CxnH-3Zt.js.map} +1 -1
  7. package/public/assets/{agent-profiles-BZ_QdiHU.js → agent-profiles-JhWQY-pg.js} +2 -2
  8. package/public/assets/{agent-profiles-BZ_QdiHU.js.map → agent-profiles-JhWQY-pg.js.map} +1 -1
  9. package/public/assets/agents-Bn7CXOMZ.js +2 -0
  10. package/public/assets/{agents-DV5y_tF1.js.map → agents-Bn7CXOMZ.js.map} +1 -1
  11. package/public/assets/{analytics-CzmIT4LJ.js → analytics-BCVgYihk.js} +3 -3
  12. package/public/assets/{analytics-CzmIT4LJ.js.map → analytics-BCVgYihk.js.map} +1 -1
  13. package/public/assets/{automation-Bcx2SOdF.js → automation-Cu5J1Yh4.js} +2 -2
  14. package/public/assets/{automation-Bcx2SOdF.js.map → automation-Cu5J1Yh4.js.map} +1 -1
  15. package/public/assets/{badge-BR4bvEsy.js → badge-D6yb-Kia.js} +2 -2
  16. package/public/assets/{badge-BR4bvEsy.js.map → badge-D6yb-Kia.js.map} +1 -1
  17. package/public/assets/branch-state-badge-fOM74RDq.js +2 -0
  18. package/public/assets/{branch-state-badge-CzlsNakd.js.map → branch-state-badge-fOM74RDq.js.map} +1 -1
  19. package/public/assets/{button-BwqJZS4O.js → button-B-w6a1Ng.js} +2 -2
  20. package/public/assets/{button-BwqJZS4O.js.map → button-B-w6a1Ng.js.map} +1 -1
  21. package/public/assets/card-j6bjYxys.js +2 -0
  22. package/public/assets/{card-C7JtSyuM.js.map → card-j6bjYxys.js.map} +1 -1
  23. package/public/assets/{channels-By6jRWVP.js → channels-D4q8I1q-.js} +2 -2
  24. package/public/assets/{channels-By6jRWVP.js.map → channels-D4q8I1q-.js.map} +1 -1
  25. package/public/assets/chat-6QaNdZGN.js +2 -0
  26. package/public/assets/{chat-9KhGPR6T.js.map → chat-6QaNdZGN.js.map} +1 -1
  27. package/public/assets/{connectors-DzhH5WYg.js → connectors-DuWMf8KT.js} +2 -2
  28. package/public/assets/{connectors-DzhH5WYg.js.map → connectors-DuWMf8KT.js.map} +1 -1
  29. package/public/assets/{copy-button-nbDhTE0M.js → copy-button-CJDmQ9UB.js} +2 -2
  30. package/public/assets/{copy-button-nbDhTE0M.js.map → copy-button-CJDmQ9UB.js.map} +1 -1
  31. package/public/assets/{dist-BIAvrITs.js → dist-1iqvQR2q.js} +2 -2
  32. package/public/assets/{dist-BIAvrITs.js.map → dist-1iqvQR2q.js.map} +1 -1
  33. package/public/assets/{dist-MdPDPcyo.js → dist-BNF6RqQf.js} +2 -2
  34. package/public/assets/{dist-MdPDPcyo.js.map → dist-BNF6RqQf.js.map} +1 -1
  35. package/public/assets/{dist-Dvspm7RE.js → dist-Bg5mAaEO.js} +2 -2
  36. package/public/assets/{dist-Dvspm7RE.js.map → dist-Bg5mAaEO.js.map} +1 -1
  37. package/public/assets/{dist-C7UYAwBf.js → dist-BtFzbpiK.js} +2 -2
  38. package/public/assets/{dist-C7UYAwBf.js.map → dist-BtFzbpiK.js.map} +1 -1
  39. package/public/assets/{dist-svixSeDF.js → dist-CLUvHFPE.js} +2 -2
  40. package/public/assets/{dist-svixSeDF.js.map → dist-CLUvHFPE.js.map} +1 -1
  41. package/public/assets/{dist-BiVJ8IWp.js → dist-Cl4PfJEy.js} +2 -2
  42. package/public/assets/{dist-BiVJ8IWp.js.map → dist-Cl4PfJEy.js.map} +1 -1
  43. package/public/assets/dist-D1g0W-kO.js +2 -0
  44. package/public/assets/{dist-BkDVLgYg.js.map → dist-D1g0W-kO.js.map} +1 -1
  45. package/public/assets/{dist-DvLO--_O.js → dist-DLc4vQoq.js} +2 -2
  46. package/public/assets/{dist-DvLO--_O.js.map → dist-DLc4vQoq.js.map} +1 -1
  47. package/public/assets/{dist-CSISzAHD.js → dist-HMkrkMzb.js} +2 -2
  48. package/public/assets/{dist-CSISzAHD.js.map → dist-HMkrkMzb.js.map} +1 -1
  49. package/public/assets/dist-MX7mVzej.js +2 -0
  50. package/public/assets/{dist-D5y1HX8f.js.map → dist-MX7mVzej.js.map} +1 -1
  51. package/public/assets/dist-fe-f7EIl.js +2 -0
  52. package/public/assets/{dist-tX4uIBFU.js.map → dist-fe-f7EIl.js.map} +1 -1
  53. package/public/assets/{es2015-Cu7l1536.js → es2015-4dO99MHc.js} +2 -2
  54. package/public/assets/{es2015-Cu7l1536.js.map → es2015-4dO99MHc.js.map} +1 -1
  55. package/public/assets/{formatted-body-impl-tuH3hn4f.js → formatted-body-impl-CTv-ZFNo.js} +2 -2
  56. package/public/assets/{formatted-body-impl-tuH3hn4f.js.map → formatted-body-impl-CTv-ZFNo.js.map} +1 -1
  57. package/public/assets/index-Cobj8Cqd.js +21 -0
  58. package/public/assets/index-Cobj8Cqd.js.map +1 -0
  59. package/public/assets/index-D7FDcoef.css +2 -0
  60. package/public/assets/{input-YoPXrp72.js → input-EazHb1Bc.js} +2 -2
  61. package/public/assets/{input-YoPXrp72.js.map → input-EazHb1Bc.js.map} +1 -1
  62. package/public/assets/{insights-Cmkftpne.js → insights-Ucwp3dHJ.js} +2 -2
  63. package/public/assets/{insights-Cmkftpne.js.map → insights-Ucwp3dHJ.js.map} +1 -1
  64. package/public/assets/{integrations-zGR2Hmle.js → integrations-eRsF4CjO.js} +2 -2
  65. package/public/assets/{integrations-zGR2Hmle.js.map → integrations-eRsF4CjO.js.map} +1 -1
  66. package/public/assets/{lib-D8ccisdr.js → lib-C7poqE0I.js} +3 -3
  67. package/public/assets/{lib-D8ccisdr.js.map → lib-C7poqE0I.js.map} +1 -1
  68. package/public/assets/{lucide-react-ChOGD4vc.js → lucide-react-Dr0-sUx6.js} +2 -2
  69. package/public/assets/{lucide-react-ChOGD4vc.js.map → lucide-react-Dr0-sUx6.js.map} +1 -1
  70. package/public/assets/{maintenance-Dr0Y-QW1.js → maintenance-BW56fE-T.js} +2 -2
  71. package/public/assets/{maintenance-Dr0Y-QW1.js.map → maintenance-BW56fE-T.js.map} +1 -1
  72. package/public/assets/{managed-agents-Dd_CLfkU.js → managed-agents-BkFAu1Ub.js} +2 -2
  73. package/public/assets/{managed-agents-Dd_CLfkU.js.map → managed-agents-BkFAu1Ub.js.map} +1 -1
  74. package/public/assets/{markdown-preview-impl-CasNfCMM.js → markdown-preview-impl-BT43MQ7E.js} +2 -2
  75. package/public/assets/{markdown-preview-impl-CasNfCMM.js.map → markdown-preview-impl-BT43MQ7E.js.map} +1 -1
  76. package/public/assets/memory-Cw279dr5.js +2 -0
  77. package/public/assets/{memory-FCZUrHDG.js.map → memory-Cw279dr5.js.map} +1 -1
  78. package/public/assets/{messages-BVidQ6qj.js → messages-5InjjgUv.js} +2 -2
  79. package/public/assets/{messages-BVidQ6qj.js.map → messages-5InjjgUv.js.map} +1 -1
  80. package/public/assets/{orchestrators-CDLPID66.js → orchestrators-B78CQxLl.js} +2 -2
  81. package/public/assets/{orchestrators-CDLPID66.js.map → orchestrators-B78CQxLl.js.map} +1 -1
  82. package/public/assets/{overview-CBBOJR6C.js → overview-C9V2X2oo.js} +2 -2
  83. package/public/assets/{overview-CBBOJR6C.js.map → overview-C9V2X2oo.js.map} +1 -1
  84. package/public/assets/{pairs-DT1DGrb8.js → pairs-Cc3tOjXB.js} +2 -2
  85. package/public/assets/{pairs-DT1DGrb8.js.map → pairs-Cc3tOjXB.js.map} +1 -1
  86. package/public/assets/{react-dom-DgWuIw1o.js → react-dom-CQSYEHV9.js} +2 -2
  87. package/public/assets/{react-dom-DgWuIw1o.js.map → react-dom-CQSYEHV9.js.map} +1 -1
  88. package/public/assets/{security-BQgWIgl4.js → security-CpBET4KN.js} +2 -2
  89. package/public/assets/{security-BQgWIgl4.js.map → security-CpBET4KN.js.map} +1 -1
  90. package/public/assets/{select-yVL8li9x.js → select-FNVeUxFZ.js} +2 -2
  91. package/public/assets/{select-yVL8li9x.js.map → select-FNVeUxFZ.js.map} +1 -1
  92. package/public/assets/settings-CPto3TdF.js +10 -0
  93. package/public/assets/settings-CPto3TdF.js.map +1 -0
  94. package/public/assets/{store-BlsqvkSE.js → store-h-egULYA.js} +3 -3
  95. package/public/assets/{store-BlsqvkSE.js.map → store-h-egULYA.js.map} +1 -1
  96. package/public/assets/{tasks-CySWSOjp.js → tasks-BPplMcnM.js} +2 -2
  97. package/public/assets/{tasks-CySWSOjp.js.map → tasks-BPplMcnM.js.map} +1 -1
  98. package/public/assets/teams-CCeuRt7v.js +2 -0
  99. package/public/assets/{teams-DhFfsGOb.js.map → teams-CCeuRt7v.js.map} +1 -1
  100. package/public/assets/{terminal-viewer-impl-BUozTzVL.js → terminal-viewer-impl-DRlbl8Yv.js} +3 -3
  101. package/public/assets/{terminal-viewer-impl-BUozTzVL.js.map → terminal-viewer-impl-DRlbl8Yv.js.map} +1 -1
  102. package/public/assets/{use-keyboard-viewport-BY99X7eI.js → use-keyboard-viewport-Iaz6IT4p.js} +2 -2
  103. package/public/assets/{use-keyboard-viewport-BY99X7eI.js.map → use-keyboard-viewport-Iaz6IT4p.js.map} +1 -1
  104. package/public/assets/{work-queue-CYeuuHjM.js → work-queue-qtjloIIF.js} +2 -2
  105. package/public/assets/{work-queue-CYeuuHjM.js.map → work-queue-qtjloIIF.js.map} +1 -1
  106. package/public/assets/workspaces-BcnSfMmi.js +3 -0
  107. package/public/assets/{workspaces-DrJwKq9X.js.map → workspaces-BcnSfMmi.js.map} +1 -1
  108. package/public/index.html +21 -21
  109. package/src/db/message-reads.ts +60 -0
  110. package/src/mcp.ts +2 -0
  111. package/src/routes/workspaces.ts +2 -2
  112. package/src/services/register-agent.ts +4 -1
  113. package/src/services/spawn-agent.ts +15 -0
  114. package/src/spawn-command.ts +8 -0
  115. package/src/workspace-actions.ts +2 -2
  116. package/src/workspace-merge.ts +4 -1
  117. package/public/assets/agents-DV5y_tF1.js +0 -2
  118. package/public/assets/branch-state-badge-CzlsNakd.js +0 -2
  119. package/public/assets/card-C7JtSyuM.js +0 -2
  120. package/public/assets/chat-9KhGPR6T.js +0 -2
  121. package/public/assets/dist-BkDVLgYg.js +0 -2
  122. package/public/assets/dist-D5y1HX8f.js +0 -2
  123. package/public/assets/dist-tX4uIBFU.js +0 -2
  124. package/public/assets/index-BRi2QbMp.js +0 -21
  125. package/public/assets/index-BRi2QbMp.js.map +0 -1
  126. package/public/assets/index-t-8AiaRW.css +0 -2
  127. package/public/assets/memory-FCZUrHDG.js +0 -2
  128. package/public/assets/settings-C5Mg9eH8.js +0 -10
  129. package/public/assets/settings-C5Mg9eH8.js.map +0 -1
  130. package/public/assets/teams-DhFfsGOb.js +0 -2
  131. package/public/assets/workspaces-DrJwKq9X.js +0 -3
@@ -9,7 +9,7 @@
9
9
  // managed came-up-running reconcile (delegated to managed-running.ts), the single
10
10
  // status broadcast, the single timeline note, the spawned-child parent-wake, and
11
11
  // the first-registration audit row.
12
- import { createActivityEvent, getAgent, upsertAgent } from "../db";
12
+ import { createActivityEvent, getAgent, seedSpawnReplyObligation, upsertAgent } from "../db";
13
13
  import { emitAgentStatus } from "../sse";
14
14
  import { noteAgentTimelineEvent } from "../compaction-watch";
15
15
  import { notifyAgentReady } from "../agent-lifecycle-events";
@@ -59,6 +59,9 @@ export function registerAgent(input: RegisterAgentInput, ctx: AuthContext): Agen
59
59
  if (agent.ready && !existing?.ready) notifyAgentReady(agent.id);
60
60
 
61
61
  if (!existing) {
62
+ // #413 — a spawned worker with a report-back contract gets a pending reply obligation to its
63
+ // spawner so it can't idle with its verdict undelivered (vent #121). First-registration only.
64
+ seedSpawnReplyObligation(agent.id, agent.spawnedBy, metaStr(agent.meta, "spawnRequestId"));
62
65
  createActivityEvent({
63
66
  clientId: `server-agent-${agent.id}-registered`,
64
67
  kind: "state",
@@ -62,6 +62,15 @@ export interface SpawnAgentInput {
62
62
  profile?: string;
63
63
  prompt?: string;
64
64
  systemPromptAppend?: string;
65
+ /**
66
+ * #413 — does this spawn carry a report-back contract? When true, relay seeds a pending
67
+ * reply obligation from the spawner to the child at registration, so the child can't go
68
+ * idle until it delivers its result (vent #121). Defaults true for an agent-initiated spawn
69
+ * that hands the child a prompt (a coordinator handing a worker a task almost always wants
70
+ * the result back); off for system/dashboard/automation spawns (no caller to report to).
71
+ * Pass false to opt a fire-and-forget agent spawn out.
72
+ */
73
+ expectReply?: boolean;
65
74
  tags?: string[];
66
75
  capabilities?: string[];
67
76
  providerArgs?: string[];
@@ -204,6 +213,11 @@ export async function spawnAgent(input: SpawnAgentInput, ctx: AuthContext): Prom
204
213
  ...(callerTeam ? { teamId: callerTeam.id } : {}),
205
214
  });
206
215
 
216
+ // #413 — default the report-back obligation ON for an agent coordinator handing a worker a
217
+ // task (callerId + a prompt); OFF for system/dashboard/automation spawns (no caller to report
218
+ // back to). Explicit input wins, so a coordinator can opt a fire-and-forget worker out.
219
+ const expectReply = input.expectReply ?? Boolean(callerId && input.prompt && input.prompt.trim());
220
+
207
221
  const command = createCommand({
208
222
  type: "agent.spawn",
209
223
  source: "system",
@@ -225,6 +239,7 @@ export async function spawnAgent(input: SpawnAgentInput, ctx: AuthContext): Prom
225
239
  providerArgs: input.providerArgs ?? [],
226
240
  prompt: input.prompt,
227
241
  systemPromptAppend: input.systemPromptAppend,
242
+ ...(expectReply ? { expectReply } : {}),
228
243
  policyName: input.policyName,
229
244
  spawnRequestId,
230
245
  env,
@@ -91,6 +91,13 @@ interface BuildSpawnCommandOptions {
91
91
  providerArgs?: string[];
92
92
  prompt?: string;
93
93
  systemPromptAppend?: string;
94
+ /**
95
+ * #413 — when true, the child registering with this spawnRequestId gets a pending reply
96
+ * obligation back to its spawner, so the Stop hook refuses to let it idle until it delivers
97
+ * its result (closes the "spawned worker strands its verdict" gap, vent #121). Read at
98
+ * registration from the persisted spawn command params.
99
+ */
100
+ expectReply?: boolean;
94
101
  profile?: string;
95
102
  agentProfile?: unknown;
96
103
  headless?: boolean;
@@ -138,6 +145,7 @@ export function buildSpawnCommand(opts: BuildSpawnCommandOptions): Record<string
138
145
  ...def(opts.providerArgs, "providerArgs"),
139
146
  ...def(opts.prompt, "prompt"),
140
147
  ...def(opts.systemPromptAppend, "systemPromptAppend"),
148
+ ...def(opts.expectReply, "expectReply"),
141
149
  ...def(opts.headless, "headless"),
142
150
  ...def(opts.policyName, "policyName"),
143
151
  ...def(opts.automationId, "automationId"),
@@ -167,8 +167,8 @@ export function applyWorkspaceAction(workspace: WorkspaceRecord, input: ApplyWor
167
167
  const result = requestWorkspaceMerge(workspace, {
168
168
  requestedBy: agentId ?? "dashboard",
169
169
  // Pass the strategy through verbatim (undefined when unset) — the single
170
- // default lives in requestWorkspaceMerge, so both land surfaces resolve it
171
- // identically instead of each applying its own fallback (#304).
170
+ // config-aware default lives in requestWorkspaceMerge, so land surfaces
171
+ // resolve it identically instead of each applying its own fallback.
172
172
  strategy: input.strategy,
173
173
  deleteBranch: input.deleteBranch !== false,
174
174
  prTitle: input.prTitle,
@@ -176,7 +176,10 @@ export function requestWorkspaceMerge(workspace: WorkspaceRecord, opts: RequestW
176
176
  releaseMergeLease({ repoRoot: workspace.repoRoot, workspaceId: workspace.id });
177
177
  return { ok: false, status: 404, error: "workspace not found" };
178
178
  }
179
- const effectiveStrategy = opts.strategy ?? DEFAULT_MERGE_STRATEGY;
179
+ const effectiveStrategy = resolveLandStrategy({
180
+ explicit: opts.strategy,
181
+ instanceStrategy: getLandingConfig().strategy,
182
+ });
180
183
 
181
184
  // Slice 6 — issue auto-linkage: append "Closes #N" to the PR body when the
182
185
  // workspace metadata carries an issue number, WITHOUT clobbering an explicit body.
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{B as t,Dt as n,Ft as r,G as i,I as a,J as o,P as s,Tn as c,Un as l,bn as u,g as d,i as f,jn as p,kn as m,l as h,m as g,ot as _}from"./lucide-react-ChOGD4vc.js";import{o as v,t as y}from"./store-BlsqvkSE.js";import{B as b,G as x,H as ee,W as te,a as S,d as C,i as ne,n as re}from"./display-CXhnBwGf.js";import{o as w,r as T}from"./dist-CSISzAHD.js";import{t as E}from"./dist-DvLO--_O.js";import{i as D,n as O}from"./dist-MdPDPcyo.js";import{t as k}from"./dist-BiVJ8IWp.js";import{t as A}from"./dist-BIAvrITs.js";import{a as j,i as M,n as N,o as P,r as ie,s as ae,t as F}from"./es2015-Cu7l1536.js";import{a as I,i as oe,n as se,r as L,t as R}from"./dist-svixSeDF.js";import{t as z}from"./badge-BR4bvEsy.js";import{t as B}from"./button-BwqJZS4O.js";import{t as ce}from"./copy-button-nbDhTE0M.js";import{B as le,H as V,P as ue,S as H,U,V as W,d as de,g as fe,h as pe,l as me,m as he,p as ge,u as _e,x as G}from"./index-BRi2QbMp.js";import{n as ve,t as ye}from"./card-C7JtSyuM.js";import{n as be,t as xe}from"./branch-state-badge-CzlsNakd.js";var K=e(l(),1),q=p(),J=`Popover`,[Se,Ce]=D(J,[I]),Y=I(),[we,X]=Se(J),Te=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Y(t),c=K.useRef(null),[l,u]=K.useState(!1),[d,f]=k({prop:r,defaultProp:i??!1,onChange:a,caller:J});return(0,q.jsx)(oe,{...s,children:(0,q.jsx)(we,{scope:t,contentId:ae(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:K.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:K.useCallback(()=>u(!0),[]),onCustomAnchorRemove:K.useCallback(()=>u(!1),[]),modal:o,children:n})})};Te.displayName=J;var Ee=`PopoverAnchor`,De=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=X(Ee,n),a=Y(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return K.useEffect(()=>(o(),()=>s()),[o,s]),(0,q.jsx)(R,{...a,...r,ref:t})});De.displayName=Ee;var Oe=`PopoverTrigger`,ke=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=X(Oe,n),a=Y(n),o=w(t,i.triggerRef),s=(0,q.jsx)(E.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ve(i.open),...r,ref:o,onClick:O(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,q.jsx)(R,{asChild:!0,...a,children:s})});ke.displayName=Oe;var Z=`PopoverPortal`,[Ae,je]=Se(Z,{forceMount:void 0}),Me=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=X(Z,t);return(0,q.jsx)(Ae,{scope:t,forceMount:n,children:(0,q.jsx)(A,{present:n||a.open,children:(0,q.jsx)(M,{asChild:!0,container:i,children:r})})})};Me.displayName=Z;var Q=`PopoverContent`,Ne=K.forwardRef((e,t)=>{let n=je(Q,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=X(Q,e.__scopePopover);return(0,q.jsx)(A,{present:r||a.open,children:a.modal?(0,q.jsx)(Fe,{...i,ref:t}):(0,q.jsx)(Ie,{...i,ref:t})})});Ne.displayName=Q;var Pe=T(`PopoverContent.RemoveScroll`),Fe=K.forwardRef((e,t)=>{let n=X(Q,e.__scopePopover),r=K.useRef(null),i=w(t,r),a=K.useRef(!1);return K.useEffect(()=>{let e=r.current;if(e)return F(e)},[]),(0,q.jsx)(N,{as:Pe,allowPinchZoom:!0,children:(0,q.jsx)(Le,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:O(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:O(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:O(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ie=K.forwardRef((e,t)=>{let n=X(Q,e.__scopePopover),r=K.useRef(!1),i=K.useRef(!1);return(0,q.jsx)(Le,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Le=K.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=X(Q,n),p=Y(n);return ie(),(0,q.jsx)(j,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(P,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,q.jsx)(L,{"data-state":Ve(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),$=`PopoverClose`,Re=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=X($,n);return(0,q.jsx)(E.button,{type:`button`,...r,ref:t,onClick:O(e.onClick,()=>i.onOpenChange(!1))})});Re.displayName=$;var ze=`PopoverArrow`,Be=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Y(n);return(0,q.jsx)(se,{...i,...r,ref:t})});Be.displayName=ze;function Ve(e){return e?`open`:`closed`}var He=Te,Ue=ke,We=Me,Ge=Ne;function Ke({...e}){return(0,q.jsx)(He,{"data-slot":`popover`,...e})}function qe({...e}){return(0,q.jsx)(Ue,{"data-slot":`popover-trigger`,...e})}function Je({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,q.jsx)(We,{children:(0,q.jsx)(Ge,{"data-slot":`popover-content`,align:t,sideOffset:n,className:m(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Ye({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`popover-header`,className:m(`flex flex-col gap-0.5 text-sm`,e),...t})}function Xe({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`popover-title`,className:m(`font-medium`,e),...t})}function Ze({agent:e,childAgents:a=[],parentAgent:c}){let l=v();y(e=>e.set);let u=y(e=>e.switchView),f=y(e=>e.openInboxThread),p=y(e=>e.openAgentDetail),m=y(e=>e.openPairInvite),w=y(e=>e.openRename),T=y(e=>e.openConfirm),E=y(e=>e.doAgentAction),D=y(e=>e.doDeleteAgent),O=y(e=>e.openFilesForAgent),k=y(e=>e.workspaceAction),A=y(e=>e.openWorkspaceFocus),{terminalOpen:j,terminalTarget:M,terminalOpening:N,openTerminal:P,closeTerminal:ie}=be(e.id),ae=le(),F=ne(l,e,ue(e),ae[e.id]||null),I=S(e,`shutdown`),oe=S(e,`compact`),se=S(e,`clearContext`),L=!!(e.providerCapabilities?.terminal?.live?.read||e.providerCapabilities?.terminal?.attach?.create),R=!!(e.providerCapabilities?.terminal?.live?.write||e.providerCapabilities?.model?.provider===`claude`),V=re(e),U=c?C(c):e.spawnedBy,W=a.length>0;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ye,{className:`group hover:border-zinc-600 transition-colors cursor-pointer`,onClick:()=>p(e),children:(0,q.jsxs)(ve,{className:`p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5 mb-2.5`,children:[(0,q.jsx)(H,{agent:e,now:l,className:`mt-0.5`}),(0,q.jsx)(G,{agent:e}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium truncate`,children:C(e)}),(0,q.jsx)(`div`,{className:`text-xs mt-0.5 ${te(F.tone)}`,children:F.label}),typeof e.meta?.cwd==`string`&&e.meta.cwd&&(0,q.jsx)(`button`,{type:`button`,className:`mt-0.5 block max-w-full truncate font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:`Open ${e.meta.cwd} in Files`,onClick:t=>{t.stopPropagation(),O(e)},children:b(e.meta.cwd)})]}),e.branchState&&e.branchWorkspaceId&&(0,q.jsx)(xe,{state:e.branchState,className:`mt-0.5 shrink-0`,onClick:t=>{t.stopPropagation(),A(e.branchWorkspaceId)}})]}),F.badges.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:F.badges.map(e=>(0,q.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full font-medium ${e.className}`,children:e.label},e.label))}),(W||e.spawnedBy&&U)&&(0,q.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,onClick:e=>e.stopPropagation(),children:[W&&(0,q.jsxs)(Ke,{children:[(0,q.jsx)(qe,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 max-w-full items-center gap-1.5 rounded-full border border-sky-500/30 bg-sky-500/10 px-2 text-[10px] font-medium text-sky-300 transition-colors hover:bg-sky-500/15`,title:`${a.length} live child ${a.length===1?`agent`:`agents`}`,children:[(0,q.jsx)(h,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:a.length}),(0,q.jsx)(`span`,{className:`flex -space-x-1`,children:a.slice(0,4).map(e=>(0,q.jsx)(H,{agent:e,now:l,className:`h-2 w-2 ring-1 ring-background`},e.id))})]})}),(0,q.jsxs)(Je,{align:`start`,className:`w-80`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(Ye,{children:(0,q.jsx)(Xe,{children:`Team`})}),(0,q.jsx)(`div`,{className:`space-y-1.5`,children:a.map(e=>(0,q.jsxs)(`div`,{className:`rounded-md border border-border bg-card/60 p-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(H,{agent:e,now:l,className:`mt-1`}),(0,q.jsx)(G,{agent:e}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-xs font-medium`,children:C(e)}),(0,q.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.providerCapabilities?.model?.alias||e.providerCapabilities?.model?.id||e.providerCapabilities?.model?.provider||e.status})]}),(0,q.jsx)(z,{variant:`outline`,className:`h-4 px-1.5 text-[9px]`,children:e.status})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex gap-1`,children:[(0,q.jsx)(B,{size:`xs`,variant:`outline`,onClick:()=>p(e),children:`Open`}),(0,q.jsxs)(B,{size:`xs`,variant:`ghost`,onClick:()=>{f(e.id),u(`chat`)},children:[(0,q.jsx)(o,{className:`h-3 w-3`}),`Chat`]})]})]},e.id))})]})]}),e.spawnedBy&&U&&(0,q.jsx)(z,{variant:`outline`,className:`max-w-full text-[10px] text-muted-foreground`,children:(0,q.jsxs)(`span`,{className:`truncate`,children:[`spawned by `,U]})})]}),(e.tags.length>0||x(e.capabilities).length>0)&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:[e.tags.slice(0,3).map(e=>(0,q.jsx)(z,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e)),x(e.capabilities).slice(0,2).map(e=>(0,q.jsx)(z,{variant:`secondary`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))]}),(0,q.jsxs)(`div`,{className:`space-y-2 mb-2`,children:[(0,q.jsx)(pe,{agent:e}),(0,q.jsx)(he,{agent:e,compact:!0}),(0,q.jsx)(fe,{agent:e})]}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.id!==`user`&&e.id!==`system`&&ee(l,e.lastSeen)}),(0,q.jsxs)(`div`,{className:`flex gap-1 mt-2.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(ce,{value:e.id,label:`Copy agent ID`,size:`icon`,className:`h-7 w-7`,iconClassName:`w-3 h-3`}),(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Chat`,onClick:()=>{f(e.id),u(`chat`)},children:(0,q.jsx)(o,{className:`w-3 h-3`})}),(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Pair`,onClick:()=>m(e.id),children:(0,q.jsx)(_,{className:`w-3 h-3`})}),(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Rename`,onClick:()=>w(e),children:(0,q.jsx)(t,{className:`w-3 h-3`})}),L&&(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Terminal`,disabled:N,onClick:()=>void P(),children:(0,q.jsx)(d,{className:`w-3 h-3`})}),(e.branchState===`changes`||e.branchState===`idle`)&&e.branchWorkspaceId&&(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7 text-amber-400 hover:text-amber-300`,title:`Mark workspace ready — hand off to the auto-merge`,onClick:()=>T(`Mark Workspace Ready`,`Mark ${C(e)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>k(e.branchWorkspaceId,`ready`)),children:(0,q.jsx)(n,{className:`w-3 h-3`})}),oe&&(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Compact`,onClick:()=>T(`Compact Agent`,`Compact context for ${C(e)}?`,()=>E(e,`compact`,`agents-grid`)),children:(0,q.jsx)(i,{className:`w-3 h-3`})}),se&&(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Clear Context`,onClick:()=>T(`Clear Context`,`Clear context for ${C(e)}?`,()=>E(e,`clearContext`,`agents-grid`)),children:(0,q.jsx)(r,{className:`w-3 h-3`})}),I&&(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7 text-red-400 hover:text-red-300`,title:`Shutdown`,onClick:()=>T(`Shutdown Agent`,`Shutdown ${C(e)}?`,()=>E(e,`shutdown`,`agents-grid`)),children:(0,q.jsx)(s,{className:`w-3 h-3`})}),V&&(0,q.jsx)(B,{size:`icon`,variant:`ghost`,className:`h-7 w-7 text-red-400 hover:text-red-300`,title:`Forget stale agent`,onClick:()=>T(`Forget Agent`,`Forget ${C(e)}?`,()=>D(e.id)),children:(0,q.jsx)(g,{className:`w-3 h-3`})})]})]})}),M&&(0,q.jsx)(ge,{open:j,onOpenChange:ie,orchestratorId:M.orchestratorId,session:M.session,interactive:M.interactive||R})]})}function Qe(){let e=y(e=>e.agentPresetFilter),t=y(e=>e.agentStatusFilter),n=y(e=>e.agentTagFilter),r=y(e=>e.agentHostFilter),i=y(e=>e.agentSort),o=y(e=>e.agentSortDir),s=y(e=>e.showOffline),l=y(e=>e.set),d=y(e=>e.openAgentSpawn),p=y(e=>e.agentsById),m=v(),h=W(),g=U(),_=V(),b=me(h,m),x=de(h,m),ee=e||t||n||r;function te(){l({agentPresetFilter:``,agentStatusFilter:``,agentTagFilter:``,agentHostFilter:``})}function S(){l({agentSortDir:o===`asc`?`desc`:`asc`})}return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`select`,{value:e,onChange:e=>l({agentPresetFilter:e.target.value}),className:`h-8 rounded-md border border-border bg-card text-sm px-2 text-foreground`,children:[(0,q.jsx)(`option`,{value:``,children:`All agents`}),(0,q.jsx)(`option`,{value:`active`,children:`Active`}),(0,q.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,q.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,q.jsx)(`option`,{value:`paired`,children:`Paired`}),(0,q.jsx)(`option`,{value:`unpaired`,children:`Unpaired`}),(0,q.jsx)(`option`,{value:`offline_stale`,children:`Offline / Stale`})]}),(0,q.jsxs)(`select`,{value:t,onChange:e=>l({agentStatusFilter:e.target.value}),className:`h-8 rounded-md border border-border bg-card text-sm px-2 text-foreground`,children:[(0,q.jsx)(`option`,{value:``,children:`Any status`}),(0,q.jsx)(`option`,{value:`online`,children:`Online`}),(0,q.jsx)(`option`,{value:`idle`,children:`Idle`}),(0,q.jsx)(`option`,{value:`busy`,children:`Busy`}),(0,q.jsx)(`option`,{value:`offline`,children:`Offline`}),(0,q.jsx)(`option`,{value:`starting`,children:`Starting`})]}),g.length>0&&(0,q.jsxs)(`select`,{value:n,onChange:e=>l({agentTagFilter:e.target.value}),className:`h-8 rounded-md border border-border bg-card text-sm px-2 text-foreground`,children:[(0,q.jsx)(`option`,{value:``,children:`Any tag`}),g.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]}),_.length>1&&(0,q.jsxs)(`select`,{value:r,onChange:e=>l({agentHostFilter:e.target.value}),className:`h-8 rounded-md border border-border bg-card text-sm px-2 text-foreground`,children:[(0,q.jsx)(`option`,{value:``,children:`Any host`}),_.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]}),(0,q.jsxs)(`select`,{value:i,onChange:e=>l({agentSort:e.target.value}),className:`h-8 rounded-md border border-border bg-card text-sm px-2 text-foreground`,children:[(0,q.jsx)(`option`,{value:`status`,children:`Sort: Status`}),(0,q.jsx)(`option`,{value:`name`,children:`Sort: Name`}),(0,q.jsx)(`option`,{value:`lastSeen`,children:`Sort: Last seen`}),(0,q.jsx)(`option`,{value:`created`,children:`Sort: Created`})]}),(0,q.jsx)(B,{size:`icon`,variant:`outline`,className:`h-8 w-8`,title:`Toggle sort direction`,onClick:S,children:o===`asc`?(0,q.jsx)(u,{className:`w-3.5 h-3.5`}):(0,q.jsx)(c,{className:`w-3.5 h-3.5`})}),(0,q.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground cursor-pointer select-none`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>l({showOffline:e.target.checked}),className:`rounded`}),`Show offline`]}),ee&&(0,q.jsxs)(B,{size:`sm`,variant:`ghost`,className:`h-8 text-muted-foreground hover:text-foreground gap-1`,onClick:te,children:[(0,q.jsx)(f,{className:`w-3 h-3`}),`Clear filters`]}),(0,q.jsx)(`div`,{className:`ml-auto`,children:(0,q.jsxs)(B,{size:`sm`,onClick:d,className:`gap-1`,children:[(0,q.jsx)(a,{className:`w-3.5 h-3.5`}),`Spawn`]})})]}),x.length===0?(0,q.jsx)(`div`,{className:`text-center py-16 text-muted-foreground text-sm`,children:`No agents match the current filters.`}):(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-3`,children:x.map(e=>(0,q.jsx)(Ze,{agent:e,parentAgent:e.spawnedBy?p[e.spawnedBy]??null:null,childAgents:_e(b.get(e.id)??[])},e.id))})]})}export{Qe as AgentsView};
2
- //# sourceMappingURL=agents-DV5y_tF1.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,Jt as n,Mn as r,Un as i,a,bt as o,jn as s,kn as c,p as l}from"./lucide-react-ChOGD4vc.js";import{t as u}from"./store-BlsqvkSE.js";var d=e(i(),1);function f(e){let t=u(e=>e.showError),[n,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1);async function l(){if(!(!e||s)){c(!0);try{o(await r(`POST`,`/agents/`+encodeURIComponent(e)+`/terminal-session`)),i(!0)}catch(e){t(`Terminal Failed`,e.message)}finally{c(!1)}}}function f(t){if(t){i(!0);return}i(!1);let n=a;o(null),e&&n?.mode===`guest`&&r(`DELETE`,`/agents/`+encodeURIComponent(e)+`/terminal-session/`+encodeURIComponent(n.session)).catch(()=>{})}return{terminalOpen:n,terminalTarget:a,terminalOpening:s,openTerminal:l,closeTerminal:f}}var p=s(),m={idle:{label:`idle`,tip:`Branch worktree — nothing to land yet.`,className:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,Icon:n},changes:{label:`changes`,tip:`Unlanded work in this branch — use "Mark workspace ready" to land it.`,className:`bg-amber-500/10 text-amber-400 border-amber-500/20`,Icon:o},ready:{label:`ready`,tip:`Handed off — the relay auto-merge will land it (~2 min sweep).`,className:`bg-blue-500/10 text-blue-400 border-blue-500/20`,Icon:t},steward:{label:`steward`,tip:`Under reconciliation — a steward is landing it. No action needed.`,className:`bg-orange-500/10 text-orange-400 border-orange-500/20`,Icon:a},blocked:{label:`blocked`,tip:`Escalated — the auto-merge/steward path is stuck. Needs human attention.`,className:`bg-red-500/10 text-red-400 border-red-500/20`,Icon:l}};function h({state:e,onClick:t,iconOnly:n=!1,className:r}){let i=m[e],{Icon:a}=i,o=!!t,s=o?`${i.tip} Click to open this workspace.`:i.tip;return(0,p.jsxs)(`span`,{role:o?`button`:void 0,tabIndex:o?0:void 0,title:s,onClick:t,onKeyDown:o?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t?.(e))}:void 0,className:c(`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium leading-none`,i.className,o&&`cursor-pointer hover:brightness-125 focus:outline-none focus:ring-1 focus:ring-current`,r),children:[(0,p.jsx)(a,{className:`h-2.5 w-2.5 shrink-0`}),!n&&(0,p.jsx)(`span`,{children:i.label})]})}export{f as n,h as t};
2
- //# sourceMappingURL=branch-state-badge-CzlsNakd.js.map
@@ -1,2 +0,0 @@
1
- import"./chunk-CilyBKbf.js";import{Un as e,jn as t,kn as n}from"./lucide-react-ChOGD4vc.js";e();var r=t();function i({className:e,size:t=`default`,...i}){return(0,r.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:n(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...i})}function a({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`card-header`,className:n(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`card-title`,className:n(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`card-content`,className:n(`px-4 group-data-[size=sm]/card:px-3`,e),...t})}export{o as i,s as n,a as r,i as t};
2
- //# sourceMappingURL=card-C7JtSyuM.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{D as t,Dt as n,E as r,En as i,Et as a,Ft as o,G as s,Gt as c,H as l,I as u,In as d,It as f,J as p,Jt as m,K as h,Lt as g,Mn as _,Nn as v,P as y,Sn as b,Tn as x,Un as S,Vt as C,Yt as w,Z as T,an as E,at as D,b as ee,bn as te,c as ne,en as O,et as re,fn as ie,g as ae,hn as oe,i as se,in as ce,it as le,jn as ue,kn as k,kt as de,nn as fe,on as pe,r as me,rn as he,s as ge,tn as _e,tt as ve,x as ye,yt as be}from"./lucide-react-ChOGD4vc.js";import{t as xe}from"./react-dom-DgWuIw1o.js";import{d as Se,f as Ce,l as we,n as Te,o as Ee,p as De,t as A}from"./store-BlsqvkSE.js";import{A as Oe,B as ke,D as Ae,F as j,G as je,H as Me,I as Ne,K as Pe,R as Fe,U as Ie,Z as Le,_ as Re,a as ze,d as Be,h as Ve,j as He,k as Ue,o as We,r as Ge,rt as Ke,w as qe}from"./display-CXhnBwGf.js";import{t as Je}from"./badge-BR4bvEsy.js";import{t as M}from"./button-BwqJZS4O.js";import{t as Ye}from"./input-YoPXrp72.js";import{t as Xe}from"./copy-button-nbDhTE0M.js";import{A as Ze,C as Qe,D as $e,F as et,H as tt,O as nt,S as rt,_ as it,a as at,b as ot,c as st,h as ct,i as lt,j as ut,k as dt,o as ft,p as pt,r as mt,t as ht,v as gt,w as _t,x as vt,y as yt}from"./index-BRi2QbMp.js";import{t as bt}from"./use-keyboard-viewport-BY99X7eI.js";import{n as xt,t as St}from"./branch-state-badge-CzlsNakd.js";import{t as Ct}from"./PlanGraphPanel-C81um9s6.js";var N=e(S(),1);function wt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Tt(e,t){if(t.startsWith(`/`))return t;let n=`${e.replace(/\/+$/,``)}/${t}`.split(`/`),r=[];for(let e of n)!e||e===`.`||(e===`..`?r.pop():r.push(e));return`/`+r.join(`/`)}function Et(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):`/`}function Dt(e,t){return e.filter(e=>e.status===`online`&&j(t,e.baseDir)).sort((e,t)=>Oe(t.baseDir).length-Oe(e.baseDir).length)[0]||e.find(e=>e.status===`online`)}function Ot(){return typeof window<`u`&&window.matchMedia(`(min-width: 1280px)`).matches}function kt(){return typeof window<`u`&&!!window.getSelection()?.toString()}function At(e){let t=e.payload?.attachments;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&typeof e.artifactId==`string`)):[]}var jt=[`👍`,`❤️`,`✅`,`👀`];function Mt(e){let t=new Map;for(let n of e.reactions||[]){let e=He(n.emoji),r=t.get(e)??{emoji:e,count:0,mine:!1,actors:[]};r.count+=1,r.mine=r.mine||n.actorId===`user`,r.actors.push(n.actorId),t.set(e,r)}return[...t.values()].sort((e,t)=>t.count-e.count||e.emoji.localeCompare(t.emoji))}function Nt(e){return qe(e)}function Pt(e,t){let n=e.readBy||[],r=e.resolvedToAgent||t||e.to,i=r?n.includes(r):!1,a=n.some(e=>e!==Ke);if(i||a){let e=i?r:n.find(e=>e!==Ke);return{label:`read`,title:e?`Read by ${e}`:`Read by agent`,tone:`ok`,icon:pe}}if(e.deliveryStatus===`delivered`)return{label:`delivered`,title:`Delivered to agent inbox`,tone:`ok`,icon:pe};if(e.deliveryStatus===`queued`)return{label:`queued`,title:`Queued until the target agent is available`,tone:`warn`,icon:c};if(e.deliveryStatus===`failed`||e.deliveryStatus===`dead`){let t=e.deliveryPoisonReason||e.deliveryLastError||e.deliveryStatus;return{label:e.deliveryStatus,title:t,tone:`danger`,icon:O}}return{label:`sent`,title:`Accepted by Relay`,tone:`muted`,icon:E}}function Ft(e){let t=Ie(e.createdAt);return(e.reactions||[]).reduce((e,t)=>Math.max(e,Ie(t.updatedAt||t.createdAt)),t)}function It(e){return e?e.messages.reduce((e,t)=>Math.max(e,Ft(t)),0):0}function Lt(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Rt(e){for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)}function zt(e,t,n,r){if(e?.teamId)return{teamId:e.teamId};let i=[...t];n&&!i.some(e=>e.id===n.id)&&i.push(n);let a=i.filter(e=>e.threadId).reverse(),o=a.find(e=>!!r[Te(e.threadId,e.channel)])??a[0];return o?.threadId?{threadId:o.threadId,...o.channel?{channel:o.channel}:{}}:null}function Bt(){let e=A(e=>e.agents),t=A(e=>e.showBuiltIns),n=A(e=>e.showOffline),r=A(e=>e.chatAgentSearch),i=A(e=>e.chatAgentProviderFilter),a=A(e=>e.chatAgentStatusFilter),o=A(e=>e.chatAgentTagFilter),s=A(e=>e.chatAgentCapFilter),c=A(e=>e.chatAgentHostFilter),l=A(e=>e.chatAgentSort),u=A(e=>e.chatAgentSortDir),d=A(e=>e.managedPolicies);return(0,N.useMemo)(()=>{let f=Pe(e,t,d);if(n||(f=f.filter(e=>e.status!==`offline`)),r){let e=r.toLowerCase();f=f.filter(t=>t.id.toLowerCase().includes(e)||(t.name||``).toLowerCase().includes(e)||(t.label||``).toLowerCase().includes(e)||(t.tags||[]).some(t=>t.toLowerCase().includes(e))||(t.capabilities||[]).some(t=>t.toLowerCase().includes(e)))}i&&(f=f.filter(e=>We(e)===i)),a&&(f=f.filter(e=>e.status===a)),o&&(f=f.filter(e=>(e.tags||[]).includes(o))),s&&(f=f.filter(e=>(e.capabilities||[]).includes(s))),c&&(f=f.filter(e=>(e.machine||``)===c));let p=u===`desc`?-1:1;return[...f].sort((e,t)=>l===`name`?Be(e).localeCompare(Be(t))*p:l===`lastSeen`?(Ie(t.lastSeen)-Ie(e.lastSeen))*p||Be(e).localeCompare(Be(t)):((Le[e.status]??9)-(Le[t.status]??9))*p||Be(e).localeCompare(Be(t)))},[e,t,n,d,r,i,a,o,s,c,l,u])}var P=ue();function Vt({threads:e,onSelectAgent:n}){let r=A(e=>e.set),i=A(e=>e.openInboxThread),a=A(e=>e.openAgentSpawn),o=A(e=>e.selectedInboxThread),s=A(e=>e.chatAgentSearch),c=A(e=>e.chatAgentSort),l=A(e=>e.chatAgentSortDir),d=A(e=>e.chatAgentProviderFilter),f=A(e=>e.chatAgentStatusFilter),p=A(e=>e.chatAgentTagFilter),m=A(e=>e.chatAgentCapFilter),h=A(e=>e.chatAgentHostFilter),g=A(e=>e.chatAgentGroupBy),_=A(e=>e.chatAgentFiltersCollapsed),v=A(e=>e.agentsById),y=Ee(),b=Bt(),S=(0,N.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.peer,n);return t},[e]),w=(0,N.useMemo)(()=>{if(c!==`lastMessage`)return b;let e=l===`desc`?-1:1;return[...b].sort((t,n)=>{let r=It(S.get(t.id));return(It(S.get(n.id))-r)*e||Be(t).localeCompare(Be(n))})},[b,c,l,S]),T=(0,N.useMemo)(()=>[...new Set(b.flatMap(e=>e.tags||[]))],[b]),E=(0,N.useMemo)(()=>[...new Set(b.flatMap(e=>je(e.capabilities||[])))],[b]),D=tt(),ee=(0,N.useMemo)(()=>{if(g!==`project`)return null;let e=new Map;for(let t of w){let n=yt(t)||`No project`,r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[w,g]),ne=[d,f,p,m,h].filter(Boolean).length,re=(0,N.useMemo)(()=>st(w,v,y),[w,v,y]);function ie(e){i(e,S.get(e)?.messages),n?.(e)}function ae(e){let{agent:t}=e,n=S.get(t.id),r=n?.attention.unread||0,i=Ge(t),a=n?.previewMessage,s=It(n),c=o===t.id,l=ot(t),u=yt(t),d=l.Icon,f=e.parent?Be(e.parent):t.spawnedBy,p=e.children.length;return(0,P.jsxs)(`li`,{className:k(e.depth===1&&`relative pl-4`),children:[e.depth===1&&(0,P.jsx)(`div`,{className:`absolute left-2 top-3.5 text-muted-foreground/55`,children:(0,P.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`button`,{className:k(`w-full text-left px-3 py-2.5 flex items-start gap-2.5 hover:bg-muted/50 transition-colors border-b border-border/50`,e.depth===1&&`bg-muted/15`,c&&`bg-muted/60`),onClick:()=>ie(t.id),children:[(0,P.jsxs)(`div`,{className:`relative shrink-0 mt-0.5`,children:[(0,P.jsx)(vt,{agent:t}),(0,P.jsx)(rt,{agent:t,now:y,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-0.5`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium truncate`,children:Be(t)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[s>0&&(0,P.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,title:Ve(s),children:Me(y,s)}),r>0&&(0,P.jsx)(Je,{className:`bg-red-500 text-white text-xs min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1`,children:r}),p>0&&(0,P.jsx)(Je,{variant:`secondary`,className:`text-[10px] h-[18px] px-1.5`,title:`${p} live child ${p===1?`agent`:`agents`}`,children:p}),!r&&i&&(0,P.jsx)(Je,{className:`bg-amber-500 text-black text-xs min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1`,title:`Needs response`,children:(0,P.jsx)(O,{className:`h-3 w-3`})})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-0.5 text-[10px] text-muted-foreground`,children:[(0,P.jsx)(`span`,{title:l.title,className:`inline-flex shrink-0`,children:(0,P.jsx)(d,{className:k(`h-3 w-3`,l.iconColor)})}),(0,P.jsx)(`span`,{className:`truncate`,children:u||l.label}),gt(t)&&(0,P.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,P.jsx)(it,{context:t.context,expected:!0,size:18})})]}),e.depth===0&&t.spawnedBy&&f&&(0,P.jsx)(`div`,{className:`mb-0.5`,children:(0,P.jsx)(Je,{variant:`outline`,className:`max-w-full text-[9px] h-4 px-1.5 text-muted-foreground`,children:(0,P.jsxs)(`span`,{className:`truncate`,children:[`spawned by `,f]})})}),a&&(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:[a.from===`user`?`You: `:``,Ue(a)]}),t.status!==`offline`&&(0,P.jsx)(`div`,{className:`mt-1`,children:(0,P.jsx)(`span`,{className:k(`text-xs`,t.status===`busy`?`text-yellow-400`:`text-emerald-400`),children:t.status})})]})]})]},t.id)}return(0,P.jsxs)(`div`,{className:`flex flex-col h-full border-r border-border min-w-0`,children:[(0,P.jsxs)(`div`,{className:`p-3 border-b border-border space-y-2`,children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(t,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none`}),(0,P.jsx)(Ye,{placeholder:`Search agents...`,value:s,onChange:e=>r({chatAgentSearch:e.target.value}),className:`pl-8 h-7 text-xs`})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r({chatAgentFiltersCollapsed:!_}),className:`sm:hidden flex w-full items-center justify-between h-6 px-1.5 text-xs rounded-md border border-border bg-background text-muted-foreground`,children:[(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,P.jsx)(ye,{className:`w-3.5 h-3.5`}),`Filters & sort`,ne>0&&(0,P.jsx)(Je,{className:`bg-primary/20 text-primary text-[10px] h-4 min-w-4 px-1 flex items-center justify-center`,children:ne})]}),_?(0,P.jsx)(ce,{className:`w-3.5 h-3.5`}):(0,P.jsx)(_e,{className:`w-3.5 h-3.5`})]}),(0,P.jsxs)(`div`,{className:k(`space-y-2`,_?`hidden`:`block`,`sm:block`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(`select`,{value:c,onChange:e=>r({chatAgentSort:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:`status`,children:`By status`}),(0,P.jsx)(`option`,{value:`name`,children:`By name`}),(0,P.jsx)(`option`,{value:`lastSeen`,children:`By last seen`}),(0,P.jsx)(`option`,{value:`lastMessage`,children:`By last activity`})]}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-xs`,onClick:()=>r({chatAgentSortDir:l===`asc`?`desc`:`asc`}),children:l===`asc`?(0,P.jsx)(te,{className:`w-3.5 h-3.5`}):(0,P.jsx)(x,{className:`w-3.5 h-3.5`})})]}),(0,P.jsxs)(`select`,{value:g,onChange:e=>r({chatAgentGroupBy:e.target.value}),className:`w-full h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`No grouping`}),(0,P.jsx)(`option`,{value:`project`,children:`Group by project`})]}),(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsxs)(`select`,{value:d,onChange:e=>r({chatAgentProviderFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All types`}),(0,P.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,P.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,P.jsx)(`option`,{value:`agent`,children:`Agent`}),(0,P.jsx)(`option`,{value:`user`,children:`User`})]}),(0,P.jsxs)(`select`,{value:f,onChange:e=>r({chatAgentStatusFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All status`}),(0,P.jsx)(`option`,{value:`online`,children:`Online`}),(0,P.jsx)(`option`,{value:`idle`,children:`Idle`}),(0,P.jsx)(`option`,{value:`busy`,children:`Busy`}),(0,P.jsx)(`option`,{value:`offline`,children:`Offline`})]}),D.length>1&&(0,P.jsxs)(`select`,{value:h,onChange:e=>r({chatAgentHostFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All hosts`}),D.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]}),(T.length>0||E.length>0)&&(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[T.length>0&&(0,P.jsxs)(`select`,{value:p,onChange:e=>r({chatAgentTagFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All tags`}),T.map(e=>(0,P.jsxs)(`option`,{value:e,children:[`#`,e]},e))]}),E.length>0&&(0,P.jsxs)(`select`,{value:m,onChange:e=>r({chatAgentCapFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All caps`}),E.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full shrink-0 items-center gap-2.5 border-b border-border px-3 py-2 text-left transition-colors hover:bg-muted/50`,onClick:a,children:[(0,P.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-dashed border-primary/50 bg-primary/10 text-primary`,children:(0,P.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium`,children:`New Agent`}),(0,P.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:`Spawn a fresh chat agent`})]})]}),(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:w.length===0?(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-4`,children:[(0,P.jsx)(oe,{className:`w-8 h-8 text-zinc-600 mb-2`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agents match filters`})]}):ee?ee.map(([e,t])=>(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 border-b border-border/50 bg-background/95 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:e}),(0,P.jsx)(`span`,{className:`text-muted-foreground/50`,children:t.length})]}),(0,P.jsx)(`ul`,{children:st(t,v,y).map(ae)})]},e)):(0,P.jsx)(`ul`,{children:re.map(ae)})})]})}var Ht=[{name:`/reply`,source:`skill`,description:`Reply to a relay message by id`,argumentHint:`<messageId> <body>`},{name:`/message`,source:`skill`,description:`Send a relay message to an agent, label, tag, or broadcast`,argumentHint:`<target> <body>`},{name:`/pair`,source:`skill`,description:`Start or manage a two-agent pair session`},{name:`/react`,source:`skill`,description:`Add a reaction to a relay message`,argumentHint:`<messageId> <emoji>`},{name:`/read-message`,source:`skill`,description:`Fetch a full relay message by id`,argumentHint:`<messageId>`},{name:`/send-claimable`,source:`skill`,description:`Enqueue a claimable work item for one agent to claim`},{name:`/status`,source:`skill`,description:`Show this agent's relay status`},{name:`/tags`,source:`skill`,description:`List or update this agent's relay tags`},{name:`/label`,source:`skill`,description:`Read, set, or clear this agent's relay label`},{name:`/disconnect`,source:`skill`,description:`End the current relay pair session`}],Ut=[{name:`/clear`,source:`builtin`,description:`Clear conversation history and free up context`},{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`,argumentHint:`[instructions]`},{name:`/model`,source:`builtin`,description:`Switch the active model`,argumentHint:`[model]`},{name:`/help`,source:`builtin`,description:`Show help`}],Wt=[{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`},{name:`/new`,source:`builtin`,description:`Start a new thread`}];function Gt(e){return[...e===`claude`?Ut:e===`codex`?Wt:[],...Ht]}function Kt({selectedInboxThread:e,agent:t,now:r,blockedState:i,thread:c,exportableThread:l,importedHistory:u,showBackButton:d,onBack:p,openAgentDetail:m,openWorkspaceFocus:h,voiceTtsEnabled:_,setVoiceTtsEnabled:v,canOpenTerminal:x,terminalOpening:S,handleOpenTerminal:C,canInterrupt:T,interruptAgent:E,canCompact:D,canClearContext:ee,canShutdown:te,openConfirm:O,workspaceAction:ie,doAgentAction:oe,openFilesForAgent:se,forkFromAgent:ce,markInboxThreadUnread:le,markInboxThreadRead:ue,exportThread:k}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-between px-3 md:px-4 py-2.5 md:py-3 border-b border-border shrink-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-2.5 min-w-0`,children:[d&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:p,className:`shrink-0 -ml-1`,children:(0,P.jsx)(b,{className:`w-4 h-4`})}),(0,P.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 md:gap-2.5 min-w-0 hover:opacity-80 transition-opacity`,onClick:()=>t&&m(t),disabled:!t,children:[(0,P.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,P.jsx)(vt,{agent:t}),(0,P.jsx)(rt,{agent:t,now:r,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,P.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t?Be(t):e}),t&&(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[i?`blocked: ${i.label}`:t.status,t.machine&&` · ${t.machine}`,typeof t.meta?.cwd==`string`&&t.meta.cwd&&` · ${ke(t.meta.cwd,1)}`]})]})]}),t&&(0,P.jsx)(ct,{agent:t,compact:!0,className:`hidden @4xl/chat:flex shrink-0`}),t&&gt(t)&&(0,P.jsx)(it,{context:t.context,expected:!0}),t?.branchState&&t.branchWorkspaceId&&(0,P.jsx)(St,{state:t.branchState,className:`shrink-0`,onClick:()=>void h(t.branchWorkspaceId)}),c?.attention.unread?(0,P.jsxs)(Je,{className:`bg-red-500/20 text-red-400 text-xs shrink-0 hidden @2xl/chat:flex`,children:[c.attention.unread,` unread`]}):null]}),(0,P.jsx)(`div`,{className:`flex items-center gap-0.5 md:gap-1 shrink-0`,children:t&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Xe,{value:t.id,label:`Copy agent ID`,size:`icon-sm`}),De.available&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:_?`Speaking agent responses aloud — click to mute (engine & voice in Settings)`:`Speak agent responses aloud (active chat) — engine & voice in Settings`,className:_?`text-primary`:``,onClick:()=>v(!_),children:_?(0,P.jsx)(ne,{className:`w-3.5 h-3.5`}):(0,P.jsx)(ge,{className:`w-3.5 h-3.5`})}),x&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,disabled:S,title:`Terminal`,onClick:()=>void C(),children:(0,P.jsx)(ae,{className:`w-3.5 h-3.5`})}),T&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`text-red-400 hover:text-red-300`,title:`Interrupt`,onClick:E,children:(0,P.jsx)(w,{className:`w-3.5 h-3.5`})}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex text-amber-400 hover:text-amber-300`,title:`Mark workspace ready — hand off to the auto-merge`,onClick:()=>O(`Mark Workspace Ready`,`Mark ${Be(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>ie(t.branchWorkspaceId,`ready`)),children:(0,P.jsx)(n,{className:`w-3.5 h-3.5`})}),D&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Compact`,onClick:()=>O(`Compact Agent`,`Compact context for ${Be(t)}?`,()=>oe(t,`compact`)),children:(0,P.jsx)(s,{className:`w-3.5 h-3.5`})}),ee&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Clear context`,onClick:()=>O(`Clear Context`,`Clear context for ${Be(t)}?`,()=>oe(t,`clearContext`)),children:(0,P.jsx)(o,{className:`w-3.5 h-3.5`})}),te&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Shutdown`,onClick:()=>O(`Shutdown Agent`,`Shutdown ${Be(t)}?`,()=>oe(t,`shutdown`)),children:(0,P.jsx)(y,{className:`w-3.5 h-3.5`})}),t&&typeof t.meta?.cwd==`string`&&t.meta.cwd&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Open ${t.meta.cwd} in Files`,onClick:()=>void se(t),children:(0,P.jsx)(a,{className:`w-3.5 h-3.5`})}),t&&c&&c.messages.length>0&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Fork — spawn new agent with this chat history`,onClick:()=>ce(t.id,c.messages),children:(0,P.jsx)(be,{className:`w-3.5 h-3.5`})}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark unread`,onClick:()=>le(e),children:(0,P.jsx)(re,{className:`w-3.5 h-3.5`})}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark read`,onClick:()=>ue(c.peer,c.messages),children:(0,P.jsx)(ve,{className:`w-3.5 h-3.5`})}),l&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Export thread`,onClick:()=>k({...l,importedHistory:u},`json`),children:(0,P.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,P.jsxs)($e,{children:[(0,P.jsx)(ut,{asChild:!0,children:(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`@4xl/chat:hidden`,children:(0,P.jsx)(f,{className:`w-3.5 h-3.5`})})}),(0,P.jsxs)(nt,{align:`end`,children:[x&&(0,P.jsxs)(dt,{disabled:S,onClick:()=>void C(),children:[(0,P.jsx)(ae,{className:`w-3.5 h-3.5`}),`Terminal`]}),T&&(0,P.jsxs)(dt,{onClick:E,children:[(0,P.jsx)(w,{className:`w-3.5 h-3.5`}),`Interrupt`]}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsxs)(dt,{onClick:()=>O(`Mark Workspace Ready`,`Mark ${Be(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>ie(t.branchWorkspaceId,`ready`)),children:[(0,P.jsx)(n,{className:`w-3.5 h-3.5`}),`Mark Ready`]}),D&&(0,P.jsxs)(dt,{onClick:()=>O(`Compact Agent`,`Compact context for ${Be(t)}?`,()=>oe(t,`compact`)),children:[(0,P.jsx)(s,{className:`w-3.5 h-3.5`}),`Compact`]}),ee&&(0,P.jsxs)(dt,{onClick:()=>O(`Clear Context`,`Clear context for ${Be(t)}?`,()=>oe(t,`clearContext`)),children:[(0,P.jsx)(o,{className:`w-3.5 h-3.5`}),`Clear Context`]}),te&&(0,P.jsxs)(dt,{onClick:()=>O(`Shutdown Agent`,`Shutdown ${Be(t)}?`,()=>oe(t,`shutdown`)),children:[(0,P.jsx)(y,{className:`w-3.5 h-3.5`}),`Shutdown`]}),t&&typeof t.meta?.cwd==`string`&&t.meta.cwd&&(0,P.jsxs)(dt,{onClick:()=>void se(t),children:[(0,P.jsx)(a,{className:`w-3.5 h-3.5`}),`Open Files`]}),t&&c&&c.messages.length>0&&(0,P.jsxs)(dt,{onClick:()=>ce(t.id,c.messages),children:[(0,P.jsx)(be,{className:`w-3.5 h-3.5`}),`Fork`]}),(x||D||ee||te)&&(0,P.jsx)(Ze,{}),c&&(0,P.jsxs)(dt,{onClick:()=>le(e),children:[(0,P.jsx)(re,{className:`w-3.5 h-3.5`}),`Mark Unread`]}),c&&(0,P.jsxs)(dt,{onClick:()=>ue(c.peer,c.messages),children:[(0,P.jsx)(ve,{className:`w-3.5 h-3.5`}),`Mark Read`]}),l&&(0,P.jsxs)(dt,{onClick:()=>k({...l,importedHistory:u},`json`),children:[(0,P.jsx)(g,{className:`w-3.5 h-3.5`}),`Download`]})]})]})]})})]})}function qt({matches:e,activeIndex:t,onAccept:n,onHover:r}){return e.length===0?null:(0,P.jsx)(`div`,{className:`absolute bottom-full left-3 right-3 md:left-4 md:right-4 mb-2 z-20 max-h-64 overflow-auto rounded-xl border border-border bg-popover shadow-lg`,children:e.map((e,i)=>(0,P.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),n(e)},onMouseEnter:()=>r(i),className:k(`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm`,i===t?`bg-accent`:`hover:bg-accent/50`),children:[(0,P.jsx)(`span`,{className:`font-medium shrink-0`,children:e.name}),e.argumentHint&&(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.argumentHint}),e.description&&(0,P.jsx)(`span`,{className:`ml-auto truncate text-xs text-muted-foreground/70`,children:e.description})]},e.name))})}function Jt({value:e,onChange:t,onKeyDown:n,onPaste:r,placeholder:i,className:a}){let o=(0,N.useRef)(null);return(0,N.useEffect)(()=>{let e=o.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[e]),(0,N.useEffect)(()=>{let e=window.visualViewport;if(!e)return;function t(){let e=o.current;!e||document.activeElement!==e||requestAnimationFrame(()=>{e.scrollIntoView({block:`nearest`,behavior:`smooth`})})}return e.addEventListener(`resize`,t),()=>e.removeEventListener(`resize`,t)},[]),(0,P.jsx)(`textarea`,{ref:o,value:e,onChange:t,onKeyDown:n,onPaste:r,placeholder:i,rows:1,className:k(`w-full resize-none rounded-xl border border-border bg-background px-3.5 py-2.5 text-sm`,`placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,`min-h-[42px] max-h-[200px] overflow-y-auto`,a)})}function Yt({item:e,onRemove:t}){let[n,r]=(0,N.useState)(!1),i=!!(e.previewUrl&&!e.error);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 text-xs`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:!i,onClick:()=>r(!0),className:`group/pending relative flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded bg-muted disabled:cursor-default`,title:i?`Preview image`:e.fileName,children:e.previewUrl?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`h-full w-full object-cover`}),(0,P.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/pending:bg-black/30 transition-colors`,children:(0,P.jsx)(me,{className:`h-3.5 w-3.5 text-white opacity-0 group-hover/pending:opacity-100 transition-opacity drop-shadow-md`})})]}):e.error?(0,P.jsx)(O,{className:`h-4 w-4 text-red-400`}):e.uploading?(0,P.jsx)(le,{className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,P.jsx)(de,{className:`h-4 w-4 text-muted-foreground`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`truncate font-medium`,children:e.fileName}),(0,P.jsx)(`p`,{className:k(`truncate text-muted-foreground`,e.error&&`text-red-400`),children:e.error||(e.uploading?`Uploading`:wt(e.size))})]}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:`Remove attachment`,onClick:t,children:(0,P.jsx)(se,{className:`h-3.5 w-3.5`})})]}),e.previewUrl&&(0,P.jsx)(lt,{open:n,onOpenChange:r,children:(0,P.jsxs)(at,{className:`max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden`,showCloseButton:!1,children:[(0,P.jsx)(ft,{className:`sr-only`,children:e.fileName}),(0,P.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,P.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>r(!1),className:`absolute top-2 right-2 rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,P.jsx)(se,{className:`w-4 h-4`})})]})]})})]})}function Xt({draft:e,placeholder:t,chatSending:n,disabled:i,hasPendingUploads:a,readyAttachmentCount:o,pendingAttachments:s,micAvailable:c,micState:u,slashMatches:d,slashActiveIndex:f,onDraftChange:p,onKeyDown:m,onPaste:g,onUploadFiles:_,onRemovePendingAttachment:v,onSend:y,onAcceptSlash:b,onSlashHover:x,onStartPtt:S,onStopPtt:C,footerText:w}){let T=(0,N.useRef)(null),[E,D]=(0,N.useState)(!1),ee=!e.trim()&&o===0||a||n||i;return(0,P.jsxs)(`div`,{className:k(`relative shrink-0 border-t border-border px-3 md:px-4 py-2.5 md:py-3 safe-area-bottom`,E&&`bg-primary/5 ring-1 ring-primary/40`),onDragOver:e=>{e.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:e=>{e.preventDefault(),D(!1),_(e.dataTransfer.files)},children:[s.length>0&&(0,P.jsx)(`div`,{className:`mb-2 grid gap-2 sm:grid-cols-2`,children:s.map(e=>(0,P.jsx)(Yt,{item:e,onRemove:()=>v(e.id)},e.id))}),(0,P.jsx)(`input`,{ref:T,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&_(e.target.files),e.currentTarget.value=``}}),(0,P.jsx)(qt,{matches:d,activeIndex:f,onAccept:b,onHover:x}),(0,P.jsxs)(`div`,{className:`hidden md:flex items-end gap-2`,children:[(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>T.current?.click(),className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,P.jsx)(l,{className:`w-4 h-4`})}),(0,P.jsx)(Jt,{value:e,onChange:e=>p(e.target.value),onKeyDown:m,onPaste:g,placeholder:t,className:`flex-1`}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:u===`recording`?`Release to transcribe`:`Hold to talk`,disabled:n||u===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),S()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}C()},className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px] ${u===`recording`?`text-red-400 animate-pulse`:``}`,children:u===`transcribing`?(0,P.jsx)(le,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(h,{className:`w-4 h-4`})}),(0,P.jsx)(M,{size:`icon`,disabled:ee,onClick:y,className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,P.jsx)(r,{className:`w-4 h-4`})})]}),(0,P.jsxs)(`div`,{className:`md:hidden space-y-2`,children:[(0,P.jsx)(Jt,{value:e,onChange:e=>p(e.target.value),onKeyDown:m,onPaste:g,placeholder:t,className:`w-full`}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>T.current?.click(),className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(l,{className:`w-4 h-4`})}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:u===`recording`?`Release to transcribe`:`Hold to talk`,disabled:n||u===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),S()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}C()},className:`rounded-xl h-9 w-9 ${u===`recording`?`text-red-400 animate-pulse`:``}`,children:u===`transcribing`?(0,P.jsx)(le,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(h,{className:`w-4 h-4`})})]}),(0,P.jsx)(M,{size:`icon`,disabled:ee,onClick:y,className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(r,{className:`w-4 h-4`})})]})]}),w&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 hidden md:block`,children:w})]})}var Zt=e(xe(),1);function Qt({preview:e,error:t,onReadError:n,onMouseEnter:r,onMouseLeave:i}){let{anchor:a}=e,o=Math.min(560,window.innerWidth-24),s=Math.min(380,window.innerHeight-24),c=Math.max(12,Math.min(a.left,window.innerWidth-o-12));return(0,Zt.createPortal)((0,P.jsxs)(`div`,{className:`fixed z-50 flex flex-col overflow-hidden rounded-lg border border-border bg-background shadow-xl`,style:{top:window.innerHeight-a.bottom>=s+8?a.bottom+8:a.top-8-s>=12?a.top-8-s:Math.max(12,window.innerHeight-s-12),left:c,width:o,height:s},onMouseEnter:r,onMouseLeave:i,children:[(0,P.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-2.5`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium text-muted-foreground`,children:e.path}),t&&(0,P.jsx)(`span`,{className:`max-w-[12rem] truncate text-[11px] text-red-400`,children:t}),(0,P.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:`click to pin`})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:e.type===`directory`?(0,P.jsx)(Qe,{orchestratorId:e.orchestratorId,selectedPath:e.path,onReadError:n}):(0,P.jsx)(_t,{orchestratorId:e.orchestratorId,selectedPath:e.path,line:e.line,onReadError:n})})]}),document.body)}var $t={online:`came online`,offline:`went offline`,shutdown:`shut down`,restarted:`restarted`,"compaction-requested":`compaction requested`,compacting:`compaction started`,compacted:`context compacted`,"compaction-stalled":`compaction stalled — may need manual intervention`,"clear-requested":`clear requested`,"clearing-context":`clear started`,"context-cleared":`context cleared`,"clear-stalled":`context clear stalled — may need manual intervention`,"shutting-down":`shutting down`},en=new Set(Object.keys($t)),tn=3e3;function nn(e){return new Date(e.occurredAt??e.createdAt).getTime()}function rn(e){if(e.kind!==`session`)return null;let t=e.payload?.session;return!t||t.type!==`narration`&&t.type!==`reasoning`&&t.type!==`tool`?null:{id:e.id,kind:t.type,label:typeof t.label==`string`?t.label:void 0,text:e.body,ts:nn(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function an(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`notice`)return null;let n=typeof t.label==`string`&&t.label?t.label:`compacted`;return{id:`notice-${e.id}`,status:n,timestamp:nn(e)}}function on(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function sn(e){let t=e.filter(e=>en.has(e.status)).slice().sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let e of t)n.some(t=>t.id===e.id)||n.some(t=>t.status===e.status&&Math.abs(t.timestamp-e.timestamp)<=tn)||n.push(e);return n}function cn(e,t,n,r=[]){let i=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,Ie(t.originalCreatedAt)),1/0),n=Number.isFinite(t)?t-1:e.importedAt;i.push({ts:n,entry:{type:`import-boundary`,history:e,timestamp:n}});for(let t of e.entries)i.push({ts:Ie(t.originalCreatedAt),entry:{type:`imported-message`,history:e,entry:t}})}if(n){let e=new Date(n).getTime();Number.isFinite(e)&&i.push({ts:e,entry:{type:`created`,timestamp:e}})}let a=new Map;for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type===`response`&&typeof e.turnId==`string`){let n=a.get(e.turnId)??[];n.push(t.body.trim()),a.set(e.turnId,n)}}let o=[];for(let t of e){let e=an(t);if(e){o.push(e);continue}let n=rn(t);if(n){if(n.kind===`narration`&&n.turnId&&a.get(n.turnId)?.some(e=>Fe(e,n.text)))continue;i.push({ts:n.ts,entry:{type:`activity`,steps:[n],timestamp:n.ts}});continue}i.push({ts:nn(t),entry:{type:`message`,msg:t}})}for(let e of sn([...t,...o]))i.push({ts:e.timestamp,entry:{type:`status`,event:e}});let s={created:0,date:1,"import-boundary":2,"imported-message":3,message:4,activity:4,status:5};i.sort((e,t)=>{let n=e.ts-t.ts;return Math.abs(n)<3e3&&s[e.entry.type]-s[t.entry.type]||n});let c=[],l=``;for(let{ts:e,entry:t}of i){if(t.type===`created`){c.push(t);continue}let n=on(e);if(n!==l&&(c.push({type:`date`,date:n,timestamp:e}),l=n),t.type===`activity`){let e=c[c.length-1];if(e&&e.type===`activity`&&ln(e,t)){e.steps.push(...t.steps);continue}}c.push(t)}return c}function ln(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}var un=[];function dn(e){return A(t=>t.chatStatusEvents[e]??un)}function fn(e,t){let n=(0,N.useRef)(!1);(0,N.useEffect)(()=>{if(!e)return;n.current||=(window.history.pushState({chatGuard:!0},``),!0);function r(e){(e.state?.chatGuard!==void 0||!n.current)&&(window.history.pushState({chatGuard:!0},``),t())}function i(e){e.preventDefault()}return window.addEventListener(`popstate`,r),window.addEventListener(`beforeunload`,i),()=>{window.removeEventListener(`popstate`,r),window.removeEventListener(`beforeunload`,i)}},[e,t]),(0,N.useEffect)(()=>{!e&&n.current&&(n.current=!1)},[e])}var pn=0,mn=1,hn=2,gn=4;function _n(e){return()=>e}function vn(e){e()}function yn(e,t){return n=>e(t(n))}function bn(e,t){return()=>e(t)}function xn(e,t){return n=>e(t,n)}function Sn(e){return e!==void 0}function Cn(...e){return()=>{e.map(vn)}}function wn(){}function Tn(e,t){return t(e),e}function En(e,t){return t(e)}function F(...e){return e}function I(e,t){return e(mn,t)}function L(e,t){e(pn,t)}function Dn(e){e(hn)}function R(e){return e(gn)}function z(e,t){return I(e,xn(t,pn))}function On(e,t){let n=e(mn,e=>{n(),t(e)});return n}function kn(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function An(e,t){return e===t}function B(e=An){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function V(e){return t=>n=>{e(n)&&t(n)}}function H(e){return t=>yn(t,e)}function jn(e){return t=>()=>{t(e)}}function U(e,...t){let n=Fn(...t);return((t,r)=>{switch(t){case hn:Dn(e);return;case mn:return I(e,n(r))}})}function Mn(e,t){return n=>r=>{n(t=e(t,r))}}function Nn(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function W(...e){let t=Array(e.length),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;I(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function Fn(...e){return t=>e.reduceRight(En,t)}function In(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case mn:return a?n===a?void 0:(r(),n=a,t=I(e,a),t):(r(),wn);case hn:r(),n=null;return}}}function G(e){let t=e,n=K();return((e,r)=>{switch(e){case pn:t=r;break;case mn:r(t);break;case gn:return t}return n(e,r)})}function Ln(e,t){return Tn(G(t),t=>z(e,t))}function K(){let e=[];return((t,n)=>{switch(t){case pn:e.slice().forEach(e=>{e(n)});return;case hn:e.splice(0,e.length);return;case mn:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function Rn(e){return Tn(K(),t=>z(e,t))}function q(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:zn(),singleton:n}}var zn=()=>Symbol();function Bn(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function Vn(...e){let t=K(),n=Array(e.length),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;I(e,e=>{n[a]=e,r|=o,r===i&&L(t,n)})}),function(e,a){switch(e){case hn:Dn(t);return;case mn:return r===i&&a(n),I(t,a)}}}function J(e,t=An){return U(e,B(t))}function Hn(...e){return function(t,n){switch(t){case hn:return;case mn:return Cn(...e.map(e=>I(e,n)))}}}var Un={DEBUG:0,INFO:1,WARN:2,ERROR:3},Wn={[Un.DEBUG]:`debug`,[Un.ERROR]:`error`,[Un.INFO]:`log`,[Un.WARN]:`warn`},Gn=()=>typeof globalThis>`u`?window:globalThis,Kn=q(()=>{let e=G(Un.ERROR);return{log:G((t,n,r=Un.INFO)=>{r>=(Gn().VIRTUOSO_LOG_LEVEL??R(e))&&console[Wn[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0}),qn=new WeakMap;function Jn(e){return`self`in e?e.document.documentElement:e}function Yn(e){let t=Jn(e),n=qn.get(t);if(n!==void 0)return n;let r=t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`;return qn.set(t,r),r}function Xn(e){qn.delete(Jn(e))}function Zn(e,t){return Yn(e)?-t:t}var Qn=Zn;function $n(e,t){return Zn(e,t)}function er(e,t,n){return tr(e,t,n).callbackRef}function tr(e,t,n){let r=N.useRef(null),i=e=>{},a=N.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function nr(e,t,n,r,i,a,o,s,c){return tr(N.useCallback(n=>{let c=rr(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?Qn(o,o.scrollLeft):o.scrollTop:u?s?Qn(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?Qn(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?ir(`column-gap`,getComputedStyle(n).columnGap,i):ir(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function rr(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},Un.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function ir(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,Un.WARN),t===`normal`?0:parseInt(t??`0`,10)}function ar(e,t,n){let r=N.useRef(null),i=N.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=tr(i,!0,n),s=N.useCallback(()=>{i(o.current)},[i,o]);return N.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var or=q(()=>{let e=K(),t=K(),n=G(0),r=K(),i=G(0),a=K(),o=K(),s=G(0),c=G(0),l=G(0),u=G(0),d=K(),f=K(),p=G(!1),m=G(!1),h=G(!1);return z(U(e,H(({scrollTop:e})=>e)),t),z(U(e,H(({scrollHeight:e})=>e)),o),z(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),sr={lvl:0};function cr(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function Y(e){return e===sr}function lr(e,t){if(!Y(e))return t===e.k?e.v:t<e.k?lr(e.l,t):lr(e.r,t)}function ur(e,t,n=`k`){if(Y(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=ur(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return ur(e.l,t,n)}function dr(e,t,n){return Y(e)?Sr(t,n,1):t===e.k?vr(e,{k:t,v:n}):t<e.k?Cr(vr(e,{l:dr(e.l,t,n)})):Cr(vr(e,{r:dr(e.r,t,n)}))}function fr(){return sr}function pr(e,t,n){if(Y(e))return[];let r=ur(e,t)[0];return Er(gr(e,r,n))}function mr(e,t){if(Y(e))return sr;let{k:n,l:r,r:i}=e;if(t===n){if(Y(r))return i;if(Y(i))return r;let[t,n]=xr(r);return _r(vr(e,{k:t,l:yr(r),v:n}))}return _r(t<n?vr(e,{l:mr(r,t)}):vr(e,{r:mr(i,t)}))}function hr(e){return Y(e)?[]:[...hr(e.l),{k:e.k,v:e.v},...hr(e.r)]}function gr(e,t,n){if(Y(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(gr(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(gr(a,t,n))),s}function _r(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(br(t))return wr(vr(e,{lvl:n-1}));if(!Y(t)&&!Y(t.r))return vr(t.r,{l:vr(t,{r:t.r.l}),lvl:n,r:vr(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(br(e))return Tr(vr(e,{lvl:n-1}));if(!Y(r)&&!Y(r.l)){let t=r.l,i=br(t)?r.lvl-1:r.lvl;return vr(t,{l:vr(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:Tr(vr(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function vr(e,t){return Sr(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function yr(e){return Y(e.r)?e.l:_r(vr(e,{r:yr(e.r)}))}function br(e){return Y(e)||e.lvl>e.r.lvl}function xr(e){return Y(e.r)?[e.k,e.v]:xr(e.r)}function Sr(e,t,n,r=sr,i=sr){return{k:e,l:r,lvl:n,r:i,v:t}}function Cr(e){return Tr(wr(e))}function wr(e){let{l:t}=e;return!Y(t)&&t.lvl===e.lvl?vr(t,{r:vr(e,{l:t.r})}):e}function Tr(e){let{lvl:t,r:n}=e;return!Y(n)&&!Y(n.r)&&n.lvl===t&&n.r.lvl===t?vr(n,{l:vr(e,{r:n.l}),lvl:t+1}):e}function Er(e){return cr(e,({k:e,v:t})=>({index:e,value:t}))}function Dr(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Or(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var kr=q(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function Ar(e,t,n){return e[jr(e,t,n)]}function jr(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function Mr(e,t,n,r){let i=jr(e,t,r),a=jr(e,n,r,i);return e.slice(i,a+1)}function Nr(e,t){return Math.round(e.getBoundingClientRect()[t])}function Pr(e){return!Y(e.groupOffsetTree)}function Fr({index:e},t){return t===e?0:t<e?-1:1}function Ir(){return{groupIndices:[],groupOffsetTree:fr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:fr()}}function Lr(e,t){let n=Y(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),Y(e)){e=dr(e,0,i);continue}let o=pr(e,a-1,t+1);if(o.some(Yr(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=mr(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=dr(e,t+1,a));c&&(e=dr(e,a,i))}return[e,n]}function Rr(e){return typeof e.groupIndex<`u`}function zr({offset:e},t){return t===e?0:t<e?-1:1}function Br(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=Ar(t,e,Fr),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function Vr(e,t){if(!Pr(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Hr(e,t,n){if(Rr(e))return t.groupIndices[e.groupIndex]+1;let r=Vr(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function Ur(e,t,n,r=0){return r>0&&(t=Math.max(t,Ar(e,r,Fr).offset)),cr(Mr(e,t,n,zr),Jr)}function Wr(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,Un.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&Y(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>dr(dr(t,n,e),n+1,r),o)}else [o,s]=Lr(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=qr(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>dr(e,t,Br(t,d,i)),fr()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Gr(e){return hr(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function Kr(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function qr(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t!==0){c=jr(i,t-1,Fr),s=i[c].offset;let e=ur(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===ur(n,t)[1]&&--c,i=i.slice(0,c+1)}else i=[];for(let{start:e,value:c}of pr(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function Jr(e){return{index:e.index,value:e}}function Yr(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var Xr={offsetHeight:`height`,offsetWidth:`width`},Zr=q(([{log:e},{recalcInProgress:t}])=>{let n=K(),r=K(),i=Ln(r,0),a=K(),o=K(),s=G(0),c=G([]),l=G(void 0),u=G(void 0),d=G(void 0),f=G(void 0),p=G((e,t)=>Nr(e,Xr[t])),m=G(void 0),h=G(0),g=Ir(),_=Ln(U(n,W(c,e,h),Mn(Wr,g),B()),g),v=Ln(U(c,B(),Mn((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),H(({prev:e})=>e)),[]);z(U(c,V(e=>e.length>0),W(_,h),H(([e,t,n])=>{let r=e.reduce((e,r,i)=>dr(e,r,Br(r,t.offsetTree,n)||i),fr());return{...t,groupIndices:e,groupOffsetTree:r}})),_),z(U(r,W(_),V(([e,{lastIndex:t}])=>e<t),H(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),z(l,u);let y=Ln(U(l,H(e=>e===void 0)),!0);z(U(u,V(e=>e!==void 0&&Y(R(_).sizeTree)),H(e=>{let t=R(d),n=R(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),z(U(f,V(e=>e!==void 0&&e.length>0&&Y(R(_).sizeTree)),H(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),z(U(c,W(d,u),V(([,e,t])=>e!==void 0&&t!==void 0),H(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=Rn(U(n,W(_),Mn(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),H(e=>e.changed)));I(U(s,Mn((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),H(e=>e.diff)),e=>{let{groupIndices:n}=R(_);if(e>0)L(t,!0),L(a,e+Kr(e,n));else if(e<0){let t=R(v);t.length>0&&(e-=Kr(-e,t)),L(o,e)}}),I(U(s,W(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},Un.ERROR)});let x=Rn(a);z(U(a,W(_),H(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=lr(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=hr(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return hr(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=Rn(U(o,W(_,h),H(([e,{offsetTree:t},n])=>Br(-e,t,n))));return z(U(o,W(_,h),H(([e,t,n])=>{if(t.groupIndices.length>0){if(Y(t.sizeTree))return t;let r=fr(),i=R(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=hr(t.sizeTree).reduce((t,{k:n,v:r})=>dr(t,Math.max(0,n+e),r),r),a!==-e){let n=lr(t.sizeTree,s);r=dr(r,0,n);let i=ur(t.sizeTree,-e+1)[1];r=dr(r,1,i)}return{...t,sizeTree:r,...qr(t.offsetTree,0,r,n)}}let r=hr(t.sizeTree).reduce((t,{k:n,v:r})=>dr(t,Math.max(0,n+e),r),fr());return{...t,sizeTree:r,...qr(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},F(Kn,kr),{singleton:!0});function Qr(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var $r=q(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=K(),o=K(),s=Rn(U(a,H(Qr)));return z(U(s,H(e=>e.totalCount)),n),z(U(s,H(e=>e.groupIndices)),e),z(U(Vn(i,t,r),V(([e,t])=>Pr(t)),H(([e,t,n])=>ur(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),B(),H(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},F(Zr,or)),ei=q(([{log:e}])=>{let t=G(!1),n=Rn(U(t,V(e=>e),B()));return I(t,t=>{t&&R(e)(`props updated`,{},Un.DEBUG)}),{didMount:n,propsReady:t}},F(Kn),{singleton:!0}),ti=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function ni(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!ti)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var ri=q(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=K(),m=K(),h=G(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),L(c,!1)}return z(U(p,W(n,d,r,h,s,o,f),W(e,a,i),H(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=ni(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=Hr(b,n,w),E=Br(T,n.offsetTree,d)+o;x===`end`?(E+=f+ur(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+ur(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},Un.DEBUG),L(p,e)):(L(m,!0),l(`list did not change, scroll successful`,{},Un.DEBUG))};if(y(),S===`smooth`){let e=!1;v=I(t,t=>{e||=t}),g=On(u,()=>{D(e)})}else g=On(U(t,ii(150)),D);return _=setTimeout(()=>{y()},1200),L(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},Un.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},F(Zr,or,Kn),{singleton:!0});function ii(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function ai(e,t){e===0?t():requestAnimationFrame(()=>{ai(e-1,t)})}function oi(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var si=q(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=G(!0),c=G(0),l=G(!0);return z(U(o,W(c),V(([e,t])=>t!==0),jn(!1)),s),z(U(o,W(c),V(([e,t])=>t!==0),jn(!1)),l),I(U(Vn(t,o),W(s,n,e,l),V(([[,e],t,{sizeTree:n},r,i])=>e&&(!Y(n)||Sn(r))&&!t&&!i),W(c)),([,e])=>{On(i,()=>{L(l,!0)}),ai(4,()=>{On(r,()=>{L(s,!0)}),L(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},F(Zr,or,ri,ei),{singleton:!0});function ci(e,t){return Math.abs(e-t)<1.01}var li=`up`,ui=`down`,di=`none`,fi={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},pi=0,mi=q(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=G(!1),s=G(!0),c=K(),l=K(),u=G(4),d=G(pi),f=Ln(U(Hn(U(J(i),Nn(1),jn(!0)),U(J(i),Nn(1),jn(!1),kn(100))),B()),!1),p=Ln(U(Hn(U(n,jn(!0)),U(n,jn(!1),kn(200))),B()),!1);z(U(Vn(J(i),J(d)),H(([e,t])=>e<=t),B()),s),z(U(s,Pn(50)),l);let m=Rn(U(Vn(r,J(a),J(t),J(e),J(u)),Mn((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},fi),B((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=Ln(U(r,Mn((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!ci(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),V(e=>e.changed),H(e=>e.jump)),0);z(U(m,H(e=>e.atBottom)),o),z(U(o,Pn(50)),c);let g=G(ui);z(U(r,H(({scrollTop:e})=>e),B(),Mn((e,t)=>R(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?li:ui,prevScrollTop:t},{direction:ui,prevScrollTop:0}),H(e=>e.direction)),g),z(U(r,Pn(50),jn(di)),g);let _=G(0);return z(U(f,V(e=>!e),jn(0)),_),z(U(i,Pn(100),W(f),V(([e,t])=>t),Mn(([e,t],[n])=>[t,n],[0,0]),H(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},F(or)),hi=`top`,gi=`bottom`,_i=`none`;function vi(e,t,n){return typeof e==`number`?n===li&&t===hi||n===ui&&t===gi?e:0:n===li?t===hi?e.main:e.reverse:t===gi?e.main:e.reverse}function yi(e,t){return typeof e==`number`?e:e[t]??0}var bi=q(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=K(),o=G(0),s=G(0),c=G(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:Ln(U(Vn(J(r),J(i),J(n),J(a,Or),J(c),J(o),J(t),J(e),J(s)),H(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=_i,m=yi(l,hi),h=yi(l,gi);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=li),i<e-f+t+h&&(p=ui),p===_i?null:[Math.max(u-n-vi(a,hi,p)-m,0),u-f-s+t+vi(a,gi,p)+h]}),V(e=>e!==null),B(Or)),[0,0])}},F(or),{singleton:!0});function xi(e,t,n){if(Pr(t)){let r=Vr(e,t);return[{index:ur(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var Si={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ci(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:Ti(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:Ti(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function wi(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=oi(t,s);return Ci(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function Ti(e,t,n){if(e.length===0)return[];if(!Pr(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=pr(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function Ei(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var Di=q(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=G([]),g=G(0),_=K(),v=G(0);z(a.topItemsIndexes,h);let y=Ln(U(Vn(p,m,J(c,Or),J(i),J(r),J(l),u,J(h),J(t),J(n),J(v),e),V(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),H(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=R(g);if(n===0)return{...Si,totalCount:n};if(e===0&&t===0)return m===0?{...Si,totalCount:n}:wi(m,i,r,s,c,u||[]);if(Y(p))return m>0?null:Ci(xi(oi(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of pr(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return Ci([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=Ur(f,e,t,_);if(v.length===0)return null;let y=n-1,b=Tn([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<_&&(a+=(_-o)*s,o=_);let l=Math.min(r.end,y);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=Ei(l,hi),S=Ei(l,gi);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=pr(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.index<y){let e=Math.min(S,y-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=pr(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return Ci(b,h,n,c,d,s)}),V(e=>e!==null),B()),Si);z(U(e,V(Sn),H(e=>e?.length)),i),z(U(y,H(e=>e.topListHeight)),d),z(d,s),z(U(y,H(e=>[e.top,e.bottom])),o),z(U(y,H(e=>e.items)),_);let b=Rn(U(y,V(({items:e})=>e.length>0),W(i,e),V(([{items:e},t])=>e[e.length-1].originalIndex===t-1),H(([,e,t])=>[e-1,t]),B(Or),H(([e])=>e))),x=Rn(U(y,Pn(200),V(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),H(({items:e})=>e[0].index),B()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:Rn(U(y,V(({items:e})=>e.length>0),H(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),B(Dr))),startReached:x,topItemsIndexes:h,...f}},F(Zr,$r,bi,si,ri,mi,ei,kr),{singleton:!0}),Oi=q(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=K(),o=Ln(U(Vn(n,e,r,t,i),H(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return z(J(o),a),{totalListHeight:o,totalListHeightChanged:a}},F(or,Di),{singleton:!0}),ki=q(([{viewportHeight:e},{totalListHeight:t}])=>{let n=G(!1);return{alignToBottom:n,paddingTopAddition:Ln(U(Vn(n,e,t),V(([e])=>e),H(([,e,t])=>Math.max(0,e-t)),Pn(0),B()),0)}},F(or,Oi),{singleton:!0}),Ai=q(()=>({context:G(null)})),ji=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,Mi=q(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=K();return z(U(u,W(t,c,n,a,i,r,s),W(e),H(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=ji,done:d,...f}=e,p=Hr(e,t,r-1),m=Br(p,t.offsetTree,l)+i+a,h=m+ur(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&On(U(o,V(e=>!e),Nn(R(o)?1:2)),d),_}),V(e=>e!==null)),l),{scrollIntoView:u}},F(Zr,or,ri,Di,Kn),{singleton:!0});function Ni(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Pi=(e,t)=>typeof e==`function`?Ni(e(t)):t&&Ni(e),Fi=q(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=G(!1),h=K(),g=null;function _(e){L(o,{align:`end`,behavior:e,index:`LAST`})}I(U(Vn(U(J(t),Nn(1)),c),W(J(m),a,s,d),H(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Pi(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),V(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),R(n)===void 0?g=On(e,()=>{R(u)(`following output to `,{totalCount:r},Un.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{R(u)(`following output to `,{totalCount:r},Un.DEBUG),_(t)})});function v(e){let t=On(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(R(u)(`scrolling to bottom due to increased size`,{},Un.DEBUG),_(`auto`))});setTimeout(t,100)}I(U(Vn(J(m),t,l),V(([e,,t])=>e!==!1&&t),Mn(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),V(({refreshed:e})=>e),W(m,t)),([,e])=>{R(s)&&v(e!==!1)}),I(h,()=>{v(R(m)!==!1)}),I(Vn(J(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=G(null),b=K();return z(Hn(U(J(r),H(e=>e?.length??0)),U(J(t))),b),I(U(Vn(U(b,Nn(1)),c),W(J(y),s,d,f),H(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),V(e=>!!e),Pn(0)),t=>{g!==null&&(g(),g=null),R(n)===void 0?g=On(e,()=>{R(u)(`scrolling into view`,{}),L(p,t),g=null}):requestAnimationFrame(()=>{R(u)(`scrolling into view`,{}),L(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},F(Zr,mi,ri,si,ei,Kn,or,Ai,Mi)),Ii=q(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(z(U(s,W(a),V(([,e])=>e!==0),W(i,r,t,n,e),H(([[,e],t,n,r,i,a=[]])=>wi(e,t,n,r,i,a))),o),{}),F(Zr,si,Di,ei),{singleton:!0}),Li=q(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=G(0);return I(U(e,W(r),V(([,e])=>e!==0),H(([,e])=>({top:e}))),e=>{On(U(n,Nn(1),V(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{L(t,e)})})}),{initialScrollTop:r}},F(ei,or,Di),{singleton:!0}),Ri=q(([{scrollVelocity:e}])=>{let t=G(!1),n=K(),r=G(!1);return z(U(e,W(r,t,n),V(([e,t])=>t!==!1&&t!==void 0),H(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),B()),t),I(U(Vn(t,e,n),W(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},F(mi),{singleton:!0}),zi=q(([{scrollContainerState:e,scrollTo:t}])=>{let n=K(),r=K(),i=K(),a=G(!1),o=G(void 0);return z(U(Vn(n,r),H(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),z(U(t,W(r),H(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},F(or)),Bi=q(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=K(),u=G(void 0),d=G(null),f=G(null);return z(s,d),z(c,f),I(U(l,W(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=Gr(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),z(U(u,V(Sn),H(Vi)),i),z(U(a,W(u),V(([,e])=>e!==void 0),B(),H(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},F(Zr,or,si,ei,zi));function Vi(e){return{align:`start`,index:0,offset:e.scrollTop}}var Hi=q(([{topItemsIndexes:e}])=>{let t=G(0);return z(U(t,V(e=>e>=0),H(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},F(Di));function Ui(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var Wi=Ui(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Gi=q(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:ee,rangeChanged:te,...ne}=b;return z(te,T.scrollSeekRangeChanged),z(U(T.windowViewportRect,H(e=>e.visibleHeight)),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:ee,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:te,...ne,...T,..._,sizes:u,...v}},F(Zr,si,or,Bi,Fi,Di,ri,q(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=Rn(U(c,W(o),Mn(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),V(([e])=>e!==0),W(r,s,n,i,p,m),V(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===li),H(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},Un.DEBUG),e))));function g(n){n>0?(L(t,{behavior:`auto`,top:-n}),L(e,0)):(L(e,0),L(t,{behavior:`auto`,top:-n}))}return I(U(h,W(e,a)),([t,n,r])=>{r&&Wi()?L(e,n-t):g(-t)}),I(U(Vn(Ln(a,!1),e,m),V(([e,t,n])=>!e&&!n&&t!==0),H(([e,t])=>t),Pn(1)),g),z(U(d,H(e=>({top:-e}))),t),I(U(l,W(f,u),H(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=lr(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{L(e,n),requestAnimationFrame(()=>{L(t,{top:n}),requestAnimationFrame(()=>{L(e,0),L(m,!1)})})}),{deviation:e}},F(or,mi,Di,Zr,Kn,kr)),Hi,$r,q(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),F(bi,Ii,ei,Ri,Oi,Li,ki,zi,Mi,Kn,Ai))));function Ki(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var qi=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Ji(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=N.createContext({});function c(e,n){e.propsReady!==void 0&&L(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];L(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];L(i,n[r])}e.propsReady!==void 0&&L(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];L(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=In(e[t.events[r]]),n),{})}return{Component:N.forwardRef(function(t,a){let{children:d,...f}=t,[p]=N.useState(()=>Tn(Bn(e),e=>{c(e,f)})),[m]=N.useState(bn(u,p));qi(()=>{for(let e of o)e in f&&I(m[e],f[e]);return()=>{Object.values(m).map(Dn)}},[f,m,p]),qi(()=>{c(p,f)}),N.useImperativeHandle(a,_n(l(p)));let h=n;return(0,P.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,P.jsx)(h,{...Ki([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=N.useContext(s)[e];qi(()=>I(n,t),[t,n])},useEmitterValue:e=>{let t=N.useContext(s)[e],n=N.useCallback(e=>I(t,e),[t]);return N.useSyncExternalStore(n,()=>R(t),()=>R(t))},usePublisher:e=>{let t=N.useContext(s);return N.useCallback(n=>{L(t[e],n)},[t,e])}}}var Yi=N.createContext(void 0),Xi=N.createContext(void 0),Zi=`-webkit-sticky`,Qi=`sticky`,$i=Ui(()=>{if(typeof document>`u`)return Qi;let e=document.createElement(`div`);return e.style.position=Zi,e.style.position===Zi?Zi:Qi}),ea=typeof document<`u`?N.useLayoutEffect:N.useEffect;function ta(e){return`self`in e}function na(e){return`body`in e}function ra(e,t,n,r=wn,i,a){let o=N.useRef(null),s=N.useRef(null),c=N.useRef(null),l=N.useCallback(n=>{let r,i,o,l=n.target;if(na(l)||ta(l)){let e=ta(l)?l:l.defaultView;o=a===!0?Qn(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?Qn(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():Zt.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);N.useEffect(()=>{let e=i||o.current;return Xn(e),r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{Xn(e),r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;ta(r)?(u=Math.max(Nr(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?Qn(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=Nr(r,a===!0?`width`:`height`),d=a===!0?Qn(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,ci(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:$n(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:$n(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function ia(e){return e}var aa=q(([e,t])=>({...e,...t}),F(Gi,q(()=>{let e=G(e=>`Item ${e}`),t=G(e=>`Group ${e}`),n=G({}),r=G(ia),i=G(`div`),a=G(wn),o=(e,t=null)=>Ln(U(n,H(t=>t[e]),B()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),oa=({height:e})=>(0,P.jsx)(`div`,{style:{height:e}}),sa={overflowAnchor:`none`,position:$i(),zIndex:1},ca={overflowAnchor:`none`},la={...ca,display:`inline-block`,height:`100%`},ua=N.memo(function({showTopList:e=!1}){let t=Z(`listState`),n=Ea(`sizeRanges`),r=Z(`useWindowScroll`),i=Z(`customScrollParent`),a=Ea(`windowScrollContainerState`),o=Ea(`scrollContainerState`),s=i||r?a:o,c=Z(`itemContent`),l=Z(`context`),u=Z(`groupContent`),d=Z(`trackItemSizes`),f=Z(`itemSize`),p=Z(`log`),m=Ea(`gap`),h=Z(`horizontalDirection`),{callbackRef:g}=nr(n,f,d,e?wn:s,p,m,i,h,Z(`skipAnimationFrameInResizeObserver`)),[_,v]=N.useState(0);Ta(`deviation`,e=>{_!==e&&v(e)});let y=Z(`EmptyPlaceholder`),b=Z(`ScrollSeekPlaceholder`)??oa,x=Z(`ListComponent`),S=Z(`ItemComponent`),C=Z(`GroupComponent`),w=Z(`computeItemKey`),T=Z(`isSeeking`),E=Z(`groupIndices`).length>0,D=Z(`alignToBottom`),ee=Z(`initialItemFinalLocationReached`),te=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?D?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?D?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...ee?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&y!=null?(0,P.jsx)(y,{...X(y,l)}):(0,P.jsx)(x,{...X(x,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:te,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=w(n+t.firstItemIndex,e.data,l);return T?(0,N.createElement)(b,{...X(b,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,N.createElement)(C,{...X(C,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:sa},u(e.index,l)):(0,N.createElement)(S,{...X(S,l),...ga(S,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?la:ca},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),da={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},fa={outline:`none`,overflowX:`auto`,position:`relative`},pa=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),ma=(e,t,n=0)=>({...pa(e),position:t?`relative`:`absolute`,top:t?-n:0}),ha={position:$i(),top:0,width:`100%`,zIndex:1};function X(e,t){if(typeof e!=`string`)return{context:t}}function ga(e,t){return{item:typeof e==`string`?void 0:t}}var _a=N.memo(function(){let e=Z(`HeaderComponent`),t=Ea(`headerHeight`),n=Z(`HeaderFooterTag`),r=er(N.useMemo(()=>e=>{t(Nr(e,`height`))},[t]),!0,Z(`skipAnimationFrameInResizeObserver`)),i=Z(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})}),va=N.memo(function(){let e=Z(`FooterComponent`),t=Ea(`footerHeight`),n=Z(`HeaderFooterTag`),r=er(N.useMemo(()=>e=>{t(Nr(e,`height`))},[t]),!0,Z(`skipAnimationFrameInResizeObserver`)),i=Z(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})});function ya({useEmitter:e,useEmitterValue:t,usePublisher:n}){return N.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=ra(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,P.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?fa:da,...i},tabIndex:0,...o,...X(c,a),children:r})})}function ba({useEmitter:e,useEmitterValue:t,usePublisher:n}){return N.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=N.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=ra(s,l,c,t(`scrollerRef`),f);return ea(()=>(h.current=f||p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,P.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...X(c,a),children:r})})}var xa=({children:e})=>{let t=N.useContext(Yi),n=Ea(`viewportHeight`),r=Ea(`fixedItemHeight`),i=Z(`alignToBottom`),a=Z(`horizontalDirection`),o=er(N.useMemo(()=>yn(n,e=>Nr(e,a?`width`:`height`)),[n,a]),!0,Z(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:pa(i),children:e})},Sa=({children:e})=>{let t=N.useContext(Yi),n=Ea(`windowViewportRect`),r=Ea(`fixedItemHeight`),i=Z(`customScrollParent`),a=Z(`useWindowScroll`),o=Z(`topListHeight`),s=ar(n,i,Z(`skipAnimationFrameInResizeObserver`)),c=Z(`alignToBottom`);return N.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:ma(c,a,o),children:e})},Ca=({children:e})=>{let t=Z(`TopItemListComponent`)??`div`,n=Z(`headerHeight`);return(0,P.jsx)(t,{style:{...ha,marginTop:`${n}px`},...X(t,Z(`context`)),children:e})},{Component:wa,useEmitter:Ta,useEmitterValue:Z,usePublisher:Ea}=Ji(aa,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},N.memo(function(e){let t=Z(`useWindowScroll`),n=Z(`topItemsIndexes`).length>0,r=Z(`customScrollParent`),i=Z(`context`);return(0,P.jsxs)(r||t?Oa:Da,{...e,context:i,children:[n&&(0,P.jsx)(Ca,{children:(0,P.jsx)(ua,{showTopList:!0})}),(0,P.jsxs)(r||t?Sa:xa,{children:[(0,P.jsx)(_a,{}),(0,P.jsx)(ua,{}),(0,P.jsx)(va,{})]})]})})),Da=ya({useEmitter:Ta,useEmitterValue:Z,usePublisher:Ea}),Oa=ba({useEmitter:Ta,useEmitterValue:Z,usePublisher:Ea}),ka=wa,Aa=q(([e,t])=>({...e,...t}),F(Gi,q(()=>{let e=G(e=>(0,P.jsxs)(`td`,{children:[`Item $`,e]})),t=G(null),n=G(e=>(0,P.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=G(null),i=G(null),a=G({}),o=G(ia),s=G(wn),c=(e,t=null)=>Ln(U(a,H(t=>t[e]),B()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),ja=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{height:e}})}),Ma=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),Na={overflowAnchor:`none`},Pa={position:$i(),zIndex:2,overflowAnchor:`none`},Fa=N.memo(function({showTopList:e=!1}){let t=Q(`listState`),n=Q(`computeItemKey`),r=Q(`firstItemIndex`),i=Q(`context`),a=Q(`isSeeking`),o=Q(`fixedHeaderHeight`),s=Q(`groupIndices`).length>0,c=Q(`itemContent`),l=Q(`groupContent`),u=Q(`ScrollSeekPlaceholder`)??ja,d=Q(`GroupComponent`),f=Q(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,N.createElement)(u,{...X(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,N.createElement)(d,{...X(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...Pa,top:o}},l(t.index,i)):(0,N.createElement)(f,{...X(f,i),...ga(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...Pa,top:o+g}:Na},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),Ia=N.memo(function(){let e=Q(`listState`),t=Q(`topItemsIndexes`).length>0,n=Va(`sizeRanges`),r=Q(`useWindowScroll`),i=Q(`customScrollParent`),a=Va(`windowScrollContainerState`),o=Va(`scrollContainerState`),s=i||r?a:o,c=Q(`trackItemSizes`),{callbackRef:l,ref:u}=nr(n,Q(`itemSize`),c,s,Q(`log`),void 0,i,!1,Q(`skipAnimationFrameInResizeObserver`)),[d,f]=N.useState(0);Ba(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=Q(`EmptyPlaceholder`),m=Q(`FillerRow`)??Ma,h=Q(`TableBodyComponent`),g=Q(`paddingTopAddition`),_=Q(`statefulTotalCount`),v=Q(`context`);if(_===0&&p!=null)return(0,P.jsx)(p,{...X(p,v)});let y=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),b=e.offsetTop+g+d-y,x=e.offsetBottom,S=b>0?(0,P.jsx)(m,{context:v,height:b},`padding-top`):null,C=x>0?(0,P.jsx)(m,{context:v,height:x},`padding-bottom`):null;return(0,P.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...X(h,v),children:[S,t&&(0,P.jsx)(Fa,{showTopList:!0}),(0,P.jsx)(Fa,{}),C]})}),La=({children:e})=>{let t=N.useContext(Yi),n=Va(`viewportHeight`),r=Va(`fixedItemHeight`),i=er(N.useMemo(()=>yn(n,e=>Nr(e,`height`)),[n]),!0,Q(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:pa(!1),children:e})},Ra=({children:e})=>{let t=N.useContext(Yi),n=Va(`windowViewportRect`),r=Va(`fixedItemHeight`),i=Q(`customScrollParent`),a=Q(`useWindowScroll`),o=ar(n,i,Q(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:ma(!1,a),children:e})},{Component:za,useEmitter:Ba,useEmitterValue:Q,usePublisher:Va}=Ji(Aa,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},N.memo(function(e){let t=Q(`useWindowScroll`),n=Q(`customScrollParent`),r=Va(`fixedHeaderHeight`),i=Va(`fixedFooterHeight`),a=Q(`fixedHeaderContent`),o=Q(`fixedFooterContent`),s=Q(`context`),c=er(N.useMemo(()=>yn(r,e=>Nr(e,`height`)),[r]),!0,Q(`skipAnimationFrameInResizeObserver`)),l=er(N.useMemo(()=>yn(i,e=>Nr(e,`height`)),[i]),!0,Q(`skipAnimationFrameInResizeObserver`)),u=n||t?Ua:Ha,d=n||t?Ra:La,f=Q(`TableComponent`),p=Q(`TableHeadComponent`),m=Q(`TableFooterComponent`),h=a?(0,P.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...X(p,s),children:a()},`TableHead`):null,g=o?(0,P.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...X(m,s),children:o()},`TableFoot`):null;return(0,P.jsx)(u,{...e,...X(u,s),children:(0,P.jsx)(d,{children:(0,P.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...X(f,s),children:[h,(0,P.jsx)(Ia,{},`TableBody`),g]})})})})),Ha=ya({useEmitter:Ba,useEmitterValue:Q,usePublisher:Va}),Ua=ba({useEmitter:Ba,useEmitterValue:Q,usePublisher:Va}),Wa={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ga={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ka,floor:qa,max:Ja,min:Ya,round:Xa}=Math;function Za(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Qa(e){return{...Ga,items:e}}function $a(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function eo(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var to=q(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=G(0),C=G(0),w=G(Wa),T=G({height:0,width:0}),E=G({height:0,width:0}),D=K(),ee=K(),te=G(0),ne=G(null),O=G({column:0,row:0}),re=K(),ie=K(),ae=G(!1),oe=G(0),se=G(!0),ce=G(!1),le=G(!1);I(U(m,W(oe),V(([e,t])=>t!==0)),()=>{L(se,!1)}),I(U(Vn(m,se,E,T,oe,ce),V(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{L(ce,!0),ai(1,()=>{L(D,e)}),On(U(l),()=>{L(t,[0,0]),L(se,!0)})}),z(U(ie,V(e=>e!=null&&e.scrollTop>0),jn(0)),C),I(U(m,W(ie),V(([,e])=>e!=null)),([,e])=>{e&&(L(T,e.viewport),L(E,e.item),L(O,e.gap),e.scrollTop>0&&(L(ae,!0),On(U(l,Nn(1)),e=>{L(ae,!1)}),L(c,{top:e.scrollTop})))}),z(U(T,H(({height:e})=>e)),d),z(U(Vn(J(T,$a),J(E,$a),J(O,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),J(l)),H(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),re),z(U(Vn(J(S),r,J(O,eo),J(E,$a),J(T,$a),J(ne),J(C),J(ae),J(se),J(oe)),V(([,,,,,,,e])=>!e),H(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return Wa;if(p===0){let t=oi(l,e);return Qa(Za(t,t+Math.max(s-1,0),o))}let h=no(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*qa((t+d)/(f+d)),_=h*Ka((n+d)/(f+d))-1,_=Ya(e-1,Ja(_,h-1)),g=Ya(_,Ja(0,g))):(g=0,_=-1);let v=Za(g,_,o),{bottom:y,top:b}=ro(a,r,i,v),x=Ka(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),z(U(ne,V(e=>e!==null),H(e=>e.length)),S),z(U(Vn(T,E,w,O),V(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),H(([e,t,{items:n},r])=>{let{bottom:i,top:a}=ro(e,r,t,n);return[a,i]}),B(Or)),t);let ue=G(!1);z(U(l,W(ue),H(([e,t])=>t||e!==0)),ue);let k=Rn(U(Vn(w,S),V(([{items:e}])=>e.length>0),W(ue),V(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),H(([[,e]])=>e-1),B())),de=Rn(U(J(w),V(({items:e})=>e.length>0&&e[0].index===0),jn(0),B())),fe=Rn(U(J(w),W(ae),V(([{items:e},t])=>e.length>0&&!t),H(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),B(Dr),Pn(0)));z(fe,p.scrollSeekRangeChanged),z(U(D,W(T,E,S,O),H(([e,t,n,r,i])=>{let a=ni(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Ja(0,l,Ya(r-1,l));let u=io(t,i,n,l);return o===`end`?u=Xa(u-t.height+n.height):o===`center`&&(u=Xa(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let pe=Ln(U(w,H(e=>e.offsetBottom+e.bottom)),0);return z(U(b,H(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:ne,deviation:te,footerHeight:i,gap:O,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:ie,scrollBy:o,scrollContainerState:s,scrollHeight:ee,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:le,initialTopMostItemIndex:oe,totalListHeight:pe,...f,endReached:k,propsReady:h,rangeChanged:fe,startReached:de,stateChanged:re,stateRestoreInProgress:ae,...x}},F(bi,or,mi,Ri,ei,zi,Kn));function no(e,t,n){return Ja(1,qa((e+n)/(qa(t)+n)))}function ro(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=io(e,t,n,r[0].index);return{bottom:io(e,t,n,r[r.length-1].index)+i,top:a}}function io(e,t,n,r){let i=qa(r/no(e.width,n.width,t.column)),a=i*n.height+Ja(0,i-1)*t.row;return a>0?a+t.row:a}var ao=q(([e,t])=>({...e,...t}),F(to,q(()=>{let e=G(e=>`Item ${e}`),t=G({}),n=G(null),r=G(`virtuoso-grid-item`),i=G(`virtuoso-grid-list`),a=G(ia),o=G(`div`),s=G(wn),c=(e,n=null)=>Ln(U(t,H(t=>t[e]),B()),n),l=G(!1),u=G(!1);return z(J(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),oo=N.memo(function(){let e=$(`gridState`),t=$(`listClassName`),n=$(`itemClassName`),r=$(`itemContent`),i=$(`computeItemKey`),a=$(`isSeeking`),o=mo(`scrollHeight`),s=$(`ItemComponent`),c=$(`ListComponent`),l=$(`ScrollSeekPlaceholder`),u=$(`context`),d=mo(`itemDimensions`),f=mo(`gap`),p=$(`log`),m=$(`stateRestoreInProgress`),h=mo(`reportReadyState`),g=er(N.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:_o(`column-gap`,getComputedStyle(e).columnGap,p),row:_o(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return ea(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,P.jsx)(c,{className:t,ref:g,...X(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,P.jsx)(l,{...X(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,N.createElement)(s,{...X(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),so=N.memo(function(){let e=$(`HeaderComponent`),t=mo(`headerHeight`),n=$(`headerFooterTag`),r=er(N.useMemo(()=>e=>{t(Nr(e,`height`))},[t]),!0,!1),i=$(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})}),co=N.memo(function(){let e=$(`FooterComponent`),t=mo(`footerHeight`),n=$(`headerFooterTag`),r=er(N.useMemo(()=>e=>{t(Nr(e,`height`))},[t]),!0,!1),i=$(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})}),lo=({children:e})=>{let t=N.useContext(Xi),n=mo(`itemDimensions`),r=mo(`viewportDimensions`),i=er(N.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return N.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,P.jsx)(`div`,{ref:i,style:pa(!1),children:e})},uo=({children:e})=>{let t=N.useContext(Xi),n=mo(`windowViewportRect`),r=mo(`itemDimensions`),i=$(`customScrollParent`),a=$(`useWindowScroll`),o=ar(n,i,!1);return N.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,P.jsx)(`div`,{ref:o,style:ma(!1,a),children:e})},{Component:fo,useEmitter:po,useEmitterValue:$,usePublisher:mo}=Ji(ao,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},N.memo(function({...e}){let t=$(`useWindowScroll`),n=$(`customScrollParent`),r=n||t?go:ho,i=n||t?uo:lo,a=$(`context`);return(0,P.jsx)(r,{...e,...X(r,a),children:(0,P.jsxs)(i,{children:[(0,P.jsx)(so,{}),(0,P.jsx)(oo,{}),(0,P.jsx)(co,{})]})})})),ho=ya({useEmitter:po,useEmitterValue:$,usePublisher:mo}),go=ba({useEmitter:po,useEmitterValue:$,usePublisher:mo});function _o(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,Un.WARN),t===`normal`?0:parseInt(t??`0`,10)}function vo(){return(0,N.useSyncExternalStore)(e=>De.subscribe(e),()=>De.getPlayingKey(),()=>null)}function yo({attachment:e,outbound:t}){let n=e.kind===`image`,r=e.title||e.artifactId,[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(!1);(0,N.useEffect)(()=>{let t=!1,n=null;async function r(){l(!0),s(null),a(null);try{let r=await v(`/artifacts/${encodeURIComponent(e.artifactId)}/content`);if(t)return;n=URL.createObjectURL(r),a(n)}catch(e){t||s(e.message)}finally{t||l(!1)}}return r(),()=>{t=!0,n&&URL.revokeObjectURL(n)}},[e.artifactId]);function f(){if(!i)return;let e=document.createElement(`a`);e.href=i,e.download=r,document.body.appendChild(e),e.click(),e.remove()}return n?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>i&&d(!0),disabled:!i,className:`group/img mt-2 block overflow-hidden rounded-md border border-foreground/10 bg-black/10 text-left disabled:cursor-default relative`,children:i?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`img`,{src:i,alt:r,loading:`lazy`,className:`block max-h-72 max-w-full object-contain`}),(0,P.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/img:bg-black/30 transition-colors`,children:(0,P.jsx)(me,{className:`w-6 h-6 text-white opacity-0 group-hover/img:opacity-100 transition-opacity drop-shadow-md`})})]}):(0,P.jsxs)(`span`,{className:k(`flex min-h-20 items-center gap-2 px-3 py-2 text-xs`,o?`text-red-400`:`text-muted-foreground`),children:[c?(0,P.jsx)(le,{className:`h-4 w-4 animate-spin`}):(0,P.jsx)(O,{className:`h-4 w-4`}),o||`Loading image`]})}),i&&(0,P.jsx)(lt,{open:u,onOpenChange:d,children:(0,P.jsxs)(at,{className:`max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden`,showCloseButton:!1,children:[(0,P.jsx)(ft,{className:`sr-only`,children:r}),(0,P.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,P.jsx)(`img`,{src:i,alt:r,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,P.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:f,className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Download`,children:(0,P.jsx)(g,{className:`w-4 h-4`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,P.jsx)(se,{className:`w-4 h-4`})})]})]})]})})]}):(0,P.jsxs)(`button`,{type:`button`,onClick:f,disabled:!i,className:k(`mt-2 flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-xs transition-colors disabled:cursor-default disabled:opacity-70`,t?`border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/15`:`border-border bg-background hover:bg-muted`),children:[c?(0,P.jsx)(le,{className:`h-4 w-4 shrink-0 animate-spin`}):o?(0,P.jsx)(O,{className:`h-4 w-4 shrink-0 text-red-400`}):(0,P.jsx)(de,{className:`h-4 w-4 shrink-0`}),(0,P.jsx)(`span`,{className:k(`min-w-0 flex-1 truncate`,o&&`text-red-400`),children:o||r}),(0,P.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`})]})}function bo({open:e,onToggle:t,onReact:n}){return(0,P.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,P.jsx)(`button`,{type:`button`,title:`Add reaction`,onClick:t,className:k(`inline-flex h-5 w-6 items-center justify-center rounded-full border border-border bg-popover text-muted-foreground shadow-sm transition hover:bg-muted hover:text-foreground`,e?`opacity-100`:`opacity-0 pointer-events-none md:group-hover/msg:opacity-100 md:group-hover/msg:pointer-events-auto`),children:(0,P.jsx)(ee,{className:`h-3 w-3`})}),e&&(0,P.jsx)(`div`,{className:`absolute bottom-full left-0 z-30 mb-1 flex gap-0.5 rounded-full border border-border bg-popover p-0.5 shadow-md`,children:jt.map(e=>(0,P.jsx)(`button`,{type:`button`,title:`React ${e}`,onClick:()=>n(e),className:`inline-flex h-6 w-7 items-center justify-center rounded-full text-xs transition-colors hover:bg-muted`,children:e},e))})]})}var xo=(0,N.memo)(function({msg:e,peer:t,onOpenReferencedPath:n,onPreviewReferencedPath:r,onPreviewReferencedPathEnd:i}){let a=e.from===Ke,o=A(e=>e.reactToMessage),s=A(e=>e.voiceTtsEnabled),c=vo(),l=A(e=>{let n=e.agentsById[t]?.meta?.cwd;return typeof n==`string`?n:``}),[u,d]=(0,N.useState)(!1),f=(0,N.useRef)(null),p=(0,N.useRef)(null),m=(0,N.useRef)(!1),h=Ae(e),g=Lt(e.occurredAt??e.createdAt),_=At(e),v=Mt(e),y=a?Pt(e,t):null,b=y?.icon,x=c===String(e.id),S=s&&!a&&!Nt(e)&&h.trim().length>0;function C(t){t.stopPropagation(),x?De.bargeIn():De.speak(e.body,String(e.id))}(0,N.useEffect)(()=>{if(!u)return;function e(e){kt()||f.current&&!f.current.contains(e.target)&&d(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[u]);function T(e){return Tt(l||`/`,e)}function E(e,t){let r=T(e);n?.(r,t)}function D(e,t,n){let i=T(e);r?.(i,t,n)}function ee(t){o(e,t),d(!1)}function te(e){e.button===0&&(p.current={x:e.clientX,y:e.clientY},m.current=!1)}function O(e){let t=p.current;t&&(Math.abs(e.clientX-t.x)>3||Math.abs(e.clientY-t.y)>3)&&(m.current=!0)}function re(t){if(!(Nt(e)||a)&&!t.target.closest(`a,button,input,textarea,select,[role="button"]`)){if(m.current||kt()){m.current=!1;return}d(e=>!e)}}return(0,P.jsx)(`div`,{"data-msg-id":e.id,className:k(`group/msg flex mb-3`,a?`justify-end`:`justify-start`),children:(0,P.jsxs)(`div`,{ref:f,className:`relative max-w-[85%] md:max-w-[75%]`,children:[S&&(0,P.jsx)(`button`,{type:`button`,title:x?`Stop playback`:`Play aloud`,onClick:C,className:k(`absolute -top-2 -right-2 z-20 inline-flex h-6 w-6 items-center justify-center rounded-full border bg-popover shadow-sm transition`,x?`border-primary/50 text-primary opacity-100`:`border-border text-muted-foreground opacity-70 hover:bg-muted hover:text-foreground hover:opacity-100 [@media(hover:hover)]:md:opacity-0 [@media(hover:hover)]:md:group-hover/msg:opacity-100`),children:x?(0,P.jsx)(w,{className:`h-3.5 w-3.5 animate-pulse`}):(0,P.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`div`,{className:k(`rounded-2xl px-3.5 py-2 text-sm select-text`,!a&&!Nt(e)&&`cursor-pointer`,a?`bg-primary text-primary-foreground rounded-br-sm`:`bg-card ring-1 ring-foreground/10 rounded-bl-sm`),onPointerDown:te,onPointerMove:O,onClick:re,children:[e.subject&&(0,P.jsx)(`p`,{className:k(`text-xs font-semibold mb-1`,a?`text-primary-foreground/70`:`text-muted-foreground`),children:e.subject}),(0,P.jsx)(ht,{text:h,rawBody:e.body,className:`leading-relaxed`,onOpenPath:E,onPreviewPath:D,onPreviewPathEnd:i,resolvePathTitle:(e,t)=>`${T(e)}${t?`:${t}`:``}`}),_.map(t=>(0,P.jsx)(yo,{attachment:t,outbound:a},`${e.id}-${t.artifactId}-${t.role||``}`)),(0,P.jsxs)(`p`,{className:k(`text-xs mt-1 flex items-center gap-1.5`,a?`justify-end text-primary-foreground/60`:`justify-end text-muted-foreground`),children:[(0,P.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.id]}),(0,P.jsx)(`span`,{children:g}),y&&b&&(0,P.jsxs)(`span`,{className:k(`inline-flex items-center gap-1`,y.tone===`ok`&&`text-emerald-300`,y.tone===`warn`&&`text-amber-200`,y.tone===`danger`&&`text-red-200`),title:y.title,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),y.label]})]})]}),!Nt(e)&&v.length>0&&(0,P.jsxs)(`div`,{className:k(`flex flex-wrap items-center gap-0.5 -mt-1 relative z-10`,a?`justify-end pr-2`:`justify-start pl-2`),children:[!a&&(0,P.jsx)(bo,{open:u,onToggle:()=>d(e=>!e),onReact:ee}),v.map(e=>(0,P.jsxs)(`button`,{type:`button`,title:e.actors.join(`, `),onClick:()=>ee(e.emoji),className:k(`inline-flex h-5 items-center gap-0.5 rounded-full border px-1.5 text-[11px] shadow-sm transition-colors`,e.mine?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-background hover:bg-muted text-foreground`),children:[(0,P.jsx)(`span`,{children:e.emoji}),e.count>1&&(0,P.jsx)(`span`,{children:e.count})]},e.emoji))]}),!Nt(e)&&!a&&v.length===0&&(0,P.jsx)(`div`,{className:`absolute -bottom-2.5 left-1 z-20`,children:(0,P.jsx)(bo,{open:u,onToggle:()=>d(e=>!e),onReact:ee})})]})})});function So({agentId:e,approval:t}){let n=A(e=>e.sendPermissionDecision),[r,i]=(0,N.useState)(null);if(!t)return null;if(t.questions&&t.questions.length)return(0,P.jsx)(To,{agentId:e,approval:t,questions:t.questions});let a=t,o=t.choices.length?t.choices:[{id:`approve`,label:`Approve`},{id:`deny`,label:`Deny`}];async function s(t){if(!r){i(t.id);try{await n(e,a.id,t.id)}finally{i(null)}}}let c=t.kind===`plan`;return(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsx)(`div`,{className:`max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-amber-500/35 px-3.5 py-3 text-sm`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[c?(0,P.jsx)(D,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}):(0,P.jsx)(O,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-100`,children:t.title}),t.body&&(c?(0,P.jsx)(`div`,{className:`mt-2 max-h-72 overflow-auto rounded-md bg-background/60 p-2.5 text-xs leading-relaxed`,children:(0,P.jsx)(ht,{text:t.body,rawBody:t.body,className:`leading-relaxed`})}):(0,P.jsx)(`pre`,{className:`mt-2 max-h-44 overflow-auto whitespace-pre-wrap break-words rounded-md bg-background/80 p-2 font-mono text-xs leading-relaxed text-muted-foreground`,children:t.body})),(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(e=>(0,P.jsxs)(M,{size:`sm`,variant:e.id===`deny`||e.id===`abort`?`outline`:`default`,disabled:!!r,onClick:()=>void s(e),className:`h-7 px-2 text-xs`,children:[r===e.id&&(0,P.jsx)(le,{className:`mr-1.5 h-3 w-3 animate-spin`}),e.label]},e.id))})]})]})})})}function Co(e){return e?e.otherActive&&e.other.trim()?!0:e.labels.length>0:!1}function wo(e){let t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(`, `)}function To({agentId:e,approval:t,questions:n}){let r=A(e=>e.sendPermissionDecision),[i,a]=(0,N.useState)(0),[o,s]=(0,N.useState)({}),[c,l]=(0,N.useState)(null),u=n[Math.min(i,n.length-1)],d=o[i];if(!u)return null;let f=!!u.multiSelect,p=n.length,m=i===p-1,h=Co(d),g=n.every((e,t)=>Co(o[t])),_=!!c;function v(e){s(t=>{let n=t[i]??{labels:[],other:``,otherActive:!1};return{...t,[i]:{...n,...e}}})}function y(e){if(f){let t=d?.labels.includes(e);v({labels:t?(d?.labels??[]).filter(t=>t!==e):[...d?.labels??[],e]})}else v({labels:[e],otherActive:!1})}function b(){v(f?{otherActive:!d?.otherActive}:{labels:[],otherActive:!0})}async function x(){if(!(!g||_)){l(`answer`);try{let i={};n.forEach((e,t)=>{let n=o[t];n&&(i[e.question]=wo(n))}),await r(e,t.id,`answer`,i)}finally{l(null)}}}async function S(){if(!_){l(`dismiss`);try{await r(e,t.id,`deny`)}finally{l(null)}}}let C=!!d?.otherActive;return(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-amber-500/35 px-3.5 py-3 text-sm`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(T,{className:`h-4 w-4 shrink-0 text-amber-400`}),(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-100`,children:t.title}),p>1&&(0,P.jsxs)(Je,{variant:`outline`,className:`ml-auto h-5 px-1.5 text-[10px] text-muted-foreground`,children:[i+1,` / `,p]})]}),(0,P.jsxs)(`div`,{className:`mt-3`,children:[u.header&&(0,P.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-amber-300/80`,children:u.header}),(0,P.jsx)(`div`,{className:`mt-0.5 text-sm text-foreground whitespace-pre-wrap break-words`,children:u.question}),f&&(0,P.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`Select all that apply`}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:[u.options.map(e=>{let t=!!d?.labels.includes(e.label);return(0,P.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>y(e.label),className:k(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,t?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,_&&`opacity-60`),children:[(0,P.jsx)(`span`,{className:k(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,f?`rounded`:`rounded-full`,t?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:t&&(0,P.jsx)(E,{className:`h-3 w-3`})}),(0,P.jsxs)(`span`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),e.description&&(0,P.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.label)}),(0,P.jsxs)(`button`,{type:`button`,disabled:_,onClick:b,className:k(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,C?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,_&&`opacity-60`),children:[(0,P.jsx)(`span`,{className:k(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,f?`rounded`:`rounded-full`,C?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:C&&(0,P.jsx)(E,{className:`h-3 w-3`})}),(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:`Other…`})]}),C&&(0,P.jsx)(mt,{autoFocus:!0,rows:2,disabled:_,value:d?.other??``,onChange:e=>v({other:e.target.value,otherActive:!0}),placeholder:`Type your answer`,className:`mt-1 text-sm`})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[i>0&&(0,P.jsxs)(M,{size:`sm`,variant:`outline`,disabled:_,onClick:()=>a(e=>e-1),className:`h-7 px-2 text-xs`,children:[(0,P.jsx)(he,{className:`mr-1 h-3 w-3`}),`Back`]}),m?(0,P.jsxs)(M,{size:`sm`,disabled:_||!g,onClick:()=>void x(),className:`h-7 px-2 text-xs`,children:[c===`answer`&&(0,P.jsx)(le,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Send answer`,p>1?`s`:``]}):(0,P.jsxs)(M,{size:`sm`,disabled:_||!h,onClick:()=>a(e=>e+1),className:`h-7 px-2 text-xs`,children:[`Next`,(0,P.jsx)(fe,{className:`ml-1 h-3 w-3`})]}),(0,P.jsxs)(M,{size:`sm`,variant:`ghost`,disabled:_,onClick:()=>void S(),className:`ml-auto h-7 px-2 text-xs text-muted-foreground`,children:[c===`dismiss`&&(0,P.jsx)(le,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Dismiss`]})]})]})})}var Eo={online:`text-emerald-400`,offline:`text-zinc-400`,shutdown:`text-zinc-400`,restarted:`text-blue-400`,"compaction-requested":`text-zinc-400`,compacting:`text-amber-400`,compacted:`text-amber-400`,"compaction-stalled":`text-red-400`,"clear-requested":`text-zinc-400`,"clearing-context":`text-amber-400`,"context-cleared":`text-amber-400`,"clear-stalled":`text-red-400`,"shutting-down":`text-zinc-400`};function Do(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===on(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===on(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}function Oo({event:e}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,P.jsx)(m,{className:k(`w-2 h-2 fill-current`,Eo[e.status]||`text-zinc-400`)}),(0,P.jsx)(`span`,{children:$t[e.status]||e.status}),(0,P.jsx)(`span`,{className:`text-muted-foreground/60`,children:Lt(e.timestamp)})]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function ko({blockedLabel:e,onInterrupt:t}){return e?(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4 py-2.5`,children:[(0,P.jsx)(O,{className:`w-3.5 h-3.5 text-red-400`}),(0,P.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.2s_infinite]`}),(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.4s_infinite]`})]}),(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),t&&(0,P.jsxs)(`button`,{onClick:t,title:`Interrupt`,className:`ml-1 flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs text-muted-foreground hover:text-red-300 hover:bg-red-500/10 transition-colors`,children:[(0,P.jsx)(w,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var Ao=`agent-relay:chat-hide-tools`,jo=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(Ao)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===Ao&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(Ao,t?`on`:`off`)}catch{}n()}}})();function Mo(){return[(0,N.useSyncExternalStore)(jo.subscribe,jo.get,()=>!1),jo.toggle]}function No({steps:e,showReasoning:t}){let[n,r]=Mo(),i=t?e:e.filter(e=>e.kind!==`reasoning`);if(!i.length)return null;let a=i.filter(e=>e.kind===`tool`).length;return(0,P.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,P.jsxs)(`div`,{className:`max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5`,children:[i.map(e=>e.kind===`narration`?(0,P.jsx)(ht,{text:e.text,className:`text-sm leading-relaxed break-words text-foreground/90 min-w-0`},e.id):e.kind===`reasoning`?(0,P.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,P.jsx)(ie,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,P.jsx)(ht,{text:e.text,className:`italic break-words min-w-0`})]},e.id):n?null:(0,P.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,P.jsx)(ae,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,P.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,P.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text?(0,P.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),a>0&&(0,P.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,P.jsx)(fe,{className:k(`w-3 h-3 shrink-0 transition-transform`,!n&&`rotate-90`)}),(0,P.jsx)(`span`,{children:n?`show ${a} tool step${a===1?``:`s`}`:`hide tool steps`})]})]})})}function Po({date:e}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:Do(e)}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Fo({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Io({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-dashed border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,P.jsx)(be,{className:`h-3 w-3`}),(0,P.jsxs)(`span`,{children:[`forked history from `,t]}),(0,P.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Lo({entry:e,sourceLabel:t}){let n=e.message,r=Ae(n),i=e.originalFrom===Ke;return(0,P.jsx)(`div`,{className:k(`flex mb-3 opacity-80`,i?`justify-end`:`justify-start`),children:(0,P.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,P.jsxs)(`div`,{className:k(`rounded-2xl border border-dashed px-3.5 py-2 text-sm select-text`,i?`border-primary/25 bg-primary/10 text-foreground rounded-br-sm`:`border-border bg-card/70 rounded-bl-sm`),children:[(0,P.jsxs)(`div`,{className:k(`mb-1 text-[10px] uppercase tracking-normal`,i?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,i?`you`:t||e.originalFrom]}),(0,P.jsx)(ht,{text:r,rawBody:n.body,className:`leading-relaxed`}),(0,P.jsxs)(`p`,{className:k(`mt-1 flex items-center justify-end gap-1.5 text-xs`,i?`text-primary/60`:`text-muted-foreground`),children:[(0,P.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,P.jsx)(`span`,{children:Lt(e.originalCreatedAt)})]})]})})})}function Ro({scrollRef:e,timeline:t}){let[n,r]=(0,N.useState)(!0),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(!0),u=(0,N.useMemo)(()=>{for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(!n||n.type!==`message`)&&n.msg.from===`user`)return{id:n.msg.id,body:Ae(n.msg)}}return null},[t]);if((0,N.useEffect)(()=>{let t=e.current;if(!u||!t){r(!0);return}let n=t.querySelector(`[data-msg-id="${u.id}"]`);if(!n){r(!0);return}let i=new IntersectionObserver(([e])=>{if(e&&(r(e.isIntersecting),!e.isIntersecting)){let n=e.rootBounds?.top??t.getBoundingClientRect().top;l(e.boundingClientRect.top<n)}},{root:t,threshold:0});i.observe(n);let a=()=>{let e=n.getBoundingClientRect(),r=t.getBoundingClientRect();l(e.top<r.top)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{i.disconnect(),t.removeEventListener(`scroll`,a)}},[u?.id,e]),n||!u||!u.body.trim())return null;let d=i?.id===u.id?i.value:!1,f=o?.id===u.id?o.value:!1;function p(){let t=e.current;!t||!u||t.querySelector(`[data-msg-id="${u.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let m=c?`↑`:`↓`;return f?(0,P.jsx)(`div`,{className:`sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 bg-background`,children:(0,P.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-1 text-[11px] text-primary/60 hover:text-primary border-b border-primary/10 transition-colors`,onClick:()=>s({id:u.id,value:!1}),children:[(0,P.jsx)(`span`,{children:`Your prompt`}),(0,P.jsx)(ce,{className:`w-3 h-3`})]})}):(0,P.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 px-2 md:px-3 pt-2 pb-1.5 bg-background border-b border-primary/10`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,P.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,P.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:p,children:[m,` scroll to original`]}),(0,P.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>s({id:u.id,value:!0}),title:`Minimize`,children:(0,P.jsx)(_e,{className:`w-3 h-3`})})]}),(0,P.jsx)(`p`,{className:k(`text-sm text-foreground leading-snug cursor-pointer`,!d&&`line-clamp-2`),onClick:()=>a({id:u.id,value:!d}),children:u.body})]})}var zo=1e6,Bo=`px-3 md:px-4`;function Vo({context:e}){if(!e)return null;let{agentId:t,agentStatus:n,pendingApproval:r,blockedLabel:i,canInterrupt:a,onInterrupt:o}=e,s=n===`busy`&&!r;return!r&&!s?null:(0,P.jsxs)(`div`,{className:`${Bo} pb-3 md:pb-4`,children:[r&&(0,P.jsx)(So,{agentId:t,approval:r},r.id),s&&(0,P.jsx)(ko,{blockedLabel:i,onInterrupt:a?o:void 0})]})}function Ho(e){return e.type===`message`?`msg-${e.msg.id}`:e.type===`activity`?`act-${e.steps[0]?.id??e.timestamp}`:e.type===`import-boundary`?`import-${e.history.id}`:e.type===`imported-message`?`import-msg-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`:e.type===`status`?`status-${e.event.id}`:e.type===`date`?`date-${e.date}`:`created-${e.timestamp}`}function Uo(e){let t=e.findIndex(e=>e.type!==`date`&&e.type!==`created`),n=t>=0?t:0,r=e[n];return{key:r?Ho(r):null,index:n}}function Wo(e,t){let[n,r]=(0,N.useState)(()=>zo-t.length),i=(0,N.useRef)({agentId:e,anchor:Uo(t)});return(0,N.useLayoutEffect)(()=>{let n=Uo(t),a=i.current;r(n=>{if(a.agentId!==e)return zo-t.length;if(!a.anchor.key)return n;let r=t.findIndex(e=>Ho(e)===a.anchor.key)-a.anchor.index;return r>0?n-r:n}),i.current={agentId:e,anchor:n}},[e,t]),n}function Go({agentId:e,agentStatus:t,timeline:n,hasMore:r,loading:a,loadedInitial:o,showReasoning:s,pendingApproval:c,blockedLabel:l,canInterrupt:u,onAtBottomChange:d,onLoadOlder:f,onInterrupt:m,onOpenReferencedPath:h,onPreviewReferencedPath:g,onPreviewReferencedPathEnd:_}){let v=(0,N.useRef)(null),y=(0,N.useRef)(null),[b,x]=(0,N.useState)(!0),S=Wo(e,n),C=n.length>0?Ho(n[n.length-1]):null,w=(0,N.useRef)(C),T=(0,N.useRef)(e);T.current!==e&&(T.current=e,w.current=C);let E=w.current?n.findIndex(e=>Ho(e)===w.current):-1,D=!b&&E>=0?n.slice(E+1).filter(e=>e.type===`message`&&e.msg.from!==`user`).length:0;(0,N.useLayoutEffect)(()=>{b&&(w.current=C)},[b,C]);let ee=(0,N.useRef)(b);ee.current=b,(0,N.useLayoutEffect)(()=>{if(!ee.current)return;let e=y.current;if(!e)return;let t=0,n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight,behavior:`auto`})})});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[C]);let te=c?.id;(0,N.useLayoutEffect)(()=>{if(!b||t!==`busy`&&!te)return;let e=y.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[t,te,b]);let ne=(0,N.useCallback)(e=>{y.current=e instanceof HTMLElement?e:null},[]),O=(0,N.useCallback)(e=>{x(e),d?.(e)},[d]),re=(0,N.useCallback)(()=>{!r||a||f()},[r,a,f]),ie=(0,N.useCallback)(()=>{w.current=C,v.current?.scrollToIndex({index:`LAST`,align:`end`});let e=y.current;e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight,behavior:`smooth`})}))},[C]),ae=(0,N.useMemo)(()=>function(){return(0,P.jsxs)(`div`,{className:Bo,children:[(0,P.jsx)(Ro,{scrollRef:y,timeline:n}),(0,P.jsx)(Ko,{hasMore:r,loading:a,loadedInitial:o,hasItems:n.length>0})]})},[r,o,a,n]),oe=(0,N.useMemo)(()=>({agentId:e,agentStatus:t,pendingApproval:c,blockedLabel:l,canInterrupt:u,onInterrupt:m}),[e,t,l,u,m,c]),se=(0,N.useMemo)(()=>function(){return(0,P.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center`,children:[a?(0,P.jsx)(le,{className:`mb-2 h-5 w-5 animate-spin text-muted-foreground`}):(0,P.jsx)(p,{className:`mb-2 h-8 w-8 text-zinc-600`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a?`Loading messages`:`No messages yet`})]})},[a]),ce=(0,N.useMemo)(()=>({Header:ae,Footer:Vo,EmptyPlaceholder:se}),[se,ae]);return(0,P.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,P.jsx)(ka,{ref:v,scrollerRef:ne,className:`h-full py-3 md:py-4`,style:{height:`100%`,overflowX:`hidden`,overscrollBehavior:`contain`},context:oe,data:n,firstItemIndex:S,initialTopMostItemIndex:Math.max(0,n.length-1),computeItemKey:(e,t)=>Ho(t),itemContent:(t,n)=>(0,P.jsx)(`div`,{className:Bo,children:(0,P.jsx)(qo,{entry:n,agentId:e,showReasoning:s,onOpenReferencedPath:h,onPreviewReferencedPath:g,onPreviewReferencedPathEnd:_})}),components:ce,startReached:re,atBottomStateChange:O,atBottomThreshold:64,followOutput:e=>e?`auto`:!1,increaseViewportBy:{top:600,bottom:600}},e),!b&&n.length>0&&(0,P.jsxs)(M,{type:`button`,size:`sm`,variant:`secondary`,className:`absolute bottom-3 right-4 z-20 h-8 gap-1.5 rounded-full border border-border/70 bg-background/95 px-3 text-xs shadow-lg backdrop-blur`,onClick:ie,children:[(0,P.jsx)(i,{className:`h-3.5 w-3.5`}),`Latest`,D>0&&(0,P.jsx)(`span`,{className:`ml-0.5 min-w-4 rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-medium leading-none text-primary-foreground`,children:D>99?`99+`:D})]})]})}function Ko({hasMore:e,loading:t,loadedInitial:n,hasItems:r}){return t?(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pb-3 text-xs text-muted-foreground`,children:[(0,P.jsx)(le,{className:`h-3.5 w-3.5 animate-spin`}),(0,P.jsx)(`span`,{children:`Loading earlier messages`})]}):!e&&n&&r?(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pb-3 text-xs text-muted-foreground/70`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsx)(`span`,{children:`Beginning of conversation`}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}):null}function qo({entry:e,agentId:t,showReasoning:n,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}){return e.type===`message`?(0,P.jsx)(xo,{msg:e.msg,peer:t,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}):e.type===`activity`?(0,P.jsx)(No,{steps:e.steps,showReasoning:n}):e.type===`import-boundary`?(0,P.jsx)(Io,{history:e.history}):e.type===`imported-message`?(0,P.jsx)(Lo,{entry:e.entry,sourceLabel:e.history.sourceAgentLabel||e.history.sourcePeerId}):e.type===`status`?(0,P.jsx)(Oo,{event:e.event}):e.type===`date`?(0,P.jsx)(Po,{date:e.date}):(0,P.jsx)(Fo,{timestamp:e.timestamp})}var Jo=[];function Yo({threads:e,onBack:t,showBackButton:n}){let r=A(e=>e.selectedInboxThread),i=A(e=>e.agentsById),a=A(e=>e.inboxDrafts),o=Ee(),s=A(e=>e.sendChatMessage),c=A(e=>e.openFilesAt),l=A(e=>e.openFilesForAgent),u=A(e=>e.openAgentDetail),f=A(e=>e.chatSending),m=A(e=>e.markInboxThreadRead),h=A(e=>e.markInboxThreadUnread),g=A(e=>e.setReplyDraft),v=A(e=>e.exportThread),y=A(e=>e.doAgentAction),b=A(e=>e.workspaceAction),x=A(e=>e.openWorkspaceFocus),S=A(e=>e.forkFromAgent),C=A(e=>e.chatHistoryImports),w=A(e=>e.agentChatByAgent[e.selectedInboxThread]),T=w?.messages??Jo,E=A(e=>e.loadOlder),D=A(e=>e.openConfirm),ee=A(e=>e.showError),te=A(e=>e.orchestrators),ne=A(e=>e.fetchOrchestrators),O=A(e=>e.showReasoning),re=A(e=>e.voiceTtsEnabled),ie=A(e=>e.setVoiceTtsEnabled),ae=A(e=>e.voiceInputMode),oe=A(e=>e.plansByThread);(0,N.useRef)(null);let ce=(0,N.useRef)(null),[le,ue]=(0,N.useState)(`idle`),k=(0,N.useRef)([]),[de,fe]=(0,N.useState)([]),[pe,me]=(0,N.useState)(!1),[he,ge]=(0,N.useState)(null),[_e,ve]=(0,N.useState)(null),[ye,be]=(0,N.useState)(``),xe=(0,N.useRef)(null),Te=(0,N.useRef)(0),Oe=dn(r),ke=(0,N.useMemo)(()=>e.find(e=>e.peer===r)||null,[e,r]),Ae=(0,N.useMemo)(()=>T.filter(e=>Re(e)===r&&!qe(e)).sort((e,t)=>e.id-t.id),[T,r]),j=i[r]||null,je=typeof j?.meta?.lifecycleAction==`string`&&j.meta.lifecycleAction.startsWith(`finalizing-`),{terminalOpen:Me,terminalTarget:Pe,terminalOpening:Fe,openTerminal:Ie,closeTerminal:Le}=xt(j?.id),Ve=typeof j?.meta?.spawnRequestId==`string`?j.meta.spawnRequestId:``,He=(0,N.useMemo)(()=>C.filter(e=>e.targetAgentId===r||!!(Ve&&e.targetSpawnRequestId===Ve)),[Ve,C,r]),Ue=Ne(j),We=Ue?.pendingApproval,Ge=(0,N.useMemo)(()=>{if(!r||!ke&&Ae.length===0)return null;let e=Ae[Ae.length-1]??ke?.lastMessage??null,t=ke?.previewMessage&&Ae.some(e=>e.id===ke.previewMessage?.id)?ke.previewMessage:e;return{id:ke?.id??r,peer:r,messages:Ae,lastMessage:e,previewMessage:t,attention:ke?.attention??{unread:0,needsHumanResponse:!1,score:0},archived:ke?.archived??!1,draft:ke?.draft??``}},[r,ke,Ae]),Ke=Ge||(He.length>0?{peer:r,messages:[],importedHistory:He}:null),Je=a[r]||``,Ye=typeof j?.meta?.tmuxSession==`string`&&j.meta.tmuxSession.trim()?j.meta.tmuxSession:null,Xe=Ye?te.find(e=>e.managedAgents?.some(e=>e.agentId===j.id||e.tmuxSession===Ye))??null:null,Ze=!!(Ye&&Xe?.status===`online`&&j?.providerCapabilities?.terminal?.live?.read),$e=j?.providerCapabilities?.model?.provider??(typeof j?.meta?.provider==`string`?j.meta.provider:void 0),et=!!(Ze&&(j?.providerCapabilities?.terminal?.live?.write||$e===`claude`)),tt=j?.providerCapabilities?.terminal?.attach?.create===!0,nt=Ze||tt,rt=ze(j,`compact`),it=ze(j,`clearContext`),at=ze(j,`shutdown`),ot=ze(j,`interrupt`),st=()=>{j&&y(j,`interrupt`)},[ct,lt]=(0,N.useState)(0),[ut,dt]=(0,N.useState)(!1),ft=j?.providerCapabilities?.liveSession?.slashCommands===!0,mt=j?.providerCapabilities?.model?.provider??(typeof j?.meta?.provider==`string`?j.meta.provider:void 0),ht=ft&&!ut&&/^\/\S*$/.test(Je)?Gt(mt).filter(e=>e.name.toLowerCase().startsWith(Je.toLowerCase())):[],gt=ht.length?Math.min(ct,ht.length-1):0;function vt(e){g(r,`${e.name} `),lt(0)}function yt(e){g(r,e),ut&&dt(!1),lt(0)}let bt=de.some(e=>e.uploading),St=de.filter(e=>e.artifact);fn(Je.trim().length>0||de.length>0,(0,N.useCallback)(()=>{},[])),k.current=de,(0,N.useEffect)(()=>()=>{Rt(k.current)},[]),(0,N.useEffect)(()=>{j?.meta?.tmuxSession&&te.length===0&&ne()},[j?.id,j?.meta?.tmuxSession,te.length]),(0,N.useEffect)(()=>()=>{xe.current!==null&&window.clearTimeout(xe.current)},[]);let wt=(0,N.useMemo)(()=>cn(Ae,Oe,j?.createdAt,He),[Ae,Oe,j?.createdAt,He]),Tt=(0,N.useMemo)(()=>zt(j,Ae,Ge?.lastMessage,oe),[j,Ge?.lastMessage,oe,Ae]),kt=(0,N.useCallback)(()=>{!r||!w?.hasMore||w.loading||E(r)},[w?.hasMore,w?.loading,E,r]),At=(0,N.useCallback)(()=>{xe.current!==null&&(window.clearTimeout(xe.current),xe.current=null)},[]),jt=(0,N.useCallback)(async e=>{let t=Dt(te,e);if(!t)return null;try{let n=await _(`GET`,`/orchestrators/${encodeURIComponent(t.id)}/files/stat?path=${encodeURIComponent(e)}`);return{orchestratorId:t.id,path:n.path,type:n.type}}catch{return null}},[te]),Mt=(0,N.useCallback)((e,t,n)=>{if(!Ot()||!n)return;let r=++Te.current;jt(e).then(e=>{Te.current===r&&e&&(At(),ve({...e,line:t||0,anchor:n}),be(``))})},[At,jt]),Nt=(0,N.useCallback)(()=>{Te.current+=1,At(),xe.current=window.setTimeout(()=>{ve(null)},250)},[At]),Pt=(0,N.useCallback)((e,t)=>{jt(e).then(n=>{if(!n){ee(`File Not Found`,e);return}if(Ot()){Te.current+=1,At(),ve(null),ge({...n,line:t||0}),be(``);return}n.type===`directory`?c({orchestratorId:n.orchestratorId,path:n.path,overlay:!0}):c({orchestratorId:n.orchestratorId,path:Et(n.path),selectedPath:n.path,line:t,overlay:!0})})},[At,c,jt,ee]);function Ft(){ge(null),be(``)}async function It(e){let t=Array.from(e).filter(e=>e.size>0);if(!t.length)return;let n=t.map(e=>({id:`${Date.now()}-${e.name}-${Math.random().toString(16).slice(2)}`,fileName:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploading:!0}));fe(e=>[...e,...n]);for(let e=0;e<t.length;e+=1){let r=t[e],i=n[e];try{let e=await d(`/artifacts`,r,{filename:r.name,sensitivity:`normal`});fe(t=>t.map(t=>t.id===i.id?{...t,artifact:e,uploading:!1}:t))}catch(e){fe(t=>t.map(t=>t.id===i.id?{...t,error:e.message,uploading:!1}:t))}}}function Lt(e){fe(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})}function Bt(){Rt(de),fe([])}function Vt(){if(!Je.trim()&&St.length===0||!r||f||bt||je)return;let e=St.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));s(Je,{peer:r,lastMessage:Ge?.lastMessage||null},e),Bt()}function Ht(e){if(ht.length){if(e.key===`ArrowDown`){e.preventDefault(),lt(e=>Math.min(e+1,ht.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),lt(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),dt(!0);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=ht[gt];t&&vt(t);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Vt())}function Ut(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),It(t))}async function Wt(){if(!Se||le!==`idle`||!r)return;De.bargeIn();let e=new we;try{await e.start(),ce.current=e,ue(`recording`)}catch(e){ce.current=null,ue(`idle`),ee(`Microphone unavailable`,e?.message||`Could not access the microphone.`)}}async function qt(){let e=ce.current;if(!(!e||le!==`recording`)){ce.current=null,ue(`transcribing`);try{let t=await e.stop();if(!t)return;let n=await Ce(t);if(!n)return;let i=Je?`${Je} ${n}`:n;if(ae===`autosend`&&!f&&!bt){let e=St.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));s(i,{peer:r,lastMessage:Ge?.lastMessage||null},e),Bt()}else g(r,i)}catch(e){ee(`Transcription failed`,e?.message||`Could not transcribe audio.`)}finally{ue(`idle`)}}}return r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex h-full min-w-0`,children:[(0,P.jsxs)(`div`,{className:`@container/chat flex h-full min-w-0 flex-1 flex-col`,children:[(0,P.jsx)(Kt,{selectedInboxThread:r,agent:j,now:o,blockedState:Ue,thread:Ge,exportableThread:Ke,importedHistory:He,showBackButton:n,onBack:t,openAgentDetail:u,openWorkspaceFocus:x,voiceTtsEnabled:re,setVoiceTtsEnabled:ie,canOpenTerminal:nt,terminalOpening:Fe,handleOpenTerminal:Ie,canInterrupt:ot,interruptAgent:st,canCompact:rt,canClearContext:it,canShutdown:at,openConfirm:D,workspaceAction:b,doAgentAction:y,openFilesForAgent:l,forkFromAgent:S,markInboxThreadUnread:h,markInboxThreadRead:m,exportThread:v}),(0,P.jsx)(Ct,{threadId:Tt&&`threadId`in Tt?Tt.threadId:null,teamId:Tt&&`teamId`in Tt?Tt.teamId:void 0,channel:Tt?.channel}),(0,P.jsx)(Go,{agentId:r,agentStatus:j?.status,timeline:wt,hasMore:w?.hasMore??!1,loading:w?.loading??!1,loadedInitial:w?.loadedInitial??!1,showReasoning:O,pendingApproval:We,blockedLabel:Ue?.label,canInterrupt:ot,onLoadOlder:kt,onInterrupt:st,onOpenReferencedPath:Pt,onPreviewReferencedPath:Mt,onPreviewReferencedPathEnd:Nt}),(0,P.jsx)(Xt,{draft:Je,placeholder:`Message ${j?Be(j):r}…`,chatSending:f,disabled:je,hasPendingUploads:bt,readyAttachmentCount:St.length,pendingAttachments:de,micAvailable:Se,micState:le,slashMatches:ht,slashActiveIndex:gt,onDraftChange:yt,onKeyDown:Ht,onPaste:Ut,onUploadFiles:e=>{It(e)},onRemovePendingAttachment:Lt,onSend:Vt,onAcceptSlash:vt,onSlashHover:lt,onStartPtt:()=>{Wt()},onStopPtt:()=>{qt()},footerText:je?`${j?Be(j):`Agent`} is wrapping up (${(j?.meta?.lifecycleAction).slice(11)}) — messaging paused`:`Enter to send · Shift+Enter for newline`})]}),he&&(0,P.jsxs)(`aside`,{className:`hidden h-full w-[min(44vw,720px)] min-w-[360px] shrink-0 flex-col border-l border-border bg-background xl:flex`,children:[(0,P.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:`File preview`}),ye&&(0,P.jsx)(`span`,{className:`max-w-[18rem] truncate text-xs text-red-400`,children:ye}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:`Close preview`,onClick:Ft,children:(0,P.jsx)(se,{className:`h-3.5 w-3.5`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:he.type===`directory`?(0,P.jsx)(Qe,{orchestratorId:he.orchestratorId,selectedPath:he.path,onReadError:be}):(0,P.jsx)(_t,{orchestratorId:he.orchestratorId,selectedPath:he.path,line:he.line,onReadError:be})})]})]}),_e&&(0,P.jsx)(Qt,{preview:_e,error:ye,onReadError:be,onMouseEnter:At,onMouseLeave:Nt}),Pe&&(0,P.jsx)(pt,{open:Me,onOpenChange:Le,orchestratorId:Pe.orchestratorId,session:Pe.session,interactive:Pe.interactive||et})]}):(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4`,children:[(0,P.jsx)(p,{className:`w-12 h-12 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Select an agent to start chatting`})]})}function Xo(){let e=A(e=>e.inboxDrafts),t=A(e=>e.agentsById),n=A(e=>e.set);(0,N.useEffect)(()=>{let r=Object.keys(e);if(r.length===0)return;let i=r.filter(e=>!t[e]&&e!==`user`);if(i.length===0)return;let a=setTimeout(()=>{let e=A.getState().agentsById,t={...A.getState().inboxDrafts},r=!1;for(let n of i)e[n]||(delete t[n],r=!0);r&&n({inboxDrafts:t})},3e4);return()=>clearTimeout(a)},[])}function Zo(e,t){(0,N.useEffect)(()=>{if(typeof window>`u`||!e||!window.matchMedia(`(max-width: 767px)`).matches)return;window.history.pushState({chatOpen:!0},``);function n(){t()}return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),window.history.state?.chatOpen&&window.history.back()}},[e,t])}function Qo(){let e=et(),t=A(e=>e.selectedInboxThread),n=A(e=>e.set),r=A(e=>e.loadAgentChat),i=Bt(),a=!!t;Xo(),(0,N.useEffect)(()=>{t&&r(t)},[t,r]),(0,N.useEffect)(()=>{t&&(i.some(e=>e.id===t)||n({selectedInboxThread:``}))},[t,i,n]);let o=(0,N.useCallback)(()=>{n({selectedInboxThread:``})},[n]);return Zo(a,o),(0,P.jsxs)(`div`,{className:`flex -m-4 md:-m-6`,style:{height:`calc(100dvh - var(--header-h) - var(--sat))`},children:[(0,P.jsxs)(`div`,{className:`hidden md:flex w-full`,children:[(0,P.jsx)(`div`,{className:`w-1/3 min-w-[240px] max-w-xs flex flex-col overflow-hidden`,children:(0,P.jsx)(Vt,{threads:e})}),(0,P.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:(0,P.jsx)(Yo,{threads:e},t||`empty`)})]}),(0,P.jsx)(`div`,{className:`md:hidden flex w-full overflow-hidden`,children:a?(0,P.jsx)($o,{children:(0,P.jsx)(Yo,{threads:e,onBack:o,showBackButton:!0},t||`empty`)}):(0,P.jsx)(`div`,{className:`w-full flex flex-col overflow-hidden`,children:(0,P.jsx)(Vt,{threads:e})})})]})}function $o({children:e}){let t=bt();return(0,P.jsx)(`div`,{className:`fixed inset-x-0 top-0 z-40 flex flex-col bg-background pt-[var(--sat)]`,style:{height:t?`${t}px`:`100dvh`},children:e})}export{Qo as ChatView};
2
- //# sourceMappingURL=chat-9KhGPR6T.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Un as t,jn as n}from"./lucide-react-ChOGD4vc.js";var r=e(t(),1);n();var i=r.createContext(void 0);function a(e){let t=r.useContext(i);return e||t||`ltr`}export{a as t};
2
- //# sourceMappingURL=dist-BkDVLgYg.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Un as t}from"./lucide-react-ChOGD4vc.js";var n=e(t(),1);function r(e){let t=n.useRef(e);return n.useEffect(()=>{t.current=e}),n.useMemo(()=>(...e)=>t.current?.(...e),[])}export{r as t};
2
- //# sourceMappingURL=dist-D5y1HX8f.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Un as t}from"./lucide-react-ChOGD4vc.js";var n=e(t(),1);function r(e){let t=n.useRef({value:e,previous:e});return n.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}export{r as t};
2
- //# sourceMappingURL=dist-tX4uIBFU.js.map