@epam/ai-dial-conversation-panel 0.0.0-dev.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 (41) hide show
  1. package/components/ConversationGroup/ConversationGroup.d.ts +29 -0
  2. package/components/ConversationGroup/ConversationGroup.d.ts.map +1 -0
  3. package/components/ConversationGroup/ConversationRow.d.ts +50 -0
  4. package/components/ConversationGroup/ConversationRow.d.ts.map +1 -0
  5. package/components/ConversationGroupHeader/ConversationGroupHeader.d.ts +29 -0
  6. package/components/ConversationGroupHeader/ConversationGroupHeader.d.ts.map +1 -0
  7. package/components/ConversationPanel/ConversationPanel.d.ts +5 -0
  8. package/components/ConversationPanel/ConversationPanel.d.ts.map +1 -0
  9. package/components/ConversationPanel/utils.d.ts +7 -0
  10. package/components/ConversationPanel/utils.d.ts.map +1 -0
  11. package/components/FilterTabs/FilterTabs.d.ts +17 -0
  12. package/components/FilterTabs/FilterTabs.d.ts.map +1 -0
  13. package/components/NewChatButton/NewChatButton.d.ts +13 -0
  14. package/components/NewChatButton/NewChatButton.d.ts.map +1 -0
  15. package/components/RowRenderer/RowRenderer.d.ts +5 -0
  16. package/components/RowRenderer/RowRenderer.d.ts.map +1 -0
  17. package/constants/virtual-list.d.ts +7 -0
  18. package/constants/virtual-list.d.ts.map +1 -0
  19. package/index.css +2 -0
  20. package/index.d.ts +7 -0
  21. package/index.d.ts.map +1 -0
  22. package/index.js +871 -0
  23. package/models/panel-props.d.ts +211 -0
  24. package/models/panel-props.d.ts.map +1 -0
  25. package/models/virtual-row.d.ts +70 -0
  26. package/models/virtual-row.d.ts.map +1 -0
  27. package/package.json +28 -0
  28. package/test-setup.d.ts +1 -0
  29. package/test-setup.d.ts.map +1 -0
  30. package/types/conversation-group-key.d.ts +8 -0
  31. package/types/conversation-group-key.d.ts.map +1 -0
  32. package/types/conversation-source.d.ts +7 -0
  33. package/types/conversation-source.d.ts.map +1 -0
  34. package/types/filter-tab.d.ts +8 -0
  35. package/types/filter-tab.d.ts.map +1 -0
  36. package/types/virtual-row.d.ts +6 -0
  37. package/types/virtual-row.d.ts.map +1 -0
  38. package/utils/conversation-row.d.ts +14 -0
  39. package/utils/conversation-row.d.ts.map +1 -0
  40. package/utils/drag.d.ts +26 -0
  41. package/utils/drag.d.ts.map +1 -0
