@photon-ai/pho-ui 4.20.0 → 4.21.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.
- package/README.md +1 -1
- package/dist/chunks/{basic-page-DTomHxEo.js → basic-page-B78a6jpw.js} +4 -4
- package/dist/chunks/{basic-page-DTomHxEo.js.map → basic-page-B78a6jpw.js.map} +1 -1
- package/dist/chunks/chat-Dfbkf7g8.js +674 -0
- package/dist/chunks/chat-Dfbkf7g8.js.map +1 -0
- package/dist/chunks/{code-block-Yxg2wZGJ.js → code-block-B7MibV6r.js} +2 -2
- package/dist/chunks/{code-block-Yxg2wZGJ.js.map → code-block-B7MibV6r.js.map} +1 -1
- package/dist/chunks/{dialog-DORIrfyJ.js → dialog-CDL6qY2a.js} +2 -2
- package/dist/chunks/{dialog-DORIrfyJ.js.map → dialog-CDL6qY2a.js.map} +1 -1
- package/dist/chunks/{scroll-area-Dhl5hqay.js → scroll-area-DjdSnx2p.js} +2 -2
- package/dist/chunks/scroll-area-DjdSnx2p.js.map +1 -0
- package/dist/chunks/{sidebar-CgaSEWVr.js → sidebar-DHYyBBUj.js} +2 -2
- package/dist/chunks/{sidebar-CgaSEWVr.js.map → sidebar-DHYyBBUj.js.map} +1 -1
- package/dist/chunks/{toast-B3oURNJC.js → toast-B1GAdxXP.js} +2 -2
- package/dist/chunks/{toast-B3oURNJC.js.map → toast-B1GAdxXP.js.map} +1 -1
- package/dist/components/chat.js +1 -1
- package/dist/components/code-block.js +1 -1
- package/dist/components/command.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/index.js +5 -5
- package/dist/sections/basic-page.js +1 -1
- package/dist/sections/sidebar.js +1 -1
- package/dist/src/components/chat/chat.d.ts +9 -4
- package/dist/src/components/scroll-area/scroll-area-edges.d.ts +1 -0
- package/package.json +1 -1
- package/src/styles/fonts.css +45 -8
- package/src/styles/theme.css +5 -5
- package/dist/chunks/chat-ZUzGmTWE.js +0 -621
- package/dist/chunks/chat-ZUzGmTWE.js.map +0 -1
- package/dist/chunks/scroll-area-Dhl5hqay.js.map +0 -1
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as g } from "./cn-CPbhpG1q.js";
|
|
3
|
+
import { n as de } from "./link-provider-DXzDQ08N.js";
|
|
4
|
+
import { FADE_SWAP as Q, PRESS_SCALE_ROW as fe, SPRING_PRESS as pe, TRAVEL_LINEAR as he } from "../motion.js";
|
|
5
|
+
import { n as me } from "./spinner-BSutFL4l.js";
|
|
6
|
+
import { a as F } from "./button-CLfWdqm-.js";
|
|
7
|
+
import { t as D } from "./createReactComponent-yKZn9MIX.js";
|
|
8
|
+
import { t as ve } from "./input-DWnb33UF.js";
|
|
9
|
+
import { n as J } from "./avatar-PgBOfszL.js";
|
|
10
|
+
import { t as xe } from "./IconSearch-DkcWWZ1H.js";
|
|
11
|
+
import { t as k } from "./scroll-area-DjdSnx2p.js";
|
|
12
|
+
import { i as ge } from "./status-view-I_Y6eEyX.js";
|
|
13
|
+
import { t as A } from "./skeleton-CqZlGphn.js";
|
|
14
|
+
import { n as we } from "./box-search-CMl5bQ7Y.js";
|
|
15
|
+
import { createContext as be, useCallback as O, useContext as ye, useEffect as re, useId as Ne, useLayoutEffect as Ce, useMemo as ne, useRef as S, useState as I } from "react";
|
|
16
|
+
import { Fragment as ae, jsx as r, jsxs as N } from "react/jsx-runtime";
|
|
17
|
+
import { AnimatePresence as Se, motion as z, useReducedMotion as ie } from "motion/react";
|
|
18
|
+
var ke = [
|
|
19
|
+
["path", {
|
|
20
|
+
d: "M5 12l14 0",
|
|
21
|
+
key: "svg-0"
|
|
22
|
+
}],
|
|
23
|
+
["path", {
|
|
24
|
+
d: "M5 12l6 6",
|
|
25
|
+
key: "svg-1"
|
|
26
|
+
}],
|
|
27
|
+
["path", {
|
|
28
|
+
d: "M5 12l6 -6",
|
|
29
|
+
key: "svg-2"
|
|
30
|
+
}]
|
|
31
|
+
], Re = D("outline", "arrow-left", "ArrowLeft", ke), _e = [
|
|
32
|
+
["path", {
|
|
33
|
+
d: "M12 5l0 14",
|
|
34
|
+
key: "svg-0"
|
|
35
|
+
}],
|
|
36
|
+
["path", {
|
|
37
|
+
d: "M18 11l-6 -6",
|
|
38
|
+
key: "svg-1"
|
|
39
|
+
}],
|
|
40
|
+
["path", {
|
|
41
|
+
d: "M6 11l6 -6",
|
|
42
|
+
key: "svg-2"
|
|
43
|
+
}]
|
|
44
|
+
], Ae = D("outline", "arrow-up", "ArrowUp", _e), Pe = [["path", {
|
|
45
|
+
d: "M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0",
|
|
46
|
+
key: "svg-0"
|
|
47
|
+
}], ["path", {
|
|
48
|
+
d: "M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",
|
|
49
|
+
key: "svg-1"
|
|
50
|
+
}]], Ie = D("outline", "user", "User", Pe), Te = [
|
|
51
|
+
["path", {
|
|
52
|
+
d: "M5 7a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",
|
|
53
|
+
key: "svg-0"
|
|
54
|
+
}],
|
|
55
|
+
["path", {
|
|
56
|
+
d: "M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",
|
|
57
|
+
key: "svg-1"
|
|
58
|
+
}],
|
|
59
|
+
["path", {
|
|
60
|
+
d: "M16 3.13a4 4 0 0 1 0 7.75",
|
|
61
|
+
key: "svg-2"
|
|
62
|
+
}],
|
|
63
|
+
["path", {
|
|
64
|
+
d: "M21 21v-2a4 4 0 0 0 -3 -3.85",
|
|
65
|
+
key: "svg-3"
|
|
66
|
+
}]
|
|
67
|
+
], Me = D("outline", "users", "Users", Te), Le = "rounded-base border border-pho-secondary bg-pho-primary", Ee = 672, Oe = 24, ze = 8, se = "min-h-[61px]", De = 273, P = 256, V = 320, He = 16;
|
|
68
|
+
function Y(t, e) {
|
|
69
|
+
const a = Math.max(P, t);
|
|
70
|
+
return e <= 0 ? Number.isFinite(a) ? a : P : Math.min(a, Math.max(P, e - V));
|
|
71
|
+
}
|
|
72
|
+
var oe = be(null);
|
|
73
|
+
function M(t) {
|
|
74
|
+
const e = ye(oe);
|
|
75
|
+
if (e == null) throw new Error(`Chat.${t} must be used inside Chat.Root`);
|
|
76
|
+
return e;
|
|
77
|
+
}
|
|
78
|
+
var T = typeof window > "u" ? re : Ce;
|
|
79
|
+
function W(t) {
|
|
80
|
+
return t === "thread" ? 1 : -1;
|
|
81
|
+
}
|
|
82
|
+
function We(t, e) {
|
|
83
|
+
return t === "compact" || t === "auto" && e > 0 && e < Ee;
|
|
84
|
+
}
|
|
85
|
+
function E(t, e) {
|
|
86
|
+
return e ? {
|
|
87
|
+
initial: { opacity: 0 },
|
|
88
|
+
animate: { opacity: 1 },
|
|
89
|
+
exit: { opacity: 0 },
|
|
90
|
+
transition: { duration: 0 }
|
|
91
|
+
} : {
|
|
92
|
+
initial: {
|
|
93
|
+
x: t * Oe,
|
|
94
|
+
opacity: 0,
|
|
95
|
+
filter: "blur(1px)"
|
|
96
|
+
},
|
|
97
|
+
animate: {
|
|
98
|
+
x: 0,
|
|
99
|
+
opacity: 1,
|
|
100
|
+
filter: "blur(0px)"
|
|
101
|
+
},
|
|
102
|
+
exit: {
|
|
103
|
+
x: -t * ze,
|
|
104
|
+
opacity: 0,
|
|
105
|
+
filter: "blur(1px)"
|
|
106
|
+
},
|
|
107
|
+
transition: {
|
|
108
|
+
x: he,
|
|
109
|
+
opacity: Q,
|
|
110
|
+
filter: Q
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function Ue(t) {
|
|
115
|
+
return {
|
|
116
|
+
enter: (e) => E(e, t).initial,
|
|
117
|
+
rest: (e) => E(e, t).animate,
|
|
118
|
+
leave: (e) => E(e, t).exit
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function le({ as: t, show: e, swapped: a, direction: o, reduceMotion: s, children: d, ...c }) {
|
|
122
|
+
const u = E(o, s), h = {
|
|
123
|
+
custom: o,
|
|
124
|
+
variants: Ue(s),
|
|
125
|
+
initial: "enter",
|
|
126
|
+
animate: "rest",
|
|
127
|
+
exit: "leave",
|
|
128
|
+
transition: u.transition
|
|
129
|
+
};
|
|
130
|
+
return /* @__PURE__ */ r(Se, {
|
|
131
|
+
initial: !a && e ? !1 : void 0,
|
|
132
|
+
mode: "popLayout",
|
|
133
|
+
custom: o,
|
|
134
|
+
children: e ? t === "aside" ? /* @__PURE__ */ r(z.aside, {
|
|
135
|
+
...c,
|
|
136
|
+
...h,
|
|
137
|
+
children: d
|
|
138
|
+
}, "list") : /* @__PURE__ */ r(z.section, {
|
|
139
|
+
...c,
|
|
140
|
+
...h,
|
|
141
|
+
children: d
|
|
142
|
+
}, "thread") : null
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function Ve({ layout: t = "default", pane: e, defaultPane: a = "list", onPaneChange: o, className: s, style: d, ref: c, ...u }) {
|
|
146
|
+
const [h, w] = I(a), [y, m] = I(De), [i, p] = I(0), f = S(null), v = e !== void 0, x = v ? e : h, [b, n] = I(() => W(x)), [l, R] = I(!1), L = S(x);
|
|
147
|
+
let _ = b, H = l;
|
|
148
|
+
L.current !== x && (_ = W(x), H = !0, L.current = x, _ !== b && n(_), l || R(!0));
|
|
149
|
+
const $ = O((C) => {
|
|
150
|
+
n(W(C)), v || w(C), o?.(C);
|
|
151
|
+
}, [v, o]), j = O((C) => {
|
|
152
|
+
m(Y(C, f.current?.clientWidth ?? 0));
|
|
153
|
+
}, []), B = We(t, i);
|
|
154
|
+
T(() => {
|
|
155
|
+
const C = f.current;
|
|
156
|
+
if (!C || typeof ResizeObserver > "u") return;
|
|
157
|
+
const K = () => {
|
|
158
|
+
const q = C.clientWidth;
|
|
159
|
+
p(q), m((ue) => Y(ue, q));
|
|
160
|
+
};
|
|
161
|
+
K();
|
|
162
|
+
const G = new ResizeObserver(K);
|
|
163
|
+
return G.observe(C), () => G.disconnect();
|
|
164
|
+
}, []);
|
|
165
|
+
const ce = ne(() => ({
|
|
166
|
+
layout: t,
|
|
167
|
+
pane: x,
|
|
168
|
+
setPane: $,
|
|
169
|
+
direction: _,
|
|
170
|
+
swap: B,
|
|
171
|
+
swapped: H,
|
|
172
|
+
listWidth: y,
|
|
173
|
+
frameWidth: i,
|
|
174
|
+
resizeList: j,
|
|
175
|
+
rootRef: f
|
|
176
|
+
}), [
|
|
177
|
+
t,
|
|
178
|
+
x,
|
|
179
|
+
$,
|
|
180
|
+
_,
|
|
181
|
+
B,
|
|
182
|
+
H,
|
|
183
|
+
y,
|
|
184
|
+
i,
|
|
185
|
+
j
|
|
186
|
+
]);
|
|
187
|
+
return /* @__PURE__ */ r(oe.Provider, {
|
|
188
|
+
value: ce,
|
|
189
|
+
children: /* @__PURE__ */ r("div", {
|
|
190
|
+
ref: (C) => {
|
|
191
|
+
f.current = C, typeof c == "function" ? c(C) : c && (c.current = C);
|
|
192
|
+
},
|
|
193
|
+
"data-chat": "",
|
|
194
|
+
"data-basic-page-card": "",
|
|
195
|
+
"data-layout": t,
|
|
196
|
+
"data-pane": x,
|
|
197
|
+
style: {
|
|
198
|
+
...d,
|
|
199
|
+
"--chat-list-width": `${y}px`
|
|
200
|
+
},
|
|
201
|
+
className: g(Le, "@container relative flex min-h-0 min-w-0 overflow-hidden", s),
|
|
202
|
+
...u
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function Xe({ className: t, children: e, id: a, ...o }) {
|
|
207
|
+
const { layout: s, pane: d, direction: c, swap: u, swapped: h } = M("List"), w = ie(), y = Ne(), m = a ?? y, i = g("border-pho-secondary bg-pho-page relative z-10 flex min-h-0 shrink-0 flex-col", s === "default" && "min-w-64 w-[var(--chat-list-width)] border-r", s === "compact" && "w-full", s === "auto" && g("w-full @2xl:min-w-64 @2xl:w-[var(--chat-list-width)] @2xl:border-r", !u && d === "thread" && "@max-2xl:hidden"), t), p = /* @__PURE__ */ N(ae, { children: [e, s !== "compact" && /* @__PURE__ */ r(Fe, { controlsId: m })] }), f = {
|
|
208
|
+
id: m,
|
|
209
|
+
"aria-label": "Conversations",
|
|
210
|
+
"data-chat-list": "",
|
|
211
|
+
className: i,
|
|
212
|
+
...o
|
|
213
|
+
};
|
|
214
|
+
return u ? /* @__PURE__ */ r(le, {
|
|
215
|
+
as: "aside",
|
|
216
|
+
show: d === "list",
|
|
217
|
+
swapped: h,
|
|
218
|
+
direction: c,
|
|
219
|
+
reduceMotion: w,
|
|
220
|
+
...f,
|
|
221
|
+
children: p
|
|
222
|
+
}) : /* @__PURE__ */ r("aside", {
|
|
223
|
+
...f,
|
|
224
|
+
children: p
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function Fe({ controlsId: t }) {
|
|
228
|
+
const { layout: e, listWidth: a, frameWidth: o, resizeList: s, rootRef: d } = M("Splitter"), c = S(null), u = (i) => {
|
|
229
|
+
i.button === 0 && (i.currentTarget.setPointerCapture?.(i.pointerId), c.current = {
|
|
230
|
+
x: i.clientX,
|
|
231
|
+
width: a
|
|
232
|
+
});
|
|
233
|
+
}, h = (i) => {
|
|
234
|
+
const p = c.current;
|
|
235
|
+
if (p == null) return;
|
|
236
|
+
const f = d.current, v = f != null && getComputedStyle(f).direction === "rtl", x = (i.clientX - p.x) * (v ? -1 : 1);
|
|
237
|
+
s(p.width + x);
|
|
238
|
+
}, w = () => {
|
|
239
|
+
c.current = null;
|
|
240
|
+
}, y = (i) => {
|
|
241
|
+
const p = d.current, f = p != null && getComputedStyle(p).direction === "rtl", v = f ? "ArrowRight" : "ArrowLeft", x = f ? "ArrowLeft" : "ArrowRight", b = i.shiftKey ? 32 : He;
|
|
242
|
+
if (i.key === v)
|
|
243
|
+
i.preventDefault(), s(a - b);
|
|
244
|
+
else if (i.key === x)
|
|
245
|
+
i.preventDefault(), s(a + b);
|
|
246
|
+
else if (i.key === "Home")
|
|
247
|
+
i.preventDefault(), s(P);
|
|
248
|
+
else if (i.key === "End") {
|
|
249
|
+
i.preventDefault();
|
|
250
|
+
const n = p?.clientWidth ?? 0;
|
|
251
|
+
n > 0 && s(n - V);
|
|
252
|
+
}
|
|
253
|
+
}, m = o > 0 ? Math.max(P, o - V) : a;
|
|
254
|
+
return /* @__PURE__ */ r("div", {
|
|
255
|
+
role: "separator",
|
|
256
|
+
"aria-orientation": "vertical",
|
|
257
|
+
"aria-label": "Resize conversation list",
|
|
258
|
+
"aria-controls": t,
|
|
259
|
+
"aria-valuenow": a,
|
|
260
|
+
"aria-valuemin": P,
|
|
261
|
+
"aria-valuemax": m,
|
|
262
|
+
"aria-valuetext": `${a} pixels`,
|
|
263
|
+
tabIndex: 0,
|
|
264
|
+
"data-chat-splitter": "",
|
|
265
|
+
onPointerDown: u,
|
|
266
|
+
onPointerMove: h,
|
|
267
|
+
onPointerUp: w,
|
|
268
|
+
onPointerCancel: w,
|
|
269
|
+
onKeyDown: y,
|
|
270
|
+
className: g("absolute inset-y-0 -right-3 z-10 w-6 cursor-col-resize touch-none select-none", "outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-2", "after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent", "[@media(hover:hover)]:hover:after:bg-pho-brand focus-visible:after:bg-pho-brand", e === "auto" && "@max-2xl:hidden")
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function $e({ className: t, wrapperClassName: e, placeholder: a = "Search", ...o }) {
|
|
274
|
+
return /* @__PURE__ */ r("div", {
|
|
275
|
+
"data-chat-search": "",
|
|
276
|
+
className: g("p-3", se, t),
|
|
277
|
+
children: /* @__PURE__ */ r(ve, {
|
|
278
|
+
size: "sm",
|
|
279
|
+
icon: xe,
|
|
280
|
+
placeholder: a,
|
|
281
|
+
"aria-label": "Search conversations",
|
|
282
|
+
autoComplete: "off",
|
|
283
|
+
spellCheck: !1,
|
|
284
|
+
wrapperClassName: g(we, "[&:focus-within>svg]:text-pho-primary [&>svg]:transition-colors [&>svg]:duration-100", e),
|
|
285
|
+
...o
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function je({ className: t, children: e, ...a }) {
|
|
290
|
+
return /* @__PURE__ */ r("div", {
|
|
291
|
+
"data-chat-conversations": "",
|
|
292
|
+
className: g("flex min-h-0 flex-1 flex-col", t),
|
|
293
|
+
...a,
|
|
294
|
+
children: /* @__PURE__ */ N(k.Root, {
|
|
295
|
+
className: "min-h-0 flex-1",
|
|
296
|
+
children: [/* @__PURE__ */ r(k.Viewport, { children: /* @__PURE__ */ r(k.Content, {
|
|
297
|
+
style: { minWidth: 0 },
|
|
298
|
+
className: "flex min-h-full flex-col px-3 py-1",
|
|
299
|
+
children: e
|
|
300
|
+
}) }), /* @__PURE__ */ r(k.Scrollbar, { children: /* @__PURE__ */ r(k.Thumb, {}) })]
|
|
301
|
+
})
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function Be({ className: t, ...e }) {
|
|
305
|
+
return /* @__PURE__ */ r("ul", {
|
|
306
|
+
"data-chat-conversation-list": "",
|
|
307
|
+
className: g("m-0 flex list-none flex-col gap-0.5 *:m-0", t),
|
|
308
|
+
...e
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
var Ke = "outline-pho-brand rounded-base flex w-full cursor-pointer items-center gap-3 px-2 py-2.5 text-left transition-colors focus-visible:outline-2 focus-visible:-outline-offset-1", Ge = "bg-pho-primary text-pho-primary ring-pho-secondary ring-1 ring-inset *:data-icon:text-pho-primary", qe = "hover:bg-pho-ghost-hover", Z = {
|
|
312
|
+
initial: !1,
|
|
313
|
+
whileTap: { scale: fe },
|
|
314
|
+
transition: pe
|
|
315
|
+
};
|
|
316
|
+
function Qe({ title: t, time: e, preview: a, avatar: o, group: s, active: d, className: c, href: u, onClick: h, ...w }) {
|
|
317
|
+
const { layout: y, setPane: m } = M("Conversation"), i = de(), p = ne(() => z.create(i), [i]), f = g(Ke, d ? Ge : qe, c), v = () => {
|
|
318
|
+
y !== "default" && m("thread");
|
|
319
|
+
}, x = /* @__PURE__ */ N(ae, { children: [o ?? /* @__PURE__ */ r(J.Root, {
|
|
320
|
+
size: "sm",
|
|
321
|
+
children: /* @__PURE__ */ r(J.Fallback, { children: s ? /* @__PURE__ */ r(Me, {
|
|
322
|
+
className: "size-4",
|
|
323
|
+
"aria-hidden": !0
|
|
324
|
+
}) : /* @__PURE__ */ r(Ie, {
|
|
325
|
+
className: "size-4",
|
|
326
|
+
"aria-hidden": !0
|
|
327
|
+
}) })
|
|
328
|
+
}), /* @__PURE__ */ N("span", {
|
|
329
|
+
className: "min-w-0 flex-1",
|
|
330
|
+
children: [/* @__PURE__ */ N("span", {
|
|
331
|
+
className: "flex items-baseline justify-between gap-2",
|
|
332
|
+
children: [/* @__PURE__ */ r("span", {
|
|
333
|
+
className: "text-pho-primary min-w-0 truncate text-base font-medium",
|
|
334
|
+
children: t
|
|
335
|
+
}), e != null && /* @__PURE__ */ r("span", {
|
|
336
|
+
className: "text-pho-description shrink-0 text-xs font-normal whitespace-nowrap tabular-nums",
|
|
337
|
+
children: e
|
|
338
|
+
})]
|
|
339
|
+
}), a != null && /* @__PURE__ */ r("span", {
|
|
340
|
+
className: "text-pho-description mt-0.5 block min-w-0 truncate text-xs font-normal",
|
|
341
|
+
children: a
|
|
342
|
+
})]
|
|
343
|
+
})] });
|
|
344
|
+
return u !== void 0 ? /* @__PURE__ */ r("li", { children: /* @__PURE__ */ r(p, {
|
|
345
|
+
href: u,
|
|
346
|
+
"aria-current": d ? "page" : void 0,
|
|
347
|
+
...w,
|
|
348
|
+
onClick: (b) => {
|
|
349
|
+
h?.(b), b.defaultPrevented || v();
|
|
350
|
+
},
|
|
351
|
+
className: f,
|
|
352
|
+
...Z,
|
|
353
|
+
children: x
|
|
354
|
+
}) }) : /* @__PURE__ */ r("li", { children: /* @__PURE__ */ r(z.button, {
|
|
355
|
+
type: "button",
|
|
356
|
+
"aria-current": d ? "true" : void 0,
|
|
357
|
+
...w,
|
|
358
|
+
onClick: (b) => {
|
|
359
|
+
h?.(b), b.defaultPrevented || v();
|
|
360
|
+
},
|
|
361
|
+
className: f,
|
|
362
|
+
...Z,
|
|
363
|
+
children: x
|
|
364
|
+
}) });
|
|
365
|
+
}
|
|
366
|
+
function Je({ className: t, children: e, ...a }) {
|
|
367
|
+
const { layout: o, pane: s, direction: d, swap: c, swapped: u } = M("Thread"), h = ie(), w = g("bg-pho-primary flex min-h-0 flex-1 flex-col", o === "default" && "min-w-80", o === "compact" && "min-w-0", o === "auto" && "min-w-0 @2xl:min-w-80", !c && o === "auto" && s === "list" && "@max-2xl:hidden", t);
|
|
368
|
+
return c ? /* @__PURE__ */ r(le, {
|
|
369
|
+
as: "section",
|
|
370
|
+
show: s === "thread",
|
|
371
|
+
swapped: u,
|
|
372
|
+
direction: d,
|
|
373
|
+
reduceMotion: h,
|
|
374
|
+
"aria-label": "Conversation",
|
|
375
|
+
"data-chat-thread": "",
|
|
376
|
+
className: w,
|
|
377
|
+
...a,
|
|
378
|
+
children: e
|
|
379
|
+
}) : /* @__PURE__ */ r("section", {
|
|
380
|
+
"aria-label": "Conversation",
|
|
381
|
+
"data-chat-thread": "",
|
|
382
|
+
className: w,
|
|
383
|
+
...a,
|
|
384
|
+
children: e
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function Ye({ avatar: t, actions: e, backLabel: a = "Back to conversations", className: o, children: s, ...d }) {
|
|
388
|
+
const { layout: c, setPane: u } = M("Header");
|
|
389
|
+
return /* @__PURE__ */ N("header", {
|
|
390
|
+
"data-chat-header": "",
|
|
391
|
+
className: g("flex shrink-0 items-center gap-3 px-4 py-1.5", se, o),
|
|
392
|
+
...d,
|
|
393
|
+
children: [
|
|
394
|
+
c !== "default" && /* @__PURE__ */ r(F, {
|
|
395
|
+
variant: "ghost",
|
|
396
|
+
size: "sm",
|
|
397
|
+
shape: "circle",
|
|
398
|
+
svgOnly: !0,
|
|
399
|
+
"aria-label": a,
|
|
400
|
+
"data-chat-back": "",
|
|
401
|
+
className: g("-ml-1 shrink-0", c === "auto" && "@2xl:hidden"),
|
|
402
|
+
onClick: () => u("list"),
|
|
403
|
+
children: /* @__PURE__ */ r(Re, {})
|
|
404
|
+
}),
|
|
405
|
+
t,
|
|
406
|
+
/* @__PURE__ */ r("div", {
|
|
407
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
408
|
+
children: s
|
|
409
|
+
}),
|
|
410
|
+
e != null && /* @__PURE__ */ r("div", {
|
|
411
|
+
className: "flex shrink-0 items-center gap-1",
|
|
412
|
+
children: e
|
|
413
|
+
})
|
|
414
|
+
]
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function Ze({ className: t, children: e, ...a }) {
|
|
418
|
+
return /* @__PURE__ */ r("h2", {
|
|
419
|
+
"data-chat-title": "",
|
|
420
|
+
className: g("text-pho-primary m-0 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 overflow-visible text-base font-medium", t),
|
|
421
|
+
...a,
|
|
422
|
+
children: e
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function et({ className: t, ...e }) {
|
|
426
|
+
return /* @__PURE__ */ r("p", {
|
|
427
|
+
"data-chat-description": "",
|
|
428
|
+
className: g("text-pho-description m-0 min-w-0 truncate text-xs", t),
|
|
429
|
+
...e
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
var ee = 40, tt = "200px 0px 0px 0px";
|
|
433
|
+
function U(t, e) {
|
|
434
|
+
return e.getBoundingClientRect().top - t.getBoundingClientRect().top;
|
|
435
|
+
}
|
|
436
|
+
function X(t) {
|
|
437
|
+
return t != null && t.isConnected && t.getClientRects().length > 0;
|
|
438
|
+
}
|
|
439
|
+
function te(t) {
|
|
440
|
+
const e = t?.querySelector("[data-message]") ?? null;
|
|
441
|
+
return X(e) ? e : null;
|
|
442
|
+
}
|
|
443
|
+
function rt({ hasEarlier: t = !1, loadingEarlier: e = !1, onLoadEarlier: a, earlierLabel: o = "Load earlier messages", className: s, children: d, ...c }) {
|
|
444
|
+
const u = S(null), h = S(null), w = S(null), y = S(!0), m = S(null), i = S(e), p = S(!1), f = S(a);
|
|
445
|
+
T(() => {
|
|
446
|
+
f.current = a;
|
|
447
|
+
});
|
|
448
|
+
const v = O(() => {
|
|
449
|
+
const n = u.current;
|
|
450
|
+
if (!n) return;
|
|
451
|
+
const l = m.current;
|
|
452
|
+
if (l) {
|
|
453
|
+
if (X(l.row) ? n.scrollTop += U(n, l.row) - l.offset : n.scrollTop = n.scrollHeight - l.height + l.top, i.current) return;
|
|
454
|
+
m.current = null, y.current = n.scrollHeight - n.scrollTop - n.clientHeight < ee;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
y.current && (n.scrollTop = n.scrollHeight);
|
|
458
|
+
}, []);
|
|
459
|
+
T(() => {
|
|
460
|
+
const n = u.current, l = h.current;
|
|
461
|
+
if (!n || !l || (v(), typeof ResizeObserver > "u")) return;
|
|
462
|
+
const R = new ResizeObserver(v);
|
|
463
|
+
return R.observe(l), R.observe(n), () => R.disconnect();
|
|
464
|
+
}, [v]), T(() => {
|
|
465
|
+
if (i.current = e, e) return;
|
|
466
|
+
const n = m.current;
|
|
467
|
+
n && (p.current = te(h.current) === n.row), v();
|
|
468
|
+
}, [e, v]);
|
|
469
|
+
const x = () => {
|
|
470
|
+
const n = u.current;
|
|
471
|
+
if (!n) return;
|
|
472
|
+
const l = m.current;
|
|
473
|
+
l && (l.height = n.scrollHeight, l.top = n.scrollTop, X(l.row) && (l.offset = U(n, l.row))), y.current = n.scrollHeight - n.scrollTop - n.clientHeight < ee;
|
|
474
|
+
}, b = O(() => {
|
|
475
|
+
const n = u.current;
|
|
476
|
+
if (n) {
|
|
477
|
+
const l = te(h.current);
|
|
478
|
+
m.current = {
|
|
479
|
+
row: l,
|
|
480
|
+
offset: l ? U(n, l) : 0,
|
|
481
|
+
height: n.scrollHeight,
|
|
482
|
+
top: n.scrollTop
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
y.current = !1, f.current?.();
|
|
486
|
+
}, []);
|
|
487
|
+
return re(() => {
|
|
488
|
+
const n = u.current, l = w.current;
|
|
489
|
+
if (!t) {
|
|
490
|
+
p.current = !1;
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (e || p.current || !n || !l || typeof IntersectionObserver > "u") return;
|
|
494
|
+
const R = new IntersectionObserver((L) => {
|
|
495
|
+
L.some((_) => _.isIntersecting) && b();
|
|
496
|
+
}, {
|
|
497
|
+
root: n,
|
|
498
|
+
rootMargin: tt
|
|
499
|
+
});
|
|
500
|
+
return R.observe(l), () => R.disconnect();
|
|
501
|
+
}, [
|
|
502
|
+
t,
|
|
503
|
+
e,
|
|
504
|
+
b
|
|
505
|
+
]), /* @__PURE__ */ r("div", {
|
|
506
|
+
"data-chat-messages": "",
|
|
507
|
+
className: g("flex min-h-0 flex-1 flex-col [--pho-bubble-backdrop:var(--background-color-pho-primary)]", s),
|
|
508
|
+
...c,
|
|
509
|
+
children: /* @__PURE__ */ N(k.Root, {
|
|
510
|
+
className: "min-h-0 flex-1",
|
|
511
|
+
children: [/* @__PURE__ */ r(k.Viewport, {
|
|
512
|
+
ref: u,
|
|
513
|
+
onScroll: x,
|
|
514
|
+
children: /* @__PURE__ */ N(k.Content, {
|
|
515
|
+
ref: h,
|
|
516
|
+
style: { minWidth: 0 },
|
|
517
|
+
className: "flex min-h-full flex-col gap-1 p-4",
|
|
518
|
+
children: [t && /* @__PURE__ */ r("div", {
|
|
519
|
+
ref: w,
|
|
520
|
+
"data-chat-earlier": "",
|
|
521
|
+
"aria-busy": e || void 0,
|
|
522
|
+
className: "flex min-h-8 items-center justify-center",
|
|
523
|
+
children: e ? /* @__PURE__ */ r(me, {
|
|
524
|
+
"aria-label": "Loading earlier messages",
|
|
525
|
+
className: "text-pho-secondary"
|
|
526
|
+
}) : /* @__PURE__ */ r(F, {
|
|
527
|
+
variant: "outlined",
|
|
528
|
+
size: "sm",
|
|
529
|
+
onClick: (n) => {
|
|
530
|
+
n.currentTarget === document.activeElement && u.current?.focus({ preventScroll: !0 }), p.current = !1, b();
|
|
531
|
+
},
|
|
532
|
+
children: o
|
|
533
|
+
})
|
|
534
|
+
}), d]
|
|
535
|
+
})
|
|
536
|
+
}), /* @__PURE__ */ r(k.Scrollbar, { children: /* @__PURE__ */ r(k.Thumb, {}) })]
|
|
537
|
+
})
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function nt({ className: t, children: e, ...a }) {
|
|
541
|
+
return /* @__PURE__ */ r("div", {
|
|
542
|
+
"data-chat-divider": "",
|
|
543
|
+
className: g("text-pho-description py-1 text-center text-xs", t),
|
|
544
|
+
...a,
|
|
545
|
+
children: e
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
function at({ className: t, ...e }) {
|
|
549
|
+
return /* @__PURE__ */ r("footer", {
|
|
550
|
+
"data-chat-footer": "",
|
|
551
|
+
className: g("shrink-0 px-4 py-3", t),
|
|
552
|
+
...e
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
var it = 200;
|
|
556
|
+
function st({ value: t, onValueChange: e, onSend: a, placeholder: o = "Message", sending: s = !1, disabled: d = !1, canSend: c, prefix: u, meta: h, sendLabel: w = "Send", children: y, textareaRef: m, className: i, ...p }) {
|
|
557
|
+
const f = S(null), v = !s && !d && (c ?? t.trim().length > 0);
|
|
558
|
+
T(() => {
|
|
559
|
+
const n = f.current;
|
|
560
|
+
n && (n.style.height = "0px", n.style.height = `${Math.min(n.scrollHeight, it)}px`);
|
|
561
|
+
}, [t]);
|
|
562
|
+
const x = (n) => {
|
|
563
|
+
n.preventDefault(), v && a();
|
|
564
|
+
}, b = (n) => {
|
|
565
|
+
n.key === "Enter" && !n.shiftKey && !n.nativeEvent.isComposing && (n.preventDefault(), v && a());
|
|
566
|
+
};
|
|
567
|
+
return /* @__PURE__ */ N("form", {
|
|
568
|
+
"aria-label": "Message composer",
|
|
569
|
+
"data-chat-composer": "",
|
|
570
|
+
onSubmit: x,
|
|
571
|
+
className: g("rounded-base bg-pho-primary ring-pho-primary focus-within:ring-pho-brand ring-1 transition-shadow duration-100 ease-linear ring-inset focus-within:ring-2", d && "opacity-50", i),
|
|
572
|
+
...p,
|
|
573
|
+
children: [
|
|
574
|
+
y,
|
|
575
|
+
/* @__PURE__ */ r("textarea", {
|
|
576
|
+
ref: (n) => {
|
|
577
|
+
f.current = n, typeof m == "function" ? m(n) : m && (m.current = n);
|
|
578
|
+
},
|
|
579
|
+
value: t,
|
|
580
|
+
onChange: (n) => e(n.target.value),
|
|
581
|
+
onKeyDown: b,
|
|
582
|
+
rows: 1,
|
|
583
|
+
placeholder: o,
|
|
584
|
+
"aria-label": "Message",
|
|
585
|
+
disabled: d,
|
|
586
|
+
readOnly: s,
|
|
587
|
+
className: "text-pho-primary placeholder:text-pho-placeholder m-0 block w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none disabled:cursor-not-allowed"
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ N("div", {
|
|
590
|
+
className: "flex items-center gap-2 px-2 pb-2",
|
|
591
|
+
children: [
|
|
592
|
+
u,
|
|
593
|
+
/* @__PURE__ */ r("p", {
|
|
594
|
+
className: "text-pho-description m-0 min-w-0 flex-1 truncate text-xs",
|
|
595
|
+
children: h
|
|
596
|
+
}),
|
|
597
|
+
/* @__PURE__ */ r(F, {
|
|
598
|
+
type: "submit",
|
|
599
|
+
size: "sm",
|
|
600
|
+
shape: "circle",
|
|
601
|
+
svgOnly: !0,
|
|
602
|
+
"aria-label": w,
|
|
603
|
+
disabled: !v,
|
|
604
|
+
loading: s,
|
|
605
|
+
children: /* @__PURE__ */ r(Ae, {})
|
|
606
|
+
})
|
|
607
|
+
]
|
|
608
|
+
})
|
|
609
|
+
]
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function ot({ className: t, size: e = "sm", ...a }) {
|
|
613
|
+
return /* @__PURE__ */ r("div", {
|
|
614
|
+
"data-chat-empty": "",
|
|
615
|
+
className: g("flex flex-1 flex-col items-center justify-center px-6 py-8", t),
|
|
616
|
+
children: /* @__PURE__ */ r(ge, {
|
|
617
|
+
size: e,
|
|
618
|
+
...a
|
|
619
|
+
})
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
function lt({ rows: t = 5 }) {
|
|
623
|
+
return /* @__PURE__ */ r("div", {
|
|
624
|
+
"aria-hidden": !0,
|
|
625
|
+
"data-chat-conversations-loading": "",
|
|
626
|
+
className: "flex flex-col gap-0.5",
|
|
627
|
+
children: Array.from({ length: t }, (e, a) => /* @__PURE__ */ N("div", {
|
|
628
|
+
className: "flex items-center gap-3 px-2 py-2.5",
|
|
629
|
+
children: [/* @__PURE__ */ r(A, { className: "size-8 shrink-0 rounded-full" }), /* @__PURE__ */ N("div", {
|
|
630
|
+
className: "min-w-0 flex-1",
|
|
631
|
+
children: [/* @__PURE__ */ N("div", {
|
|
632
|
+
className: "flex items-center justify-between gap-2",
|
|
633
|
+
children: [/* @__PURE__ */ r(A, { className: "h-3.5 w-32" }), /* @__PURE__ */ r(A, { className: "h-2.5 w-8" })]
|
|
634
|
+
}), /* @__PURE__ */ r(A, { className: "mt-2 h-2.5 w-44" })]
|
|
635
|
+
})]
|
|
636
|
+
}, a))
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function ct() {
|
|
640
|
+
return /* @__PURE__ */ N("div", {
|
|
641
|
+
"aria-hidden": !0,
|
|
642
|
+
"data-chat-messages-loading": "",
|
|
643
|
+
className: "flex flex-col gap-3",
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ r(A, { className: "rounded-base h-10 w-1/2 self-start" }),
|
|
646
|
+
/* @__PURE__ */ r(A, { className: "rounded-base h-10 w-2/5 self-end" }),
|
|
647
|
+
/* @__PURE__ */ r(A, { className: "rounded-base h-16 w-3/5 self-start" })
|
|
648
|
+
]
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
var _t = {
|
|
652
|
+
Root: Ve,
|
|
653
|
+
List: Xe,
|
|
654
|
+
Search: $e,
|
|
655
|
+
Conversations: je,
|
|
656
|
+
ConversationList: Be,
|
|
657
|
+
Conversation: Qe,
|
|
658
|
+
Thread: Je,
|
|
659
|
+
Header: Ye,
|
|
660
|
+
Title: Ze,
|
|
661
|
+
Description: et,
|
|
662
|
+
Messages: rt,
|
|
663
|
+
Divider: nt,
|
|
664
|
+
Footer: at,
|
|
665
|
+
Composer: st,
|
|
666
|
+
Empty: ot,
|
|
667
|
+
ConversationsLoading: lt,
|
|
668
|
+
MessagesLoading: ct
|
|
669
|
+
};
|
|
670
|
+
export {
|
|
671
|
+
_t as t
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
//# sourceMappingURL=chat-Dfbkf7g8.js.map
|