@burdenoff/microfe-botmanor 2026.1120.28 → 2026.1123.2

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.
@@ -1,31 +1,34 @@
1
1
  import { useTr as e } from "../../shared/hooks/useTr.js";
2
2
  import { useAgents as t } from "../hooks/useAgents.js";
3
3
  import { PageLayout as n } from "../components/PageLayout.js";
4
- import { Card as r, CardContent as i, CardDescription as a, CardHeader as o, CardTitle as s } from "../components/Card.js";
5
- import { Button as c } from "../components/Button.js";
6
- import { Badge as l } from "../components/Badge.js";
7
- import { EmptyState as u } from "../components/EmptyState.js";
8
- import { ErrorState as d } from "../components/ErrorState.js";
9
- import { Textarea as f } from "../components/Input.js";
4
+ import { BOTMANOR_PERMISSIONS as r } from "../permissions/botmanorPermissions.js";
5
+ import { useBotmanorPermission as i } from "../permissions/useBotmanorPermissions.js";
6
+ import { Card as a, CardContent as o, CardDescription as s, CardHeader as c, CardTitle as l } from "../components/Card.js";
7
+ import { Button as u } from "../components/Button.js";
8
+ import { Badge as d } from "../components/Badge.js";
9
+ import { EmptyState as f } from "../components/EmptyState.js";
10
+ import { ErrorState as p } from "../components/ErrorState.js";
11
+ import { Textarea as m } from "../components/Input.js";
10
12
  import "../hooks/index.js";
11
- import { BotmanorHandoffMessageRole as p, BotmanorHandoffStatus as m } from "../../generated/wspace-types.js";
12
- import { formatRelativeTime as h } from "../utils/formatters.js";
13
- import { isActiveHandoff as g, useAcceptHandoff as _, useAssignHandoff as v, useHandoffTranscript as y, useRejectHandoff as b, useReleaseHandoff as x, useReplyToHandoff as ee, useResolveHandoff as te } from "../hooks/useHandoffs.js";
14
- import { useHandoffInbox as S } from "../hooks/useHandoffInbox.js";
15
- import { shortUserLabel as ne, useWorkspaceMemberDirectory as C } from "../hooks/useWorkspaceMemberDirectory.js";
16
- import { isHandoffConflict as w } from "../utils/handoffInbox.js";
17
- import { LoadMore as T } from "../components/LoadMore.js";
18
- import { useEffect as E, useMemo as D, useRef as re, useState as O } from "react";
19
- import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
20
- import { useSearchParams as M } from "react-router";
13
+ import { BotmanorHandoffMessageRole as h, BotmanorHandoffStatus as g } from "../../generated/wspace-types.js";
14
+ import { formatRelativeTime as _ } from "../utils/formatters.js";
15
+ import { useHandoffInbox as v } from "../hooks/useHandoffInbox.js";
16
+ import { isActiveHandoff as y, useAcceptHandoff as b, useAssignHandoff as x, useHandoffTranscript as S, useRejectHandoff as C, useReleaseHandoff as w, useReplyToHandoff as ee, useResolveHandoff as te } from "../hooks/useHandoffs.js";
17
+ import { shortUserLabel as ne, useWorkspaceMemberDirectory as T } from "../hooks/useWorkspaceMemberDirectory.js";
18
+ import { isHandoffConflict as E } from "../utils/handoffInbox.js";
19
+ import { LoadMore as D } from "../components/LoadMore.js";
20
+ import "../permissions/index.js";
21
+ import { useEffect as O, useMemo as k, useRef as re, useState as A } from "react";
22
+ import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
23
+ import { useSearchParams as P } from "react-router";
21
24
  // src/botlit/pages/HandoffsPage.tsx
