@voltro/plugin-chat 0.89.2 → 0.90.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.
@@ -1,9 +1,10 @@
1
- import { insertMentionDraft as e, mentionDraftToken as t } from "./mentionDraft.js";
2
- import { useEffect as n, useId as r, useLayoutEffect as i, useMemo as a, useRef as o, useState as s } from "react";
3
- import { Button as c, Textarea as l } from "@voltro/ui-shadcn";
4
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
1
+ import { chatMessageSegments as e } from "./messageLinks.js";
2
+ import { insertMentionDraft as t, mentionDraftToken as n } from "./mentionDraft.js";
3
+ import { useEffect as r, useId as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
4
+ import { Button as l, ExternalLink as u, Textarea as d } from "@voltro/ui-shadcn";
5
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
5
6
  // src/components.tsx
6
- var f = {
7
+ var h = {
7
8
  en: {
8
9
  title: "Chat",
9
10
  empty: "No messages yet. Start the conversation.",
@@ -44,35 +45,35 @@ var f = {
44
45
  media: "Bild",
45
46
  openMedia: "Bild öffnen"
46
47
  }
47
- }, p = ({ message: e, author: t, labels: r, locale: i, position: a, total: s, onHeight: l, onReport: p, onOpenMedia: m, onFocused: h }) => {
48
- let g = o(null);
49
- return n(() => {
50
- let t = g.current;
48
+ }, g = ({ message: e, author: t, labels: n, locale: i, position: a, total: o, onHeight: c, onReport: u, onOpenMedia: d, onFocused: f, selfId: g }) => {
49
+ let v = s(null);
50
+ return r(() => {
51
+ let t = v.current;
51
52
  if (!t) return;
52
53
  let n = () => {
53
54
  let n = Math.ceil(t.getBoundingClientRect().height);
54
- n > 0 && l(e.id, n);
55
+ n > 0 && c(e.id, n);
55
56
  };
56
57
  if (n(), typeof ResizeObserver > "u") return;
57
58
  let r = new ResizeObserver(n);
58
59
  return r.observe(t), () => r.disconnect();
59
- }, [e.id, l]), /* @__PURE__ */ d("li", {
60
- ref: g,
60
+ }, [e.id, c]), /* @__PURE__ */ m("li", {
61
+ ref: v,
61
62
  tabIndex: 0,
62
63
  "data-message-id": e.id,
63
64
  "aria-posinset": a,
64
- "aria-setsize": s,
65
- onFocus: () => h(e.id),
65
+ "aria-setsize": o,
66
+ onFocus: () => f(e.id),
66
67
  className: "min-w-0 space-y-2 border-b border-border px-4 py-4 outline-offset-[-2px] focus-visible:outline-2 focus-visible:outline-ring",
67
68
  children: [
68
- /* @__PURE__ */ d("div", {
69
+ /* @__PURE__ */ m("div", {
69
70
  className: "flex flex-wrap items-baseline gap-x-3 gap-y-1 text-sm",
70
71
  children: [
71
- /* @__PURE__ */ u("span", {
72
+ /* @__PURE__ */ p("span", {
72
73
  className: "break-words font-medium",
73
- children: e.authorId === null || !t ? r.unknown : t.displayName
74
+ children: e.authorId === null || !t ? n.unknown : t.displayName
74
75
  }),
75
- /* @__PURE__ */ u("time", {
76
+ /* @__PURE__ */ p("time", {
76
77
  dateTime: new Date(e.createdAt).toISOString(),
77
78
  className: "text-muted-foreground tabular-nums",
78
79
  children: new Intl.DateTimeFormat(i, {
@@ -80,53 +81,61 @@ var f = {
80
81
  timeStyle: "short"
81
82
  }).format(e.createdAt)
82
83
  }),
83
- e.editedAt === null ? null : /* @__PURE__ */ u("span", {
84
+ e.editedAt === null ? null : /* @__PURE__ */ p("span", {
84
85
  className: "text-muted-foreground",
85
- children: r.edited
86
+ children: n.edited
86
87
  })
87
88
  ]
88
89
  }),
89
- /* @__PURE__ */ u("p", {
90
+ /* @__PURE__ */ p("p", {
90
91
  className: "max-w-prose whitespace-pre-wrap break-words text-sm leading-relaxed",
91
- children: e.deletedAt === null ? e.body : r.deleted
92
+ children: e.deletedAt === null ? /* @__PURE__ */ p(_, {
93
+ body: e.body,
94
+ locale: i
95
+ }) : n.deleted
92
96
  }),
93
- e.kind === "media" && e.deletedAt === null ? /* @__PURE__ */ u("p", {
97
+ e.kind === "media" && e.deletedAt === null ? /* @__PURE__ */ p("p", {
94
98
  className: "text-sm text-muted-foreground",
95
- children: r.media ?? f.en.media
99
+ children: n.media ?? h.en.media
96
100
  }) : null,
97
- e.kind === "media" && e.deletedAt === null && m ? /* @__PURE__ */ u(c, {
101
+ e.kind === "media" && e.deletedAt === null && d ? /* @__PURE__ */ p(l, {
98
102
  type: "button",
99
103
  variant: "outline",
100
104
  size: "sm",
101
- onClick: () => m(e.id),
102
- children: r.openMedia ?? f.en.openMedia
105
+ onClick: () => d(e.id),
106
+ children: n.openMedia ?? h.en.openMedia
103
107
  }) : null,
104
- e.flagged ? /* @__PURE__ */ u("p", {
108
+ e.flagged ? /* @__PURE__ */ p("p", {
105
109
  className: "text-sm text-muted-foreground",
106
- children: r.flagged
110
+ children: n.flagged
107
111
  }) : null,
108
- p && e.deletedAt === null ? /* @__PURE__ */ u(c, {
112
+ u && e.deletedAt === null && (g === void 0 || e.authorId !== g) ? /* @__PURE__ */ p(l, {
109
113
  type: "button",
110
114
  variant: "ghost",
111
115
  size: "sm",
112
- onClick: () => p(e.id),
113
- children: r.report
116
+ onClick: () => u(e.id),
117
+ children: n.report
114
118
  }) : null
115
119
  ]
116
120
  });
117
- }, m = ({ messages: e, authors: t, labels: r = f.en, locale: i = "en", loading: c = !1, onReport: l, onOpenMedia: d }) => {
118
- let m = o(null), [h, g] = s({
121
+ }, _ = ({ body: t, locale: n }) => /* @__PURE__ */ p(f, { children: e(t).map((e, t) => e.kind === "text" ? e.text : /* @__PURE__ */ p(u, {
122
+ href: e.href,
123
+ locale: n.startsWith("de") ? "de" : "en",
124
+ className: "underline underline-offset-2",
125
+ children: e.text
126
+ }, t)) }), v = ({ messages: e, authors: t, labels: n = h.en, locale: i = "en", loading: a = !1, onReport: l, onOpenMedia: u, selfId: d }) => {
127
+ let f = s(null), [m, _] = c({
119
128
  top: 0,
120
129
  height: 480
121
- }), [_, v] = s(() => /* @__PURE__ */ new Map()), [y, b] = s(null), x = a(() => [...e].sort((e, t) => e.createdAt - t.createdAt || (e.id < t.id ? -1 : +(e.id > t.id))), [e]), S = a(() => new Map(t.map((e) => [e.subjectId, e])), [t]), C = a(() => (e, t) => v((n) => {
130
+ }), [v, y] = c(() => /* @__PURE__ */ new Map()), [b, x] = c(null), S = o(() => [...e].sort((e, t) => e.createdAt - t.createdAt || (e.id < t.id ? -1 : +(e.id > t.id))), [e]), C = o(() => new Map(t.map((e) => [e.subjectId, e])), [t]), w = o(() => (e, t) => y((n) => {
122
131
  if (n.get(e) === t) return n;
123
132
  let r = new Map(n);
124
133
  return r.set(e, t), r;
125
134
  }), []);
126
- n(() => {
127
- let e = m.current;
135
+ r(() => {
136
+ let e = f.current;
128
137
  if (!e) return;
129
- let t = () => g({
138
+ let t = () => _({
130
139
  top: e.scrollTop,
131
140
  height: e.clientHeight || 480
132
141
  });
@@ -134,54 +143,55 @@ var f = {
134
143
  let n = new ResizeObserver(t);
135
144
  return n.observe(e), () => n.disconnect();
136
145
  }, []);
137
- let w = [0];
138
- for (let e of x) w.push(w[w.length - 1] + (_.get(e.id) ?? 112));
139
- let T = [], E = 0;
140
- return x.forEach((e, t) => {
141
- let n = w[t], a = w[t + 1];
142
- (a >= h.top - 336 && n <= h.top + h.height + 336 || e.id === y) && (n > E && T.push(/* @__PURE__ */ u("li", {
146
+ let T = [0];
147
+ for (let e of S) T.push(T[T.length - 1] + (v.get(e.id) ?? 112));
148
+ let E = [], D = 0;
149
+ return S.forEach((e, t) => {
150
+ let r = T[t], a = T[t + 1];
151
+ (a >= m.top - 336 && r <= m.top + m.height + 336 || e.id === b) && (r > D && E.push(/* @__PURE__ */ p("li", {
143
152
  "aria-hidden": "true",
144
153
  role: "presentation",
145
- style: { height: n - E }
146
- }, `space-${e.id}`)), T.push(/* @__PURE__ */ u(p, {
154
+ style: { height: r - D }
155
+ }, `space-${e.id}`)), E.push(/* @__PURE__ */ p(g, {
147
156
  message: e,
148
- author: e.authorId === null ? void 0 : S.get(e.authorId),
149
- labels: r,
157
+ author: e.authorId === null ? void 0 : C.get(e.authorId),
158
+ labels: n,
150
159
  locale: i,
151
160
  position: t + 1,
152
- total: x.length,
153
- onHeight: C,
154
- onFocused: b,
161
+ total: S.length,
162
+ onHeight: w,
163
+ onFocused: x,
155
164
  onReport: l,
156
- onOpenMedia: d
157
- }, e.id)), E = a);
158
- }), w.at(-1) > E && T.push(/* @__PURE__ */ u("li", {
165
+ onOpenMedia: u,
166
+ selfId: d
167
+ }, e.id)), D = a);
168
+ }), T.at(-1) > D && E.push(/* @__PURE__ */ p("li", {
159
169
  "aria-hidden": "true",
160
170
  role: "presentation",
161
- style: { height: w.at(-1) - E }
162
- }, "space-end")), /* @__PURE__ */ u("div", {
163
- ref: m,
171
+ style: { height: T.at(-1) - D }
172
+ }, "space-end")), /* @__PURE__ */ p("div", {
173
+ ref: f,
164
174
  tabIndex: 0,
165
- "aria-label": r.title,
166
- "aria-busy": c,
175
+ "aria-label": n.title,
176
+ "aria-busy": a,
167
177
  className: "max-h-[min(60dvh,40rem)] min-h-48 overflow-y-auto rounded-md border border-border",
168
- onScroll: (e) => g({
178
+ onScroll: (e) => _({
169
179
  top: e.currentTarget.scrollTop,
170
180
  height: e.currentTarget.clientHeight || 480
171
181
  }),
172
182
  onBlur: (e) => {
173
- e.currentTarget.contains(e.relatedTarget) || b(null);
183
+ e.currentTarget.contains(e.relatedTarget) || x(null);
174
184
  },
175
- children: x.length === 0 ? /* @__PURE__ */ u("p", {
185
+ children: S.length === 0 ? /* @__PURE__ */ p("p", {
176
186
  className: "px-4 py-8 text-sm text-muted-foreground",
177
- role: c ? "status" : void 0,
178
- children: c ? r.loading : r.empty
179
- }) : /* @__PURE__ */ u("ol", {
187
+ role: a ? "status" : void 0,
188
+ children: a ? n.loading : n.empty
189
+ }) : /* @__PURE__ */ p("ol", {
180
190
  className: "m-0 list-none p-0",
181
- children: T
191
+ children: E
182
192
  })
183
193
  });
184
- }, h = {
194
+ }, y = {
185
195
  en: {
186
196
  typing: "is typing…",
187
197
  peopleTyping: "players are typing…",
@@ -192,16 +202,16 @@ var f = {
192
202
  peopleTyping: "Spieler schreiben…",
193
203
  someoneTyping: "Jemand schreibt…"
194
204
  }
195
- }, g = ({ subjects: e, authors: t, labels: n = h.en, locale: r = "en" }) => {
205
+ }, b = ({ subjects: e, authors: t, labels: n = y.en, locale: r = "en" }) => {
196
206
  let i = [...new Set(e.slice(0, 128))], a = i.length === 1 ? t.find((e) => e.subjectId === i[0]) : void 0, o = i.length === 0 ? "" : i.length > 1 ? `${new Intl.NumberFormat(r).format(i.length)} ${n.peopleTyping}` : a ? `${a.displayName} ${n.typing}` : n.someoneTyping;
197
- return /* @__PURE__ */ u("p", {
207
+ return /* @__PURE__ */ p("p", {
198
208
  role: "status",
199
209
  "aria-live": "polite",
200
210
  "aria-atomic": "true",
201
211
  className: "min-h-5 break-words text-sm text-muted-foreground",
202
212
  children: o
203
213
  });
204
- }, _ = {
214
+ }, x = {
205
215
  en: {
206
216
  title: "Mention a player",
207
217
  empty: "No matching players on this page.",
@@ -216,56 +226,56 @@ var f = {
216
226
  more: "Weitere Personen laden",
217
227
  help: "Mit Tab oder Pfeil nach unten eine Person wählen. Escape schließt Vorschläge."
218
228
  }
219
- }, v = ({ value: n, onChange: a, onSend: p, onTyping: m, mentionCandidates: h, mentionLabels: g = _.en, mentionsLoading: v = !1, onLoadMoreMentions: y, pending: b = !1, disabled: x = !1, error: S, labels: C = f.en, maxBodyLength: w = 2e3 }) => {
220
- let T = r(), E = [...n].length, D = x || b || !n.trim() || E > w, O = o(null), k = o(null), [A, j] = s({
229
+ }, S = ({ value: e, onChange: r, onSend: o, onTyping: u, mentionCandidates: f, mentionLabels: g = x.en, mentionsLoading: _ = !1, onLoadMoreMentions: v, pending: y = !1, disabled: b = !1, error: S, labels: C = h.en, maxBodyLength: w = 2e3 }) => {
230
+ let T = i(), E = [...e].length, D = b || y || !e.trim() || E > w, O = s(null), k = s(null), [A, j] = c({
221
231
  start: 0,
222
232
  end: 0
223
- }), [M, N] = s(!1), [P, F] = s(!1), I = o(null), L = !x && !b && M && !P && h !== void 0 ? t(n, A.start, A.end) : null, R = L === null || v ? [] : h.slice(0, 128).filter((t, r, i) => i.findIndex((e) => e.subjectId === t.subjectId) === r && t.displayName.normalize("NFKC").toLowerCase().startsWith(L.prefix.normalize("NFKC").toLowerCase()) && e(n, L, t.displayName, w) !== null).slice(0, 8), z = (e) => j({
233
+ }), [M, N] = c(!1), [P, F] = c(!1), I = s(null), L = !b && !y && M && !P && f !== void 0 ? n(e, A.start, A.end) : null, R = L === null || _ ? [] : f.slice(0, 128).filter((n, r, i) => i.findIndex((e) => e.subjectId === n.subjectId) === r && n.displayName.normalize("NFKC").toLowerCase().startsWith(L.prefix.normalize("NFKC").toLowerCase()) && t(e, L, n.displayName, w) !== null).slice(0, 8), z = (e) => j({
224
234
  start: e.selectionStart,
225
235
  end: e.selectionEnd
226
236
  });
227
- i(() => {
228
- let e = I.current;
229
- e && e.body === n ? (I.current = null, O.current?.focus(), O.current?.setSelectionRange(e.caret, e.caret), j({
230
- start: e.caret,
231
- end: e.caret
232
- })) : e && (I.current = null);
233
- }, [n]);
234
- let B = o(m);
235
- return i(() => {
236
- B.current = m;
237
- }), i(() => {
238
- (x || b || !n.trim()) && B.current?.(!1);
237
+ a(() => {
238
+ let t = I.current;
239
+ t && t.body === e ? (I.current = null, O.current?.focus(), O.current?.setSelectionRange(t.caret, t.caret), j({
240
+ start: t.caret,
241
+ end: t.caret
242
+ })) : t && (I.current = null);
243
+ }, [e]);
244
+ let B = s(u);
245
+ return a(() => {
246
+ B.current = u;
247
+ }), a(() => {
248
+ (b || y || !e.trim()) && B.current?.(!1);
239
249
  }, [
240
- x,
241
250
  b,
242
- n
243
- ]), i(() => () => {
251
+ y,
252
+ e
253
+ ]), a(() => () => {
244
254
  B.current?.(!1);
245
- }, []), /* @__PURE__ */ d("form", {
255
+ }, []), /* @__PURE__ */ m("form", {
246
256
  className: "space-y-3",
247
- "aria-busy": b,
257
+ "aria-busy": y,
248
258
  onBlur: (e) => {
249
259
  e.currentTarget.contains(e.relatedTarget) || (N(!1), F(!0));
250
260
  },
251
261
  onKeyDown: (e) => {
252
262
  e.key === "Escape" && L && (e.preventDefault(), F(!0), O.current?.focus());
253
263
  },
254
- onSubmit: (e) => {
255
- e.preventDefault(), D || (B.current?.(!1), p(n));
264
+ onSubmit: (t) => {
265
+ t.preventDefault(), D || (B.current?.(!1), o(e));
256
266
  },
257
267
  children: [
258
- /* @__PURE__ */ u("label", {
268
+ /* @__PURE__ */ p("label", {
259
269
  htmlFor: T,
260
270
  className: "block text-sm font-medium",
261
271
  children: C.draft
262
272
  }),
263
- /* @__PURE__ */ u(l, {
273
+ /* @__PURE__ */ p(d, {
264
274
  ref: O,
265
275
  id: T,
266
- value: n,
276
+ value: e,
267
277
  rows: 3,
268
- readOnly: x || b,
278
+ readOnly: b || y,
269
279
  "aria-describedby": `${T}-count${L ? ` ${T}-mention-help` : ""}`,
270
280
  ...L ? { "aria-controls": `${T}-mentions` } : {},
271
281
  onFocus: (e) => {
@@ -278,63 +288,63 @@ var f = {
278
288
  },
279
289
  onBlur: () => B.current?.(!1),
280
290
  onChange: (e) => {
281
- if (!x && !b) {
291
+ if (!b && !y) {
282
292
  let t = e.target.value;
283
- z(e.target), F(!1), a(t), B.current?.(t.trim().length > 0);
293
+ z(e.target), F(!1), r(t), B.current?.(t.trim().length > 0);
284
294
  }
285
295
  }
286
296
  }),
287
- L ? /* @__PURE__ */ d("div", {
297
+ L ? /* @__PURE__ */ m("div", {
288
298
  ref: k,
289
299
  id: `${T}-mentions`,
290
300
  role: "group",
291
301
  "aria-labelledby": `${T}-mention-title`,
292
302
  className: "space-y-2 rounded-md border border-border p-3",
293
303
  children: [
294
- /* @__PURE__ */ u("p", {
304
+ /* @__PURE__ */ p("p", {
295
305
  id: `${T}-mention-title`,
296
306
  className: "text-sm font-medium",
297
307
  children: g.title
298
308
  }),
299
- /* @__PURE__ */ u("p", {
309
+ /* @__PURE__ */ p("p", {
300
310
  id: `${T}-mention-help`,
301
311
  className: "text-sm text-muted-foreground",
302
312
  children: g.help
303
313
  }),
304
- v ? /* @__PURE__ */ u("p", {
314
+ _ ? /* @__PURE__ */ p("p", {
305
315
  role: "status",
306
316
  className: "text-sm text-muted-foreground",
307
317
  children: g.loading
308
- }) : R.length === 0 ? /* @__PURE__ */ u("p", {
318
+ }) : R.length === 0 ? /* @__PURE__ */ p("p", {
309
319
  role: "status",
310
320
  className: "text-sm text-muted-foreground",
311
321
  children: g.empty
312
322
  }) : null,
313
- /* @__PURE__ */ u("div", {
323
+ /* @__PURE__ */ p("div", {
314
324
  className: "flex flex-wrap gap-2",
315
- children: R.map((t) => /* @__PURE__ */ u(c, {
325
+ children: R.map((n) => /* @__PURE__ */ p(l, {
316
326
  type: "button",
317
327
  variant: "outline",
318
328
  className: "max-w-full whitespace-normal break-words",
319
329
  onClick: () => {
320
- let r = e(n, L, t.displayName, w);
321
- x || b || !r || (I.current = r, F(!0), a(r.body), B.current?.(!0));
330
+ let i = t(e, L, n.displayName, w);
331
+ b || y || !i || (I.current = i, F(!0), r(i.body), B.current?.(!0));
322
332
  },
323
- children: t.displayName
324
- }, t.subjectId))
333
+ children: n.displayName
334
+ }, n.subjectId))
325
335
  }),
326
- y ? /* @__PURE__ */ u(c, {
336
+ v ? /* @__PURE__ */ p(l, {
327
337
  type: "button",
328
338
  variant: "ghost",
329
- disabled: v,
330
- onClick: y,
339
+ disabled: _,
340
+ onClick: v,
331
341
  children: g.more
332
342
  }) : null
333
343
  ]
334
344
  }) : null,
335
- /* @__PURE__ */ d("div", {
345
+ /* @__PURE__ */ m("div", {
336
346
  className: "flex flex-wrap items-center justify-between gap-3",
337
- children: [/* @__PURE__ */ d("span", {
347
+ children: [/* @__PURE__ */ m("span", {
338
348
  id: `${T}-count`,
339
349
  className: "text-sm text-muted-foreground tabular-nums",
340
350
  children: [
@@ -342,25 +352,25 @@ var f = {
342
352
  " / ",
343
353
  w
344
354
  ]
345
- }), /* @__PURE__ */ u(c, {
355
+ }), /* @__PURE__ */ p(l, {
346
356
  type: "submit",
347
357
  "aria-disabled": D,
348
- children: b ? C.sending : C.send
358
+ children: y ? C.sending : C.send
349
359
  })]
350
360
  }),
351
- S === void 0 ? null : /* @__PURE__ */ u("p", {
361
+ S === void 0 ? null : /* @__PURE__ */ p("p", {
352
362
  role: "alert",
353
363
  className: "text-sm text-destructive",
354
364
  children: C.failed
355
365
  })
356
366
  ]
357
367
  });
358
- }, y = ({ channels: e, selectedId: t, onSelect: n, unread: r = [], labels: i = f.en, disabled: a = !1 }) => /* @__PURE__ */ u("nav", {
368
+ }, C = ({ channels: e, selectedId: t, onSelect: n, unread: r = [], labels: i = h.en, disabled: a = !1 }) => /* @__PURE__ */ p("nav", {
359
369
  "aria-label": i.choose,
360
370
  className: "flex flex-wrap gap-2",
361
371
  children: e.map((e) => {
362
372
  let o = r.find((t) => t.channelId === e.id);
363
- return /* @__PURE__ */ d(c, {
373
+ return /* @__PURE__ */ m(l, {
364
374
  type: "button",
365
375
  variant: t === e.id ? "default" : "outline",
366
376
  "aria-current": t === e.id ? "page" : void 0,
@@ -369,7 +379,7 @@ var f = {
369
379
  a || n(e.id);
370
380
  },
371
381
  className: "max-w-full whitespace-normal break-words",
372
- children: [e.name || i.title, o && (o.count > 0 || o.truncated) ? /* @__PURE__ */ d("span", {
382
+ children: [e.name || i.title, o && (o.count > 0 || o.truncated) ? /* @__PURE__ */ m("span", {
373
383
  className: "tabular-nums",
374
384
  children: [
375
385
  " · ",
@@ -381,51 +391,52 @@ var f = {
381
391
  }) : null]
382
392
  }, e.id);
383
393
  })
384
- }), b = ({ scopeKey: e, dataScopeKey: t, channelId: n, messages: i, authors: a, labels: o = f.en, locale: s, loading: l = !1, onReport: p, onOpenMedia: y, canLoadOlder: b = !1, onLoadOlder: x, typing: S, typingLabels: C, ...w }) => {
385
- let T = r(), E = e === t;
386
- return /* @__PURE__ */ d("section", {
387
- "aria-labelledby": T,
394
+ }), w = ({ scopeKey: e, dataScopeKey: t, channelId: n, messages: r, authors: a, labels: o = h.en, locale: s, loading: c = !1, onReport: u, onOpenMedia: d, selfId: f, canLoadOlder: g = !1, onLoadOlder: _, typing: C, typingLabels: w, ...T }) => {
395
+ let E = i(), D = e === t;
396
+ return /* @__PURE__ */ m("section", {
397
+ "aria-labelledby": E,
388
398
  className: "min-w-0 space-y-4",
389
399
  children: [
390
- /* @__PURE__ */ u("h2", {
391
- id: T,
400
+ /* @__PURE__ */ p("h2", {
401
+ id: E,
392
402
  className: "text-lg font-semibold",
393
403
  children: o.title
394
404
  }),
395
- b && x ? /* @__PURE__ */ u(c, {
405
+ g && _ ? /* @__PURE__ */ p(l, {
396
406
  type: "button",
397
407
  variant: "outline",
398
- "aria-disabled": l || !E,
408
+ "aria-disabled": c || !D,
399
409
  onClick: () => {
400
- !l && E && x();
410
+ !c && D && _();
401
411
  },
402
412
  children: o.older
403
413
  }) : null,
404
- /* @__PURE__ */ u(m, {
405
- messages: E ? i.filter((e) => e.channelId === n) : [],
406
- authors: E ? a : [],
414
+ /* @__PURE__ */ p(v, {
415
+ messages: D ? r.filter((e) => e.channelId === n) : [],
416
+ authors: D ? a : [],
407
417
  labels: o,
408
418
  locale: s,
409
- loading: l || !E,
410
- onReport: E ? p : void 0,
411
- onOpenMedia: E ? y : void 0
412
- }, `${e}:${n}`),
413
- /* @__PURE__ */ u(g, {
414
- subjects: E && S?.channelId === n && S.status === "live" ? S.subjects : [],
415
- authors: E ? a : [],
416
- labels: C ?? (s?.startsWith("de") ? h.de : h.en),
419
+ loading: c || !D,
420
+ onReport: D ? u : void 0,
421
+ onOpenMedia: D ? d : void 0,
422
+ selfId: f
423
+ }, `messages:${e}:${n}`),
424
+ /* @__PURE__ */ p(b, {
425
+ subjects: D && C?.channelId === n && C.status === "live" ? C.subjects : [],
426
+ authors: D ? a : [],
427
+ labels: w ?? (s?.startsWith("de") ? y.de : y.en),
417
428
  locale: s
418
429
  }),
419
- /* @__PURE__ */ u(v, {
420
- ...w,
421
- value: E ? w.value : "",
430
+ /* @__PURE__ */ p(S, {
431
+ ...T,
432
+ value: D ? T.value : "",
422
433
  labels: o,
423
- mentionCandidates: E ? w.mentionCandidates : void 0,
424
- mentionLabels: w.mentionLabels ?? (s?.startsWith("de") ? _.de : _.en),
425
- onLoadMoreMentions: E ? w.onLoadMoreMentions : void 0,
426
- disabled: w.disabled || !E
427
- }, `${e}:${n}`)
434
+ mentionCandidates: D ? T.mentionCandidates : void 0,
435
+ mentionLabels: T.mentionLabels ?? (s?.startsWith("de") ? x.de : x.en),
436
+ onLoadMoreMentions: D ? T.onLoadMoreMentions : void 0,
437
+ disabled: T.disabled || !D
438
+ }, `composer:${e}:${n}`)
428
439
  ]
429
440
  });
430
441
  };
431
- export { y as ChannelTabs, b as ChatPanel, v as Composer, m as MessageList, g as TypingIndicator, f as chatLabels, _ as chatMentionLabels, h as chatTypingLabels };
442
+ export { C as ChannelTabs, w as ChatPanel, S as Composer, v as MessageList, b as TypingIndicator, h as chatLabels, x as chatMentionLabels, y as chatTypingLabels };
package/dist/index.d.ts CHANGED
@@ -213,7 +213,7 @@ export declare const chatMembersTable: Table<"_voltro_chat_members", FieldDefini
213
213
  readonly tenantId: ColumnBuilder<string, "text", boolean>;
214
214
  readonly channelId: ColumnBuilder<string, "text", boolean>;
215
215
  readonly subjectId: ColumnBuilder<string, "text", boolean>;
216
- readonly role: ColumnBuilder<"member" | "owner" | "mod", "text", boolean>;
216
+ readonly role: ColumnBuilder<"owner" | "member" | "mod", "text", boolean>;
217
217
  readonly mutedUntil: ColumnBuilder<Date | null, "timestamp", boolean>;
218
218
  readonly lastReadAt: ColumnBuilder<Date, "timestamp", boolean>;
219
219
  readonly lastReadId: ColumnBuilder<string | null, "text", boolean>;
@@ -343,6 +343,8 @@ export declare interface ChatOptions {
343
343
  readonly mediaUrlTtlSec?: number;
344
344
  readonly rateLimit?: RedisStoreOptions;
345
345
  readonly now?: () => number;
346
+ /** Voice chat signalling for a third-party SFU (`liveKitVoiceProvider`, `devVoiceProvider`). */
347
+ readonly voice?: ChatVoiceOptions;
346
348
  }
347
349
 
348
350
  export declare type ChatOriginal = typeof ChatOriginalSchema.Type;
@@ -502,6 +504,44 @@ declare const ChatUnreadSchema: Schema.Struct<{
502
504
  readonly truncated: Schema.Boolean;
503
505
  }>;
504
506
 
507
+ export declare interface ChatVoiceGrant {
508
+ /** The provider's room name for this channel. */
509
+ readonly room: string;
510
+ /** The player's identity in the voice room (their subject ID). */
511
+ readonly identity: string;
512
+ readonly canPublish: boolean;
513
+ readonly ttlSeconds: number;
514
+ }
515
+
516
+ export declare interface ChatVoiceJoin extends ChatVoiceTicket {
517
+ readonly provider: string;
518
+ readonly room: string;
519
+ readonly canPublish: boolean;
520
+ }
521
+
522
+ export declare interface ChatVoiceOptions {
523
+ readonly provider: ChatVoiceProvider;
524
+ /** Token lifetime (default 600 s, 30 to 3600). The client asks again to stay longer. */
525
+ readonly ttlSeconds?: number | undefined;
526
+ /** The provider room for a channel (default `<tenantId>:<channelId>`). */
527
+ readonly room?: ((input: {
528
+ readonly tenantId: string;
529
+ readonly channelId: string;
530
+ }) => string) | undefined;
531
+ readonly now?: (() => number) | undefined;
532
+ }
533
+
534
+ export declare interface ChatVoiceProvider {
535
+ readonly name: string;
536
+ readonly mint: (grant: ChatVoiceGrant) => Effect.Effect<ChatVoiceTicket, unknown>;
537
+ }
538
+
539
+ export declare interface ChatVoiceTicket {
540
+ readonly url: string;
541
+ readonly token: string;
542
+ readonly expiresAt: number;
543
+ }
544
+
505
545
  export declare interface CreateChatChannelInput {
506
546
  readonly tenantId: string;
507
547
  readonly kind: typeof CHANNEL_KINDS[number];
@@ -547,6 +587,17 @@ export declare const dataStoreChat: (store: DataStore, options: ResolvedChatOpti
547
587
  }) => Effect.Effect<void, ChatError>;
548
588
  archiveMatch: (subject: Subject, input: ArchiveMatchInput) => Effect.Effect<ChatChannel, ChatError>;
549
589
  exportSubject: (target: PluginPrivacyTarget) => Effect.Effect<unknown, ChatError, never>;
590
+ /** Account merge inside the coordinator's transaction. The guest's messages, evidence, media
591
+ * and mentions name the target (the same person keeps their history). Its memberships move; a
592
+ * channel both are in keeps the target's row, with the higher of the two roles. A direct
593
+ * conversation with someone becomes the target's conversation with them: re-keyed to the new
594
+ * pair, or folded into the one the target already has with that person. */
595
+ mergeSubject: (context: {
596
+ readonly store: DataStore;
597
+ readonly tenantId: string;
598
+ readonly sourceId: string;
599
+ readonly targetId: string;
600
+ }) => Effect.Effect<void, ChatError, never>;
550
601
  eraseSubject: (input: PluginPrivacyTarget) => Effect.Effect<void, ChatError, never>;
551
602
  };
552
603
 
@@ -557,6 +608,12 @@ export declare interface DeleteChatInput {
557
608
  readonly baseVersion: number;
558
609
  }
559
610
 
611
+ /** Development stub: an unsigned, readable token for a local fake SFU. Never for production. */
612
+ export declare const devVoiceProvider: (options?: {
613
+ readonly url?: string;
614
+ readonly now?: () => number;
615
+ }) => ChatVoiceProvider;
616
+
560
617
  export declare interface EditChatInput {
561
618
  readonly messageId: string;
562
619
  readonly baseVersion: number;
@@ -571,6 +628,14 @@ declare const fixedChatRateBudgets: (input: ChatRateInput) => {
571
628
  /** Composition over the existing moderation provider, not another classifier. */
572
629
  declare const keywordChatModeration: (input: ChatModerationInput) => Effect.Effect<ChatModerationResult, ChatError>;
573
630
 
631
+ /** LiveKit access tokens: an HS256 JWT with a `video` grant, signed with the API secret. */
632
+ export declare const liveKitVoiceProvider: (options: {
633
+ readonly url: string;
634
+ readonly apiKey: string;
635
+ readonly apiSecret: string;
636
+ readonly now?: () => number;
637
+ }) => ChatVoiceProvider;
638
+
574
639
  /** Exact Name#Tag claims from Players; Chat still admits every result against its channel. */
575
640
  declare const playerChatMentions: (input: ChatMentionInput) => Effect.Effect<ReadonlyArray<string>, ChatError>;
576
641