package/index.js ADDED
@@ -0,0 +1,871 @@
1
+ import { DeploymentIcon as e, buildCssVars as t, mergeClasses as n } from "@epam/ai-dial-chat-shared";
2
+ import { PanelEmpty as r, PanelNoResults as i, SearchInput as a, SidebarOrientation as o, SidebarPanel as s } from "@epam/ai-dial-sidebar";
3
+ import { ButtonAppearance as c, DIAL_ICON_SIZE as l, DialButton as u, DialDropdown as d, DialEllipsisTooltip as f, DialIconButton as p, DialSkeleton as m, DialSkeletonVariant as h, DialTag as g, ElementSize as _ } from "@epam/ai-dial-ui-kit";
4
+ import { createElement as v, memo as y, useCallback as b, useEffect as x, useImperativeHandle as S, useLayoutEffect as C, useMemo as w, useRef as T, useState as E } from "react";
5
+ import { jsx as D, jsxs as O } from "react/jsx-runtime";
6
+ import { IconCaretDownFilled as k, IconCaretRightFilled as A, IconDotsVertical as j, IconPlus as M } from "@tabler/icons-react";
7
+ //#region ../../node_modules/react-window/dist/react-window.js
8
+ var N = typeof window < "u" ? C : x;
9
+ function P(e) {
10
+ if (e !== void 0) switch (typeof e) {
11
+ case "number": return e;
12
+ case "string":
13
+ if (e.endsWith("px")) return parseFloat(e);
14
+ break;
15
+ }
16
+ }
17
+ function F({ box: e, defaultHeight: t, defaultWidth: n, disabled: r, element: i, mode: a, style: o }) {
18
+ let { styleHeight: s, styleWidth: c } = w(() => ({
19
+ styleHeight: P(o?.height),
20
+ styleWidth: P(o?.width)
21
+ }), [o?.height, o?.width]), [l, u] = E({
22
+ height: t,
23
+ width: n
24
+ }), d = r || a === "only-height" && s !== void 0 || a === "only-width" && c !== void 0 || s !== void 0 && c !== void 0;
25
+ return N(() => {
26
+ if (i === null || d) return;
27
+ let t = new ResizeObserver((e) => {
28
+ for (let t of e) {
29
+ let { contentRect: e, target: n } = t;
30
+ i === n && u((t) => t.height === e.height && t.width === e.width ? t : {
31
+ height: e.height,
32
+ width: e.width
33
+ });
34
+ }
35
+ });
36
+ return t.observe(i, { box: e }), () => {
37
+ t?.unobserve(i);
38
+ };
39
+ }, [
40
+ e,
41
+ d,
42
+ i,
43
+ s,
44
+ c
45
+ ]), w(() => ({
46
+ height: s ?? l.height,
47
+ width: c ?? l.width
48
+ }), [
49
+ l,
50
+ s,
51
+ c
52
+ ]);
53
+ }
54
+ function ee(e) {
55
+ let t = T(() => {
56
+ throw Error("Cannot call during render.");
57
+ });
58
+ return N(() => {
59
+ t.current = e;
60
+ }, [e]), b((e) => t.current?.(e), [t]);
61
+ }
62
+ var I = null;
63
+ function te(e = !1) {
64
+ if (I === null || e) {
65
+ let e = document.createElement("div"), t = e.style;
66
+ t.width = "50px", t.height = "50px", t.overflow = "scroll", t.direction = "rtl";
67
+ let n = document.createElement("div"), r = n.style;
68
+ return r.width = "100px", r.height = "100px", e.appendChild(n), document.body.appendChild(e), e.scrollLeft > 0 ? I = "positive-descending" : (e.scrollLeft = 1, I = e.scrollLeft === 0 ? "negative" : "positive-ascending"), document.body.removeChild(e), I;
69
+ }
70
+ return I;
71
+ }
72
+ function L({ containerElement: e, direction: t, isRtl: n, scrollOffset: r }) {
73
+ if (t === "horizontal" && n) switch (te()) {
74
+ case "negative": return -r;
75
+ case "positive-descending":
76
+ if (e) {
77
+ let { clientWidth: t, scrollLeft: n, scrollWidth: r } = e;
78
+ return r - t - n;
79
+ }
80
+ break;
81
+ }
82
+ return r;
83
+ }
84
+ function R(e, t = "Assertion error") {
85
+ if (!e) throw console.error(t), Error(t);
86
+ }
87
+ function z(e, t) {
88
+ if (e === t) return !0;
89
+ if (!!e != !!t || (R(e !== void 0), R(t !== void 0), Object.keys(e).length !== Object.keys(t).length)) return !1;
90
+ for (let n in e) if (!Object.is(t[n], e[n])) return !1;
91
+ return !0;
92
+ }
93
+ function B({ cachedBounds: e, itemCount: t, itemSize: n }) {
94
+ if (t === 0) return 0;
95
+ if (typeof n == "number") return t * n;
96
+ {
97
+ let n = e.get(e.size === 0 ? 0 : e.size - 1);
98
+ return R(n !== void 0, "Unexpected bounds cache miss"), t * ((n.scrollOffset + n.size) / e.size);
99
+ }
100
+ }
101
+ function ne({ align: e, cachedBounds: t, index: n, itemCount: r, itemSize: i, containerScrollOffset: a, containerSize: o }) {
102
+ if (n < 0 || n >= r) throw RangeError(`Invalid index specified: ${n}`, { cause: `Index ${n} is not within the range of 0 - ${r - 1}` });
103
+ let s = B({
104
+ cachedBounds: t,
105
+ itemCount: r,
106
+ itemSize: i
107
+ }), c = t.get(n), l = Math.max(0, Math.min(s - o, c.scrollOffset)), u = Math.max(0, c.scrollOffset - o + c.size);
108
+ switch (e === "smart" && (e = a >= u && a <= l ? "auto" : "center"), e) {
109
+ case "start": return l;
110
+ case "end": return u;
111
+ case "center": return c.scrollOffset <= o / 2 ? 0 : c.scrollOffset + c.size / 2 >= s - o / 2 ? s - o : c.scrollOffset + c.size / 2 - o / 2;
112
+ default: return a >= u && a <= l ? a : a < u ? u : l;
113
+ }
114
+ }
115
+ function V({ cachedBounds: e, containerScrollOffset: t, containerSize: n, itemCount: r, overscanCount: i }) {
116
+ let a = r - 1, o = 0, s = -1, c = 0, l = -1, u = 0;
117
+ for (; u < a;) {
118
+ let n = e.get(u);
119
+ if (n.scrollOffset + n.size > t) break;
120
+ u++;
121
+ }
122
+ for (o = u, c = Math.max(0, o - i); u < a;) {
123
+ let r = e.get(u);
124
+ if (r.scrollOffset + r.size >= t + n) break;
125
+ u++;
126
+ }
127
+ return s = Math.min(a, u), l = Math.min(r - 1, s + i), o < 0 && (o = 0, s = -1, c = 0, l = -1), {
128
+ startIndexVisible: o,
129
+ stopIndexVisible: s,
130
+ startIndexOverscan: c,
131
+ stopIndexOverscan: l
132
+ };
133
+ }
134
+ function H({ itemCount: e, itemProps: t, itemSize: n }) {
135
+ let r = /* @__PURE__ */ new Map();
136
+ return {
137
+ get(i) {
138
+ for (R(i < e, `Invalid index ${i}`); r.size - 1 < i;) {
139
+ let e = r.size, a;
140
+ switch (typeof n) {
141
+ case "function":
142
+ a = n(e, t);
143
+ break;
144
+ case "number":
145
+ a = n;
146
+ break;
147
+ }
148
+ if (e === 0) r.set(e, {
149
+ size: a,
150
+ scrollOffset: 0
151
+ });
152
+ else {
153
+ let t = r.get(e - 1);
154
+ R(t !== void 0, `Unexpected bounds cache miss for index ${i}`), r.set(e, {
155
+ scrollOffset: t.scrollOffset + t.size,
156
+ size: a
157
+ });
158
+ }
159
+ }
160
+ let a = r.get(i);
161
+ return R(a !== void 0, `Unexpected bounds cache miss for index ${i}`), a;
162
+ },
163
+ set(e, t) {
164
+ r.set(e, t);
165
+ },
166
+ get size() {
167
+ return r.size;
168
+ }
169
+ };
170
+ }
171
+ function U({ itemCount: e, itemProps: t, itemSize: n }) {
172
+ return w(() => H({
173
+ itemCount: e,
174
+ itemProps: t,
175
+ itemSize: n
176
+ }), [
177
+ e,
178
+ t,
179
+ n
180
+ ]);
181
+ }
182
+ function re({ containerSize: e, itemSize: t }) {
183
+ let n;
184
+ switch (typeof t) {
185
+ case "string":
186
+ R(t.endsWith("%"), `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`), R(e !== void 0, "Container size must be defined if a percentage item size is specified"), n = e * parseInt(t) / 100;
187
+ break;
188
+ default:
189
+ n = t;
190
+ break;
191
+ }
192
+ return n;
193
+ }
194
+ function W({ containerElement: e, containerStyle: t, defaultContainerSize: n = 0, direction: r, isRtl: i = !1, itemCount: a, itemProps: o, itemSize: s, onResize: c, overscanCount: l }) {
195
+ let { height: u = n, width: d = n } = F({
196
+ defaultHeight: r === "vertical" ? n : void 0,
197
+ defaultWidth: r === "horizontal" ? n : void 0,
198
+ element: e,
199
+ mode: r === "vertical" ? "only-height" : "only-width",
200
+ style: t
201
+ }), f = T({
202
+ height: 0,
203
+ width: 0
204
+ }), p = r === "vertical" ? u : d, m = re({
205
+ containerSize: p,
206
+ itemSize: s
207
+ });
208
+ C(() => {
209
+ if (typeof c == "function") {
210
+ let e = f.current;
211
+ (e.height !== u || e.width !== d) && (c({
212
+ height: u,
213
+ width: d
214
+ }, { ...e }), e.height = u, e.width = d);
215
+ }
216
+ }, [
217
+ u,
218
+ c,
219
+ d
220
+ ]);
221
+ let h = U({
222
+ itemCount: a,
223
+ itemProps: o,
224
+ itemSize: m
225
+ }), g = b((e) => h.get(e), [h]), [_, v] = E(() => V({
226
+ cachedBounds: h,
227
+ containerScrollOffset: 0,
228
+ containerSize: p,
229
+ itemCount: a,
230
+ overscanCount: l
231
+ })), { startIndexVisible: y, startIndexOverscan: x, stopIndexVisible: S, stopIndexOverscan: w } = {
232
+ startIndexVisible: Math.min(a - 1, _.startIndexVisible),
233
+ startIndexOverscan: Math.min(a - 1, _.startIndexOverscan),
234
+ stopIndexVisible: Math.min(a - 1, _.stopIndexVisible),
235
+ stopIndexOverscan: Math.min(a - 1, _.stopIndexOverscan)
236
+ }, D = b(() => B({
237
+ cachedBounds: h,
238
+ itemCount: a,
239
+ itemSize: m
240
+ }), [
241
+ h,
242
+ a,
243
+ m
244
+ ]), O = b((t) => V({
245
+ cachedBounds: h,
246
+ containerScrollOffset: L({
247
+ containerElement: e,
248
+ direction: r,
249
+ isRtl: i,
250
+ scrollOffset: t
251
+ }),
252
+ containerSize: p,
253
+ itemCount: a,
254
+ overscanCount: l
255
+ }), [
256
+ h,
257
+ e,
258
+ p,
259
+ r,
260
+ i,
261
+ a,
262
+ l
263
+ ]);
264
+ return N(() => {
265
+ v(O((r === "vertical" ? e?.scrollTop : e?.scrollLeft) ?? 0));
266
+ }, [
267
+ e,
268
+ r,
269
+ O
270
+ ]), N(() => {
271
+ if (!e) return;
272
+ let t = () => {
273
+ v((t) => {
274
+ let { scrollLeft: n, scrollTop: o } = e, s = V({
275
+ cachedBounds: h,
276
+ containerScrollOffset: L({
277
+ containerElement: e,
278
+ direction: r,
279
+ isRtl: i,
280
+ scrollOffset: r === "vertical" ? o : n
281
+ }),
282
+ containerSize: p,
283
+ itemCount: a,
284
+ overscanCount: l
285
+ });
286
+ return z(s, t) ? t : s;
287
+ });
288
+ };
289
+ return e.addEventListener("scroll", t), () => {
290
+ e.removeEventListener("scroll", t);
291
+ };
292
+ }, [
293
+ h,
294
+ e,
295
+ p,
296
+ r,
297
+ a,
298
+ l
299
+ ]), {
300
+ getCellBounds: g,
301
+ getEstimatedSize: D,
302
+ scrollToIndex: ee(({ align: t = "auto", containerScrollOffset: n, index: o }) => {
303
+ let s = ne({
304
+ align: t,
305
+ cachedBounds: h,
306
+ containerScrollOffset: n,
307
+ containerSize: p,
308
+ index: o,
309
+ itemCount: a,
310
+ itemSize: m
311
+ });
312
+ if (e) {
313
+ if (s = L({
314
+ containerElement: e,
315
+ direction: r,
316
+ isRtl: i,
317
+ scrollOffset: s
318
+ }), typeof e.scrollTo != "function") {
319
+ let e = O(s);
320
+ z(_, e) || v(e);
321
+ }
322
+ return s;
323
+ }
324
+ }),
325
+ startIndexOverscan: x,
326
+ startIndexVisible: y,
327
+ stopIndexOverscan: w,
328
+ stopIndexVisible: S
329
+ };
330
+ }
331
+ function ie(e) {
332
+ return w(() => e, Object.values(e));
333
+ }
334
+ function G(e, t) {
335
+ let { ariaAttributes: n, style: r, ...i } = e, { ariaAttributes: a, style: o, ...s } = t;
336
+ return z(n, a) && z(r, o) && z(i, s);
337
+ }
338
+ function ae(e) {
339
+ return typeof e == "object" && !!e && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
340
+ }
341
+ var oe = "data-react-window-index";
342
+ function se({ children: e, className: t, defaultHeight: n = 0, listRef: r, onResize: i, onRowsRendered: a, overscanCount: o = 3, rowComponent: s, rowCount: c, rowHeight: l, rowProps: u, tagName: d = "div", style: f, ...p }) {
343
+ let m = ie(u), h = w(() => y(s, G), [s]), [g, _] = E(null), b = ae(l), { getCellBounds: C, getEstimatedSize: T, scrollToIndex: O, startIndexOverscan: k, startIndexVisible: A, stopIndexOverscan: j, stopIndexVisible: M } = W({
344
+ containerElement: g,
345
+ containerStyle: f,
346
+ defaultContainerSize: n,
347
+ direction: "vertical",
348
+ itemCount: c,
349
+ itemProps: m,
350
+ itemSize: w(() => b ? (e) => l.getRowHeight(e) ?? l.getAverageRowHeight() : l, [b, l]),
351
+ onResize: i,
352
+ overscanCount: o
353
+ });
354
+ S(r, () => ({
355
+ get element() {
356
+ return g;
357
+ },
358
+ scrollToRow({ align: e = "auto", behavior: t = "auto", index: n }) {
359
+ let r = O({
360
+ align: e,
361
+ containerScrollOffset: g?.scrollTop ?? 0,
362
+ index: n
363
+ });
364
+ typeof g?.scrollTo == "function" && g.scrollTo({
365
+ behavior: t,
366
+ top: r
367
+ });
368
+ }
369
+ }), [g, O]), N(() => {
370
+ if (!g) return;
371
+ let e = Array.from(g.children).filter((e, t) => {
372
+ if (e.hasAttribute("aria-hidden")) return !1;
373
+ let n = `${k + t}`;
374
+ return e.setAttribute(oe, n), !0;
375
+ });
376
+ if (b) return l.observeRowElements(e);
377
+ }, [
378
+ g,
379
+ b,
380
+ l,
381
+ k,
382
+ j
383
+ ]), x(() => {
384
+ k >= 0 && j >= 0 && a && a({
385
+ startIndex: A,
386
+ stopIndex: M
387
+ }, {
388
+ startIndex: k,
389
+ stopIndex: j
390
+ });
391
+ }, [
392
+ a,
393
+ k,
394
+ A,
395
+ j,
396
+ M
397
+ ]);
398
+ let P = w(() => {
399
+ let e = [];
400
+ if (c > 0) for (let t = k; t <= j; t++) {
401
+ let n = C(t);
402
+ e.push(/* @__PURE__ */ v(h, {
403
+ ...m,
404
+ ariaAttributes: {
405
+ "aria-posinset": t + 1,
406
+ "aria-setsize": c,
407
+ role: "listitem"
408
+ },
409
+ key: t,
410
+ index: t,
411
+ style: {
412
+ position: "absolute",
413
+ left: 0,
414
+ transform: `translateY(${n.scrollOffset}px)`,
415
+ height: b ? void 0 : n.size,
416
+ width: "100%"
417
+ }
418
+ }));
419
+ }
420
+ return e;
421
+ }, [
422
+ h,
423
+ C,
424
+ b,
425
+ c,
426
+ m,
427
+ k,
428
+ j
429
+ ]), F = /* @__PURE__ */ D("div", {
430
+ "aria-hidden": !0,
431
+ style: {
432
+ height: T(),
433
+ width: "100%",
434
+ zIndex: -1
435
+ }
436
+ });
437
+ return v(d, {
438
+ role: "list",
439
+ ...p,
440
+ className: t,
441
+ ref: _,
442
+ style: {
443
+ position: "relative",
444
+ maxHeight: "100%",
445
+ flexGrow: 1,
446
+ overflowY: "auto",
447
+ ...f
448
+ }
449
+ }, P, e, F);
450
+ }
451
+ //#endregion
452
+ //#region src/types/virtual-row.ts
453
+ var K = /* @__PURE__ */ function(e) {
454
+ return e.Header = "header", e.Item = "item", e;
455
+ }({}), q = /* @__PURE__ */ function(e) {
456
+ return e.Pinned = "pinned", e.MyChats = "myChats", e.Shared = "shared", e.Organization = "organization", e;
457
+ }({}), J = /* @__PURE__ */ function(e) {
458
+ return e.MyChats = "my-chats", e.Shared = "shared", e.Organization = "organization", e;
459
+ }({}), Y = /* @__PURE__ */ function(e) {
460
+ return e.All = "all", e.MyChats = "my-chats", e.Shared = "shared", e.Organization = "organization", e;
461
+ }({}), ce = (e) => `${60 + e * 23 % 35}%`, le = (e, t) => e ? t ? "pe-9" : "pe-2 group-hover/conversation:pe-9" : "pe-3", ue = (e, t) => t.rows[e].kind === K.Item ? 36 : e === 0 ? 24 : 56, de = (e) => {
462
+ switch (e) {
463
+ case J.Shared: return q.Shared;
464
+ case J.Organization: return q.Organization;
465
+ default: return q.MyChats;
466
+ }
467
+ }, fe = (e, t) => {
468
+ let n = null;
469
+ for (let r of e) if (r.kind === K.Header) n = r.groupKey;
470
+ else if (r.item.id === t) return n;
471
+ return null;
472
+ }, pe = (e, t, n) => {
473
+ let r = /* @__PURE__ */ new Set();
474
+ if (t != null && r.add(t), t === q.Pinned) {
475
+ let t = n.find((t) => t.id === e);
476
+ t && r.add(de(t.source));
477
+ } else r.add(q.Pinned);
478
+ return r;
479
+ }, me = (e, t, n, r) => {
480
+ let i = e.currentTarget.getBoundingClientRect();
481
+ if (e.clientY >= i.top + i.height / 2) return t;
482
+ let a = null, o = !1;
483
+ for (let e of n) if (e.kind === K.Header) o = e.groupKey === r;
484
+ else if (o) {
485
+ if (e.item.id === t) return a;
486
+ a = e.item.id;
487
+ }
488
+ return null;
489
+ }, X = {
490
+ filterTabs: "_filterTabs_3jujg_1",
491
+ tab: "_tab_3jujg_4",
492
+ tabActive: "_tabActive_3jujg_16"
493
+ }, he = [
494
+ {
495
+ value: Y.All,
496
+ labelKey: "all"
497
+ },
498
+ {
499
+ value: Y.MyChats,
500
+ labelKey: "myChats"
501
+ },
502
+ {
503
+ value: Y.Shared,
504
+ labelKey: "shared"
505
+ },
506
+ {
507
+ value: Y.Organization,
508
+ labelKey: "organization"
509
+ }
510
+ ], ge = y(({ activeTab: e, labels: t, onChange: r, tabClassName: i = "dial-tiny-semi-text" }) => /* @__PURE__ */ D("div", {
511
+ className: n("mx-3 my-2 flex flex-nowrap gap-1", X.filterTabs),
512
+ children: he.map(({ value: a, labelKey: o }) => /* @__PURE__ */ D(g, {
513
+ label: t[o],
514
+ selected: e === a,
515
+ onClick: () => r(a),
516
+ className: n("box-border h-auto flex-1 justify-center rounded-full p-2 text-center", i, X.tab, e === a && X.tabActive)
517
+ }, a))
518
+ })), _e = { button: "_button_1blz1_1" }, ve = y(({ label: e, onClick: t, labelClassName: r = "dial-small-semi-text" }) => /* @__PURE__ */ D("div", {
519
+ className: "px-3 py-2",
520
+ children: /* @__PURE__ */ O("button", {
521
+ onClick: t,
522
+ type: "button",
523
+ className: n("flex h-[36px] w-full cursor-pointer items-center justify-center gap-2 px-3 py-1", _e.button),
524
+ children: [/* @__PURE__ */ D(M, {
525
+ size: 18,
526
+ stroke: 2,
527
+ className: "shrink-0"
528
+ }), /* @__PURE__ */ D("span", {
529
+ className: r,
530
+ children: e
531
+ })]
532
+ })
533
+ })), Z = {
534
+ header: "_header_1o9mn_1",
535
+ item: "_item_1o9mn_5",
536
+ itemActive: "_itemActive_1o9mn_11",
537
+ groupHeader: "_groupHeader_1o9mn_16",
538
+ trigger: "_trigger_1o9mn_21",
539
+ triggerActive: "_triggerActive_1o9mn_21",
540
+ triggerIcon: "_triggerIcon_1o9mn_24"
541
+ }, ye = ({ item: t, isActive: r, onSelectConversation: i, getActions: a, actionsLabel: o = "More actions", itemTitleClassName: s = "dial-small-text", itemIconBadgeClassName: g, rowGroupKey: v, rows: y, draggingId: x, dragOverId: S, allowedDropGroups: C, onDragStart: w, onDragEnd: T, onDragOver: k, onDragLeave: A, onDrop: M }) => {
542
+ let [N, P] = E(!1), F = a?.(t) ?? [], ee = F.length > 0, I = t.isIconLoading ? /* @__PURE__ */ D(m, {
543
+ variant: h.Circular,
544
+ width: l.LG,
545
+ height: l.LG,
546
+ color: "var(--bg-layer-4)",
547
+ "aria-hidden": !0
548
+ }) : /* @__PURE__ */ D(e, {
549
+ src: t.iconUrl,
550
+ size: l.LG,
551
+ initialsName: t.iconTooltip ?? "",
552
+ tooltip: t.iconTooltip,
553
+ badgeClassName: g
554
+ }), te = le(ee, N), L = v != null, R = b((e) => {
555
+ e.currentTarget.contains(e.relatedTarget) || A?.();
556
+ }, [A]), z = b((e) => {
557
+ if (!v || !y || !M) return;
558
+ e.preventDefault();
559
+ let n = me(e, t.id, y, v);
560
+ M(t.id, v, n);
561
+ }, [
562
+ t.id,
563
+ y,
564
+ v,
565
+ M
566
+ ]), B = t.id === x, ne = t.id === S, V = v != null && (C?.has(v) ?? !1);
567
+ return /* @__PURE__ */ O("li", {
568
+ className: n("group/conversation relative", B && "cursor-grabbing opacity-50", ne && V && "ring-accent-secondary rounded ring-1 ring-inset", x != null && !B && !V && "cursor-not-allowed"),
569
+ draggable: L || void 0,
570
+ onDragStart: L ? () => w?.(t.id) : void 0,
571
+ onDragEnd: L ? T : void 0,
572
+ onDragOver: L ? (e) => {
573
+ e.preventDefault(), k?.(t.id);
574
+ } : void 0,
575
+ onDragLeave: L ? R : void 0,
576
+ onDrop: L ? z : void 0,
577
+ children: [/* @__PURE__ */ D("a", {
578
+ href: t.href,
579
+ className: "contents",
580
+ onClick: (e) => e.preventDefault(),
581
+ children: /* @__PURE__ */ D(u, {
582
+ iconBefore: I,
583
+ label: /* @__PURE__ */ D(f, {
584
+ text: t.title,
585
+ className: s
586
+ }),
587
+ textClassName: "min-w-0",
588
+ "aria-current": r ? "page" : void 0,
589
+ onClick: () => i(t.id),
590
+ tabIndex: t.href ? -1 : void 0,
591
+ className: n("flex h-8 w-full items-center justify-start gap-2 rounded-xl py-2 ps-3", te, Z.item, r && Z.itemActive, N && Z.itemActive)
592
+ })
593
+ }), ee && /* @__PURE__ */ D("div", {
594
+ className: n("absolute inset-y-0 end-1 flex items-center", N ? "opacity-100" : "opacity-0 group-hover/conversation:opacity-100"),
595
+ children: /* @__PURE__ */ D(d, {
596
+ items: F,
597
+ onOpenChange: P,
598
+ matchReferenceWidth: !1,
599
+ listClassName: "w-[140px] cp-dropdown-overlay",
600
+ children: /* @__PURE__ */ D(p, {
601
+ icon: /* @__PURE__ */ D(j, {
602
+ size: l.SM,
603
+ className: Z.triggerIcon
604
+ }),
605
+ appearance: c.Ghost,
606
+ size: _.Small,
607
+ "aria-label": o,
608
+ className: n("flex items-center justify-center rounded", Z.trigger, N && Z.triggerActive)
609
+ })
610
+ })
611
+ })]
612
+ });
613
+ }, be = ({ label: e, isExpanded: t, onToggle: r, className: i = "dial-tiny-semi-text uppercase", dropZoneGroupKey: a, isDragOver: o, onDragOver: s, onDragLeave: c, onDrop: l }) => {
614
+ let u = a != null;
615
+ return /* @__PURE__ */ O("button", {
616
+ type: "button",
617
+ "aria-expanded": t,
618
+ onClick: r,
619
+ onDragOver: u ? (e) => {
620
+ u && (e.preventDefault(), s?.(a));
621
+ } : void 0,
622
+ onDragLeave: u ? (e) => {
623
+ u && (e.currentTarget.contains(e.relatedTarget) || c?.());
624
+ } : void 0,
625
+ onDrop: u ? (e) => {
626
+ u && (e.preventDefault(), l?.(a, a, null));
627
+ } : void 0,
628
+ className: n("flex h-6 w-full items-center gap-1 rounded py-1 pe-3 text-start", i, Z.groupHeader, o && "ring-accent-secondary ring-1 ring-inset"),
629
+ children: [D(t ? k : A, {
630
+ stroke: .5,
631
+ size: 12,
632
+ className: "shrink-0"
633
+ }), /* @__PURE__ */ D(f, { text: e })]
634
+ });
635
+ }, xe = ({ index: e, style: t, rows: n, expandedGroups: r, onToggleGroup: i, activeConversationId: a, onSelectConversation: o, getActions: s, actionsLabel: c, groupHeaderClassName: l, itemTitleClassName: u, itemIconBadgeClassName: d, draggingId: f, dragOverId: p, allowedDropGroups: m, onDragStart: h, onDragEnd: g, onDragOver: _, onDragLeave: v, onDrop: y }) => {
636
+ let b = n[e];
637
+ if (b.kind === K.Header) {
638
+ let n = b.groupKey === q.Pinned;
639
+ return /* @__PURE__ */ D("div", {
640
+ style: t,
641
+ className: e === 0 ? "pt-0" : "pt-8",
642
+ children: /* @__PURE__ */ D(be, {
643
+ label: b.label,
644
+ isExpanded: r.has(b.groupKey),
645
+ onToggle: () => i(b.groupKey),
646
+ className: l,
647
+ dropZoneGroupKey: n ? q.Pinned : void 0,
648
+ isDragOver: n && p === q.Pinned,
649
+ onDragOver: n ? _ : void 0,
650
+ onDragLeave: n ? v : void 0,
651
+ onDrop: n ? y : void 0
652
+ })
653
+ });
654
+ }
655
+ return /* @__PURE__ */ D("div", {
656
+ style: t,
657
+ className: "pt-1",
658
+ children: /* @__PURE__ */ D(ye, {
659
+ item: b.item,
660
+ isActive: b.item.id === a,
661
+ onSelectConversation: o,
662
+ getActions: s,
663
+ actionsLabel: c,
664
+ itemTitleClassName: u,
665
+ itemIconBadgeClassName: d,
666
+ rowGroupKey: b.groupKey,
667
+ rows: n,
668
+ draggingId: f,
669
+ dragOverId: p,
670
+ allowedDropGroups: m,
671
+ onDragStart: h,
672
+ onDragEnd: g,
673
+ onDragOver: _,
674
+ onDragLeave: v,
675
+ onDrop: y
676
+ })
677
+ });
678
+ }, Se = (e, t) => t === Y.All ? !0 : e.source === t, Ce = (e, t) => t ? e.title.toLowerCase().includes(t.toLowerCase()) : !0, we = new Set(Object.values(q)), Te = y(({ conversations: e, isLoading: c, isOpen: l, onSelectConversation: u, activeConversationId: d, title: f, emptyLabel: p, noResultsLabel: h, onNewChat: g, newChatLabel: _, searchPlaceholder: v, searchClearLabel: y, filterLabels: S, groupLabels: C, styles: k, className: A, getActions: j, actionsLabel: M, onToggle: N, closeAriaLabel: P, resizable: F, defaultPanelWidth: ee = 325, minPanelWidth: I = 312, maxPanelWidth: te = 600, onPanelResizeStop: L, headerActions: R, onMoveConversation: z, activeFilter: B, onActiveFilterChange: ne }) => {
679
+ let { colors: V, typography: H } = k ?? {}, [U, re] = E(""), [W, ie] = E(Y.All);
680
+ x(() => {
681
+ B != null && (ie(B), ne?.(B));
682
+ }, [B]);
683
+ let [G, ae] = E(() => we), [oe, le] = E(5), [de, me] = E(null), [X, he] = E(null), [_e, Z] = E(null), ye = T(null), be = T(null), Te = b(({ height: e }) => {
684
+ le(Math.ceil(e / 36 * 2));
685
+ }, []), Ee = b((e) => {
686
+ ae((t) => {
687
+ let n = new Set(t);
688
+ return n.has(e) ? n.delete(e) : n.add(e), n;
689
+ });
690
+ }, []), De = b(() => {
691
+ ye.current = null, be.current = null, me(null), he(null), Z(null);
692
+ }, []), Oe = b((t, n) => {
693
+ let r = pe(t, fe(n, t), e);
694
+ ye.current = t, be.current = r, me(t), Z(r);
695
+ }, [e]), ke = b(() => {
696
+ De();
697
+ }, [De]), Ae = b((e) => {
698
+ he(e);
699
+ }, []), je = b(() => {
700
+ he(null);
701
+ }, []), Me = b((e, t, n) => {
702
+ let r = ye.current, i = be.current;
703
+ De(), r != null && r !== e && i?.has(t) && z?.({
704
+ draggedId: r,
705
+ targetGroupKey: t,
706
+ afterId: n
707
+ });
708
+ }, [De, z]), Ne = t({
709
+ "--cp-bg": V?.background,
710
+ "--sb-border": V?.border,
711
+ "--cp-item-hover": V?.itemHover,
712
+ "--cp-item-active": V?.itemActive,
713
+ "--cp-text": V?.text,
714
+ "--cp-text-secondary": V?.textSecondary,
715
+ "--cp-new-chat-hover": V?.newChatHoverBackground,
716
+ "--cp-new-chat-active": V?.newChatActiveBackground,
717
+ "--cp-new-chat-bg": V?.newChatBackground
718
+ }), Q = w(() => e.filter((e) => Se(e, W) && Ce(e, U)), [
719
+ e,
720
+ W,
721
+ U
722
+ ]), Pe = w(() => Q.filter((e) => e.isPinned), [Q]), Fe = w(() => Q.filter((e) => !e.isPinned && e.source !== J.Shared && e.source !== J.Organization), [Q]), Ie = w(() => Q.filter((e) => !e.isPinned && e.source === J.Shared), [Q]), Le = w(() => Q.filter((e) => !e.isPinned && e.source === J.Organization), [Q]), Re = w(() => [
723
+ {
724
+ key: q.Pinned,
725
+ label: C?.pinned ?? "Pinned",
726
+ items: Pe
727
+ },
728
+ {
729
+ key: q.MyChats,
730
+ label: C?.myChats ?? "My chats",
731
+ items: Fe
732
+ },
733
+ {
734
+ key: q.Shared,
735
+ label: C?.shared ?? "Shared",
736
+ items: Ie
737
+ },
738
+ {
739
+ key: q.Organization,
740
+ label: C?.organization ?? "Organization",
741
+ items: Le
742
+ }
743
+ ], [
744
+ C,
745
+ Pe,
746
+ Fe,
747
+ Ie,
748
+ Le
749
+ ]), $ = w(() => {
750
+ let e = [];
751
+ for (let t of Re) if (t.items.length !== 0 && (e.push({
752
+ kind: K.Header,
753
+ groupKey: t.key,
754
+ label: t.label
755
+ }), G.has(t.key))) for (let n of t.items) e.push({
756
+ kind: K.Item,
757
+ item: n,
758
+ groupKey: t.key
759
+ });
760
+ return e;
761
+ }, [Re, G]), ze = w(() => ({
762
+ rows: $,
763
+ expandedGroups: G,
764
+ onToggleGroup: Ee,
765
+ activeConversationId: d,
766
+ onSelectConversation: u,
767
+ getActions: j,
768
+ actionsLabel: M,
769
+ groupHeaderClassName: H?.groupHeaderClassName,
770
+ itemTitleClassName: H?.itemTitleClassName,
771
+ itemIconBadgeClassName: H?.itemIconBadgeClassName,
772
+ draggingId: de,
773
+ dragOverId: X,
774
+ allowedDropGroups: _e,
775
+ onDragStart: (e) => Oe(e, $),
776
+ onDragEnd: ke,
777
+ onDragOver: Ae,
778
+ onDragLeave: je,
779
+ onDrop: Me
780
+ }), [
781
+ $,
782
+ G,
783
+ Ee,
784
+ d,
785
+ u,
786
+ j,
787
+ M,
788
+ H?.groupHeaderClassName,
789
+ H?.itemTitleClassName,
790
+ H?.itemIconBadgeClassName,
791
+ de,
792
+ X,
793
+ _e,
794
+ Oe,
795
+ ke,
796
+ Ae,
797
+ je,
798
+ Me
799
+ ]), Be = e.length === 0, Ve = e.length > 0 && Q.length === 0;
800
+ return /* @__PURE__ */ O(s, {
801
+ isOpen: l,
802
+ orientation: o.Left,
803
+ title: f,
804
+ ariaLabel: f,
805
+ onClose: N,
806
+ closeLabel: P,
807
+ headerClassName: "h-[64px]",
808
+ styles: {
809
+ colors: {
810
+ background: V?.background,
811
+ border: V?.border
812
+ },
813
+ typography: { fontClassName: H?.fontClassName },
814
+ bodyClassName: "flex flex-col overflow-hidden p-0 gap-3",
815
+ cssVars: Ne,
816
+ titleClassName: H?.fontClassName
817
+ },
818
+ className: n(l ? F ? "border-l border-r mobile:w-full" : "w-[325px] border-l border-r mobile:w-full" : "w-0", A),
819
+ resizable: F,
820
+ defaultWidth: ee,
821
+ minWidth: I,
822
+ maxWidth: te,
823
+ onResizeStop: L,
824
+ rightActions: R,
825
+ children: [
826
+ /* @__PURE__ */ D(ve, {
827
+ label: _,
828
+ onClick: g,
829
+ labelClassName: H?.newChatLabelClassName
830
+ }),
831
+ /* @__PURE__ */ D(a, {
832
+ placeholder: v,
833
+ value: U,
834
+ onChange: re,
835
+ clearLabel: y
836
+ }),
837
+ /* @__PURE__ */ D(ge, {
838
+ activeTab: W,
839
+ labels: S,
840
+ onChange: (e) => {
841
+ ie(e), ne?.(e);
842
+ },
843
+ tabClassName: H?.tabClassName
844
+ }),
845
+ /* @__PURE__ */ D("div", {
846
+ className: "flex-1 overflow-hidden px-2 py-1",
847
+ children: c ? /* @__PURE__ */ D("div", {
848
+ className: "flex flex-col gap-3 px-2 py-3",
849
+ children: Array.from({ length: 15 }, (e, t) => /* @__PURE__ */ D(m, {
850
+ avatar: { size: 24 },
851
+ showTitle: { width: ce(t) },
852
+ paragraph: !1,
853
+ active: !0,
854
+ color: "var(--bg-layer-4)"
855
+ }, t))
856
+ }) : Be ? /* @__PURE__ */ D(r, { label: p }) : Ve ? /* @__PURE__ */ D(i, { label: h }) : /* @__PURE__ */ D(se, {
857
+ role: "list",
858
+ style: { height: "100%" },
859
+ rowComponent: xe,
860
+ rowCount: $.length,
861
+ rowHeight: ue,
862
+ overscanCount: oe,
863
+ onResize: Te,
864
+ rowProps: ze
865
+ })
866
+ })
867
+ ]
868
+ });
869
+ });
870
+ //#endregion
871
+ export { q as ConversationGroupKey, Te as ConversationPanel, J as ConversationSource, Y as FilterTab };