22
- var N = "handoff", P = [
25
+ var F = "handoff", I = [
23
26
  {
24
27
  id: "active",
25
28
  statuses: [
26
- m.Requested,
27
- m.Assigned,
28
- m.Accepted
29
+ g.Requested,
30
+ g.Assigned,
31
+ g.Accepted
29
32
  ],
30
33
  labelKey: "botlit.handoffs.filter.active",
31
34
  label: "Active"
@@ -33,9 +36,9 @@ var N = "handoff", P = [
33
36
  {
34
37
  id: "resolved",
35
38
  statuses: [
36
- m.Resolved,
37
- m.Released,
38
- m.Rejected
39
+ g.Resolved,
40
+ g.Released,
41
+ g.Rejected
39
42
  ],
40
43
  labelKey: "botlit.handoffs.filter.resolved",
41
44
  label: "Closed"
@@ -55,37 +58,37 @@ var N = "handoff", P = [
55
58
  POLICY_REFUSAL: n("botlit.handoffs.trigger.policyRefusal", "Policy refusal"),
56
59
  MANUAL: n("botlit.handoffs.trigger.manual", "Manual")
57
60
  };
58
- return /* @__PURE__ */ A(l, {
61
+ return /* @__PURE__ */ M(d, {
59
62
  variant: "outline",
60
63
  children: r[t.trigger] ?? t.trigger
61
64
  });
62
- }, F = ({ status: t }) => {
65
+ }, ae = ({ status: t }) => {
63
66
  let n = e(), r = {
64
- [m.Requested]: {
67
+ [g.Requested]: {
65
68
  text: n("botlit.handoffs.status.requested", "Requested"),
66
69
  variant: "warning"
67
70
  },
68
- [m.Assigned]: {
71
+ [g.Assigned]: {
69
72
  text: n("botlit.handoffs.status.assigned", "Assigned"),
70
73
  variant: "warning"
71
74
  },
72
- [m.Accepted]: {
75
+ [g.Accepted]: {
73
76
  text: n("botlit.handoffs.status.accepted", "Accepted"),
74
77
  variant: "success"
75
78
  },
76
- [m.Resolved]: {
79
+ [g.Resolved]: {
77
80
  text: n("botlit.handoffs.status.resolved", "Resolved"),
78
81
  variant: "outline"
79
82
  },
80
- [m.Released]: {
83
+ [g.Released]: {
81
84
  text: n("botlit.handoffs.status.released", "Released to bot"),
82
85
  variant: "outline"
83
86
  },
84
- [m.Rejected]: {
87
+ [g.Rejected]: {
85
88
  text: n("botlit.handoffs.status.rejected", "Rejected"),
86
89
  variant: "destructive"
87
90
  },
88
- [m.Expired]: {
91
+ [g.Expired]: {
89
92
  text: n("botlit.handoffs.status.expired", "Expired"),
90
93
  variant: "outline"
91
94
  }
@@ -93,378 +96,379 @@ var N = "handoff", P = [
93
96
  text: String(t),
94
97
  variant: "outline"
95
98
  };
96
- return /* @__PURE__ */ A(l, {
99
+ return /* @__PURE__ */ M(d, {
97
100
  variant: r.variant,
98
101
  children: r.text
99
102
  });
100
- }, ae = 1e4;
101
- function I(e, t) {
103
+ }, L = 1e4;
104
+ function R(e, t) {
102
105
  return Math.round((new Date(e).getTime() - t) / 6e4);
103
106
  }
104
107
  var oe = ({ handoff: t }) => {
105
- let n = e(), [r, i] = O(() => Date.now()), a = g(t.status) && !t.firstResponseAt;
106
- if (E(() => {
108
+ let n = e(), [r, i] = A(() => Date.now()), a = y(t.status) && !t.firstResponseAt;
109
+ if (O(() => {
107
110
  if (!a) return;
108
111
  let e = window.setInterval(() => i(Date.now()), 3e4);
109
112
  return () => window.clearInterval(e);
110
113
  }, [a]), !t.slaDueAt) return null;
111
- if (t.slaBreached || a && new Date(t.slaDueAt).getTime() <= r) return /* @__PURE__ */ A(l, {
114
+ if (t.slaBreached || a && new Date(t.slaDueAt).getTime() <= r) return /* @__PURE__ */ M(d, {
112
115
  variant: "destructive",
113
116
  "data-testid": "handoff-sla",
114
117
  children: n("botlit.handoffs.sla.breached", "SLA breached")
115
118
  });
116
- if (t.firstResponseAt) return /* @__PURE__ */ A(l, {
119
+ if (t.firstResponseAt) return /* @__PURE__ */ M(d, {
117
120
  variant: "success",
118
121
  "data-testid": "handoff-sla",
119
122
  children: n("botlit.handoffs.sla.met", "SLA met")
120
123
  });
121
124
  if (!a) return null;
122
- let o = Math.max(I(t.slaDueAt, r), 0);
123
- return /* @__PURE__ */ A(l, {
125
+ let o = Math.max(R(t.slaDueAt, r), 0);
126
+ return /* @__PURE__ */ M(d, {
124
127
  variant: "warning",
125
128
  "data-testid": "handoff-sla",
126
129
  children: n("botlit.handoffs.sla.due", "Reply due in {{minutes}} min", { minutes: o })
127
130
  });
128
- }, L = {
129
- [p.Customer]: {
131
+ }, z = {
132
+ [h.Customer]: {
130
133
  key: "botlit.handoffs.thread.customer",
131
134
  label: "Customer"
132
135
  },
133
- [p.Bot]: {
136
+ [h.Bot]: {
134
137
  key: "botlit.handoffs.thread.bot",
135
138
  label: "Bot"
136
139
  },
137
- [p.Operator]: {
140
+ [h.Operator]: {
138
141
  key: "botlit.handoffs.thread.operator",
139
142
  label: "Operator"
140
143
  }
141
- }, R = ({ handoffId: t, messages: n }) => {
144
+ }, se = ({ handoffId: t, messages: n }) => {
142
145
  let r = e();
143
- return n.length === 0 ? /* @__PURE__ */ A("p", {
146
+ return n.length === 0 ? /* @__PURE__ */ M("p", {
144
147
  className: "text-sm text-text-secondary",
145
148
  children: r("botlit.handoffs.thread.empty", "No messages on this handoff yet.")
146
- }) : /* @__PURE__ */ A("ol", {
149
+ }) : /* @__PURE__ */ M("ol", {
147
150
  className: "grid gap-2 rounded-card border border-border-seam p-3",
148
151
  "aria-label": r("botlit.handoffs.thread.label", "Conversation"),
149
152
  "data-testid": `handoff-thread-${t}`,
150
153
  children: n.map((e) => {
151
- let t = L[e.role] ?? {
154
+ let t = z[e.role] ?? {
152
155
  key: "",
153
156
  label: String(e.role)
154
157
  };
155
- return /* @__PURE__ */ j("li", {
158
+ return /* @__PURE__ */ N("li", {
156
159
  className: "grid gap-0.5",
157
- children: [/* @__PURE__ */ j("span", {
160
+ children: [/* @__PURE__ */ N("span", {
158
161
  className: "text-xs font-medium text-text-secondary",
159
162
  children: [
160
163
  t.key ? r(t.key, t.label) : t.label,
161
164
  " ·",
162
165
  " ",
163
- h(e.createdAt)
166
+ _(e.createdAt)
164
167
  ]
165
- }), /* @__PURE__ */ A("span", {
168
+ }), /* @__PURE__ */ M("span", {
166
169
  className: "text-sm whitespace-pre-wrap text-text-primary",
167
170
  children: e.text
168
171
  })]
169
172
  }, e.id);
170
173
  })
171
174
  });
172
- }, z = ({ handoff: t, agents: n, members: r, isNew: i, onChanged: a, linked: o = !1 }) => {
173
- let s = e(), [u, d] = _(), [p, S] = x(), [C, T] = te(), [D, M] = b(), [N, P] = v(), [I, L] = ee(), z = g(t.status), B = t.status === m.Accepted, [V, H] = O(null), U = V && V.linked === o ? V.open : o, W = re(null);
174
- E(() => {
175
- o && W.current?.scrollIntoView?.({
175
+ }, B = ({ handoff: t, agents: n, members: r, isNew: i, canManage: a, onChanged: o, linked: s = !1 }) => {
176
+ let c = e(), [l, f] = b(), [p, h] = w(), [v, T] = te(), [D, k] = C(), [P, F] = x(), [I, R] = ee(), z = y(t.status), B = t.status === g.Accepted, [V, H] = A(null), U = V && V.linked === s ? V.open : s, W = re(null);
177
+ O(() => {
178
+ s && W.current?.scrollIntoView?.({
176
179
  block: "center",
177
180
  behavior: "smooth"
178
181
  });
179
- }, [o]);
180
- let G = y(U ? t.id : void 0), K = G.refetch;
181
- E(() => {
182
+ }, [s]);
183
+ let G = S(U ? t.id : void 0), K = G.refetch;
184
+ O(() => {
182
185
  if (!U || !z) return;
183
186
  let e = window.setInterval(() => {
184
187
  K();
185
- }, ae);
188
+ }, L);
186
189
  return () => window.clearInterval(e);
187
190
  }, [
188
191
  U,
189
192
  z,
190
193
  K
191
194
  ]);
192
- let [q, J] = O(""), [Y, X] = O(""), Z = d.loading || S.loading || T.loading || M.loading || P.loading || L.loading, Q = d.error ?? S.error ?? T.error ?? M.error ?? P.error ?? L.error, se = Q ? w(Q) : !1, ce = (e) => r.find((t) => t.userId === e)?.displayName ?? ne(e), le = async (e) => {
195
+ let [q, J] = A(""), [Y, X] = A(""), Z = f.loading || h.loading || T.loading || k.loading || F.loading || R.loading, Q = f.error ?? h.error ?? T.error ?? k.error ?? F.error ?? R.error, ce = Q ? E(Q) : !1, le = (e) => r.find((t) => t.userId === e)?.displayName ?? ne(e), ue = async (e) => {
193
196
  e.preventDefault();
194
197
  let n = q.trim();
195
198
  if (n) try {
196
199
  await I({
197
200
  id: t.id,
198
201
  message: n
199
- }), J(""), await G.refetch(), a();
202
+ }), J(""), await G.refetch(), o();
200
203
  } catch {}
201
- }, ue = async (e) => {
204
+ }, de = async (e) => {
202
205
  e.preventDefault();
203
206
  let n = Y.trim();
204
207
  if (n) try {
205
- await N({
208
+ await P({
206
209
  id: t.id,
207
210
  assigneeId: n
208
- }), X(""), a();
211
+ }), X(""), o();
209
212
  } catch {}
210
213
  }, $ = async (e) => {
211
214
  try {
212
- await e(t.id), a();
215
+ await e(t.id), o();
213
216
  } catch (e) {
214
- w(e) && a();
217
+ E(e) && o();
215
218
  }
216
219
  };
217
- return /* @__PURE__ */ j("li", {
220
+ return /* @__PURE__ */ N("li", {
218
221
  ref: W,
219
222
  "data-testid": `handoff-row-${t.id}`,
220
- "aria-current": o ? "true" : void 0,
221
- className: `grid gap-3 rounded-card border bg-bg-surface p-4 ${o ? "border-primary ring-2 ring-primary" : "border-border-seam"}`,
223
+ "aria-current": s ? "true" : void 0,
224
+ className: `grid gap-3 rounded-card border bg-bg-surface p-4 ${s ? "border-primary ring-2 ring-primary" : "border-border-seam"}`,
222
225
  children: [
223
- /* @__PURE__ */ j("div", {
226
+ /* @__PURE__ */ N("div", {
224
227
  className: "flex flex-wrap items-center gap-2",
225
228
  children: [
226
- i ? /* @__PURE__ */ A(l, {
229
+ i ? /* @__PURE__ */ M(d, {
227
230
  variant: "default",
228
- children: s("botlit.handoffs.new", "New")
231
+ children: c("botlit.handoffs.new", "New")
229
232
  }) : null,
230
- /* @__PURE__ */ A(F, { status: t.status }),
231
- /* @__PURE__ */ A(ie, { handoff: t }),
232
- /* @__PURE__ */ A(oe, { handoff: t }),
233
- t.replyChannel ? /* @__PURE__ */ A(l, {
233
+ /* @__PURE__ */ M(ae, { status: t.status }),
234
+ /* @__PURE__ */ M(ie, { handoff: t }),
235
+ /* @__PURE__ */ M(oe, { handoff: t }),
236
+ t.replyChannel ? /* @__PURE__ */ M(d, {
234
237
  variant: "outline",
235
238
  children: t.replyChannel
236
239
  }) : null,
237
- /* @__PURE__ */ A("span", {
240
+ /* @__PURE__ */ M("span", {
238
241
  className: "text-xs text-text-secondary",
239
- children: s("botlit.handoffs.opened", "Opened {{time}}", { time: h(t.createdAt) })
242
+ children: c("botlit.handoffs.opened", "Opened {{time}}", { time: _(t.createdAt) })
240
243
  })
241
244
  ]
242
245
  }),
243
- /* @__PURE__ */ A("p", {
246
+ /* @__PURE__ */ M("p", {
244
247
  className: "text-sm text-text-primary",
245
248
  children: t.reason
246
249
  }),
247
- t.userMessage ? /* @__PURE__ */ A("blockquote", {
250
+ t.userMessage ? /* @__PURE__ */ M("blockquote", {
248
251
  className: "border-l-2 border-border-seam pl-3 text-sm text-text-secondary italic",
249
252
  children: t.userMessage
250
253
  }) : null,
251
- /* @__PURE__ */ j("div", {
254
+ /* @__PURE__ */ N("div", {
252
255
  className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
253
- children: [/* @__PURE__ */ A("span", { children: n.get(t.agentId) ? s("botlit.handoffs.agent", "Agent {{name}}", { name: n.get(t.agentId) }) : s("botlit.handoffs.conversation", "Conversation {{key}}", { key: t.conversationKey }) }), t.assignedToId ? /* @__PURE__ */ A("span", { children: s("botlit.handoffs.assignedTo", "· with {{who}}", { who: ce(t.assignedToId) }) }) : null]
256
+ children: [/* @__PURE__ */ M("span", { children: n.get(t.agentId) ? c("botlit.handoffs.agent", "Agent {{name}}", { name: n.get(t.agentId) }) : c("botlit.handoffs.conversation", "Conversation {{key}}", { key: t.conversationKey }) }), t.assignedToId ? /* @__PURE__ */ M("span", { children: c("botlit.handoffs.assignedTo", "· with {{who}}", { who: le(t.assignedToId) }) }) : null]
254
257
  }),
255
- /* @__PURE__ */ A("div", { children: /* @__PURE__ */ A(c, {
258
+ /* @__PURE__ */ M("div", { children: /* @__PURE__ */ M(u, {
256
259
  size: "sm",
257
260
  variant: "ghost",
258
261
  "aria-expanded": U,
259
262
  onClick: () => H({
260
- linked: o,
263
+ linked: s,
261
264
  open: !U
262
265
  }),
263
- children: U ? s("botlit.handoffs.thread.hide", "Hide conversation") : s("botlit.handoffs.thread.show", "Show conversation")
266
+ children: U ? c("botlit.handoffs.thread.hide", "Hide conversation") : c("botlit.handoffs.thread.show", "Show conversation")
264
267
  }) }),
265
- U ? G.loading && G.data.length === 0 ? /* @__PURE__ */ A("p", {
268
+ U ? G.loading && G.data.length === 0 ? /* @__PURE__ */ M("p", {
266
269
  role: "status",
267
270
  className: "text-sm text-text-secondary",
268
- children: s("botlit.handoffs.thread.loading", "Loading conversation…")
269
- }) : G.error ? /* @__PURE__ */ A("p", {
271
+ children: c("botlit.handoffs.thread.loading", "Loading conversation…")
272
+ }) : G.error ? /* @__PURE__ */ M("p", {
270
273
  role: "alert",
271
274
  className: "text-sm text-status-danger-text",
272
275
  children: G.error.message
273
- }) : /* @__PURE__ */ A(R, {
276
+ }) : /* @__PURE__ */ M(se, {
274
277
  handoffId: t.id,
275
278
  messages: G.data
276
279
  }) : null,
277
- B && t.replyChannel ? /* @__PURE__ */ j("form", {
280
+ a && B && t.replyChannel ? /* @__PURE__ */ N("form", {
278
281
  className: "grid gap-2",
279
- onSubmit: (e) => void le(e),
282
+ onSubmit: (e) => void ue(e),
280
283
  children: [
281
- /* @__PURE__ */ A("label", {
284
+ /* @__PURE__ */ M("label", {
282
285
  className: "text-sm font-medium text-text-primary",
283
286
  htmlFor: `reply-${t.id}`,
284
- children: s("botlit.handoffs.reply.label", "Reply to the customer")
287
+ children: c("botlit.handoffs.reply.label", "Reply to the customer")
285
288
  }),
286
- /* @__PURE__ */ A(f, {
289
+ /* @__PURE__ */ M(m, {
287
290
  id: `reply-${t.id}`,
288
291
  value: q,
289
292
  maxLength: 4e3,
290
293
  rows: 3,
291
294
  onChange: (e) => J(e.target.value),
292
- placeholder: s("botlit.handoffs.reply.placeholder", "Sent in the same thread as the bot — the bot stays quiet until you hand back.")
295
+ placeholder: c("botlit.handoffs.reply.placeholder", "Sent in the same thread as the bot — the bot stays quiet until you hand back.")
293
296
  }),
294
- /* @__PURE__ */ A("div", { children: /* @__PURE__ */ A(c, {
297
+ /* @__PURE__ */ M("div", { children: /* @__PURE__ */ M(u, {
295
298
  size: "sm",
296
299
  type: "submit",
297
300
  disabled: Z || !q.trim(),
298
- children: s("botlit.handoffs.reply.send", "Send reply")
301
+ children: c("botlit.handoffs.reply.send", "Send reply")
299
302
  }) })
300
303
  ]
301
304
  }) : null,
302
- B && !t.replyChannel ? /* @__PURE__ */ A("p", {
305
+ B && !t.replyChannel ? /* @__PURE__ */ M("p", {
303
306
  className: "text-sm text-text-secondary",
304
- children: s("botlit.handoffs.reply.webChat", "This conversation came from web chat, which has no channel to reply on.")
307
+ children: c("botlit.handoffs.reply.webChat", "This conversation came from web chat, which has no channel to reply on.")
305
308
  }) : null,
306
- z ? /* @__PURE__ */ j("form", {
309
+ a && z ? /* @__PURE__ */ N("form", {
307
310
  className: "flex flex-wrap items-center gap-2",
308
- onSubmit: (e) => void ue(e),
311
+ onSubmit: (e) => void de(e),
309
312
  children: [
310
- /* @__PURE__ */ A("label", {
313
+ /* @__PURE__ */ M("label", {
311
314
  className: "sr-only",
312
315
  htmlFor: `assign-${t.id}`,
313
- children: s("botlit.handoffs.assign.label", "Assign to a teammate")
316
+ children: c("botlit.handoffs.assign.label", "Assign to a teammate")
314
317
  }),
315
- /* @__PURE__ */ j("select", {
318
+ /* @__PURE__ */ N("select", {
316
319
  id: `assign-${t.id}`,
317
320
  className: "h-9 max-w-xs rounded-md border border-border-default bg-bg-surface px-3 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
318
321
  value: Y,
319
322
  onChange: (e) => X(e.target.value),
320
- children: [/* @__PURE__ */ A("option", {
323
+ children: [/* @__PURE__ */ M("option", {
321
324
  value: "",
322
- children: s("botlit.handoffs.assign.placeholder", "Choose a teammate")
323
- }), r.filter((e) => e.userId !== t.assignedToId).map((e) => /* @__PURE__ */ A("option", {
325
+ children: c("botlit.handoffs.assign.placeholder", "Choose a teammate")
326
+ }), r.filter((e) => e.userId !== t.assignedToId).map((e) => /* @__PURE__ */ M("option", {
324
327
  value: e.userId,
325
328
  children: e.email ? `${e.displayName} (${e.email})` : e.displayName
326
329
  }, e.userId))]
327
330
  }),
328
- /* @__PURE__ */ A(c, {
331
+ /* @__PURE__ */ M(u, {
329
332
  size: "sm",
330
333
  variant: "outline",
331
334
  type: "submit",
332
335
  disabled: Z || !Y.trim(),
333
- children: s("botlit.handoffs.assign.submit", "Assign")
336
+ children: c("botlit.handoffs.assign.submit", "Assign")
334
337
  })
335
338
  ]
336
339
  }) : null,
337
- Q ? /* @__PURE__ */ A("div", {
340
+ Q ? /* @__PURE__ */ M("div", {
338
341
  role: "alert",
339
342
  className: "flex flex-wrap items-center gap-2 text-sm text-status-danger-text",
340
- children: /* @__PURE__ */ A("span", { children: se ? s("botlit.handoffs.conflict", "A teammate changed this handoff first (for example, took it over). The inbox has been refreshed.") : Q.message })
343
+ children: /* @__PURE__ */ M("span", { children: ce ? c("botlit.handoffs.conflict", "A teammate changed this handoff first (for example, took it over). The inbox has been refreshed.") : Q.message })
341
344
  }) : null,
342
- /* @__PURE__ */ j("div", {
345
+ a ? /* @__PURE__ */ N("div", {
343
346
  className: "flex flex-wrap gap-2",
344
- children: [t.status === m.Requested || t.status === m.Assigned ? /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A(c, {
347
+ children: [t.status === g.Requested || t.status === g.Assigned ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(u, {
345
348
  size: "sm",
346
349
  disabled: Z,
347
- onClick: () => void $(u),
348
- children: s("botlit.handoffs.actions.takeOver", "Take over")
349
- }), /* @__PURE__ */ A(c, {
350
+ onClick: () => void $(l),
351
+ children: c("botlit.handoffs.actions.takeOver", "Take over")
352
+ }), /* @__PURE__ */ M(u, {
350
353
  size: "sm",
351
354
  variant: "outline",
352
355
  disabled: Z,
353
356
  onClick: () => void $(D),
354
- children: s("botlit.handoffs.actions.reject", "Reject")
355
- })] }) : null, t.status === m.Accepted ? /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A(c, {
357
+ children: c("botlit.handoffs.actions.reject", "Reject")
358
+ })] }) : null, t.status === g.Accepted ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(u, {
356
359
  size: "sm",
357
360
  variant: "outline",
358
361
  disabled: Z,
359
362
  onClick: () => void $(p),
360
- children: s("botlit.handoffs.actions.handBack", "Hand back to bot")
361
- }), /* @__PURE__ */ A(c, {
363
+ children: c("botlit.handoffs.actions.handBack", "Hand back to bot")
364
+ }), /* @__PURE__ */ M(u, {
362
365
  size: "sm",
363
366
  disabled: Z,
364
- onClick: () => void $(C),
365
- children: s("botlit.handoffs.actions.resolve", "Resolve")
367
+ onClick: () => void $(v),
368
+ children: c("botlit.handoffs.actions.resolve", "Resolve")
366
369
  })] }) : null]
367
- })
370
+ }) : null
368
371
  ]
369
372
  });
370
- }, B = ({ linkedId: t, filter: n, items: r }) => {
373
+ }, V = ({ linkedId: t, filter: n, items: r }) => {
371
374
  let i = e();
372
- return !t || !r || r.some((e) => e.id === t) ? null : /* @__PURE__ */ A("p", {
375
+ return !t || !r || r.some((e) => e.id === t) ? null : /* @__PURE__ */ M("p", {
373
376
  role: "status",
374
377
  className: "text-sm text-text-secondary",
375
378
  "data-testid": "handoff-link-missing",
376
379
  children: n === "all" ? i("botlit.handoffs.linkMissing", "The handoff from your notification could not be found. It may have been removed.") : i("botlit.handoffs.linkMissingFiltered", "The handoff from your notification is not in this list. Switch to All to see every status.")
377
380
  });
378
381
  };
379
- function V(e) {
380
- let [t, n] = O(null), r = e ? "all" : "active";
382
+ function H(e) {
383
+ let [t, n] = A(null), r = e ? "all" : "active";
381
384
  return [t && t.linkedId === e ? t.filter : r, (t) => n({
382
385
  linkedId: e,
383
386
  filter: t
384
387
  })];
385
388
  }
386
- var H = () => {
387
- let l = e(), [f] = M(), p = f.get("handoff")?.trim() || null, [m, h] = V(p), g = P.find((e) => e.id === m) ?? P[0], _ = S({ statuses: g.statuses ?? void 0 }), v = C(), y = t(), b = D(() => new Map((y.data ?? []).map((e) => [e.id, e.name])), [y.data]);
388
- return /* @__PURE__ */ A(n, {
389
- title: l("botlit.handoffs.title", "Human Handoffs"),
390
- description: l("botlit.handoffs.description", "Conversations the runtime handed to your team. Taking one over stops the bot from replying until you hand it back."),
391
- children: /* @__PURE__ */ j("div", {
389
+ var U = () => {
390
+ let d = e(), m = i(r.AGENT_UPDATE), [h] = P(), g = h.get("handoff")?.trim() || null, [_, y] = H(g), b = I.find((e) => e.id === _) ?? I[0], x = v({ statuses: b.statuses ?? void 0 }), S = T(), C = t(), w = k(() => new Map((C.data ?? []).map((e) => [e.id, e.name])), [C.data]);
391
+ return /* @__PURE__ */ M(n, {
392
+ title: d("botlit.handoffs.title", "Human Handoffs"),
393
+ description: d("botlit.handoffs.description", "Conversations the runtime handed to your team. Taking one over stops the bot from replying until you hand it back."),
394
+ children: /* @__PURE__ */ N("div", {
392
395
  className: "mx-auto flex w-full max-w-4xl flex-col gap-4 p-4",
393
396
  children: [
394
- /* @__PURE__ */ j("div", {
397
+ /* @__PURE__ */ N("div", {
395
398
  className: "flex flex-wrap items-center gap-2",
396
399
  children: [
397
- P.map((e) => /* @__PURE__ */ A(c, {
400
+ I.map((e) => /* @__PURE__ */ M(u, {
398
401
  size: "sm",
399
- variant: m === e.id ? "primary" : "outline",
400
- onClick: () => h(e.id),
401
- children: l(e.labelKey, e.label)
402
+ variant: _ === e.id ? "primary" : "outline",
403
+ onClick: () => y(e.id),
404
+ children: d(e.labelKey, e.label)
402
405
  }, e.id)),
403
- /* @__PURE__ */ A(c, {
406
+ /* @__PURE__ */ M(u, {
404
407
  size: "sm",
405
408
  variant: "outline",
406
- isLoading: _.refreshing,
407
- onClick: () => void _.refresh(),
408
- children: l("botlit.handoffs.refresh", "Refresh")
409
+ isLoading: x.refreshing,
410
+ onClick: () => void x.refresh(),
411
+ children: d("botlit.handoffs.refresh", "Refresh")
409
412
  }),
410
- /* @__PURE__ */ A("span", {
413
+ /* @__PURE__ */ M("span", {
411
414
  className: "text-xs text-text-secondary",
412
- children: l("botlit.handoffs.autoRefresh", "Updates automatically while this page is open.")
415
+ children: d("botlit.handoffs.autoRefresh", "Updates automatically while this page is open.")
413
416
  })
414
417
  ]
415
418
  }),
416
- /* @__PURE__ */ A(B, {
417
- linkedId: p,
418
- filter: m,
419
- items: _.loading || _.error ? null : _.items
419
+ /* @__PURE__ */ M(V, {
420
+ linkedId: g,
421
+ filter: _,
422
+ items: x.loading || x.error ? null : x.items
420
423
  }),
421
- /* @__PURE__ */ A("div", {
424
+ /* @__PURE__ */ M("div", {
422
425
  "aria-live": "polite",
423
- children: _.newIds.size > 0 ? /* @__PURE__ */ j("div", {
426
+ children: x.newIds.size > 0 ? /* @__PURE__ */ N("div", {
424
427
  className: "flex flex-wrap items-center gap-2 rounded-card border border-status-info-border bg-status-info-bg-subtle p-3 text-sm text-text-primary",
425
- children: [/* @__PURE__ */ A("span", { children: l("botlit.handoffs.newArrived", "{{count}} new handoff(s) arrived.", { count: _.newIds.size }) }), /* @__PURE__ */ A(c, {
428
+ children: [/* @__PURE__ */ M("span", { children: d("botlit.handoffs.newArrived", "{{count}} new handoff(s) arrived.", { count: x.newIds.size }) }), /* @__PURE__ */ M(u, {
426
429
  size: "sm",
427
430
  variant: "ghost",
428
- onClick: _.acknowledgeNew,
429
- children: l("botlit.handoffs.markSeen", "Mark as seen")
431
+ onClick: x.acknowledgeNew,
432
+ children: d("botlit.handoffs.markSeen", "Mark as seen")
430
433
  })]
431
434
  }) : null
432
435
  }),
433
- _.loading && _.items.length === 0 ? /* @__PURE__ */ A("p", {
436
+ x.loading && x.items.length === 0 ? /* @__PURE__ */ M("p", {
434
437
  role: "status",
435
- children: l("botlit.handoffs.loading", "Loading handoffs…")
436
- }) : _.error && _.items.length === 0 ? /* @__PURE__ */ A(d, {
437
- resource: l("botlit.handoffs.errorResource", "handoffs"),
438
- error: _.error,
439
- onRetry: () => void _.refresh()
440
- }) : _.items.length > 0 ? /* @__PURE__ */ j(r, { children: [/* @__PURE__ */ j(o, { children: [/* @__PURE__ */ A(s, { children: l("botlit.handoffs.queue", "Team inbox") }), /* @__PURE__ */ A(a, { children: l("botlit.handoffs.queueDescription", "Newest first — accept a conversation to take it over.") })] }), /* @__PURE__ */ j(i, { children: [_.error ? /* @__PURE__ */ A("p", {
438
+ children: d("botlit.handoffs.loading", "Loading handoffs…")
439
+ }) : x.error && x.items.length === 0 ? /* @__PURE__ */ M(p, {
440
+ resource: d("botlit.handoffs.errorResource", "handoffs"),
441
+ error: x.error,
442
+ onRetry: () => void x.refresh()
443
+ }) : x.items.length > 0 ? /* @__PURE__ */ N(a, { children: [/* @__PURE__ */ N(c, { children: [/* @__PURE__ */ M(l, { children: d("botlit.handoffs.queue", "Team inbox") }), /* @__PURE__ */ M(s, { children: d("botlit.handoffs.queueDescription", "Newest first — accept a conversation to take it over.") })] }), /* @__PURE__ */ N(o, { children: [x.error ? /* @__PURE__ */ M("p", {
441
444
  role: "alert",
442
445
  className: "mb-3 text-sm text-status-danger-text",
443
- children: l("botlit.handoffs.refreshFailed", "Could not refresh the inbox: {{message}}", { message: _.error.message })
444
- }) : null, /* @__PURE__ */ A("ul", {
446
+ children: d("botlit.handoffs.refreshFailed", "Could not refresh the inbox: {{message}}", { message: x.error.message })
447
+ }) : null, /* @__PURE__ */ M("ul", {
445
448
  className: "grid gap-3",
446
- children: _.items.map((e) => /* @__PURE__ */ A(z, {
449
+ children: x.items.map((e) => /* @__PURE__ */ M(B, {
447
450
  handoff: e,
448
- agents: b,
449
- members: v.members,
450
- isNew: _.newIds.has(e.id),
451
- onChanged: () => void _.refresh(),
452
- linked: e.id === p
451
+ agents: w,
452
+ members: S.members,
453
+ isNew: x.newIds.has(e.id),
454
+ canManage: m,
455
+ onChanged: () => void x.refresh(),
456
+ linked: e.id === g
453
457
  }, e.id))
454
- })] })] }) : /* @__PURE__ */ A(u, {
455
- title: l("botlit.handoffs.empty", "No handoffs"),
456
- description: l("botlit.handoffs.emptyDescription", "Nothing needs a human right now. Triggered handoffs from your agents land here.")
458
+ })] })] }) : /* @__PURE__ */ M(f, {
459
+ title: d("botlit.handoffs.empty", "No handoffs"),
460
+ description: d("botlit.handoffs.emptyDescription", "Nothing needs a human right now. Triggered handoffs from your agents land here.")
457
461
  }),
458
- /* @__PURE__ */ A(T, {
459
- hasMore: _.hasMore,
460
- loadingMore: _.loadingMore,
461
- onLoadMore: () => void _.loadMore(),
462
- loadedCount: _.items.length
462
+ /* @__PURE__ */ M(D, {
463
+ hasMore: x.hasMore,
464
+ loadingMore: x.loadingMore,
465
+ onLoadMore: () => void x.loadMore(),
466
+ loadedCount: x.items.length
463
467
  })
464
468
  ]
465
469
  })
466
470
  });
467
471
  };
468
- export { N as HANDOFF_QUERY_PARAM, H as HandoffsPage };
472
+ export { F as HANDOFF_QUERY_PARAM, U as HandoffsPage };
469
473
 
470
474
  //# sourceMappingURL=HandoffsPage.js.map