@gentiq/ui 1.0.0-alpha.4 → 1.0.0-alpha.5

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,3516 +0,0 @@
1
- "use client";
2
- import { jsx as n, jsxs as d, Fragment as R } from "react/jsx-runtime";
3
- import { withDefaults as H, useServerConfig as De, createOptionsStore as pn, useOptionsStore as fn, useGentiqOptions as Te, useGentiqTranslation as k, References as et, useMessage as M, useGentiqLanguage as $, useToolApproval as gn, useFileUrl as hn, useChatReferencesActions as bn, useThreadView as Y, useThreadScope as xt, Thread as Ne, localizeError as vn, Message as X, ActionBar as J, getLocalizedErrorMessage as yt, Composer as G, useComposer as Pe, useGentiqUser as xn, useComposerVoice as wt, useGentiqStatus as yn, useGentiqFeature as wn, useComposerRoot as Nn, useGentiqEntitlement as kn } from "@gentiq/react";
4
- import * as ke from "react";
5
- import { useContext as le, useMemo as E, createContext as te, useSyncExternalStore as Cn, useEffect as T, useState as C, useRef as P, useLayoutEffect as _n, memo as fe, useCallback as ee, Component as Sn, Suspense as Ce, lazy as Me, Children as zn, forwardRef as In } from "react";
6
- import { QuoteIcon as Re, ChevronDownIcon as ne, BrainIcon as Dn, XIcon as V, WrenchIcon as Tn, ImagePlusIcon as Pn, CodeIcon as Mn, DownloadIcon as de, GlobeIcon as Rn, XCircleIcon as Nt, CopyIcon as kt, BanIcon as An, CheckCircleIcon as En, ClockIcon as tt, ShieldQuestionIcon as On, CircleIcon as qn, FileIcon as Ct, ListChecksIcon as jn, ArrowUpIcon as _t, BookIcon as $n, ArrowDownIcon as Ln, CheckIcon as ce, RefreshCcwIcon as Fn, ThumbsUpIcon as Bn, ThumbsDownIcon as Un, PencilIcon as Hn, SquareIcon as Vn, AlertCircleIcon as Qn, RotateCwIcon as Wn, CameraOffIcon as Gn, Loader2Icon as St, RotateCcwIcon as Kn, SwitchCameraIcon as Jn, PlusIcon as Yn, FileTextIcon as Xn, ImagesIcon as Zn, CameraIcon as es, MicIcon as ts, Wrench as zt, RefreshCw as ns, ChevronUpIcon as ss } from "lucide-react";
7
- import rs from "rehype-sanitize";
8
- import { defaultRemarkPlugins as os, Streamdown as as, defaultRehypePlugins as Ae } from "streamdown";
9
- import { cjk as is } from "@streamdown/cjk";
10
- import { getTextDirection as L, resolveMessageId as ls, writeStored as cs, readStored as ds, isGentiqError as It, HIDDEN_PART_TYPES as us, messageText as ms, textOrKey as nt, createDateFormatter as ps } from "@gentiq/core";
11
- import { getToolName as Dt, isToolUIPart as Tt } from "ai";
12
- import * as Ee from "@radix-ui/react-collapsible";
13
- import { toast as K } from "sonner";
14
- import { Slot as Pt } from "@radix-ui/react-slot";
15
- import { cva as Oe } from "class-variance-authority";
16
- import * as Z from "@radix-ui/react-tooltip";
17
- import { flushSync as fs } from "react-dom";
18
- import * as _ from "@radix-ui/react-dialog";
19
- import * as ie from "@radix-ui/react-dropdown-menu";
20
- import * as ae from "@radix-ui/react-scroll-area";
21
- import * as me from "@radix-ui/react-hover-card";
22
- import { useControllableState as st } from "@radix-ui/react-use-controllable-state";
23
- import * as q from "@radix-ui/react-select";
24
- import * as rt from "@radix-ui/react-checkbox";
25
- import { clsx as gs } from "clsx";
26
- import { twMerge as hs } from "tailwind-merge";
27
- function p(...e) {
28
- return hs(gs(e));
29
- }
30
- function Ha(e, t) {
31
- return {
32
- history: U(e.history, t.history),
33
- welcome: U(e.welcome, t.welcome),
34
- threadActions: U(e.threadActions, t.threadActions),
35
- composer: e.composer && t.composer ? {
36
- ...H(e.composer, t.composer),
37
- attachments: U(e.composer.attachments, t.composer.attachments),
38
- references: U(e.composer.references, t.composer.references),
39
- voice: U(e.composer.voice, t.composer.voice)
40
- } : t.composer ?? e.composer,
41
- disclaimer: t.disclaimer ?? e.disclaimer,
42
- settings: e.settings && t.settings ? {
43
- sections: {
44
- profile: U(e.settings.sections?.profile, t.settings.sections?.profile),
45
- account: U(e.settings.sections?.account, t.settings.sections?.account)
46
- }
47
- } : t.settings ?? e.settings
48
- };
49
- }
50
- function U(e, t) {
51
- return e && t ? H(e, t) : t ?? e;
52
- }
53
- function bs(e, t) {
54
- const { history: s, welcome: r, threadActions: o, composer: i, disclaimer: a, settings: l } = e;
55
- return {
56
- history: H(
57
- { enabled: !0, showDelete: !0, showRename: !0, showShare: !0, showPin: !0 },
58
- s,
59
- {
60
- enabled: t?.history_enabled,
61
- showDelete: t?.history_show_delete,
62
- showRename: t?.history_show_rename,
63
- showShare: t?.history_show_share,
64
- showPin: t?.history_show_pin
65
- }
66
- ),
67
- welcome: H({ icon: null }, r, {
68
- greeting: typeof r?.greeting == "function" ? r.greeting : t?.welcome_greeting || r?.greeting,
69
- subtitle: t?.welcome_subtitle || r?.subtitle
70
- }),
71
- threadActions: H(
72
- { feedback: !0, retry: !0, edit: !0 },
73
- o,
74
- {
75
- feedback: t?.thread_actions_feedback,
76
- retry: t?.thread_actions_retry,
77
- edit: t?.thread_actions_edit
78
- }
79
- ),
80
- composer: {
81
- ...H({ maxLength: 1e4, collapseLines: 8 }, i),
82
- attachments: H(
83
- { enabled: !0 },
84
- i?.attachments,
85
- {
86
- enabled: t?.composer_attachments
87
- }
88
- ),
89
- references: H(
90
- { enabled: !0, maxItems: 5, maxExcerptLength: 500 },
91
- i?.references
92
- ),
93
- // The microphone needs a transcriber on the backend, which only `/config` can vouch for:
94
- // until it has, or when it can't be reached, there's no microphone.
95
- voice: {
96
- ...i?.voice,
97
- enabled: (t?.composer_voice ?? i?.voice?.enabled ?? !0) && !!t?.voice_input
98
- }
99
- },
100
- disclaimer: t?.disclaimer || a,
101
- settings: {
102
- sections: {
103
- general: be(
104
- l?.sections?.general,
105
- t?.settings_general_mode,
106
- t?.settings_general_fields
107
- ),
108
- profile: be(
109
- l?.sections?.profile,
110
- t?.settings_profile_mode,
111
- t?.settings_profile_fields
112
- ),
113
- account: be(
114
- l?.sections?.account,
115
- t?.settings_account_mode,
116
- t?.settings_account_fields
117
- )
118
- }
119
- },
120
- headerActionsEnabled: t?.header_actions ?? void 0,
121
- configured: e
122
- };
123
- }
124
- function be(e, t, s) {
125
- return {
126
- ...e,
127
- mode: t || e?.mode,
128
- enabled: e?.enabled ?? !0,
129
- fields: { ...e?.fields, ...s }
130
- };
131
- }
132
- const vs = te(null);
133
- function se(e) {
134
- const t = le(vs), s = De(), r = E(() => pn(bs({}, s)), [s]);
135
- return fn(t ?? r, e);
136
- }
137
- const qe = ({ className: e, from: t, ...s }) => /* @__PURE__ */ n(
138
- "div",
139
- {
140
- className: p(
141
- "group flex w-full items-end gap-3",
142
- t === "user" ? "is-user justify-end" : "is-assistant",
143
- e
144
- ),
145
- ...s
146
- }
147
- ), je = ({ children: e, className: t, isPlain: s, ...r }) => /* @__PURE__ */ n(
148
- "div",
149
- {
150
- className: p(
151
- "flex flex-col gap-2 overflow-hidden text-base",
152
- // User bubble: a flat fill from the `--gentiq-bubble` tokens.
153
- !s && [
154
- "group-[.is-user]:rounded-lg group-[.is-user]:rounded-ee-sm",
155
- "group-[.is-user]:bg-bubble group-[.is-user]:text-bubble-foreground",
156
- "group-[.is-user]:px-5 group-[.is-user]:py-3.5",
157
- "group-[.is-user]:max-w-[88%] md:group-[.is-user]:max-w-[78%]"
158
- ],
159
- // Assistant: transparent, full-width, generous leading
160
- "group-[.is-assistant]:bg-transparent",
161
- "group-[.is-assistant]:px-0 group-[.is-assistant]:py-1",
162
- "group-[.is-assistant]:w-full group-[.is-assistant]:leading-[1.7]",
163
- t
164
- ),
165
- ...r,
166
- children: e
167
- }
168
- ), xs = /(```[\s\S]*?(?:```|$)|~~~[\s\S]*?(?:~~~|$)|`+[^`\n]*`+)|\\\[([\s\S]+?)\\\]|\\\(([\s\S]+?)\\\)|\$\$([^$]+?)\$\$/g, ys = /\n[ \t]*\n/, ws = (e, t) => {
169
- let s = 0;
170
- for (; t - s > 0 && e[t - s - 1] === "\\"; ) s += 1;
171
- return s % 2 === 0;
172
- }, Ns = /^[ \t]*\n[\s\S]*\n[ \t>]*$/, ks = /(?:^|[^\\])%/, ot = String.raw`(?:(?=\p{Script=Arabic})[\p{L}\p{M}])`, Cs = new RegExp(
173
- `${ot}(?:[\\p{Script=Arabic}\\p{M}\\s\\u200c]*${ot})?`,
174
- "gu"
175
- ), _s = (e) => (e.includes(`
176
- `) && !Ns.test(e) && !ks.test(e) ? e.replace(/[ \t]*\n[ \t]*/g, " ") : e).replace(Cs, (s) => `\\text{${s}}`), Ss = (e) => {
177
- if (!e.includes("\\") && !e.includes("$$")) return e;
178
- const t = (s, r, o, i, a, l) => {
179
- if (r !== void 0) return s;
180
- const c = o ?? i ?? a ?? "";
181
- return !c.trim() || ys.test(c) || !ws(e, l) ? s : `$$${_s(c)}$$`;
182
- };
183
- return e.replace(xs, t);
184
- }, Mt = (e) => e.type === "element", Rt = (e) => {
185
- const t = e.properties?.className;
186
- return Array.isArray(t) ? t.filter((s) => typeof s == "string") : typeof t == "string" ? t.split(/\s+/) : [];
187
- }, zs = (e) => Mt(e) && e.tagName === "code" && Rt(e).includes("language-math"), Is = (e) => e.type === "text" && !e.value.trim(), Ds = (e) => {
188
- if (!Mt(e) || e.tagName !== "p") return null;
189
- const t = e.children.filter((r) => !Is(r)), [s] = t;
190
- return t.length === 1 && zs(s) ? s : null;
191
- }, Ts = (e) => {
192
- e.properties = { ...e.properties, className: [...Rt(e), "math-display"] };
193
- }, At = (e) => {
194
- for (const t of e.children ?? []) {
195
- const s = Ds(t);
196
- if (s) {
197
- Ts(s);
198
- continue;
199
- }
200
- At(t);
201
- }
202
- }, Ps = () => (e) => {
203
- At(e);
204
- }, Ms = /* @__PURE__ */ new Set(["a", "code", "pre", "math", "svg", "style", "script", "textarea"]), Rs = (e) => e.type === "element", As = /* @__PURE__ */ new Set(["math", "math-inline", "math-display"]), Es = (e) => {
205
- const t = e.properties?.className;
206
- return (Array.isArray(t) ? t : typeof t == "string" ? [t] : []).some(
207
- (r) => typeof r == "string" && (r.startsWith("katex") || As.has(r))
208
- );
209
- }, Os = /(\s+)/, qs = (e) => {
210
- if (!e.trim()) return null;
211
- const t = [];
212
- for (const s of e.split(Os))
213
- if (s) {
214
- if (!s.trim()) {
215
- t.push({ type: "text", value: s });
216
- continue;
217
- }
218
- t.push({
219
- type: "element",
220
- tagName: "span",
221
- properties: { className: ["gentiq-word"] },
222
- children: [{ type: "text", value: s }]
223
- });
224
- }
225
- return t;
226
- }, Et = (e) => {
227
- const t = e.children;
228
- if (!t?.length) return;
229
- const s = [];
230
- let r = !1;
231
- for (const o of t) {
232
- if (o.type === "text") {
233
- const i = qs(o.value);
234
- if (i) {
235
- s.push(...i), r = !0;
236
- continue;
237
- }
238
- s.push(o);
239
- continue;
240
- }
241
- if (Rs(o) && (Ms.has(o.tagName) || Es(o))) {
242
- s.push(o);
243
- continue;
244
- }
245
- Et(o), s.push(o);
246
- }
247
- r && (e.children = s);
248
- }, js = () => (e) => {
249
- Et(e);
250
- }, Ot = (e) => e.type === "element", $s = /* @__PURE__ */ new Set([
251
- "p",
252
- "h1",
253
- "h2",
254
- "h3",
255
- "h4",
256
- "h5",
257
- "h6",
258
- "li",
259
- "blockquote",
260
- "dt",
261
- "dd",
262
- "td",
263
- "th",
264
- "figcaption",
265
- "summary"
266
- ]), Ls = /* @__PURE__ */ new Set(["pre", "code", "kbd", "samp", "var"]), Fs = /* @__PURE__ */ new Set(["math", "svg", "style", "script", "textarea"]), at = (e) => e.type === "text" ? !!e.value.trim() : e.type === "element", qt = (e) => Ot(e) && e.tagName === "br", Bs = (e, t) => {
267
- const s = [[]], r = (o) => s[s.length - 1].push(o);
268
- for (const o of e) {
269
- if (qt(o)) {
270
- s.push([]);
271
- continue;
272
- }
273
- if (t && o.type === "text" && o.value.includes(`
274
- `)) {
275
- o.value.split(`
276
- `).forEach((a, l) => {
277
- l && s.push([]), a && r({ type: "text", value: a });
278
- });
279
- continue;
280
- }
281
- r(o);
282
- }
283
- return s;
284
- }, Us = (e) => {
285
- const [t] = e;
286
- if (t?.type !== "text") return e;
287
- const s = t.value.replace(/^[^\S\n]*\n[^\S\n]*/, "");
288
- return s === t.value ? e : s ? [{ type: "text", value: s }, ...e.slice(1)] : e.slice(1);
289
- }, Hs = (e) => ({
290
- type: "element",
291
- tagName: "span",
292
- properties: { className: ["gentiq-line"], dir: "auto" },
293
- children: e
294
- }), it = () => ({
295
- type: "element",
296
- tagName: "br",
297
- properties: {},
298
- children: []
299
- }), Vs = (e, t) => {
300
- const [s, ...r] = Bs(e.children, t).map(Us);
301
- e.children = [
302
- // An empty run is a blank line the author asked for; it keeps its break
303
- // rather than collapsing into a zero-height box.
304
- ...s.some(at) ? s : [it()],
305
- ...r.map((o) => o.some(at) ? Hs(o) : it())
306
- ];
307
- }, Qs = (e, t) => e.some(
308
- (s) => qt(s) || t && s.type === "text" && s.value.includes(`
309
- `)
310
- ), jt = (e, t) => {
311
- for (const s of e.children ?? [])
312
- if (Ot(s) && !Fs.has(s.tagName)) {
313
- if (Ls.has(s.tagName)) {
314
- s.properties = { ...s.properties, dir: "ltr" };
315
- continue;
316
- }
317
- jt(s, t), $s.has(s.tagName) && (Qs(s.children, t) && Vs(s, t), s.properties = { ...s.properties, dir: "auto" });
318
- }
319
- }, Ws = (e = {}) => (t) => {
320
- jt(t, e.preserveNewlines ?? !1);
321
- }, Gs = { cjk: is };
322
- let _e = Gs;
323
- const Se = /* @__PURE__ */ new Set(), Ks = (e) => (Se.add(e), () => {
324
- Se.delete(e);
325
- }), lt = () => _e, ve = /* @__PURE__ */ new Map(), xe = (e) => {
326
- if (ve.has(e)) return;
327
- const t = e === "code" ? import("@streamdown/code").then(({ code: s }) => ({ code: s })) : e === "math" ? import("@streamdown/math").then(({ math: s }) => ({ math: s })) : import("@streamdown/mermaid").then(({ mermaid: s }) => ({ mermaid: s }));
328
- ve.set(
329
- e,
330
- t.then((s) => {
331
- _e = { ..._e, ...s };
332
- for (const r of Se) r();
333
- }).catch(() => {
334
- ve.delete(e);
335
- })
336
- );
337
- }, Js = "```", Ys = /```[ \t]*mermaid\b/;
338
- let Xs = null;
339
- function Zs(e) {
340
- const t = Cn(Ks, lt, lt), s = e.includes(Js), r = s && Ys.test(e), o = e.includes("$$");
341
- return T(() => {
342
- s && xe("code");
343
- }, [s]), T(() => {
344
- r && xe("mermaid");
345
- }, [r]), T(() => {
346
- o && (xe("math"), Xs ??= import("katex/dist/katex.min.css").catch(() => {
347
- }));
348
- }, [o]), t;
349
- }
350
- const er = { linkMode: "text-only" }, tr = { enabled: !1 }, $e = (e) => {
351
- const t = Ae[e];
352
- return Array.isArray(t) ? t[1] ?? {} : {};
353
- }, nr = (e, t) => {
354
- const s = Ae[e];
355
- return [Array.isArray(s) ? s[0] : s, { ...$e(e), ...t }];
356
- }, sr = (e) => {
357
- const t = $e("sanitize");
358
- return [
359
- rs,
360
- {
361
- ...t,
362
- protocols: {
363
- ...t.protocols,
364
- href: [...t.protocols?.href ?? [], ...e]
365
- }
366
- }
367
- ];
368
- }, rr = (e, t, s) => {
369
- const r = e.length ? {
370
- // Sanitizing is what drops the href: its schema is an allow-list of
371
- // schemes, and an unknown one leaves the link href-less.
372
- sanitize: sr(e),
373
- // Hardening runs a second, independent scheme check. Streamdown happens
374
- // to configure it wide open today, but riding on that would mean a
375
- // stricter upstream default silently blocking these links again.
376
- harden: nr("harden", {
377
- allowedProtocols: [
378
- ...$e("harden").allowedProtocols ?? [],
379
- ...e.map((o) => `${o}:`)
380
- ]
381
- })
382
- } : {};
383
- return [
384
- ...Object.entries(Ae).map(([o, i]) => r[o] ?? i),
385
- // After sanitizing, which is what strips the marker it has to put back, and
386
- // before KaTeX, which Streamdown appends after everything supplied here.
387
- Ps,
388
- // After sanitizing and hardening, which both strip a `dir` they were not
389
- // configured to expect, and before the word spans, which are not blocks and
390
- // would only be walked for nothing.
391
- [Ws, { preserveNewlines: s }],
392
- // Dead last, after sanitizing and hardening: the spans it adds are ours,
393
- // not the model's, and neither pass should have an opinion about them.
394
- ...t ? [js] : []
395
- ];
396
- }, ct = /* @__PURE__ */ new Map(), or = (e, t, s) => {
397
- const r = `${t ? "w" : "-"}|${s ? "n" : "-"}|${e.join(",")}`;
398
- let o = ct.get(r);
399
- return o || (o = rr(e, t, s), ct.set(r, o)), o;
400
- }, ge = ({
401
- className: e,
402
- children: t,
403
- remarkPlugins: s,
404
- rehypePlugins: r,
405
- linkProtocols: o,
406
- wordFade: i = !1,
407
- mode: a = "static",
408
- preserveNewlines: l = !1,
409
- ...c
410
- }) => {
411
- const u = typeof t == "string" ? t : "", m = E(() => Ss(u), [u]), h = Zs(m), b = E(
412
- () => s?.length ? [...Object.values(os), ...s] : void 0,
413
- [s]
414
- ), g = o?.join(",") ?? "", f = E(() => {
415
- const w = or(
416
- g ? g.split(",") : [],
417
- i,
418
- l
419
- );
420
- return r?.length ? [...w, ...r] : w;
421
- }, [r, g, i, l]);
422
- return (
423
- // `Streamdown` is itself memoized on `children`, so a settled message never
424
- // re-renders this subtree — no outer `memo` needed here.
425
- /* @__PURE__ */ n(
426
- as,
427
- {
428
- className: p("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 code-bg ", e),
429
- mode: a,
430
- plugins: h,
431
- remend: er,
432
- linkSafety: tr,
433
- ...c,
434
- remarkPlugins: b,
435
- rehypePlugins: f,
436
- children: typeof t == "string" ? m : t
437
- }
438
- )
439
- );
440
- };
441
- ge.displayName = "Response";
442
- const $t = 40, Lt = 900, ar = 220, ir = 120, lr = 250, cr = 1e3, dt = 48, dr = (e, t) => {
443
- if (t >= e.length) return e.length;
444
- const s = Math.max(0, t - dt);
445
- for (let r = t; r > s; r--)
446
- if (/\s/.test(e[r])) return r;
447
- return t < dt ? 0 : t;
448
- }, ur = 120, mr = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
449
- function Ft(e, t, s = {}) {
450
- const {
451
- minCharsPerSecond: r = $t,
452
- maxCharsPerSecond: o = Lt,
453
- enabled: i = !0
454
- } = s, [a] = C(mr), l = i && !a, [c, u] = C(
455
- () => t && e.length <= ur ? Math.min(e.length, 1) : e.length
456
- ), m = P(c), h = P(0);
457
- T(() => {
458
- if (!l) {
459
- m.current = e.length;
460
- return;
461
- }
462
- if (e.length < m.current) {
463
- m.current = e.length, h.current = 0, u(e.length);
464
- return;
465
- }
466
- if (m.current >= e.length) {
467
- u((v) => v >= e.length ? v : e.length);
468
- return;
469
- }
470
- let g = 0, f = performance.now();
471
- const w = t ? 0 : Math.min(
472
- Math.max((e.length - m.current) / ir * 1e3, r),
473
- o
474
- ), x = Math.floor(o * cr / 1e3), y = (v) => {
475
- g = 0;
476
- const I = Math.min(v - f, lr);
477
- f = v, e.length - m.current > x && (m.current = e.length - x, h.current = 0);
478
- const N = e.length - m.current;
479
- if (N <= 0) return;
480
- const S = (t ? Math.min(Math.max(N / ar * 1e3, r), o) : w) * I / 1e3 + h.current, O = Math.floor(S);
481
- if (h.current = S - O, O > 0) {
482
- const D = Math.min(e.length, m.current + O);
483
- if (m.current = D, u(D), D >= e.length) return;
484
- }
485
- g = requestAnimationFrame(y);
486
- };
487
- return g = requestAnimationFrame(y), () => {
488
- g && cancelAnimationFrame(g);
489
- };
490
- }, [e, t, l, r, o]);
491
- const b = l && c < e.length;
492
- return [b ? e.slice(0, dr(e, c)) : e, b];
493
- }
494
- function Bt() {
495
- const t = Te((s) => s.app)?.smoothStreaming;
496
- return E(() => {
497
- const s = typeof t == "object" ? t : {};
498
- return {
499
- enabled: t !== !1,
500
- minCharsPerSecond: s.minCharsPerSecond ?? $t,
501
- maxCharsPerSecond: s.maxCharsPerSecond ?? Lt
502
- };
503
- }, [t]);
504
- }
505
- function pr({
506
- showAction: e = !0,
507
- className: t,
508
- children: s,
509
- ...r
510
- }) {
511
- const { t: o } = k(["chat"]);
512
- return /* @__PURE__ */ d(
513
- et.Source,
514
- {
515
- className: `group/reference relative rounded-md transition-colors ${t ?? ""}`,
516
- ...r,
517
- children: [
518
- s,
519
- e && /* @__PURE__ */ n(
520
- et.Quote,
521
- {
522
- className: "absolute end-1.5 top-1.5 z-10 flex size-7 items-center justify-center rounded-lg bg-background text-muted-foreground opacity-0 shadow-sm ring-1 ring-border/60 transition hover:text-foreground group-hover/reference:opacity-100 focus-visible:opacity-100",
523
- "aria-label": o("reference"),
524
- title: o("reference"),
525
- children: /* @__PURE__ */ n(Re, { className: "size-3.5" })
526
- }
527
- )
528
- ]
529
- }
530
- );
531
- }
532
- function ze({
533
- text: e,
534
- role: t,
535
- streaming: s,
536
- reference: r
537
- }) {
538
- const { textComponents: o, remarkPlugins: i, rehypePlugins: a, linkProtocols: l } = B(), c = se((x) => x.composer), u = Bt(), m = L(e), h = s && t === "assistant", [b] = Ft(e, h, u), g = P(!1);
539
- h && (g.current = !0);
540
- const f = g.current ? "streaming" : "static", w = t === "user" ? /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap break-words", children: b.split(`
541
- `).map((x, y) => /* @__PURE__ */ n("div", { dir: "auto", children: x || /* @__PURE__ */ n("br", {}) }, y)) }) : /* @__PURE__ */ n(
542
- ge,
543
- {
544
- components: o,
545
- remarkPlugins: i,
546
- rehypePlugins: a,
547
- linkProtocols: l,
548
- wordFade: g.current,
549
- mode: f,
550
- children: b
551
- }
552
- );
553
- return /* @__PURE__ */ n("div", { className: "group py-2 first:pt-4 animate-in-bubble", children: /* @__PURE__ */ n(qe, { from: t, children: /* @__PURE__ */ n(je, { dir: m, children: /* @__PURE__ */ n(fr, { lines: t === "user" ? c?.collapseLines ?? 0 : 0, children: /* @__PURE__ */ n(pr, { showAction: !1, reference: r, children: w }) }) }) }) });
554
- }
555
- function fr({ lines: e, children: t }) {
556
- const { t: s } = k(["chat"]), r = P(null), [o, i] = C(!1), [a, l] = C(!1);
557
- return _n(() => {
558
- const u = r.current;
559
- if (!u || !e || a) return;
560
- const m = u.firstElementChild, h = () => i((m?.offsetHeight ?? u.scrollHeight) > u.clientHeight + 1);
561
- h();
562
- const b = typeof ResizeObserver > "u" ? null : new ResizeObserver(h);
563
- return b?.observe(u), m && b?.observe(m), () => b?.disconnect();
564
- }, [e, a]), e ? /* @__PURE__ */ d(R, { children: [
565
- /* @__PURE__ */ n(
566
- "div",
567
- {
568
- ref: r,
569
- className: "overflow-hidden",
570
- style: !a ? {
571
- maxHeight: `${e}lh`,
572
- ...o && {
573
- maskImage: "linear-gradient(to bottom, black calc(100% - 2lh), transparent)"
574
- }
575
- } : void 0,
576
- children: t
577
- }
578
- ),
579
- o && // `self-end` follows the bubble's `dir`, so it sits at the end the text runs toward.
580
- /* @__PURE__ */ n(
581
- "button",
582
- {
583
- type: "button",
584
- onClick: () => l((u) => !u),
585
- "aria-expanded": a,
586
- "aria-label": s(a ? "show_less" : "show_more"),
587
- title: s(a ? "show_less" : "show_more"),
588
- className: "-mb-1.5 -me-2 flex size-7 shrink-0 items-center justify-center self-end rounded-full bg-primary-foreground/15 transition-colors hover:bg-primary-foreground/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-foreground/50",
589
- children: /* @__PURE__ */ n(
590
- ne,
591
- {
592
- className: p("size-4 transition-transform duration-200", a && "rotate-180")
593
- }
594
- )
595
- }
596
- )
597
- ] }) : /* @__PURE__ */ n(R, { children: t });
598
- }
599
- function gr({ part: e, index: t }) {
600
- const s = e.text;
601
- return s.trim() ? /* @__PURE__ */ n(hr, { text: s, index: t, segment: "text" }) : null;
602
- }
603
- function hr({ text: e, index: t, segment: s }) {
604
- const { t: r } = k("chat"), o = M((l) => l.message.id), i = M((l) => l.message.role), a = M((l) => l.isStreaming);
605
- return /* @__PURE__ */ n(
606
- ze,
607
- {
608
- text: e,
609
- role: i,
610
- streaming: a,
611
- reference: {
612
- kind: "text",
613
- messageId: o,
614
- partIndex: t,
615
- sourceId: `${o}-${t}-${s}`,
616
- role: i,
617
- label: r(i === "user" ? "reference_user_message" : "reference_assistant_response"),
618
- excerpt: e
619
- }
620
- }
621
- );
622
- }
623
- function Le({ ...e }) {
624
- return /* @__PURE__ */ n(Ee.Root, { "data-slot": "collapsible", ...e });
625
- }
626
- function Fe({ ...e }) {
627
- return /* @__PURE__ */ n(Ee.CollapsibleTrigger, { "data-slot": "collapsible-trigger", ...e });
628
- }
629
- function Be({ ...e }) {
630
- return /* @__PURE__ */ n(Ee.CollapsibleContent, { "data-slot": "collapsible-content", ...e });
631
- }
632
- const Ut = te(null), br = () => {
633
- const e = le(Ut);
634
- if (!e)
635
- throw new Error("Reasoning components must be used within Reasoning");
636
- return e;
637
- }, vr = 1e3, xr = 1e3, Ht = fe(
638
- ({
639
- className: e,
640
- isStreaming: t = !1,
641
- open: s,
642
- defaultOpen: r = !0,
643
- // eslint-disable-next-line @typescript-eslint/unbound-method
644
- onOpenChange: o,
645
- duration: i,
646
- children: a,
647
- ...l
648
- }) => {
649
- const [c, u] = st({
650
- prop: s,
651
- defaultProp: r,
652
- onChange: o
653
- }), [m, h] = st({
654
- prop: i,
655
- defaultProp: 0
656
- }), [b, g] = C(!1), [f, w] = C(null);
657
- T(() => {
658
- t ? f === null && w(Date.now()) : f !== null && (h(Math.ceil((Date.now() - f) / xr)), w(null));
659
- }, [t, f, h]), T(() => {
660
- if (r && !t && c && !b) {
661
- const v = setTimeout(() => {
662
- u(!1), g(!0);
663
- }, vr);
664
- return () => {
665
- clearTimeout(v);
666
- };
667
- }
668
- }, [t, c, r, u, b]);
669
- const x = ee(
670
- (v) => {
671
- u(v);
672
- },
673
- [u]
674
- ), y = E(
675
- () => ({ isStreaming: t, isOpen: c, setIsOpen: u, duration: m }),
676
- [t, c, u, m]
677
- );
678
- return /* @__PURE__ */ n(Ut.Provider, { value: y, children: /* @__PURE__ */ n(
679
- Le,
680
- {
681
- className: p("not-prose mb-4", e),
682
- onOpenChange: x,
683
- open: c,
684
- ...l,
685
- children: a
686
- }
687
- ) });
688
- }
689
- ), Vt = fe(({ className: e, children: t, ...s }) => {
690
- const { isStreaming: r, isOpen: o, duration: i } = br(), { t: a } = k(["chat"]);
691
- return /* @__PURE__ */ n(
692
- Fe,
693
- {
694
- className: p("flex items-center gap-2 text-muted-foreground text-sm", e),
695
- ...s,
696
- children: t ?? /* @__PURE__ */ d(R, { children: [
697
- /* @__PURE__ */ n(Dn, { className: "size-4" }),
698
- r ? /* @__PURE__ */ n("p", { children: a("thinking") }) : i > 0 ? /* @__PURE__ */ n("p", { children: a("thought_for", { count: i }) }) : /* @__PURE__ */ n("p", { children: a("thought") }),
699
- /* @__PURE__ */ n(
700
- ne,
701
- {
702
- className: p(
703
- "size-4 text-muted-foreground transition-transform",
704
- o ? "rotate-180" : "rotate-0"
705
- )
706
- }
707
- )
708
- ] })
709
- }
710
- );
711
- }), Qt = fe(
712
- ({ className: e, children: t, wordFade: s, mode: r, ...o }) => /* @__PURE__ */ n(
713
- Be,
714
- {
715
- className: p(
716
- "mt-4 text-base",
717
- "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
718
- e
719
- ),
720
- ...o,
721
- children: /* @__PURE__ */ n(ge, { className: "grid gap-2", wordFade: s, mode: r, children: t })
722
- }
723
- )
724
- );
725
- Ht.displayName = "Reasoning";
726
- Vt.displayName = "ReasoningTrigger";
727
- Qt.displayName = "ReasoningContent";
728
- function yr({ part: e }) {
729
- const t = M((u) => u.isStreaming), { dir: s } = $(), r = Bt(), o = L(e.text), i = e.state === "streaming" && t, [a] = Ft(e.text, i, r), l = P(!1);
730
- i && (l.current = !0);
731
- const c = l.current ? "streaming" : "static";
732
- return e.text.trim() ? /* @__PURE__ */ d(Ht, { className: "w-full animate-in-bubble", dir: s, isStreaming: i, children: [
733
- /* @__PURE__ */ n(Vt, {}),
734
- /* @__PURE__ */ n(Qt, { dir: o, wordFade: l.current, mode: c, children: a })
735
- ] }) : null;
736
- }
737
- function Wt(e) {
738
- const [t, s] = C(!1), r = P(void 0);
739
- T(() => () => clearTimeout(r.current), []);
740
- const o = ee(() => {
741
- clearTimeout(r.current), s(!0), r.current = setTimeout(() => s(!1), e);
742
- }, [e]);
743
- return [t, o];
744
- }
745
- const wr = Oe(
746
- "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
747
- {
748
- variants: {
749
- variant: {
750
- default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
751
- secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
752
- destructive: "border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
753
- outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
754
- }
755
- },
756
- defaultVariants: {
757
- variant: "default"
758
- }
759
- }
760
- );
761
- function Nr({
762
- className: e,
763
- variant: t,
764
- asChild: s = !1,
765
- ...r
766
- }) {
767
- return /* @__PURE__ */ n(s ? Pt : "span", { "data-slot": "badge", className: p(wr({ variant: t }), e), ...r });
768
- }
769
- const kr = Oe(
770
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
771
- {
772
- variants: {
773
- variant: {
774
- default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
775
- destructive: "bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
776
- outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
777
- secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
778
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
779
- link: "text-primary underline-offset-4 hover:underline"
780
- },
781
- size: {
782
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
783
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
784
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
785
- icon: "size-9"
786
- }
787
- },
788
- defaultVariants: {
789
- variant: "default",
790
- size: "default"
791
- }
792
- }
793
- );
794
- function F({
795
- className: e,
796
- variant: t,
797
- size: s,
798
- asChild: r = !1,
799
- ...o
800
- }) {
801
- return /* @__PURE__ */ n(r ? Pt : "button", { "data-slot": "button", className: p(kr({ variant: t, size: s, className: e })), ...o });
802
- }
803
- const Cr = te(null);
804
- function Q() {
805
- return le(Cr);
806
- }
807
- function _r({ ...e }) {
808
- return /* @__PURE__ */ n(_.Root, { "data-slot": "dialog", ...e });
809
- }
810
- function Sr({ ...e }) {
811
- return /* @__PURE__ */ n(_.Trigger, { "data-slot": "dialog-trigger", ...e });
812
- }
813
- function zr({ ...e }) {
814
- const t = Q();
815
- return /* @__PURE__ */ n(_.Portal, { "data-slot": "dialog-portal", container: t, ...e });
816
- }
817
- function Va({ ...e }) {
818
- return /* @__PURE__ */ n(_.Close, { "data-slot": "dialog-close", ...e });
819
- }
820
- function Ir({ className: e, ...t }) {
821
- return /* @__PURE__ */ n(
822
- _.Overlay,
823
- {
824
- "data-slot": "dialog-overlay",
825
- className: p(
826
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-overlay",
827
- e
828
- ),
829
- ...t
830
- }
831
- );
832
- }
833
- function Dr({
834
- className: e,
835
- children: t,
836
- showCloseButton: s = !0,
837
- ...r
838
- }) {
839
- return /* @__PURE__ */ d(zr, { "data-slot": "dialog-portal", children: [
840
- /* @__PURE__ */ n(Ir, {}),
841
- /* @__PURE__ */ d(
842
- _.Content,
843
- {
844
- "data-slot": "dialog-content",
845
- className: p(
846
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed inset-0 z-50 m-auto grid h-fit w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
847
- e
848
- ),
849
- ...r,
850
- children: [
851
- t,
852
- s && /* @__PURE__ */ d(
853
- _.Close,
854
- {
855
- "data-slot": "dialog-close",
856
- className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 end-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
857
- children: [
858
- /* @__PURE__ */ n(V, {}),
859
- /* @__PURE__ */ n(Mr, {})
860
- ]
861
- }
862
- )
863
- ]
864
- }
865
- )
866
- ] });
867
- }
868
- function Tr({ className: e, ...t }) {
869
- return /* @__PURE__ */ n(
870
- "div",
871
- {
872
- "data-slot": "dialog-header",
873
- className: p("flex flex-col gap-2 text-center sm:text-start", e),
874
- ...t
875
- }
876
- );
877
- }
878
- function Qa({ className: e, ...t }) {
879
- return /* @__PURE__ */ n(
880
- "div",
881
- {
882
- "data-slot": "dialog-footer",
883
- className: p("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", e),
884
- ...t
885
- }
886
- );
887
- }
888
- function Pr({ className: e, ...t }) {
889
- return /* @__PURE__ */ n(
890
- _.Title,
891
- {
892
- "data-slot": "dialog-title",
893
- className: p("text-xl leading-none font-semibold", e),
894
- ...t
895
- }
896
- );
897
- }
898
- function Wa({ className: e, ...t }) {
899
- return /* @__PURE__ */ n(
900
- _.Description,
901
- {
902
- "data-slot": "dialog-description",
903
- className: p("text-muted-foreground text-base", e),
904
- ...t
905
- }
906
- );
907
- }
908
- function Mr() {
909
- const { t: e } = k("common");
910
- return /* @__PURE__ */ n("span", { className: "sr-only", children: e("close") });
911
- }
912
- const Rr = te({
913
- code: ""
914
- }), Ie = fe(function({
915
- code: t,
916
- className: s,
917
- children: r,
918
- ...o
919
- }) {
920
- return /* @__PURE__ */ n(Rr.Provider, { value: { code: t }, children: /* @__PURE__ */ d(
921
- "div",
922
- {
923
- className: p(
924
- "relative w-full overflow-hidden rounded-md border bg-background text-foreground",
925
- s
926
- ),
927
- dir: "ltr",
928
- ...o,
929
- children: [
930
- /* @__PURE__ */ n("pre", { className: "m-0 overflow-x-auto p-4 font-mono text-sm", children: /* @__PURE__ */ n("code", { children: t }) }),
931
- r && /* @__PURE__ */ n("div", { className: "absolute top-2 end-2 flex items-center gap-2", children: r })
932
- ]
933
- }
934
- ) });
935
- });
936
- function Ar(e, t = "size-4") {
937
- return {
938
- web_search: /* @__PURE__ */ n(Rn, { className: t }),
939
- web_fetch: /* @__PURE__ */ n(de, { className: t }),
940
- code_execution: /* @__PURE__ */ n(Mn, { className: t }),
941
- image_generation: /* @__PURE__ */ n(Pn, { className: t })
942
- }[e] ?? /* @__PURE__ */ n(Tn, { className: t });
943
- }
944
- const Er = ({ className: e, ...t }) => /* @__PURE__ */ n(Le, { className: p("not-prose mb-4 w-full rounded-md border", e), ...t }), Or = ({ status: e }) => {
945
- const { t } = k(["tools_ui"]), s = {
946
- "input-streaming": t("pending"),
947
- "input-available": t("running"),
948
- "approval-requested": t("awaiting_approval"),
949
- "approval-responded": t("approval_responded"),
950
- "output-available": t("completed"),
951
- "output-error": t("error"),
952
- "output-denied": t("denied")
953
- };
954
- return /* @__PURE__ */ d(Nr, { className: "gap-1.5 rounded-full text-xs", variant: "secondary", children: [
955
- {
956
- "input-streaming": /* @__PURE__ */ n(qn, { className: "size-4" }),
957
- "input-available": /* @__PURE__ */ n(tt, { className: "size-4 animate-pulse" }),
958
- "approval-requested": /* @__PURE__ */ n(On, { className: "size-4 text-warning" }),
959
- "approval-responded": /* @__PURE__ */ n(tt, { className: "size-4 animate-pulse" }),
960
- "output-available": /* @__PURE__ */ n(En, { className: "size-4 text-success" }),
961
- "output-error": /* @__PURE__ */ n(Nt, { className: "size-4 text-destructive" }),
962
- "output-denied": /* @__PURE__ */ n(An, { className: "size-4 text-destructive" })
963
- }[e],
964
- s[e]
965
- ] });
966
- }, qr = ({ className: e, type: t, state: s, toolName: r, ...o }) => {
967
- const i = r || (t.startsWith("tool-") ? t.slice(5) : t), a = Ar(i, "size-4 text-muted-foreground");
968
- return /* @__PURE__ */ d(
969
- Fe,
970
- {
971
- className: p("flex w-full items-center justify-between gap-4 p-3", e),
972
- ...o,
973
- children: [
974
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
975
- a,
976
- /* @__PURE__ */ n("span", { className: "font-medium text-sm", children: i }),
977
- /* @__PURE__ */ n(Or, { status: s })
978
- ] }),
979
- /* @__PURE__ */ n(ne, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })
980
- ]
981
- }
982
- );
983
- }, jr = ({ className: e, ...t }) => /* @__PURE__ */ n(
984
- Be,
985
- {
986
- className: p(
987
- "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
988
- e
989
- ),
990
- ...t
991
- }
992
- ), Gt = (e) => {
993
- if (typeof e == "string")
994
- try {
995
- return JSON.stringify(JSON.parse(e), null, 2);
996
- } catch {
997
- return e;
998
- }
999
- return JSON.stringify(e, null, 2);
1000
- }, $r = ({ className: e, input: t, state: s, ...r }) => {
1001
- const { t: o } = k(["tools_ui"]), i = E(() => Gt(t), [t]), a = s === "input-streaming";
1002
- return /* @__PURE__ */ d("div", { className: p("space-y-2 overflow-hidden p-4", e), ...r, children: [
1003
- /* @__PURE__ */ n("h4", { className: "font-medium text-muted-foreground text-xs uppercase tracking-wide", children: o("parameters") }),
1004
- /* @__PURE__ */ n("div", { className: "rounded-md bg-muted/50", children: a ? /* @__PURE__ */ n("pre", { className: "overflow-x-auto p-4 font-mono text-sm whitespace-pre-wrap", dir: "ltr", children: i }) : /* @__PURE__ */ n(Ie, { code: i }) })
1005
- ] });
1006
- }, Lr = ({ className: e, output: t, errorText: s, ...r }) => {
1007
- const { t: o } = k(["tools_ui"]), [i, a] = Wt(2e3), l = E(() => {
1008
- if (typeof t == "string")
1009
- try {
1010
- return JSON.stringify(JSON.parse(t), null, 2);
1011
- } catch {
1012
- return null;
1013
- }
1014
- return typeof t == "object" && t !== null && !("$$typeof" in t) ? JSON.stringify(t, null, 2) : null;
1015
- }, [t]);
1016
- if (!(t || s))
1017
- return null;
1018
- const c = () => {
1019
- s && navigator.clipboard.writeText(s).then(() => {
1020
- a();
1021
- });
1022
- }, u = () => typeof t == "string" ? l === null ? /* @__PURE__ */ n("div", { className: "p-4 text-sm whitespace-pre-wrap", dir: "ltr", children: t }) : /* @__PURE__ */ n(Ie, { code: l }) : typeof t == "object" && t !== null && !("$$typeof" in t) ? /* @__PURE__ */ n(Ie, { code: l ?? "" }) : t;
1023
- return /* @__PURE__ */ d("div", { className: p("space-y-2 p-4", e), ...r, children: [
1024
- /* @__PURE__ */ n("h4", { className: "font-medium text-muted-foreground text-xs uppercase tracking-wide", children: o(s ? "error" : "result") }),
1025
- s && /* @__PURE__ */ d(_r, { children: [
1026
- /* @__PURE__ */ n(Sr, { asChild: !0, children: /* @__PURE__ */ d(F, { variant: "destructive", size: "sm", children: [
1027
- /* @__PURE__ */ n(Nt, { className: "me-1.5 size-4" }),
1028
- o("view_error")
1029
- ] }) }),
1030
- /* @__PURE__ */ d(Dr, { className: "max-w-2xl", children: [
1031
- /* @__PURE__ */ n(Tr, { children: /* @__PURE__ */ n(Pr, { className: "text-destructive", children: o("tool_error") }) }),
1032
- /* @__PURE__ */ d("div", { className: "space-y-4", children: [
1033
- /* @__PURE__ */ n("div", { className: "max-h-96 overflow-auto rounded-md bg-destructive/10 p-4 text-destructive text-sm", children: /* @__PURE__ */ n("pre", { className: "whitespace-pre-wrap break-words", children: Gt(s) }) }),
1034
- /* @__PURE__ */ d(F, { variant: "outline", size: "sm", onClick: c, children: [
1035
- /* @__PURE__ */ n(kt, { className: "me-1.5 size-4" }),
1036
- o(i ? "copied" : "copy_error")
1037
- ] })
1038
- ] })
1039
- ] })
1040
- ] }),
1041
- t && !s && /* @__PURE__ */ n("div", { className: "overflow-x-auto rounded-md bg-muted/50 text-foreground text-xs [&_table]:w-full line-clamp-[20]", children: /* @__PURE__ */ n("div", { children: u() }) })
1042
- ] });
1043
- };
1044
- function Fr({ part: e }) {
1045
- const { t } = k(["tools_ui"]), s = gn(e);
1046
- if (!s.isPending) return null;
1047
- const r = t("approval_prompt", { tool: Dt(e) });
1048
- return /* @__PURE__ */ d(
1049
- "div",
1050
- {
1051
- role: "group",
1052
- "aria-label": r,
1053
- className: "flex flex-wrap items-center gap-2 border-t p-3",
1054
- children: [
1055
- /* @__PURE__ */ n("p", { className: "me-auto text-sm text-muted-foreground", children: r }),
1056
- /* @__PURE__ */ n(
1057
- F,
1058
- {
1059
- size: "sm",
1060
- variant: "outline",
1061
- disabled: !s.canRespond,
1062
- onClick: () => {
1063
- s.deny();
1064
- },
1065
- children: t("deny")
1066
- }
1067
- ),
1068
- /* @__PURE__ */ n(F, { size: "sm", disabled: !s.canRespond, onClick: () => {
1069
- s.approve();
1070
- }, children: t("approve") })
1071
- ]
1072
- }
1073
- );
1074
- }
1075
- function Br({ part: e }) {
1076
- const t = Te((r) => r.app.showToolDetails ?? !0), s = e.state === "approval-requested";
1077
- return !t && !s ? null : /* @__PURE__ */ d(Er, { className: "animate-in-bubble", defaultOpen: s, children: [
1078
- /* @__PURE__ */ n(qr, { type: e.type, state: e.state, toolName: Dt(e) }),
1079
- /* @__PURE__ */ d(jr, { children: [
1080
- /* @__PURE__ */ n($r, { input: e.input, state: e.state }),
1081
- (e.state === "output-available" || e.state === "output-error") && /* @__PURE__ */ n(Lr, { errorText: e.errorText, output: e.output })
1082
- ] }),
1083
- /* @__PURE__ */ n(Fr, { part: e })
1084
- ] });
1085
- }
1086
- function Ur({ part: e }) {
1087
- const t = M((c) => c.message.role), { t: s } = k(["chat", "admin"]), r = e, o = hn(e), i = r.mediaType.startsWith("image/"), a = r.filename ?? "file", l = (c) => {
1088
- if (c.preventDefault(), !o) return;
1089
- const u = document.createElement("a");
1090
- u.href = o, u.download = a, document.body.appendChild(u), u.click(), document.body.removeChild(u);
1091
- };
1092
- return /* @__PURE__ */ n("div", { className: "py-2 animate-in-bubble", children: /* @__PURE__ */ n(qe, { from: t, children: /* @__PURE__ */ n(je, { isPlain: !0, children: i ? /* @__PURE__ */ d("div", { className: "group relative max-w-[280px] rounded-xl overflow-hidden border border-border/5 transition-all duration-300 hover:border-primary/30", children: [
1093
- /* @__PURE__ */ n(
1094
- "img",
1095
- {
1096
- src: o || void 0,
1097
- alt: a,
1098
- className: "max-h-[280px] w-full rounded-xl object-cover"
1099
- }
1100
- ),
1101
- /* @__PURE__ */ d("div", { className: "absolute inset-x-0 bottom-0 p-3 bg-black/60 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity flex items-center justify-between", children: [
1102
- /* @__PURE__ */ n("span", { className: "text-xs text-white truncate max-w-[150px] font-medium", children: a }),
1103
- /* @__PURE__ */ n(
1104
- "button",
1105
- {
1106
- onClick: l,
1107
- className: "p-1.5 bg-white/20 hover:bg-white/30 rounded-full text-white transition-all active:scale-95",
1108
- title: s("download", "Download"),
1109
- children: /* @__PURE__ */ n(de, { className: "size-4" })
1110
- }
1111
- )
1112
- ] }),
1113
- /* @__PURE__ */ n("div", { className: "absolute top-2 end-2 md:hidden", children: /* @__PURE__ */ n(
1114
- "button",
1115
- {
1116
- onClick: l,
1117
- className: "p-1.5 bg-black/60 rounded-full text-white",
1118
- children: /* @__PURE__ */ n(de, { className: "size-4" })
1119
- }
1120
- ) })
1121
- ] }) : /* @__PURE__ */ n("div", { className: "flex flex-col gap-1.5", children: /* @__PURE__ */ d("div", { className: "group inline-flex items-center gap-3 rounded-xl p-3 text-sm transition-all duration-300 bg-secondary/10 border border-border/5 hover:border-primary/30 hover:bg-secondary/20", children: [
1122
- /* @__PURE__ */ n("div", { className: "p-2.5 rounded-lg bg-background/50 border border-border/10 group-hover:border-primary/20 group-hover:text-primary transition-colors", children: /* @__PURE__ */ n(Ct, { className: "size-4 shrink-0" }) }),
1123
- /* @__PURE__ */ d("div", { className: "flex flex-col min-w-0 me-4", children: [
1124
- /* @__PURE__ */ n("span", { className: "truncate max-w-[180px] font-semibold text-foreground/90 leading-none mb-1 group-hover:text-foreground transition-colors", children: a }),
1125
- r.mediaType && /* @__PURE__ */ n("span", { className: "text-xs text-muted-foreground uppercase font-bold tracking-widest opacity-60", children: r.mediaType.split("/").pop() })
1126
- ] }),
1127
- /* @__PURE__ */ n(
1128
- "button",
1129
- {
1130
- onClick: l,
1131
- className: "ms-auto p-2 hover:bg-primary hover:text-primary-foreground rounded-lg text-muted-foreground transition-all active:scale-90",
1132
- title: s("download", "Download"),
1133
- children: /* @__PURE__ */ n(de, { className: "size-4" })
1134
- }
1135
- )
1136
- ] }) }) }) }) });
1137
- }
1138
- function Hr({ part: e }) {
1139
- const t = M((u) => u.message.role), { t: s } = k(["chat"]), { focusReference: r } = bn(), [o, i] = Wt(1200), a = e.data, l = a.excerpt || a.label || s("source_unavailable"), c = a.label && a.label !== l ? a.label : s("referenced_context");
1140
- return /* @__PURE__ */ n("div", { className: p("my-1.5 flex", t === "user" && "justify-end"), children: /* @__PURE__ */ d(
1141
- "button",
1142
- {
1143
- type: "button",
1144
- className: p(
1145
- "inline-flex max-w-[min(100%,34rem)] items-start gap-2 rounded-lg border border-border/60 bg-muted/35 px-3 py-2 text-start text-xs text-foreground transition hover:border-primary/30 hover:bg-muted/55 focus-visible:ring-2 focus-visible:ring-primary/30",
1146
- o && "ring-2 ring-primary/35"
1147
- ),
1148
- onClick: () => {
1149
- r(a) || i();
1150
- },
1151
- title: c,
1152
- children: [
1153
- /* @__PURE__ */ n(Re, { className: "mt-0.5 size-3.5 shrink-0 opacity-70" }),
1154
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n("span", { className: "line-clamp-2 opacity-85", dir: "auto", children: l }) })
1155
- ]
1156
- }
1157
- ) });
1158
- }
1159
- function Ue(e) {
1160
- const { input: t } = e, s = typeof t?.question == "string" ? t.question.trim() : "", r = (Array.isArray(t?.choices) ? t.choices : []).filter((o) => typeof o == "string").map((o) => o.trim()).filter(Boolean).map((o) => ({ label: o }));
1161
- return !s || r.length === 0 && e.state !== "input-streaming" ? null : { question: s, choices: r, allowCustom: t?.allow_custom !== !1 };
1162
- }
1163
- function Vr(e) {
1164
- return e.type === "tool-ask_user";
1165
- }
1166
- function Kt(e, { streaming: t = !1 } = {}) {
1167
- return e?.parts.find(
1168
- (s) => Vr(s) && (s.state === "input-available" || t && s.state === "input-streaming")
1169
- );
1170
- }
1171
- const Jt = (e) => e.replace(/\s+/g, " ").trim().toLowerCase().replace(/[?!.:؟،]+$/, ""), ut = /* @__PURE__ */ new WeakMap();
1172
- function Qr(e) {
1173
- const t = ut.get(e);
1174
- if (t !== void 0) return t;
1175
- const s = e.parts.flatMap((o) => o.type === "text" ? [o.text] : []).join(" "), r = Jt(s);
1176
- return ut.set(e, r), r;
1177
- }
1178
- function Yt(e, t) {
1179
- const s = Jt(t.question);
1180
- return s ? e ? Qr(e).includes(s) : !1 : !0;
1181
- }
1182
- function Wr(e) {
1183
- const { readonly: t, lastMessage: s, isFinished: r, status: o } = e;
1184
- return !t && !!s && !!r && o === "ready";
1185
- }
1186
- function Xt({
1187
- choices: e,
1188
- selected: t,
1189
- disabled: s,
1190
- dir: r,
1191
- onSelect: o,
1192
- className: i
1193
- }) {
1194
- return /* @__PURE__ */ n("div", { className: p("flex flex-col gap-1", i), children: e.map((a) => /* @__PURE__ */ n(
1195
- "button",
1196
- {
1197
- type: "button",
1198
- disabled: s,
1199
- dir: L(a.label, r),
1200
- onClick: () => o(a.label),
1201
- className: p(
1202
- "w-full rounded-full px-3 py-2.5 text-start text-sm leading-snug",
1203
- "transition-colors duration-150 outline-none",
1204
- // Inset, so a focus ring can never overflow a scrolling container
1205
- // (which would hand it a scrollbar).
1206
- "focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/40",
1207
- t === a.label ? "bg-primary/12 text-primary" : p(
1208
- "text-foreground/85 hover:bg-foreground/[0.06] hover:text-foreground",
1209
- "disabled:cursor-not-allowed disabled:opacity-55 disabled:hover:bg-transparent"
1210
- )
1211
- ),
1212
- children: a.label
1213
- },
1214
- a.label
1215
- )) });
1216
- }
1217
- function Gr({
1218
- part: e,
1219
- message: t,
1220
- disabled: s,
1221
- dismissed: r,
1222
- onReopen: o,
1223
- onAnswer: i
1224
- }) {
1225
- const { t: a } = k(["chat"]), { dir: l } = $(), { textComponents: c, remarkPlugins: u, rehypePlugins: m, linkProtocols: h } = B(), b = E(() => Ue(e), [e]), [g, f] = C(""), [w, x] = C(null), [y, v] = C(!1);
1226
- if (!b) return null;
1227
- const I = !s && !!i, N = !I || y || w !== null, z = !Yt(t, b), S = L(b.question, l);
1228
- if (!z && !I && !r) return null;
1229
- const O = async (j) => {
1230
- const W = j.trim();
1231
- if (!(!W || N)) {
1232
- v(!0), x(W);
1233
- try {
1234
- await i?.(W);
1235
- } catch {
1236
- x(null), v(!1);
1237
- return;
1238
- }
1239
- v(!1);
1240
- }
1241
- }, D = (j) => {
1242
- j.preventDefault(), O(g);
1243
- };
1244
- return /* @__PURE__ */ d("div", { className: "group py-2 first:pt-4 animate-in-bubble", children: [
1245
- z && /* @__PURE__ */ n(qe, { from: t.role, children: /* @__PURE__ */ n(je, { dir: S, children: /* @__PURE__ */ n(
1246
- ge,
1247
- {
1248
- components: c,
1249
- remarkPlugins: u,
1250
- rehypePlugins: m,
1251
- linkProtocols: h,
1252
- children: b.question
1253
- }
1254
- ) }) }),
1255
- r && /* @__PURE__ */ n(
1256
- "div",
1257
- {
1258
- className: p("flex w-full justify-start", z && "mt-2.5"),
1259
- dir: S,
1260
- children: /* @__PURE__ */ d(
1261
- "button",
1262
- {
1263
- type: "button",
1264
- onClick: o,
1265
- disabled: !o,
1266
- className: "inline-flex max-w-full items-center gap-2 rounded-full border border-border/60 px-3 py-1.5 text-start text-xs text-muted-foreground outline-none transition-colors hover:border-border hover:bg-foreground/[0.04] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default disabled:hover:border-border/60 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
1267
- children: [
1268
- /* @__PURE__ */ n(jn, { className: "size-3.5 shrink-0" }),
1269
- /* @__PURE__ */ n("span", { className: "truncate", children: a("choice_dismissed") })
1270
- ]
1271
- }
1272
- )
1273
- }
1274
- ),
1275
- I && !r && /* @__PURE__ */ d("div", { className: p("max-w-xl", z && "mt-2.5"), dir: S, children: [
1276
- /* @__PURE__ */ n(
1277
- Xt,
1278
- {
1279
- choices: b.choices,
1280
- selected: w,
1281
- disabled: N,
1282
- dir: S,
1283
- onSelect: (j) => {
1284
- O(j);
1285
- }
1286
- }
1287
- ),
1288
- b.allowCustom && /* @__PURE__ */ d("form", { onSubmit: D, className: "mt-1.5 flex items-center gap-1.5", children: [
1289
- /* @__PURE__ */ n(
1290
- "input",
1291
- {
1292
- value: g,
1293
- disabled: N,
1294
- dir: L(g || a("choice_other_placeholder"), S),
1295
- onChange: (j) => f(j.target.value),
1296
- placeholder: a("choice_other_placeholder"),
1297
- className: "h-11 min-w-0 flex-1 rounded-full bg-transparent px-3 text-start text-sm outline-none transition-colors placeholder:text-muted-foreground/60 hover:bg-foreground/[0.04] focus-visible:bg-foreground/[0.06] disabled:cursor-not-allowed disabled:opacity-55"
1298
- }
1299
- ),
1300
- /* @__PURE__ */ n(
1301
- "button",
1302
- {
1303
- type: "submit",
1304
- disabled: N || !g.trim(),
1305
- className: "flex size-11 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-35",
1306
- "aria-label": a("choice_send_answer"),
1307
- title: a("choice_send_answer"),
1308
- children: /* @__PURE__ */ n(_t, { className: "size-4" })
1309
- }
1310
- )
1311
- ] })
1312
- ] })
1313
- ] });
1314
- }
1315
- const Zt = "dismissed-choice-questions";
1316
- function Kr(e) {
1317
- const t = ds(e, Zt);
1318
- if (!t) return [];
1319
- try {
1320
- const s = JSON.parse(t);
1321
- return Array.isArray(s) ? s.filter((r) => typeof r == "string") : [];
1322
- } catch {
1323
- return [];
1324
- }
1325
- }
1326
- const Jr = {
1327
- question: null,
1328
- messageId: null,
1329
- disabled: !0,
1330
- dismissed: !1,
1331
- setDismissed: () => {
1332
- },
1333
- answer: () => {
1334
- },
1335
- dockHeight: 0,
1336
- reportDockHeight: () => {
1337
- }
1338
- }, en = te(null);
1339
- function Ga({
1340
- message: e,
1341
- disabled: t = !1,
1342
- readonly: s = !1,
1343
- cacheNamespace: r = "gentiq",
1344
- onAnswer: o,
1345
- children: i
1346
- }) {
1347
- const [a, l] = C(0), c = s || e?.role !== "assistant" ? void 0 : Kt(e, { streaming: t }), u = E(() => c ? Ue(c) : null, [c]), m = c?.toolCallId, h = ee((I) => {
1348
- l((N) => Math.abs(N - I) < 1 ? N : I);
1349
- }, []), b = u ? e?.id ?? null : null, g = u && e ? ls(e) : null, [f, w] = C(() => Kr(r)), x = g !== null && f.includes(g), y = ee(
1350
- (I) => {
1351
- g && w((N) => {
1352
- const z = N.filter((S) => S !== g);
1353
- return I ? [...z, g].slice(-50) : z.length === N.length ? N : z;
1354
- });
1355
- },
1356
- [g]
1357
- );
1358
- T(() => {
1359
- cs(r, Zt, JSON.stringify(f));
1360
- }, [r, f]);
1361
- const v = E(
1362
- () => ({
1363
- question: u,
1364
- messageId: b,
1365
- disabled: t || !o,
1366
- dismissed: x,
1367
- setDismissed: y,
1368
- answer: (I) => {
1369
- m && o?.({ toolCallId: m, output: { answer: I } });
1370
- },
1371
- dockHeight: u ? a : 0,
1372
- reportDockHeight: h
1373
- }),
1374
- [
1375
- u,
1376
- b,
1377
- t,
1378
- x,
1379
- y,
1380
- o,
1381
- m,
1382
- a,
1383
- h
1384
- ]
1385
- );
1386
- return /* @__PURE__ */ n(en.Provider, { value: v, children: i });
1387
- }
1388
- function he() {
1389
- return le(en) ?? Jr;
1390
- }
1391
- function He(e) {
1392
- const t = M((f) => f.message), s = M((f) => f.isLast), r = M((f) => f.isStreaming), o = Y((f) => f.status), { readonly: i, actions: a } = xt(), l = ee(
1393
- (f) => {
1394
- e && a?.addToolOutput({ toolCallId: e, output: { answer: f } });
1395
- },
1396
- [a, e]
1397
- ), c = ee((f) => {
1398
- a?.send({ text: f });
1399
- }, [a]), { messageId: u, dismissed: m, setDismissed: h } = he(), b = u === t.id, g = s && !r && t.role === "assistant";
1400
- return {
1401
- message: t,
1402
- isLast: s,
1403
- isFinished: g,
1404
- status: o,
1405
- readonly: i,
1406
- docked: b && !m,
1407
- dismissedHere: b && m,
1408
- reopen: () => h(!1),
1409
- answerable: Wr({ readonly: i, lastMessage: s, isFinished: g, status: o }),
1410
- answer: l,
1411
- sendText: c
1412
- };
1413
- }
1414
- function Yr({
1415
- part: e,
1416
- question: t,
1417
- index: s
1418
- }) {
1419
- const { t: r } = k("chat"), { ChoiceQuestionPart: o } = B(), { message: i, answerable: a, dismissedHere: l, reopen: c, answer: u } = He(
1420
- e.toolCallId
1421
- );
1422
- if (a && e.state === "input-available")
1423
- return /* @__PURE__ */ n(
1424
- o,
1425
- {
1426
- part: e,
1427
- message: i,
1428
- disabled: !1,
1429
- dismissed: l,
1430
- onReopen: l ? c : void 0,
1431
- onAnswer: u
1432
- }
1433
- );
1434
- const m = e.state === "output-available" ? e.output?.answer : void 0;
1435
- return /* @__PURE__ */ d(R, { children: [
1436
- !Yt(i, t) && /* @__PURE__ */ n(
1437
- ze,
1438
- {
1439
- text: t.question,
1440
- role: i.role,
1441
- streaming: !1,
1442
- reference: {
1443
- kind: "text",
1444
- messageId: i.id,
1445
- partIndex: s,
1446
- sourceId: `${i.id}-${s}-choice-question`,
1447
- role: i.role,
1448
- label: r("reference_assistant_response"),
1449
- excerpt: t.question
1450
- }
1451
- }
1452
- ),
1453
- m && /* @__PURE__ */ n(
1454
- ze,
1455
- {
1456
- text: m,
1457
- role: "user",
1458
- streaming: !1,
1459
- reference: {
1460
- kind: "text",
1461
- messageId: i.id,
1462
- partIndex: s,
1463
- sourceId: `${i.id}-${s}-choice-answer`,
1464
- role: "user",
1465
- label: r("reference_user_message"),
1466
- excerpt: m
1467
- }
1468
- }
1469
- )
1470
- ] });
1471
- }
1472
- function Xr({ part: e, index: t }) {
1473
- const { docked: s } = He(e.toolCallId);
1474
- if (s && (e.state === "input-available" || e.state === "input-streaming")) return null;
1475
- const r = Ue(e);
1476
- return r ? /* @__PURE__ */ n(Yr, { part: e, question: r, index: t }) : null;
1477
- }
1478
- function ue(e) {
1479
- if (Array.isArray(e)) return ue(e[0]);
1480
- if (typeof e == "string")
1481
- try {
1482
- return ue(JSON.parse(e));
1483
- } catch {
1484
- return null;
1485
- }
1486
- if (!e || typeof e != "object") return null;
1487
- const t = e;
1488
- if (!t.suggestions && t.data) return ue(t.data);
1489
- if (!Array.isArray(t.suggestions)) return null;
1490
- const s = /* @__PURE__ */ new Set(), r = t.suggestions.filter((o) => typeof o == "string").map((o) => o.trim()).filter((o) => {
1491
- const i = o.toLocaleLowerCase();
1492
- return !o || s.has(i) ? !1 : (s.add(i), !0);
1493
- }).slice(0, 3);
1494
- return r.length > 0 ? { suggestions: r } : null;
1495
- }
1496
- function Zr({ part: e }) {
1497
- const { FollowUpSuggestions: t } = B(), s = M(
1498
- (m) => m.message.parts.find((h) => h.type === "tool-suggest_follow_ups") === e
1499
- ), { message: r, isLast: o, isFinished: i, status: a, readonly: l, sendText: c } = He();
1500
- if (!s || r.role !== "assistant" || !o || !i || a !== "ready" || l || Kt(r) !== void 0)
1501
- return null;
1502
- const u = ue(e.input);
1503
- return u ? /* @__PURE__ */ n(t, { suggestions: u.suggestions, onSelect: c }) : null;
1504
- }
1505
- const eo = {
1506
- text: gr,
1507
- reasoning: yr,
1508
- file: Ur,
1509
- tool: Br,
1510
- "source-url": null,
1511
- "source-document": null,
1512
- "data-reference": Hr,
1513
- "tool-ask_user": Xr,
1514
- "tool-suggest_follow_ups": Zr
1515
- }, to = () => /* @__PURE__ */ n(R, { children: [0, 1, 2].map((e) => /* @__PURE__ */ n(
1516
- "span",
1517
- {
1518
- className: "gentiq-loader-dot size-2 rounded-full bg-primary/70",
1519
- style: {
1520
- animation: "gentiq-typing-bounce 1.2s ease-in-out infinite",
1521
- animationDelay: `${e * 0.18}s`
1522
- }
1523
- },
1524
- e
1525
- )) }), ye = ({ className: e, variant: t, ...s }) => {
1526
- const o = B().Loader;
1527
- return o ? /* @__PURE__ */ n(o, { className: e, variant: t, ...s }) : /* @__PURE__ */ n(
1528
- "div",
1529
- {
1530
- "data-gentiq-loader": "dots",
1531
- className: p("flex items-center gap-1.5 px-1 py-3", e),
1532
- ...s,
1533
- children: /* @__PURE__ */ n(to, {})
1534
- }
1535
- );
1536
- };
1537
- class pe extends Sn {
1538
- state = { error: null };
1539
- static getDerivedStateFromError(t) {
1540
- return { error: t };
1541
- }
1542
- componentDidCatch(t, s) {
1543
- console.error("Gentiq: render error contained by ErrorBoundary", t, s), this.props.onError?.(t, s);
1544
- }
1545
- componentDidUpdate(t) {
1546
- if (!this.state.error) return;
1547
- const s = t.resetKeys, r = this.props.resetKeys;
1548
- if (!r) return;
1549
- (!s || s.length !== r.length || r.some((i, a) => !Object.is(i, s[a]))) && this.reset();
1550
- }
1551
- reset = () => {
1552
- this.setState({ error: null });
1553
- };
1554
- render() {
1555
- const { error: t } = this.state;
1556
- if (!t) return this.props.children;
1557
- const { fallback: s } = this.props;
1558
- return s !== void 0 ? typeof s == "function" ? s(t, this.reset) : s : /* @__PURE__ */ n("div", { className: "my-2 rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-xs text-destructive/80", children: t.message || /* @__PURE__ */ n(no, {}) });
1559
- }
1560
- }
1561
- function no() {
1562
- const { t: e } = k("chat");
1563
- return e("render_error");
1564
- }
1565
- const so = ({ className: e, ...t }) => /* @__PURE__ */ n(Le, { className: p("not-prose mb-4 text-primary text-xs", e), ...t }), ro = ({ className: e, count: t, children: s, ...r }) => {
1566
- const { t: o } = k(["chat"]);
1567
- return /* @__PURE__ */ n(Fe, { className: p("flex items-center gap-2", e), ...r, children: s ?? /* @__PURE__ */ d(R, { children: [
1568
- /* @__PURE__ */ n("p", { className: "font-medium", children: o("used_sources", { count: t }) }),
1569
- /* @__PURE__ */ n(ne, { className: "h-4 w-4" })
1570
- ] }) });
1571
- }, oo = ({ className: e, ...t }) => /* @__PURE__ */ n(
1572
- Be,
1573
- {
1574
- className: p(
1575
- "mt-3 flex w-fit flex-col gap-2",
1576
- "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
1577
- e
1578
- ),
1579
- ...t
1580
- }
1581
- ), ao = ({ href: e, title: t, children: s, ...r }) => /* @__PURE__ */ n("a", { className: "flex items-center gap-2", href: e, rel: "noreferrer", target: "_blank", ...r, children: s ?? /* @__PURE__ */ d(R, { children: [
1582
- /* @__PURE__ */ n($n, { className: "h-4 w-4" }),
1583
- /* @__PURE__ */ n("span", { className: "block font-medium", children: t })
1584
- ] }) });
1585
- function io() {
1586
- const { t: e } = k(["chat"]);
1587
- return /* @__PURE__ */ n(
1588
- Ne.ScrollToBottom,
1589
- {
1590
- "aria-label": e("scroll_to_bottom"),
1591
- className: "absolute inset-x-0 bottom-32 z-10 mx-auto w-fit rounded-full border bg-background px-4 py-2 text-foreground/80 shadow-lg hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
1592
- children: /* @__PURE__ */ n(Ln, { className: "size-3.5" })
1593
- }
1594
- );
1595
- }
1596
- const lo = (e) => us.includes(e.type) ? !1 : e.type === "text" || e.type === "reasoning" ? e.text.trim().length > 0 : e.type === "file" ? !0 : Tt(e), co = ({
1597
- latestProgress: e,
1598
- parts: t,
1599
- isFinished: s
1600
- }) => {
1601
- const { status: r, message: o } = e.data;
1602
- if (!o) return null;
1603
- const i = t.lastIndexOf(e), a = t.slice(i + 1), l = a.some(
1604
- (g) => g.type === "text" && g.text.trim().length > 0 || g.type === "tool-ask_user"
1605
- ), c = a.some(Tt), u = r === "running";
1606
- if (!(u ? !l && !s : !l && !c)) return null;
1607
- const h = r === "error", b = L(o);
1608
- return /* @__PURE__ */ n(
1609
- "div",
1610
- {
1611
- className: p(
1612
- "flex w-full py-3 mx-auto max-w-4xl px-4 md:px-0 animate-in-bubble",
1613
- b === "rtl" ? "justify-end" : "justify-start"
1614
- ),
1615
- children: /* @__PURE__ */ d(
1616
- "div",
1617
- {
1618
- className: p(
1619
- "flex items-center gap-3 text-sm text-muted-foreground",
1620
- b === "rtl" && "flex-row-reverse"
1621
- ),
1622
- dir: b,
1623
- children: [
1624
- u ? /* @__PURE__ */ n("div", { className: "size-4 animate-spin rounded-full border-2 border-primary border-e-transparent shrink-0" }) : h ? /* @__PURE__ */ n(V, { className: "size-4 text-destructive shrink-0" }) : /* @__PURE__ */ n(ce, { className: "size-4 text-success shrink-0" }),
1625
- /* @__PURE__ */ n("span", { className: p("font-medium", u && "animate-pulse"), children: o })
1626
- ]
1627
- }
1628
- )
1629
- }
1630
- );
1631
- }, uo = Me(
1632
- () => import("./MessageEditor-PAl3Jjcu.js").then((e) => ({ default: e.MessageEditor }))
1633
- ), mo = { UserMessage: po, AssistantMessage: go };
1634
- function po() {
1635
- const e = M((o) => o.message.id), t = M((o) => o.isEditing), { MessageActions: s } = B(), r = se((o) => o.threadActions);
1636
- return /* @__PURE__ */ d(
1637
- X.Root,
1638
- {
1639
- "data-gentiq-message-id": e,
1640
- "data-gentiq-message-role": "user",
1641
- className: "group/message",
1642
- children: [
1643
- t ? /* @__PURE__ */ d(Ce, { fallback: /* @__PURE__ */ n(X.Parts, {}), children: [
1644
- /* @__PURE__ */ n(X.Parts, { components: fo }),
1645
- /* @__PURE__ */ n(uo, {})
1646
- ] }) : /* @__PURE__ */ n(X.Parts, {}),
1647
- /* @__PURE__ */ n(s, { retry: !1, feedback: !1, edit: r.edit })
1648
- ]
1649
- }
1650
- );
1651
- }
1652
- const fo = { text: null };
1653
- function go() {
1654
- const e = M((a) => a.message.id), t = M((a) => a.message.parts), { MessageActions: s } = B(), r = se((a) => a.threadActions), { sourceUrls: o, hasText: i } = E(
1655
- () => ({
1656
- sourceUrls: t.flatMap((a) => a.type === "source-url" ? [a.url] : []),
1657
- hasText: ms({ parts: t }).length > 0
1658
- }),
1659
- [t]
1660
- );
1661
- return /* @__PURE__ */ d(
1662
- X.Root,
1663
- {
1664
- "data-gentiq-message-id": e,
1665
- "data-gentiq-message-role": "assistant",
1666
- className: "group/message",
1667
- children: [
1668
- o.length > 0 && /* @__PURE__ */ d(so, { children: [
1669
- /* @__PURE__ */ n(ro, { count: o.length }),
1670
- o.map((a, l) => /* @__PURE__ */ n(oo, { children: /* @__PURE__ */ n(ao, { href: a, title: a }) }, `${e}-source-${l}`))
1671
- ] }),
1672
- /* @__PURE__ */ n(X.Parts, {}),
1673
- i && /* @__PURE__ */ n(
1674
- s,
1675
- {
1676
- retry: r.retry,
1677
- feedback: r.feedback,
1678
- edit: !1
1679
- }
1680
- )
1681
- ]
1682
- }
1683
- );
1684
- }
1685
- function ho({ className: e }) {
1686
- const { t } = k(["chat", "errors"]), { ChatError: s } = B(), { actions: r } = xt(), o = Y((v) => v.messages), i = Y((v) => v.status), a = Y((v) => v.isLoadingHistory), l = Y((v) => v.error), c = E(
1687
- () => l === void 0 ? null : vn(l, t),
1688
- [l, t]
1689
- ), { dockHeight: u } = he(), m = `calc(var(--gentiq-composer-inset, calc(6.5rem + ${u}px)) + 1.5rem)`, h = a, b = Y((v) => v.earlier.status), g = r?.loadEarlier, f = o[o.length - 1], w = f?.role === "assistant" && (i === "ready" || f.parts.some((v) => v.type === "data-chat-finished")), x = !h && (i === "submitted" || i === "streaming" && !(f?.role === "assistant" && f.parts.some(lo)));
1690
- let y;
1691
- if (f?.role === "assistant")
1692
- for (const v of f.parts)
1693
- v.type === "data-progress-update" && (y = v);
1694
- return /* @__PURE__ */ d("div", { className: p("relative min-h-0 flex-1 overflow-hidden", e), children: [
1695
- /* @__PURE__ */ d(
1696
- Ne.Viewport,
1697
- {
1698
- scrollClassName: "custom-scrollbar",
1699
- className: "stick-to-bottom max-w-4xl mx-auto w-full p-4 pb-6 md:px-0",
1700
- style: { paddingBottom: m },
1701
- "aria-busy": h,
1702
- dir: "ltr",
1703
- children: [
1704
- /* @__PURE__ */ n(pe, { children: /* @__PURE__ */ n(Ne.Messages, { components: mo }) }),
1705
- y && /* @__PURE__ */ n(
1706
- co,
1707
- {
1708
- latestProgress: y,
1709
- parts: f.parts,
1710
- isFinished: w
1711
- }
1712
- ),
1713
- x && /* @__PURE__ */ n("div", { className: "animate-in-bubble", children: /* @__PURE__ */ n(ye, {}) }),
1714
- i === "error" && c && /* @__PURE__ */ n("div", { className: "mx-auto max-w-4xl w-full px-4 my-3 animate-in-bubble", children: /* @__PURE__ */ n(s, { error: c, code: It(c) ? c.code : void 0 }) })
1715
- ]
1716
- }
1717
- ),
1718
- b !== "idle" && /* @__PURE__ */ n("div", { className: "absolute inset-x-0 top-2 flex justify-center pointer-events-none", children: b === "loading" ? /* @__PURE__ */ n("div", { role: "status", "aria-label": t("loading_earlier"), children: /* @__PURE__ */ n(ye, {}) }) : /* @__PURE__ */ n(
1719
- "button",
1720
- {
1721
- type: "button",
1722
- onClick: () => {
1723
- g?.();
1724
- },
1725
- className: "pointer-events-auto rounded-full border border-border bg-background px-3 py-1.5 text-sm text-muted-foreground shadow-sm hover:text-foreground",
1726
- children: t("load_earlier_failed")
1727
- }
1728
- ) }),
1729
- h && /* @__PURE__ */ n(
1730
- "div",
1731
- {
1732
- className: "absolute inset-0 flex items-center justify-center pointer-events-none",
1733
- role: "status",
1734
- "aria-label": t("loading_chat"),
1735
- children: /* @__PURE__ */ n(ye, { className: "animate-in fade-in duration-300" })
1736
- }
1737
- ),
1738
- !h && /* @__PURE__ */ n(io, {})
1739
- ] });
1740
- }
1741
- function bo({ delayDuration: e = 400, ...t }) {
1742
- return /* @__PURE__ */ n(Z.Provider, { "data-slot": "tooltip-provider", delayDuration: e, ...t });
1743
- }
1744
- function Ve({ ...e }) {
1745
- return /* @__PURE__ */ n(bo, { children: /* @__PURE__ */ n(Z.Root, { "data-slot": "tooltip", ...e }) });
1746
- }
1747
- function Qe({ ...e }) {
1748
- return /* @__PURE__ */ n(Z.Trigger, { "data-slot": "tooltip-trigger", ...e });
1749
- }
1750
- function We({
1751
- className: e,
1752
- sideOffset: t = 0,
1753
- children: s,
1754
- ...r
1755
- }) {
1756
- const o = Q();
1757
- return /* @__PURE__ */ n(Z.Portal, { container: o, children: /* @__PURE__ */ d(
1758
- Z.Content,
1759
- {
1760
- "data-slot": "tooltip-content",
1761
- sideOffset: t,
1762
- className: p(
1763
- "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-sm text-balance",
1764
- e
1765
- ),
1766
- ...r,
1767
- children: [
1768
- s,
1769
- /* @__PURE__ */ n(Z.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
1770
- ]
1771
- }
1772
- ) });
1773
- }
1774
- const vo = 2e3, xo = "size-7 rounded-lg p-1 text-muted-foreground hover:bg-accent/70 hover:text-foreground disabled:opacity-40";
1775
- function yo({ retry: e, feedback: t, edit: s }) {
1776
- const { t: r } = k(["chat", "errors"]), o = M((m) => m.message.role === "user"), i = (m) => K.error(yt(m, r)), [a, l] = C(!1), c = P(void 0), u = () => {
1777
- l(!0), clearTimeout(c.current), c.current = setTimeout(() => l(!1), vo);
1778
- };
1779
- return /* @__PURE__ */ d(
1780
- J.Root,
1781
- {
1782
- "aria-label": r("message_actions"),
1783
- className: `mt-1 flex items-center gap-0.5 group-data-[editing]/message:hidden ${o ? "justify-end" : "ms-0.5"}`,
1784
- children: [
1785
- e && /* @__PURE__ */ n(oe, { label: r("retry"), children: /* @__PURE__ */ n(J.Reload, { "aria-label": r("retry"), children: /* @__PURE__ */ n(Fn, { className: "size-4" }) }) }),
1786
- t && /* @__PURE__ */ d(R, { children: [
1787
- /* @__PURE__ */ n(oe, { label: r("like"), children: /* @__PURE__ */ n(
1788
- J.FeedbackPositive,
1789
- {
1790
- "aria-label": r("like"),
1791
- onError: i,
1792
- className: "data-[active]:text-primary",
1793
- children: /* @__PURE__ */ n(Bn, { className: "size-4" })
1794
- }
1795
- ) }),
1796
- /* @__PURE__ */ n(oe, { label: r("dislike"), children: /* @__PURE__ */ n(
1797
- J.FeedbackNegative,
1798
- {
1799
- "aria-label": r("dislike"),
1800
- onError: i,
1801
- className: "data-[active]:text-destructive",
1802
- children: /* @__PURE__ */ n(Un, { className: "size-4" })
1803
- }
1804
- ) })
1805
- ] }),
1806
- s && /* @__PURE__ */ n(oe, { label: r("edit_message"), children: /* @__PURE__ */ n(J.Edit, { "aria-label": r("edit_message"), children: /* @__PURE__ */ n(Hn, { className: "size-4" }) }) }),
1807
- /* @__PURE__ */ n(oe, { label: r("copy"), children: /* @__PURE__ */ d(
1808
- J.Copy,
1809
- {
1810
- "aria-label": r("copy"),
1811
- onCopied: u,
1812
- onError: () => K.error(r("copy_failed")),
1813
- className: "group/copy",
1814
- children: [
1815
- /* @__PURE__ */ n(kt, { className: "size-4 group-data-[copied]/copy:hidden" }),
1816
- /* @__PURE__ */ n(ce, { className: "hidden size-4 group-data-[copied]/copy:block" })
1817
- ]
1818
- }
1819
- ) }),
1820
- /* @__PURE__ */ n("span", { role: "status", className: "sr-only", children: a ? r("copied") : null })
1821
- ]
1822
- }
1823
- );
1824
- }
1825
- function oe({ label: e, children: t }) {
1826
- return /* @__PURE__ */ d(Ve, { children: [
1827
- /* @__PURE__ */ n(Qe, { asChild: !0, children: /* @__PURE__ */ n(F, { variant: "ghost", size: "sm", className: xo, asChild: !0, children: t }) }),
1828
- /* @__PURE__ */ n(We, { children: e })
1829
- ] });
1830
- }
1831
- const wo = ({ className: e, ...t }) => /* @__PURE__ */ n("div", { className: "bg-transparent w-full", children: /* @__PURE__ */ n(
1832
- G.Root,
1833
- {
1834
- className: p(
1835
- "w-full flex items-end gap-2 overflow-hidden",
1836
- "rounded-lg bg-surface",
1837
- "px-3 py-2",
1838
- "transition-[border-color,box-shadow] duration-200 ease-out",
1839
- "border-[1.5px] border-border/60 shadow-sm shadow-foreground/[0.03]",
1840
- "hover:border-border",
1841
- "has-focus-visible:border-foreground/25 has-focus-visible:shadow-md has-focus-visible:shadow-foreground/[0.04]",
1842
- e
1843
- ),
1844
- ...t
1845
- }
1846
- ) }), No = In(
1847
- function({ className: t, placeholder: s, ...r }, o) {
1848
- const { dir: i } = $(), a = Pe().draft, l = L(a, i), c = `${a || s || ""} `;
1849
- return /* @__PURE__ */ d("div", { className: "grid min-w-0 flex-1", children: [
1850
- /* @__PURE__ */ n(
1851
- "div",
1852
- {
1853
- "aria-hidden": !0,
1854
- dir: l,
1855
- className: p(
1856
- "invisible col-start-1 row-start-1 max-h-[6lh] overflow-hidden",
1857
- "whitespace-pre-wrap break-words px-2 py-2.5 text-base"
1858
- ),
1859
- children: c
1860
- }
1861
- ),
1862
- /* @__PURE__ */ n(
1863
- G.Input,
1864
- {
1865
- ref: o,
1866
- dir: l,
1867
- rows: 1,
1868
- placeholder: s,
1869
- className: p(
1870
- "col-start-1 row-start-1 w-full min-w-0 disabled:cursor-not-allowed disabled:opacity-50",
1871
- "resize-none rounded-none border-none shadow-none outline-none ring-0",
1872
- "px-2 py-2.5",
1873
- "field-sizing-content max-h-[6lh] bg-transparent dark:bg-transparent",
1874
- "focus-visible:ring-0 min-h-[40px] md:min-h-[44px]",
1875
- "text-base placeholder:text-muted-foreground/60",
1876
- "transition-all duration-200",
1877
- t
1878
- ),
1879
- ...r
1880
- }
1881
- )
1882
- ] });
1883
- }
1884
- ), ko = ({ className: e, ...t }) => /* @__PURE__ */ n("div", { className: p("flex shrink-0 items-center gap-1.5 pb-1", e), ...t }), Co = ({ className: e, ...t }) => /* @__PURE__ */ n("div", { className: p("flex items-center gap-0.5", e), ...t }), tn = ({
1885
- variant: e = "ghost",
1886
- className: t,
1887
- size: s,
1888
- ...r
1889
- }) => {
1890
- const o = s ?? zn.count(r.children) > 1 ? "default" : "icon";
1891
- return /* @__PURE__ */ n(
1892
- F,
1893
- {
1894
- className: p(
1895
- "shrink-0 gap-1.5 rounded-xl",
1896
- "text-muted-foreground hover:text-foreground",
1897
- "hover:bg-accent/60 transition-all duration-200",
1898
- "active:scale-95",
1899
- o === "default" && "px-3",
1900
- t
1901
- ),
1902
- size: o,
1903
- type: "button",
1904
- variant: e,
1905
- ...r
1906
- }
1907
- );
1908
- }, mt = ({
1909
- className: e,
1910
- variant: t = "default",
1911
- size: s = "icon",
1912
- status: r,
1913
- children: o,
1914
- ...i
1915
- }) => {
1916
- const { t: a } = k("chat");
1917
- let l = /* @__PURE__ */ n(_t, { className: "size-4" }), c = a("send_message");
1918
- return r === "submitted" || r === "streaming" ? (l = /* @__PURE__ */ n(Vn, { className: "size-3.5 fill-current" }), c = a("stop_generation")) : r === "error" && (l = /* @__PURE__ */ n(V, { className: "size-4" }), c = a("send_failed")), /* @__PURE__ */ n(
1919
- F,
1920
- {
1921
- "aria-label": c,
1922
- className: p(
1923
- "shrink-0 rounded-lg size-9",
1924
- "bg-primary text-primary-foreground hover:bg-primary/90",
1925
- "transition-colors duration-200",
1926
- "disabled:opacity-40",
1927
- r === "submitted" && "bg-muted text-foreground hover:bg-muted",
1928
- e
1929
- ),
1930
- size: s,
1931
- type: r === "streaming" || r === "submitted" ? "button" : "submit",
1932
- variant: t,
1933
- ...i,
1934
- children: o ?? l
1935
- }
1936
- );
1937
- }, we = 768;
1938
- function _o() {
1939
- const [e, t] = ke.useState(void 0);
1940
- return ke.useEffect(() => {
1941
- const s = window.matchMedia(`(max-width: ${we - 1}px)`), r = () => {
1942
- t(window.innerWidth < we);
1943
- };
1944
- return s.addEventListener("change", r), t(window.innerWidth < we), () => {
1945
- s.removeEventListener("change", r);
1946
- };
1947
- }, []), !!e;
1948
- }
1949
- function So({ entry: e, onRemove: t, onRetry: s }) {
1950
- const { t: r } = k(["chat", "errors"]), { file: o, status: i, progress: a, error: l, retryable: c } = e, u = zo(o.type.startsWith("image/") ? o : null), m = i === "failed";
1951
- return /* @__PURE__ */ d(
1952
- "div",
1953
- {
1954
- className: `flex max-w-full items-center gap-2 rounded-xl border bg-muted/60 py-1.5 ps-2.5 pe-1.5 text-sm ${m ? "border-destructive/50" : "border-border/60"}`,
1955
- "data-status": i,
1956
- children: [
1957
- u ? /* @__PURE__ */ n(
1958
- "img",
1959
- {
1960
- src: u,
1961
- alt: o.name,
1962
- className: "size-7 shrink-0 rounded-lg object-cover ring-1 ring-border/50"
1963
- }
1964
- ) : /* @__PURE__ */ n(Ct, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": !0 }),
1965
- /* @__PURE__ */ d("span", { className: "flex min-w-0 flex-col", children: [
1966
- /* @__PURE__ */ n("span", { className: "max-w-[120px] truncate text-xs font-medium text-foreground/80", dir: "auto", children: o.name }),
1967
- i === "uploading" && /* @__PURE__ */ n(
1968
- "span",
1969
- {
1970
- role: "progressbar",
1971
- "aria-label": r("uploading_file", { name: o.name }),
1972
- "aria-valuemin": 0,
1973
- "aria-valuemax": 100,
1974
- "aria-valuenow": a === null ? void 0 : Math.round(a * 100),
1975
- className: "mt-1 block h-1 w-20 overflow-hidden rounded-full bg-foreground/10",
1976
- children: /* @__PURE__ */ n(
1977
- "span",
1978
- {
1979
- className: `block h-full rounded-full bg-primary transition-[width] motion-reduce:transition-none ${a === null ? "w-1/3 animate-pulse motion-reduce:animate-none" : ""}`,
1980
- style: a === null ? void 0 : { width: `${Math.round(a * 100)}%` }
1981
- }
1982
- )
1983
- }
1984
- ),
1985
- m && /* @__PURE__ */ d("span", { className: "flex items-center gap-1 text-xs text-destructive", role: "alert", children: [
1986
- /* @__PURE__ */ n(Qn, { className: "size-3 shrink-0", "aria-hidden": !0 }),
1987
- /* @__PURE__ */ n("span", { className: "max-w-[180px] truncate", title: pt(l, r), children: pt(l, r) })
1988
- ] })
1989
- ] }),
1990
- m && c && /* @__PURE__ */ n(
1991
- "button",
1992
- {
1993
- type: "button",
1994
- onClick: s,
1995
- className: "flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1996
- "aria-label": r("retry_upload", { name: o.name }),
1997
- children: /* @__PURE__ */ n(Wn, { className: "size-3.5", "aria-hidden": !0 })
1998
- }
1999
- ),
2000
- /* @__PURE__ */ n(
2001
- "button",
2002
- {
2003
- type: "button",
2004
- onClick: t,
2005
- className: "flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-destructive/15 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2006
- "aria-label": `${r("remove_file")}: ${o.name}`,
2007
- children: /* @__PURE__ */ n(V, { className: "size-3", "aria-hidden": !0 })
2008
- }
2009
- )
2010
- ]
2011
- }
2012
- );
2013
- }
2014
- function pt(e, t) {
2015
- return It(e) ? yt(e, t) : t("upload_failed");
2016
- }
2017
- function zo(e) {
2018
- const [t, s] = C();
2019
- return T(() => {
2020
- if (!e) return;
2021
- const r = URL.createObjectURL(e);
2022
- return s(r), () => {
2023
- URL.revokeObjectURL(r), s(void 0);
2024
- };
2025
- }, [e]), t;
2026
- }
2027
- function Io({ reference: e, remove: t, focus: s }) {
2028
- const { t: r } = k(["chat"]);
2029
- return /* @__PURE__ */ d(
2030
- "div",
2031
- {
2032
- className: "group/reference-chip flex min-w-0 max-w-[min(100%,260px)] items-center gap-2 rounded-lg border border-primary/15 bg-primary/8 px-2.5 py-1.5 text-start text-xs shadow-sm transition hover:bg-primary/12",
2033
- title: e.excerpt,
2034
- children: [
2035
- /* @__PURE__ */ d(
2036
- "button",
2037
- {
2038
- type: "button",
2039
- onClick: s,
2040
- className: "flex min-w-0 flex-1 items-center gap-2 text-start",
2041
- children: [
2042
- /* @__PURE__ */ n(Re, { className: "size-3.5 shrink-0 text-primary" }),
2043
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n("span", { className: "block truncate font-medium text-foreground/80", dir: "auto", children: e.excerpt }) })
2044
- ]
2045
- }
2046
- ),
2047
- /* @__PURE__ */ n(
2048
- "button",
2049
- {
2050
- type: "button",
2051
- onClick: (o) => {
2052
- o.stopPropagation(), t();
2053
- },
2054
- className: "ms-0.5 flex size-4 shrink-0 items-center justify-center rounded-full text-muted-foreground/60 transition hover:bg-destructive/15 hover:text-destructive",
2055
- "aria-label": `${r("remove_reference")}: ${e.excerpt}`,
2056
- title: r("remove_reference"),
2057
- children: /* @__PURE__ */ n(V, { className: "size-2.5" })
2058
- }
2059
- )
2060
- ]
2061
- }
2062
- );
2063
- }
2064
- const ft = ["byte", "kilobyte", "megabyte", "gigabyte"];
2065
- function Do(e, t) {
2066
- let s = e, r = 0;
2067
- for (; s >= 1024 && r < ft.length - 1; )
2068
- s /= 1024, r += 1;
2069
- return new Intl.NumberFormat(t, {
2070
- style: "unit",
2071
- unit: ft[r],
2072
- unitDisplay: "short",
2073
- maximumFractionDigits: r === 0 ? 0 : 1
2074
- }).format(s);
2075
- }
2076
- function To(e, { t, language: s, maxSize: r }) {
2077
- for (const { file: o, reason: i } of e)
2078
- i === "unsupported_type" ? K.error(t("chat:file_type_not_supported", { name: o.name })) : i === "too_large" && r !== void 0 && K.error(
2079
- t("chat:file_too_large", { name: o.name, size: Do(r, s) })
2080
- );
2081
- }
2082
- const Po = {
2083
- mic_denied: "chat:voice_mic_denied",
2084
- mic_missing: "chat:voice_mic_missing",
2085
- mic_error: "chat:voice_mic_error",
2086
- no_speech: "chat:voice_no_speech",
2087
- time_limit: "chat:voice_time_limit",
2088
- failed: "chat:voice_failed"
2089
- };
2090
- function Mo(e, t) {
2091
- const s = t(Po[e.kind]);
2092
- e.kind === "failed" ? K.error(s, { action: { label: t("chat:voice_retry"), onClick: e.retry } }) : e.kind === "no_speech" || e.kind === "time_limit" ? K(s) : K.error(s);
2093
- }
2094
- function nn({
2095
- enabled: e = !0
2096
- } = {}) {
2097
- const { t, i18n: s } = k(["chat"]), { dir: r } = $(), o = se((y) => y.welcome), i = typeof o?.greeting == "function", a = typeof o?.typingPrompts == "function", { user: l, firstName: c, isLoading: u } = xn({
2098
- enabled: e && (i || a)
2099
- }), m = o?.typingPrompts, h = typeof m == "function" ? m({ user: l, firstName: c, isLoading: u, t }) : m, b = t("welcome.typing_prompts", { returnObjects: !0, defaultValue: [] }), g = (h ? h.map((y) => t(y)) : Array.isArray(b) ? b : []).filter((y) => typeof y == "string" && y !== ""), f = o?.greeting, w = typeof f == "function" ? f({ user: l, firstName: c, isLoading: u, t }) : f ? nt(f, t, s, ["chat"]) : t("welcome.title"), x = o?.subtitle ? nt(o.subtitle, t, s, ["chat"]) : null;
2100
- return {
2101
- title: w,
2102
- subtitle: x,
2103
- typingMessages: g,
2104
- isRtl: r === "rtl",
2105
- icon: o?.icon
2106
- };
2107
- }
2108
- const Ro = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2109
- function Ao(e, t = {}) {
2110
- const { typingSpeed: s = 20, deletingSpeed: r = 15, pauseMs: o = 2e3, startDelayMs: i = 250 } = t, a = e.join("\0"), [l, c] = C(""), u = P(e);
2111
- return u.current = e, T(() => {
2112
- const m = u.current;
2113
- if (m.length === 0) {
2114
- c("");
2115
- return;
2116
- }
2117
- let h, b = 0, g = "typing", f = 0;
2118
- if (Ro()) {
2119
- c(m[0]);
2120
- const y = setInterval(() => {
2121
- b = (b + 1) % m.length, c(m[b]);
2122
- }, o);
2123
- return () => clearInterval(y);
2124
- }
2125
- const x = () => {
2126
- const y = m[b];
2127
- if (g === "typing") {
2128
- f++, c(y.slice(0, f)), f >= y.length ? (g = "pausing", h = setTimeout(x, o)) : h = setTimeout(x, s);
2129
- return;
2130
- }
2131
- if (g === "pausing") {
2132
- g = "deleting", h = setTimeout(x, r);
2133
- return;
2134
- }
2135
- f--, c(y.slice(0, Math.max(f, 0))), f <= 0 ? (g = "typing", b = (b + 1) % m.length, h = setTimeout(x, s)) : h = setTimeout(x, r);
2136
- };
2137
- return c(""), h = setTimeout(x, i), () => clearTimeout(h);
2138
- }, [a, s, r, o, i]), l;
2139
- }
2140
- function Eo({ ...e }) {
2141
- return /* @__PURE__ */ n(ie.Root, { "data-slot": "dropdown-menu", ...e });
2142
- }
2143
- function Oo({ ...e }) {
2144
- return /* @__PURE__ */ n(ie.Trigger, { "data-slot": "dropdown-menu-trigger", ...e });
2145
- }
2146
- function qo({
2147
- className: e,
2148
- sideOffset: t = 4,
2149
- ...s
2150
- }) {
2151
- const r = Q();
2152
- return /* @__PURE__ */ n(ie.Portal, { container: r, children: /* @__PURE__ */ n(
2153
- ie.Content,
2154
- {
2155
- "data-slot": "dropdown-menu-content",
2156
- sideOffset: t,
2157
- className: p(
2158
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
2159
- e
2160
- ),
2161
- ...s
2162
- }
2163
- ) });
2164
- }
2165
- function jo({
2166
- className: e,
2167
- inset: t,
2168
- variant: s = "default",
2169
- ...r
2170
- }) {
2171
- return /* @__PURE__ */ n(
2172
- ie.Item,
2173
- {
2174
- "data-slot": "dropdown-menu-item",
2175
- "data-inset": t,
2176
- "data-variant": s,
2177
- className: p(
2178
- "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2179
- e
2180
- ),
2181
- ...r
2182
- }
2183
- );
2184
- }
2185
- function $o({ open: e, onOpenChange: t, onCapture: s }) {
2186
- const r = Q();
2187
- return /* @__PURE__ */ n(_.Root, { open: e, onOpenChange: t, children: /* @__PURE__ */ d(_.Portal, { container: r, children: [
2188
- /* @__PURE__ */ n(_.Overlay, { className: "fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0" }),
2189
- /* @__PURE__ */ n(
2190
- _.Content,
2191
- {
2192
- "aria-describedby": void 0,
2193
- onOpenAutoFocus: (o) => {
2194
- o.preventDefault(), o.target.focus();
2195
- },
2196
- className: "fixed inset-0 z-50 m-auto h-fit w-[calc(100%-2rem)] max-w-2xl overflow-hidden rounded-3xl bg-black shadow-2xl ring-1 ring-white/10 outline-none duration-200 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
2197
- children: /* @__PURE__ */ n(
2198
- Lo,
2199
- {
2200
- onKeep: (o) => {
2201
- s(o), t(!1);
2202
- }
2203
- }
2204
- )
2205
- }
2206
- )
2207
- ] }) });
2208
- }
2209
- const gt = "grid size-10 place-items-center rounded-full bg-white/12 text-white backdrop-blur-md transition hover:bg-white/20 active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60", ht = "flex h-10 items-center gap-2 rounded-full px-4 text-sm font-medium transition active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60";
2210
- function Lo({ onKeep: e }) {
2211
- const { t } = k("chat"), s = P(null), [r, o] = C(), [i, a] = C(null), [l, c] = C([]), [u, m] = C(!1), [h, b] = C(!1), [g, f] = C(null);
2212
- T(() => {
2213
- let N = !1, z = null;
2214
- return navigator.mediaDevices.getUserMedia({
2215
- audio: !1,
2216
- video: {
2217
- ...r ? { deviceId: { exact: r } } : { facingMode: "user" },
2218
- width: { ideal: 1920 },
2219
- height: { ideal: 1080 }
2220
- }
2221
- }).then(async (S) => {
2222
- if (N) {
2223
- S.getTracks().forEach((D) => D.stop());
2224
- return;
2225
- }
2226
- z = S, a(S);
2227
- const O = await navigator.mediaDevices.enumerateDevices();
2228
- N || c(O.filter((D) => D.kind === "videoinput").map((D) => D.deviceId));
2229
- }).catch(() => {
2230
- N || b(!0);
2231
- }), () => {
2232
- N = !0, z?.getTracks().forEach((S) => S.stop());
2233
- };
2234
- }, [r]), T(() => {
2235
- s.current && (s.current.srcObject = i);
2236
- }, [i]), T(() => () => {
2237
- g && URL.revokeObjectURL(g.url);
2238
- }, [g]);
2239
- const w = i?.getVideoTracks()[0]?.getSettings(), x = w?.facingMode !== "environment", y = () => {
2240
- const N = l[(l.indexOf(w?.deviceId ?? "") + 1) % l.length];
2241
- !N || N === w?.deviceId || (a(null), m(!1), o(N));
2242
- }, v = () => {
2243
- const N = s.current;
2244
- if (!N?.videoWidth) return;
2245
- const z = document.createElement("canvas");
2246
- z.width = N.videoWidth, z.height = N.videoHeight, z.getContext("2d")?.drawImage(N, 0, 0), z.toBlob(
2247
- (S) => S && f({ blob: S, url: URL.createObjectURL(S) }),
2248
- "image/jpeg",
2249
- 0.92
2250
- );
2251
- }, I = () => {
2252
- if (!g) return;
2253
- const N = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/[-:]/g, "").replace("T", "-");
2254
- e(new File([g.blob], `photo-${N}.jpg`, { type: "image/jpeg" }));
2255
- };
2256
- return /* @__PURE__ */ d("div", { className: "relative aspect-[3/4] max-h-[80dvh] w-full sm:aspect-video", children: [
2257
- /* @__PURE__ */ n(
2258
- "video",
2259
- {
2260
- ref: s,
2261
- autoPlay: !0,
2262
- playsInline: !0,
2263
- muted: !0,
2264
- onPlaying: () => m(!0),
2265
- className: p(
2266
- "absolute inset-0 size-full object-cover transition-opacity duration-500",
2267
- u ? "opacity-100" : "opacity-0",
2268
- x && "-scale-x-100"
2269
- )
2270
- }
2271
- ),
2272
- g && /* @__PURE__ */ n(
2273
- "img",
2274
- {
2275
- src: g.url,
2276
- alt: "",
2277
- className: "absolute inset-0 size-full object-cover animate-in fade-in-0 zoom-in-[1.02] duration-200"
2278
- }
2279
- ),
2280
- h ? /* @__PURE__ */ d("div", { className: "absolute inset-0 flex flex-col items-center justify-center gap-4 px-8 text-center", children: [
2281
- /* @__PURE__ */ n("span", { className: "grid size-14 place-items-center rounded-full bg-white/10", children: /* @__PURE__ */ n(Gn, { className: "size-6 text-white/80" }) }),
2282
- /* @__PURE__ */ n("p", { className: "max-w-xs text-sm leading-relaxed text-white/70", children: t("camera_error") })
2283
- ] }) : !u && /* @__PURE__ */ n("div", { className: "absolute inset-0 grid place-items-center", children: /* @__PURE__ */ n(St, { className: "size-6 animate-spin text-white/50" }) }),
2284
- /* @__PURE__ */ d("div", { className: "absolute inset-x-0 top-0 flex items-center justify-between gap-4 bg-gradient-to-b from-black/55 to-transparent px-4 pt-4 pb-10", children: [
2285
- /* @__PURE__ */ n(_.Title, { className: "ps-1 text-sm font-medium text-white/90", children: t("camera_title") }),
2286
- /* @__PURE__ */ n(_.Close, { className: gt, "aria-label": t("camera_close"), children: /* @__PURE__ */ n(V, { className: "size-4.5" }) })
2287
- ] }),
2288
- !h && /* @__PURE__ */ n("div", { className: "absolute inset-x-0 bottom-0 grid grid-cols-[1fr_auto_1fr] items-center gap-4 bg-gradient-to-t from-black/65 to-transparent px-5 pt-14 pb-5", children: g ? /* @__PURE__ */ d(R, { children: [
2289
- /* @__PURE__ */ d(
2290
- "button",
2291
- {
2292
- type: "button",
2293
- onClick: () => f(null),
2294
- className: p(
2295
- ht,
2296
- "justify-self-start bg-white/12 text-white backdrop-blur-md hover:bg-white/20"
2297
- ),
2298
- children: [
2299
- /* @__PURE__ */ n(Kn, { className: "size-4" }),
2300
- t("camera_retake")
2301
- ]
2302
- }
2303
- ),
2304
- /* @__PURE__ */ n("span", {}),
2305
- /* @__PURE__ */ d(
2306
- "button",
2307
- {
2308
- type: "button",
2309
- onClick: I,
2310
- className: p(
2311
- ht,
2312
- "justify-self-end bg-white text-black shadow-lg hover:bg-white/90"
2313
- ),
2314
- children: [
2315
- /* @__PURE__ */ n(ce, { className: "size-4" }),
2316
- t("camera_use")
2317
- ]
2318
- }
2319
- )
2320
- ] }) : /* @__PURE__ */ d(R, { children: [
2321
- /* @__PURE__ */ n("span", {}),
2322
- /* @__PURE__ */ n(
2323
- "button",
2324
- {
2325
- type: "button",
2326
- onClick: v,
2327
- disabled: !u,
2328
- "aria-label": t("camera_capture"),
2329
- className: "group grid size-[4.25rem] place-items-center rounded-full border-[3px] border-white/90 transition-opacity focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-white/40 disabled:opacity-40",
2330
- children: /* @__PURE__ */ n("span", { className: "size-[3.375rem] rounded-full bg-white transition-transform duration-150 ease-out group-hover:scale-[0.94] group-active:scale-[0.82]" })
2331
- }
2332
- ),
2333
- l.length > 1 ? /* @__PURE__ */ n(
2334
- "button",
2335
- {
2336
- type: "button",
2337
- onClick: y,
2338
- disabled: !u,
2339
- "aria-label": t("camera_switch"),
2340
- className: p(gt, "size-11 justify-self-end disabled:opacity-40"),
2341
- children: /* @__PURE__ */ n(Jn, { className: "size-5" })
2342
- }
2343
- ) : /* @__PURE__ */ n("span", {})
2344
- ] }) })
2345
- ] });
2346
- }
2347
- const sn = {
2348
- camera: {
2349
- icon: es,
2350
- label: "attach_camera"
2351
- },
2352
- gallery: {
2353
- icon: Zn,
2354
- label: "attach_gallery"
2355
- },
2356
- files: {
2357
- icon: Xn,
2358
- label: "attach_files"
2359
- }
2360
- };
2361
- function Fo() {
2362
- return window.matchMedia("(pointer: coarse)").matches ? "native" : "mediaDevices" in navigator ? "webcam" : null;
2363
- }
2364
- function Bo({ disabled: e, addFiles: t, isMobile: s }) {
2365
- const { t: r } = k("chat"), { dir: o } = $(), [i, a] = C(!1), [l, c] = C(!1), [u] = C(Fo), m = {
2366
- camera: P(null),
2367
- gallery: P(null),
2368
- files: P(null)
2369
- }, h = De()?.attachments.types ?? [], b = h.filter((v) => v.startsWith("image/")), g = b.length ? [...u ? ["camera"] : [], "gallery", "files"] : ["files"], f = (v) => {
2370
- v === "camera" && u === "webcam" ? c(!0) : m[v].current?.click();
2371
- }, w = (v) => {
2372
- v.target.files && t(Array.from(v.target.files)), v.target.value = "";
2373
- }, x = r("attach"), y = /* @__PURE__ */ n(
2374
- tn,
2375
- {
2376
- variant: "ghost",
2377
- disabled: e,
2378
- "aria-label": x,
2379
- onClick: g.length === 1 ? () => f("files") : s ? () => a(!0) : void 0,
2380
- className: p(i && "bg-accent/60 text-foreground transition-colors active:scale-100"),
2381
- children: /* @__PURE__ */ n(
2382
- Yn,
2383
- {
2384
- className: p(
2385
- "size-6 transition-transform duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]",
2386
- i && "rotate-45"
2387
- )
2388
- }
2389
- )
2390
- }
2391
- );
2392
- return /* @__PURE__ */ d(R, { children: [
2393
- /* @__PURE__ */ n(
2394
- "input",
2395
- {
2396
- type: "file",
2397
- ref: m.camera,
2398
- onChange: w,
2399
- accept: b.join(","),
2400
- capture: "environment",
2401
- className: "hidden"
2402
- }
2403
- ),
2404
- /* @__PURE__ */ n(
2405
- "input",
2406
- {
2407
- type: "file",
2408
- ref: m.gallery,
2409
- onChange: w,
2410
- accept: b.join(","),
2411
- multiple: !0,
2412
- className: "hidden"
2413
- }
2414
- ),
2415
- /* @__PURE__ */ n(
2416
- "input",
2417
- {
2418
- type: "file",
2419
- ref: m.files,
2420
- onChange: w,
2421
- accept: h.join(","),
2422
- multiple: !0,
2423
- className: "hidden"
2424
- }
2425
- ),
2426
- g.length === 1 ? /* @__PURE__ */ d(Ve, { children: [
2427
- /* @__PURE__ */ n(Qe, { asChild: !0, children: y }),
2428
- /* @__PURE__ */ n(We, { children: x })
2429
- ] }) : s ? /* @__PURE__ */ d(R, { children: [
2430
- y,
2431
- /* @__PURE__ */ n(
2432
- Uo,
2433
- {
2434
- open: i,
2435
- onOpenChange: a,
2436
- title: x,
2437
- sources: g,
2438
- onPick: (v) => {
2439
- f(v), a(!1);
2440
- }
2441
- }
2442
- )
2443
- ] }) : (
2444
- // Not modal: a modal menu that hands off to the camera dialog leaves the
2445
- // page unclickable once both have closed. Given the language's direction
2446
- // because Radix doesn't read the document's: it would lay the menu out
2447
- // left-to-right, and `align="start"` would hug the left edge in RTL too.
2448
- /* @__PURE__ */ d(Eo, { dir: o, modal: !1, open: i, onOpenChange: a, children: [
2449
- /* @__PURE__ */ n(Oo, { asChild: !0, children: y }),
2450
- /* @__PURE__ */ n(
2451
- qo,
2452
- {
2453
- side: "bottom",
2454
- align: "start",
2455
- sideOffset: 10,
2456
- className: "min-w-0 rounded-2xl border-border/60 bg-popover p-1.5 shadow-xl",
2457
- onCloseAutoFocus: (v) => l && v.preventDefault(),
2458
- children: g.map((v) => {
2459
- const { icon: I, label: N } = sn[v];
2460
- return /* @__PURE__ */ d(
2461
- jo,
2462
- {
2463
- onSelect: () => f(v),
2464
- className: "cursor-pointer gap-3 rounded-xl py-1.5 ps-1.5 pe-4 font-medium",
2465
- children: [
2466
- /* @__PURE__ */ n("span", { className: "grid size-8 place-items-center rounded-lg bg-foreground/[0.06] text-foreground/75", children: /* @__PURE__ */ n(I, { className: "size-4 text-current" }) }),
2467
- r(N)
2468
- ]
2469
- },
2470
- v
2471
- );
2472
- })
2473
- }
2474
- )
2475
- ] })
2476
- ),
2477
- u === "webcam" && /* @__PURE__ */ n(
2478
- $o,
2479
- {
2480
- open: l,
2481
- onOpenChange: c,
2482
- onCapture: (v) => t([v])
2483
- }
2484
- )
2485
- ] });
2486
- }
2487
- function Uo({ open: e, onOpenChange: t, title: s, sources: r, onPick: o }) {
2488
- const i = Q();
2489
- return /* @__PURE__ */ n(_.Root, { open: e, onOpenChange: t, children: /* @__PURE__ */ d(_.Portal, { container: i, children: [
2490
- /* @__PURE__ */ n(_.Overlay, { className: "fixed inset-0 z-50 bg-overlay data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0" }),
2491
- /* @__PURE__ */ n(
2492
- _.Content,
2493
- {
2494
- "aria-describedby": void 0,
2495
- onOpenAutoFocus: (a) => a.preventDefault(),
2496
- className: "fixed inset-x-0 bottom-0 z-50 outline-none duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] data-[state=open]:animate-in data-[state=open]:slide-in-from-bottom data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom",
2497
- children: /* @__PURE__ */ n(Vo, { title: s, onDismiss: () => t(!1), children: /* @__PURE__ */ n("div", { className: p("grid gap-3", r.length === 3 ? "grid-cols-3" : "grid-cols-2"), children: r.map((a, l) => /* @__PURE__ */ n(Qo, { source: a, index: l, onPick: o }, a)) }) })
2498
- }
2499
- )
2500
- ] }) });
2501
- }
2502
- const Ho = 72;
2503
- function Vo({
2504
- title: e,
2505
- onDismiss: t,
2506
- children: s
2507
- }) {
2508
- const [r, o] = C(0), [i, a] = C(!1), l = P(0), c = (h) => {
2509
- l.current = h.clientY, a(!0), h.currentTarget.setPointerCapture(h.pointerId);
2510
- }, u = (h) => {
2511
- if (!i) return;
2512
- const b = h.clientY - l.current;
2513
- o(b > 0 ? b : -Math.sqrt(-b) * 2);
2514
- }, m = () => {
2515
- a(!1), r > Ho ? t() : o(0);
2516
- };
2517
- return /* @__PURE__ */ d(
2518
- "div",
2519
- {
2520
- className: "mx-auto w-full max-w-lg rounded-t-[1.75rem] border border-b-0 border-border/60 bg-popover px-4 pb-[max(1.25rem,env(safe-area-inset-bottom))] shadow-[0_-12px_48px_-16px_rgb(0_0_0/0.3)]",
2521
- style: {
2522
- transform: r ? `translateY(${r}px)` : void 0,
2523
- transition: i ? "none" : "transform 250ms cubic-bezier(0.32,0.72,0,1)"
2524
- },
2525
- children: [
2526
- /* @__PURE__ */ d(
2527
- "div",
2528
- {
2529
- className: "cursor-grab touch-none pt-2.5 pb-5 select-none active:cursor-grabbing",
2530
- onPointerDown: c,
2531
- onPointerMove: u,
2532
- onPointerUp: m,
2533
- onPointerCancel: m,
2534
- children: [
2535
- /* @__PURE__ */ n("div", { className: "mx-auto h-1.5 w-10 rounded-full bg-muted-foreground/25" }),
2536
- /* @__PURE__ */ n(_.Title, { className: "mt-4 text-center text-base font-semibold text-foreground", children: e })
2537
- ]
2538
- }
2539
- ),
2540
- s
2541
- ]
2542
- }
2543
- );
2544
- }
2545
- function Qo({
2546
- source: e,
2547
- index: t,
2548
- onPick: s
2549
- }) {
2550
- const { t: r } = k("chat"), { icon: o, label: i } = sn[e];
2551
- return /* @__PURE__ */ d(
2552
- "button",
2553
- {
2554
- type: "button",
2555
- onClick: () => s(e),
2556
- className: "flex flex-col items-center gap-2.5 rounded-2xl bg-muted/45 px-2 pt-4 pb-3.5 outline-none transition-[transform,background-color] duration-150 animate-in fade-in-0 slide-in-from-bottom-3 [-webkit-tap-highlight-color:transparent] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.96] active:bg-muted/80",
2557
- style: {
2558
- animationDuration: "400ms",
2559
- animationDelay: `${90 + t * 45}ms`,
2560
- animationFillMode: "both"
2561
- },
2562
- children: [
2563
- /* @__PURE__ */ n("span", { className: "grid size-14 place-items-center rounded-full bg-background text-foreground/80 shadow-sm ring-1 ring-border/60", children: /* @__PURE__ */ n(o, { className: "size-6", strokeWidth: 1.75 }) }),
2564
- /* @__PURE__ */ n("span", { className: "text-sm font-medium text-foreground/85", children: r(i) })
2565
- ]
2566
- }
2567
- );
2568
- }
2569
- function Wo() {
2570
- const { t: e } = k("chat"), t = wt().status === "starting", s = e("voice_dictate");
2571
- return /* @__PURE__ */ d(Ve, { children: [
2572
- /* @__PURE__ */ n(Qe, { asChild: !0, children: /* @__PURE__ */ n(G.Voice, { asChild: !0, children: /* @__PURE__ */ n(tn, { "aria-label": s, children: t ? /* @__PURE__ */ n(St, { className: "size-5 animate-spin" }) : /* @__PURE__ */ n(ts, { className: "size-5" }) }) }) }),
2573
- /* @__PURE__ */ n(We, { children: s })
2574
- ] });
2575
- }
2576
- const Go = Me(
2577
- () => import("./VoiceInput-DX0ZCnIA.js").then((e) => ({ default: e.VoiceRecordingBar }))
2578
- ), Ko = Me(
2579
- () => import("./VoiceInput-DX0ZCnIA.js").then((e) => ({ default: e.VoiceRecordingControls }))
2580
- );
2581
- function Jo({
2582
- onSend: e,
2583
- status: t,
2584
- isErrorVisible: s,
2585
- threadId: r,
2586
- newChat: o,
2587
- className: i
2588
- }) {
2589
- const { t: a, i18n: l } = k(["chat", "maintenance"]), c = se((A) => A.composer), u = De(), { ChoiceQuestionDock: m, ComposerFooter: h, composerTools: b } = B(), { blocksChat: g } = yn(), {
2590
- question: f,
2591
- disabled: w,
2592
- dismissed: x,
2593
- setDismissed: y,
2594
- answer: v
2595
- } = he(), I = x ? null : f, { typingMessages: N } = nn({ enabled: !!o }), z = Ao(o ? N : []), S = !!o && N.length > 0, O = c?.placeholder ? a(c.placeholder) : a("input_placeholder"), D = g ? a("maintenance:composer_placeholder") : I?.allowCustom !== !1 && I ? a("choice_custom_placeholder") : S ? z : O, j = _o(), W = t === "streaming" || t === "submitted", ln = wn("voice_input", { enabled: !!c?.voice?.enabled }), cn = !!c?.voice?.enabled && ln === !0, Ke = u?.attachments, Je = (c?.attachments?.enabled ?? !1) && !!Ke, dn = E(
2596
- () => [...b ?? []].sort((A, re) => (A.order ?? 0) - (re.order ?? 0)),
2597
- [b]
2598
- ), { draft: un, setDraft: mn, isClosed: Ye } = Pe(), Xe = P(null), Ze = {
2599
- newChat: !!o,
2600
- threadId: r,
2601
- status: t,
2602
- disabled: W || Ye,
2603
- draft: un,
2604
- send: (A) => {
2605
- W || Ye || !A.trim() || e({ text: A });
2606
- },
2607
- setDraft: (A) => {
2608
- fs(() => mn(A));
2609
- const re = Xe.current;
2610
- re && (re.focus(), re.setSelectionRange(A.length, A.length));
2611
- }
2612
- };
2613
- return /* @__PURE__ */ n("div", { className: p("shrink-0 px-4 pb-5 pt-2 md:px-6 md:pb-6 w-full", i), children: /* @__PURE__ */ d("div", { className: "max-w-[50rem] mx-auto w-full", children: [
2614
- I && /* @__PURE__ */ n(
2615
- m,
2616
- {
2617
- question: I,
2618
- disabled: w || W || g,
2619
- onDismiss: () => y(!0),
2620
- onAnswer: v
2621
- }
2622
- ),
2623
- /* @__PURE__ */ n("div", { className: "relative z-10", children: /* @__PURE__ */ n(
2624
- wo,
2625
- {
2626
- className: "relative",
2627
- onSend: e,
2628
- allowFiles: Je,
2629
- maxVoiceDuration: c?.voice?.maxDuration,
2630
- onFilesRejected: (A) => To(A, {
2631
- t: a,
2632
- language: l.language,
2633
- maxSize: Ke?.max_size
2634
- }),
2635
- onVoiceNotice: (A) => Mo(A, a),
2636
- children: /* @__PURE__ */ n(
2637
- Yo,
2638
- {
2639
- textareaRef: Xe,
2640
- slotProps: Ze,
2641
- isErrorVisible: s,
2642
- placeholder: D,
2643
- isMobile: j,
2644
- attachEnabled: Je,
2645
- voiceEnabled: cn,
2646
- tools: dn
2647
- }
2648
- )
2649
- }
2650
- ) }),
2651
- h && /* @__PURE__ */ n(pe, { fallback: null, resetKeys: [r], children: /* @__PURE__ */ n(h, { ...Ze }) })
2652
- ] }) });
2653
- }
2654
- function Yo({
2655
- textareaRef: e,
2656
- slotProps: t,
2657
- isErrorVisible: s,
2658
- placeholder: r,
2659
- isMobile: o,
2660
- attachEnabled: i,
2661
- voiceEnabled: a,
2662
- tools: l
2663
- }) {
2664
- const { t: c, i18n: u } = k(["chat"]), m = se((D) => D.composer?.maxLength), { draft: h, files: b, references: g, isBusy: f } = Pe(), { addFiles: w, dragging: x } = Nn(), y = wt(), { threadId: v, status: I } = t, N = !!m && h.length >= m * 0.9;
2665
- T(() => {
2666
- o || e.current?.focus();
2667
- }, [v, o, e]);
2668
- const z = g.length, S = P(z);
2669
- T(() => {
2670
- z > S.current && !o && e.current?.focus(), S.current = z;
2671
- }, [z, o, e]);
2672
- const O = { ...t, isMobile: o, addFiles: w };
2673
- return /* @__PURE__ */ d(R, { children: [
2674
- x && /* @__PURE__ */ n(
2675
- "div",
2676
- {
2677
- className: "pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-background/90 text-sm font-medium text-foreground",
2678
- "aria-hidden": !0,
2679
- children: c("drop_files")
2680
- }
2681
- ),
2682
- i && !y.active && // Matches the toolbar's bottom padding, so the + lines up with the send button.
2683
- /* @__PURE__ */ n("div", { className: "-ms-1 -me-1 flex shrink-0 items-center pb-1", children: /* @__PURE__ */ n(pe, { fallback: null, resetKeys: [v], children: /* @__PURE__ */ n(Bo, { ...O }) }) }),
2684
- /* @__PURE__ */ d("div", { className: "flex flex-col flex-1 gap-2", children: [
2685
- g.length > 0 && /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-2 px-2 pt-2", children: /* @__PURE__ */ n(G.References, { component: Io }) }),
2686
- b.length > 0 && /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-2 px-2 pt-2", children: /* @__PURE__ */ n(G.Attachments, { component: Xo }) }),
2687
- y.active ? /* @__PURE__ */ n(Ce, { fallback: null, children: /* @__PURE__ */ n(Go, {}) }) : /* @__PURE__ */ n(
2688
- No,
2689
- {
2690
- ref: e,
2691
- autoFocus: !o,
2692
- placeholder: r,
2693
- maxLength: m,
2694
- "aria-label": c("input_placeholder")
2695
- }
2696
- )
2697
- ] }),
2698
- /* @__PURE__ */ n(ko, { children: y.active ? /* @__PURE__ */ n(Ce, { fallback: null, children: /* @__PURE__ */ n(Ko, {}) }) : /* @__PURE__ */ d(R, { children: [
2699
- N && /* @__PURE__ */ d(
2700
- "span",
2701
- {
2702
- className: p(
2703
- "px-1 text-xs tabular-nums text-muted-foreground",
2704
- h.length >= m && "text-destructive"
2705
- ),
2706
- "aria-live": "polite",
2707
- children: [
2708
- h.length.toLocaleString(u.language),
2709
- "/",
2710
- m.toLocaleString(u.language)
2711
- ]
2712
- }
2713
- ),
2714
- /* @__PURE__ */ d(Co, { children: [
2715
- l.map(({ id: D, component: j }) => (
2716
- // Contained so a throwing tool can't take the composer or the other tools with it.
2717
- /* @__PURE__ */ n(pe, { fallback: null, resetKeys: [v], children: /* @__PURE__ */ n(j, { ...O }) }, D)
2718
- )),
2719
- a && /* @__PURE__ */ n(Wo, {})
2720
- ] }),
2721
- f ? /* @__PURE__ */ n(G.Stop, { asChild: !0, children: /* @__PURE__ */ n(mt, { status: I === "submitted" ? "submitted" : "streaming" }) }) : /* @__PURE__ */ n(G.Send, { asChild: !0, children: /* @__PURE__ */ n(mt, { status: s ? "error" : "ready" }) })
2722
- ] }) })
2723
- ] });
2724
- }
2725
- function Xo({ file: e, remove: t, retry: s }) {
2726
- return /* @__PURE__ */ n(So, { entry: e, onRemove: t, onRetry: s });
2727
- }
2728
- const Zo = (e) => {
2729
- const { title: t, subtitle: s, isRtl: r, icon: o } = nn();
2730
- return /* @__PURE__ */ d(
2731
- "div",
2732
- {
2733
- dir: r ? "rtl" : "ltr",
2734
- className: "flex flex-col items-center text-center px-6 animate-in fade-in duration-700 ease-out",
2735
- children: [
2736
- o && /* @__PURE__ */ n("div", { className: "mb-8 flex items-center justify-center", children: /* @__PURE__ */ n("div", { className: "size-12 md:size-16 rounded-xl bg-secondary flex items-center justify-center border border-border", children: typeof o == "function" ? /* @__PURE__ */ n(o, { className: "size-6 md:size-8 text-primary opacity-80" }) : o }) }),
2737
- (t || s) && /* @__PURE__ */ d("div", { className: "space-y-3 max-w-xl mx-auto", children: [
2738
- t && /* @__PURE__ */ n("h1", { className: "text-2xl md:text-3xl font-black tracking-tight leading-tight text-foreground", children: t }),
2739
- s && /* @__PURE__ */ n("p", { className: "text-muted-foreground text-base md:text-lg font-medium max-w-md mx-auto leading-relaxed opacity-85 dark:opacity-70", children: s })
2740
- ] })
2741
- ]
2742
- }
2743
- );
2744
- };
2745
- function ea({
2746
- question: e,
2747
- disabled: t,
2748
- onDismiss: s,
2749
- onAnswer: r,
2750
- className: o
2751
- }) {
2752
- const { t: i } = k(["chat"]), { dir: a } = $(), { reportDockHeight: l } = he(), c = P(null), [u, m] = C(null);
2753
- T(() => {
2754
- const f = c.current;
2755
- if (!f) return;
2756
- const w = () => l(f.offsetHeight);
2757
- w();
2758
- const x = typeof ResizeObserver > "u" ? null : new ResizeObserver(w);
2759
- return x?.observe(f), () => {
2760
- x?.disconnect(), l(0);
2761
- };
2762
- }, [l]);
2763
- const h = L(e.question, a), b = t || !r || u !== null, g = async (f) => {
2764
- if (!b) {
2765
- m(f);
2766
- try {
2767
- await r?.(f);
2768
- } catch {
2769
- m(null);
2770
- }
2771
- }
2772
- };
2773
- return /* @__PURE__ */ d(
2774
- "div",
2775
- {
2776
- ref: c,
2777
- dir: h,
2778
- className: p(
2779
- // `-mb-3` slides the bottom edge under the composer, which paints over
2780
- // it (see the `z-10` wrapper there) so the joint reads as one surface.
2781
- "animate-choice-dock relative z-0 -mb-3 rounded-t-lg bg-surface px-2 pb-6 pt-4",
2782
- o
2783
- ),
2784
- children: [
2785
- /* @__PURE__ */ d("div", { className: "flex items-start gap-2 px-3", children: [
2786
- /* @__PURE__ */ n("p", { className: "min-w-0 flex-1 text-base leading-snug text-foreground", children: e.question }),
2787
- s && /* @__PURE__ */ n(
2788
- "button",
2789
- {
2790
- type: "button",
2791
- onClick: s,
2792
- "aria-label": i("choice_dismiss"),
2793
- title: i("choice_dismiss"),
2794
- className: "-me-1 -mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground/70 outline-none transition-colors hover:bg-foreground/[0.06] hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/40",
2795
- children: /* @__PURE__ */ n(V, { className: "size-4" })
2796
- }
2797
- )
2798
- ] }),
2799
- /* @__PURE__ */ n(
2800
- Xt,
2801
- {
2802
- choices: e.choices,
2803
- selected: u,
2804
- disabled: b,
2805
- dir: h,
2806
- onSelect: (f) => {
2807
- g(f);
2808
- },
2809
- className: "custom-scrollbar mt-3 max-h-[40vh] overflow-y-auto"
2810
- }
2811
- )
2812
- ]
2813
- }
2814
- );
2815
- }
2816
- function ta({ className: e, children: t, ...s }) {
2817
- return /* @__PURE__ */ d(ae.Root, { "data-slot": "scroll-area", className: p("relative", e), ...s, children: [
2818
- /* @__PURE__ */ n(
2819
- ae.Viewport,
2820
- {
2821
- "data-slot": "scroll-area-viewport",
2822
- className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
2823
- children: t
2824
- }
2825
- ),
2826
- /* @__PURE__ */ n(rn, {}),
2827
- /* @__PURE__ */ n(ae.Corner, {})
2828
- ] });
2829
- }
2830
- function rn({
2831
- className: e,
2832
- orientation: t = "vertical",
2833
- ...s
2834
- }) {
2835
- return /* @__PURE__ */ n(
2836
- ae.ScrollAreaScrollbar,
2837
- {
2838
- "data-slot": "scroll-area-scrollbar",
2839
- orientation: t,
2840
- className: p(
2841
- "flex touch-none p-px transition-colors select-none",
2842
- t === "vertical" && "h-full w-2.5 border-s border-s-transparent",
2843
- t === "horizontal" && "h-2.5 flex-col border-t border-t-transparent",
2844
- e
2845
- ),
2846
- ...s,
2847
- children: /* @__PURE__ */ n(
2848
- ae.ScrollAreaThumb,
2849
- {
2850
- "data-slot": "scroll-area-thumb",
2851
- className: "bg-border relative flex-1 rounded-full"
2852
- }
2853
- )
2854
- }
2855
- );
2856
- }
2857
- const na = ({ className: e, children: t, ...s }) => {
2858
- const { dir: r } = $();
2859
- return /* @__PURE__ */ d(ta, { className: "w-full overflow-x-auto whitespace-nowrap", dir: r, ...s, children: [
2860
- /* @__PURE__ */ n("div", { className: p("flex w-max flex-nowrap items-center gap-2", e), children: t }),
2861
- /* @__PURE__ */ n(rn, { className: "hidden", orientation: "horizontal" })
2862
- ] });
2863
- }, sa = ({
2864
- suggestion: e,
2865
- onClick: t,
2866
- className: s,
2867
- variant: r = "outline",
2868
- size: o = "sm",
2869
- children: i,
2870
- ...a
2871
- }) => {
2872
- const l = () => {
2873
- t?.(e);
2874
- };
2875
- return /* @__PURE__ */ n(
2876
- F,
2877
- {
2878
- className: p("cursor-pointer rounded-full px-4", s),
2879
- onClick: l,
2880
- size: o,
2881
- type: "button",
2882
- variant: r,
2883
- ...a,
2884
- children: i ?? e
2885
- }
2886
- );
2887
- };
2888
- function ra({
2889
- suggestions: e,
2890
- disabled: t = !1,
2891
- onSelect: s,
2892
- className: r
2893
- }) {
2894
- const { t: o } = k("chat"), [i, a] = C(!1), l = async (c) => {
2895
- if (!(t || i || !s)) {
2896
- a(!0);
2897
- try {
2898
- await s(c);
2899
- } catch {
2900
- a(!1);
2901
- }
2902
- }
2903
- };
2904
- return /* @__PURE__ */ n("div", { className: p("mx-auto w-full max-w-4xl py-2", r), children: /* @__PURE__ */ n(na, { className: "pb-1", "aria-label": o("follow_up_suggestions"), children: e.map((c) => /* @__PURE__ */ n(
2905
- sa,
2906
- {
2907
- suggestion: c,
2908
- onClick: (u) => {
2909
- l(u);
2910
- },
2911
- disabled: t || i || !s,
2912
- dir: L(c),
2913
- className: "max-w-[min(32rem,80vw)] shrink-0"
2914
- },
2915
- c
2916
- )) }) });
2917
- }
2918
- function oa({ error: e, code: t }) {
2919
- const { t: s, i18n: r } = k(["chat", "quota"]), o = Te((c) => c.app.showToolDetails ?? !0), i = $().dir === "rtl", a = e.details, l = o && a && (t === "quota_exceeded" || a.limit !== void 0 || a.resets_at !== void 0);
2920
- return /* @__PURE__ */ d(
2921
- "div",
2922
- {
2923
- className: "flex flex-col w-full gap-2 px-4 py-3.5 rounded-xl bg-destructive/8 border border-destructive/15 border-s-2 border-s-destructive/60",
2924
- dir: i ? "rtl" : "ltr",
2925
- children: [
2926
- /* @__PURE__ */ d("div", { className: "flex w-full items-start gap-3", children: [
2927
- /* @__PURE__ */ n("div", { className: "size-1.5 rounded-full bg-destructive mt-2 shrink-0" }),
2928
- /* @__PURE__ */ d("div", { className: "text-sm text-destructive/90 leading-relaxed flex-1 text-start", children: [
2929
- /* @__PURE__ */ n("span", { className: "font-semibold", children: s("error") }),
2930
- " ",
2931
- e.message
2932
- ] })
2933
- ] }),
2934
- l && /* @__PURE__ */ d("div", { className: "mt-1 ps-4.5 pt-2 border-t border-destructive/10 text-xs text-muted-foreground flex flex-wrap gap-x-4 gap-y-1", children: [
2935
- typeof a.limit == "number" && /* @__PURE__ */ n("span", { children: s("quota:left", {
2936
- amount: Math.max(0, a.limit - (a.used ?? a.limit)),
2937
- total: a.limit
2938
- }) }),
2939
- a.window?.per && /* @__PURE__ */ n("span", { children: s(`quota:window.per_${a.window.per}`, {
2940
- defaultValue: a.window.per
2941
- }) }),
2942
- a.resets_at && /* @__PURE__ */ n("span", { children: s("quota:resets_at", {
2943
- datetime: new Date(a.resets_at).toLocaleString(r.language)
2944
- }) })
2945
- ] })
2946
- ]
2947
- }
2948
- );
2949
- }
2950
- const Ka = ["messages", "tokens", "model_requests", "cost"], Ja = [
2951
- "minute",
2952
- "hour",
2953
- "day",
2954
- "week",
2955
- "month",
2956
- "subscription"
2957
- ];
2958
- function aa(e, t) {
2959
- return e(`quota:meters.${t}`, { defaultValue: t.replace(/_/g, " ") });
2960
- }
2961
- function Ya(e, t, s) {
2962
- return e === "cost" ? new Intl.NumberFormat(s, { maximumFractionDigits: 4 }).format(t / 1e6) : e === "tokens" && t >= 1e4 ? new Intl.NumberFormat(s, {
2963
- notation: "compact",
2964
- maximumFractionDigits: 1
2965
- }).format(t) : new Intl.NumberFormat(s).format(t);
2966
- }
2967
- function bt(e, t) {
2968
- if (t.per === "subscription") return e("quota:window.whole_plan");
2969
- const s = t.every ?? 1;
2970
- return s === 1 ? e(`quota:window.per_${t.per}`) : e("quota:window.every", { count: s, unit: e(`quota:units.${t.per}`) });
2971
- }
2972
- function Xa(e, t) {
2973
- return t ? e(`quota:duration.${t.per}`, { count: t.every ?? 1 }) : e("quota:duration.until_canceled");
2974
- }
2975
- function ia(e, t) {
2976
- if (!e) return "";
2977
- const s = new Date(e);
2978
- return Number.isNaN(s.getTime()) ? e : ps(t, {
2979
- year: "numeric",
2980
- month: "short",
2981
- day: "numeric",
2982
- hour: "2-digit",
2983
- minute: "2-digit"
2984
- }).format(s);
2985
- }
2986
- function la(e) {
2987
- let t = null, s = 1 / 0;
2988
- for (const r of e) {
2989
- const o = Ge(r.remaining, r.amount);
2990
- o < s && (t = r, s = o);
2991
- }
2992
- return t;
2993
- }
2994
- function Ge(e, t) {
2995
- return t <= 0 ? 0 : Math.max(0, Math.min(100, e / t * 100));
2996
- }
2997
- function on(e, t) {
2998
- let s = Math.round(e);
2999
- return e > 0 && s === 0 && (s = 1), e < 100 && s === 100 && (s = 99), new Intl.NumberFormat(t, { style: "percent" }).format(s / 100);
3000
- }
3001
- function an(e) {
3002
- return e > 60 ? "bg-success" : e > 20 ? "bg-warning" : "bg-destructive";
3003
- }
3004
- function ca(e) {
3005
- return e > 60 ? "border-success/70" : e > 20 ? "border-warning/70" : "border-destructive/70";
3006
- }
3007
- function da({ ...e }) {
3008
- return /* @__PURE__ */ n(me.Root, { "data-slot": "hover-card", ...e });
3009
- }
3010
- function ua({ ...e }) {
3011
- return /* @__PURE__ */ n(me.Trigger, { "data-slot": "hover-card-trigger", ...e });
3012
- }
3013
- function ma({
3014
- className: e,
3015
- align: t = "center",
3016
- sideOffset: s = 4,
3017
- ...r
3018
- }) {
3019
- const o = Q();
3020
- return /* @__PURE__ */ n(me.Portal, { "data-slot": "hover-card-portal", container: o, children: /* @__PURE__ */ n(
3021
- me.Content,
3022
- {
3023
- "data-slot": "hover-card-content",
3024
- align: t,
3025
- sideOffset: s,
3026
- className: p(
3027
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
3028
- e
3029
- ),
3030
- ...r
3031
- }
3032
- ) });
3033
- }
3034
- function vt({ label: e, remaining: t, amount: s }) {
3035
- const { t: r, i18n: o } = k(["quota"]), i = Ge(t, s);
3036
- return /* @__PURE__ */ d("div", { className: "space-y-1", children: [
3037
- /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-3", children: [
3038
- /* @__PURE__ */ n("span", { className: "truncate text-foreground/80", children: e }),
3039
- /* @__PURE__ */ n("span", { className: "shrink-0 tabular-nums font-medium text-foreground", children: r("quota:percent_left", { percent: on(i, o.language) }) })
3040
- ] }),
3041
- /* @__PURE__ */ n("div", { className: "h-1 w-full rounded-full bg-muted overflow-hidden", children: /* @__PURE__ */ n(
3042
- "div",
3043
- {
3044
- className: p("h-full rounded-full transition-all duration-700", an(i)),
3045
- style: { width: `${i}%` }
3046
- }
3047
- ) })
3048
- ] });
3049
- }
3050
- function pa({ className: e, details: t = !0 }) {
3051
- const { t: s, i18n: r } = k(["quota"]), { data: o } = kn(), [i, a] = C(!1);
3052
- if (!o) return null;
3053
- let l, c, u;
3054
- if (o.kind === "plan") {
3055
- const x = la(o.windows);
3056
- if (!x) return null;
3057
- ({ remaining: l, amount: c } = x), u = `${aa(s, x.meter)} ${bt(s, x)}`;
3058
- } else if (o.kind === "credits" && o.credits)
3059
- ({ remaining: l } = o.credits), c = o.credits.granted, u = s("quota:credits");
3060
- else
3061
- return null;
3062
- const m = Ge(l, c), h = o.kind === "credits" ? s("quota:credits") : o.plan?.name ?? s("quota:plan"), b = on(m, r.language), g = l <= 0, f = p(
3063
- "flex items-center gap-2 h-8 ps-2.5 pe-3 rounded-full border text-xs font-medium tabular-nums transition-colors",
3064
- g ? "border-destructive/40 bg-destructive/10 text-destructive" : "border-border/60 bg-background/40 text-muted-foreground",
3065
- e
3066
- ), w = /* @__PURE__ */ d(R, { children: [
3067
- /* @__PURE__ */ n(
3068
- "span",
3069
- {
3070
- className: p(
3071
- "block h-2 w-8 md:w-12 rounded-full border overflow-hidden bg-muted/40 transition-colors duration-700",
3072
- ca(m)
3073
- ),
3074
- role: "meter",
3075
- "aria-label": s("quota:usage_label", { label: u, percent: b }),
3076
- "aria-valuemin": 0,
3077
- "aria-valuemax": c,
3078
- "aria-valuenow": l,
3079
- children: /* @__PURE__ */ n(
3080
- "span",
3081
- {
3082
- className: p("block h-full transition-all duration-700", an(m)),
3083
- style: { width: `${m}%` }
3084
- }
3085
- )
3086
- }
3087
- ),
3088
- /* @__PURE__ */ n("span", { "aria-hidden": !0, children: b })
3089
- ] });
3090
- return t ? /* @__PURE__ */ d(da, { open: i, onOpenChange: a, openDelay: 150, closeDelay: 100, children: [
3091
- /* @__PURE__ */ n(ua, { asChild: !0, children: /* @__PURE__ */ n(
3092
- "button",
3093
- {
3094
- type: "button",
3095
- onClick: () => a((x) => !x),
3096
- className: p(
3097
- f,
3098
- g ? "hover:bg-destructive/15" : "hover:bg-accent/60 hover:text-foreground"
3099
- ),
3100
- children: w
3101
- }
3102
- ) }),
3103
- /* @__PURE__ */ d(ma, { align: "end", sideOffset: 6, className: "w-64 p-3 text-xs space-y-3", children: [
3104
- /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-2", children: [
3105
- /* @__PURE__ */ n("span", { className: "font-semibold text-foreground truncate", children: h }),
3106
- o.ends_at && /* @__PURE__ */ n("span", { className: "shrink-0 text-xs text-muted-foreground", children: s("quota:ends_at", { datetime: ia(o.ends_at, r.language) }) })
3107
- ] }),
3108
- o.kind === "plan" ? o.windows.map((x) => /* @__PURE__ */ n(
3109
- vt,
3110
- {
3111
- label: bt(s, x),
3112
- amount: x.amount,
3113
- remaining: x.remaining
3114
- },
3115
- x.key
3116
- )) : o.credits && /* @__PURE__ */ n(vt, { amount: o.credits.granted, remaining: o.credits.remaining })
3117
- ] })
3118
- ] }) : /* @__PURE__ */ n("div", { className: f, children: w });
3119
- }
3120
- function fa({ title: e, message: t, endsAt: s }) {
3121
- const { t: r } = k(["maintenance"]), o = $().dir === "rtl";
3122
- return /* @__PURE__ */ n(
3123
- "div",
3124
- {
3125
- role: "status",
3126
- "aria-live": "polite",
3127
- dir: o ? "rtl" : "ltr",
3128
- className: "shrink-0 border-b border-warning/30 bg-warning/10 px-4 py-2.5",
3129
- children: /* @__PURE__ */ d("div", { className: "mx-auto flex max-w-[50rem] items-start gap-2.5", children: [
3130
- /* @__PURE__ */ n(zt, { className: "mt-0.5 size-4 shrink-0 text-warning" }),
3131
- /* @__PURE__ */ d("p", { className: "min-w-0 flex-1 text-sm leading-relaxed text-warning", children: [
3132
- /* @__PURE__ */ n("span", { className: "font-semibold", children: e }),
3133
- /* @__PURE__ */ n("span", { "aria-hidden": !0, className: "mx-1.5 opacity-50", children: "·" }),
3134
- /* @__PURE__ */ n("span", { children: t }),
3135
- s && /* @__PURE__ */ d("span", { className: "text-warning/80", children: [
3136
- " ",
3137
- r("maintenance:until", { datetime: s })
3138
- ] })
3139
- ] })
3140
- ] })
3141
- }
3142
- );
3143
- }
3144
- function ga({ title: e, message: t, endsAt: s, refresh: r }) {
3145
- const { t: o } = k(["maintenance"]), i = $().dir === "rtl";
3146
- return /* @__PURE__ */ n(
3147
- "div",
3148
- {
3149
- role: "status",
3150
- "aria-live": "polite",
3151
- dir: i ? "rtl" : "ltr",
3152
- className: "flex min-h-dvh w-full flex-1 items-center justify-center bg-background px-6",
3153
- children: /* @__PURE__ */ d("div", { className: "flex max-w-md flex-col items-center gap-4 text-center", children: [
3154
- /* @__PURE__ */ n("div", { className: "flex size-14 items-center justify-center rounded-2xl border border-warning/30 bg-warning/10", children: /* @__PURE__ */ n(zt, { className: "size-6 text-warning" }) }),
3155
- /* @__PURE__ */ n("h1", { className: "text-xl font-semibold text-foreground", children: e }),
3156
- /* @__PURE__ */ n("p", { className: "text-sm leading-relaxed text-muted-foreground", children: t }),
3157
- s && /* @__PURE__ */ n("p", { className: "text-xs text-muted-foreground/80", children: o("maintenance:until", { datetime: s }) }),
3158
- /* @__PURE__ */ d(F, { variant: "outline", size: "sm", onClick: r, className: "mt-2 gap-2", children: [
3159
- /* @__PURE__ */ n(ns, { className: "size-3.5" }),
3160
- o("maintenance:retry")
3161
- ] })
3162
- ] })
3163
- }
3164
- );
3165
- }
3166
- const ha = {
3167
- MessageList: ho,
3168
- MessageActions: yo,
3169
- PromptInput: Jo,
3170
- WelcomeScreen: Zo,
3171
- parts: eo,
3172
- ChoiceQuestionPart: Gr,
3173
- ChoiceQuestionDock: ea,
3174
- FollowUpSuggestions: ra,
3175
- ChatError: oa,
3176
- UsageMeter: pa,
3177
- MaintenanceBanner: fa,
3178
- MaintenanceScreen: ga
3179
- };
3180
- function Za(e, t) {
3181
- if (!t) return e;
3182
- const s = { ...e };
3183
- for (const [r, o] of Object.entries(t))
3184
- o !== void 0 && (s[r] = o);
3185
- return {
3186
- ...s,
3187
- parts: t.parts ? { ...e.parts, ...t.parts } : e.parts,
3188
- referenceAdapters: t.referenceAdapters ? { ...e.referenceAdapters, ...t.referenceAdapters } : e.referenceAdapters
3189
- };
3190
- }
3191
- const ba = te(ha);
3192
- function B() {
3193
- return le(ba);
3194
- }
3195
- function ei({ ...e }) {
3196
- return /* @__PURE__ */ n(q.Root, { "data-slot": "select", ...e });
3197
- }
3198
- function ti({ ...e }) {
3199
- return /* @__PURE__ */ n(q.Value, { "data-slot": "select-value", ...e });
3200
- }
3201
- function ni({
3202
- className: e,
3203
- size: t = "default",
3204
- children: s,
3205
- ...r
3206
- }) {
3207
- return /* @__PURE__ */ d(
3208
- q.Trigger,
3209
- {
3210
- "data-slot": "select-trigger",
3211
- "data-size": t,
3212
- className: p(
3213
- // Inside a form, Radix renders a hidden native <select> right after the trigger, so a trigger that
3214
- // ends its `space-y-*` stack is no longer the last child and picks up a stray bottom margin.
3215
- "[&:has(+select[aria-hidden]:last-child)]:mb-0",
3216
- "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
3217
- e
3218
- ),
3219
- ...r,
3220
- children: [
3221
- s,
3222
- /* @__PURE__ */ n(q.Icon, { asChild: !0, children: /* @__PURE__ */ n(ne, { className: "size-4 opacity-50" }) })
3223
- ]
3224
- }
3225
- );
3226
- }
3227
- function si({
3228
- className: e,
3229
- children: t,
3230
- position: s = "popper",
3231
- ...r
3232
- }) {
3233
- const o = Q();
3234
- return /* @__PURE__ */ n(q.Portal, { container: o, children: /* @__PURE__ */ d(
3235
- q.Content,
3236
- {
3237
- "data-slot": "select-content",
3238
- className: p(
3239
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
3240
- s === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
3241
- e
3242
- ),
3243
- position: s,
3244
- ...r,
3245
- children: [
3246
- /* @__PURE__ */ n(va, {}),
3247
- /* @__PURE__ */ n(
3248
- q.Viewport,
3249
- {
3250
- className: p(
3251
- "p-1",
3252
- s === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
3253
- ),
3254
- children: t
3255
- }
3256
- ),
3257
- /* @__PURE__ */ n(xa, {})
3258
- ]
3259
- }
3260
- ) });
3261
- }
3262
- function ri({ className: e, children: t, ...s }) {
3263
- return /* @__PURE__ */ d(
3264
- q.Item,
3265
- {
3266
- "data-slot": "select-item",
3267
- className: p(
3268
- "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 text-start",
3269
- e
3270
- ),
3271
- ...s,
3272
- children: [
3273
- /* @__PURE__ */ n("span", { className: "absolute end-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ n(q.ItemIndicator, { children: /* @__PURE__ */ n(ce, { className: "size-4" }) }) }),
3274
- /* @__PURE__ */ n(q.ItemText, { children: t })
3275
- ]
3276
- }
3277
- );
3278
- }
3279
- function va({ className: e, ...t }) {
3280
- return /* @__PURE__ */ n(
3281
- q.ScrollUpButton,
3282
- {
3283
- "data-slot": "select-scroll-up-button",
3284
- className: p("flex cursor-default items-center justify-center py-1", e),
3285
- ...t,
3286
- children: /* @__PURE__ */ n(ss, { className: "size-4" })
3287
- }
3288
- );
3289
- }
3290
- function xa({
3291
- className: e,
3292
- ...t
3293
- }) {
3294
- return /* @__PURE__ */ n(
3295
- q.ScrollDownButton,
3296
- {
3297
- "data-slot": "select-scroll-down-button",
3298
- className: p("flex cursor-default items-center justify-center py-1", e),
3299
- ...t,
3300
- children: /* @__PURE__ */ n(ne, { className: "size-4" })
3301
- }
3302
- );
3303
- }
3304
- function oi({ className: e, ...t }) {
3305
- return /* @__PURE__ */ n(
3306
- rt.Root,
3307
- {
3308
- "data-slot": "checkbox",
3309
- className: p(
3310
- "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
3311
- e
3312
- ),
3313
- ...t,
3314
- children: /* @__PURE__ */ n(
3315
- rt.Indicator,
3316
- {
3317
- "data-slot": "checkbox-indicator",
3318
- className: "grid place-content-center text-current transition-none",
3319
- children: /* @__PURE__ */ n(ce, { className: "size-3.5" })
3320
- }
3321
- )
3322
- }
3323
- );
3324
- }
3325
- const ya = Oe(
3326
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
3327
- ), wa = ke.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ n(
3328
- "label",
3329
- {
3330
- ref: s,
3331
- className: p(ya(), e),
3332
- ...t
3333
- }
3334
- ));
3335
- wa.displayName = "Label";
3336
- function ai({ className: e, type: t, ...s }) {
3337
- return /* @__PURE__ */ n(
3338
- "input",
3339
- {
3340
- type: t,
3341
- "data-slot": "input",
3342
- className: p(
3343
- "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
3344
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
3345
- "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
3346
- e
3347
- ),
3348
- ...s
3349
- }
3350
- );
3351
- }
3352
- function ii({ ...e }) {
3353
- return /* @__PURE__ */ n(_.Root, { "data-slot": "sheet", ...e });
3354
- }
3355
- function Na({ ...e }) {
3356
- const t = Q();
3357
- return /* @__PURE__ */ n(_.Portal, { "data-slot": "sheet-portal", container: t, ...e });
3358
- }
3359
- function ka({ className: e, ...t }) {
3360
- return /* @__PURE__ */ n(
3361
- _.Overlay,
3362
- {
3363
- "data-slot": "sheet-overlay",
3364
- className: p(
3365
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-overlay",
3366
- e
3367
- ),
3368
- ...t
3369
- }
3370
- );
3371
- }
3372
- function li({
3373
- className: e,
3374
- children: t,
3375
- side: s = "end",
3376
- ...r
3377
- }) {
3378
- return /* @__PURE__ */ d(Na, { children: [
3379
- /* @__PURE__ */ n(ka, {}),
3380
- /* @__PURE__ */ d(
3381
- _.Content,
3382
- {
3383
- "data-slot": "sheet-content",
3384
- className: p(
3385
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
3386
- s === "end" && "data-[state=closed]:slide-out-to-end data-[state=open]:slide-in-from-end inset-y-0 end-0 h-full w-3/4 border-s sm:max-w-sm",
3387
- s === "start" && "data-[state=closed]:slide-out-to-start data-[state=open]:slide-in-from-start inset-y-0 start-0 h-full w-3/4 border-e sm:max-w-sm",
3388
- s === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
3389
- s === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
3390
- e
3391
- ),
3392
- ...r,
3393
- children: [
3394
- t,
3395
- /* @__PURE__ */ d(_.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 end-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
3396
- /* @__PURE__ */ n(V, { className: "size-4" }),
3397
- /* @__PURE__ */ n(Ca, {})
3398
- ] })
3399
- ]
3400
- }
3401
- )
3402
- ] });
3403
- }
3404
- function ci({ className: e, ...t }) {
3405
- return /* @__PURE__ */ n("div", { "data-slot": "sheet-header", className: p("flex flex-col gap-1.5 p-4", e), ...t });
3406
- }
3407
- function di({ className: e, ...t }) {
3408
- return /* @__PURE__ */ n(
3409
- _.Title,
3410
- {
3411
- "data-slot": "sheet-title",
3412
- className: p("text-foreground font-semibold", e),
3413
- ...t
3414
- }
3415
- );
3416
- }
3417
- function ui({ className: e, ...t }) {
3418
- return /* @__PURE__ */ n(
3419
- _.Description,
3420
- {
3421
- "data-slot": "sheet-description",
3422
- className: p("text-muted-foreground text-sm", e),
3423
- ...t
3424
- }
3425
- );
3426
- }
3427
- function Ca() {
3428
- const { t: e } = k("common");
3429
- return /* @__PURE__ */ n("span", { className: "sr-only", children: e("close") });
3430
- }
3431
- const _a = "data:image/svg+xml,%3csvg%20version='1.2'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201280%201280'%20width='500'%20height='500'%3e%3cstyle%3e%20.s0%20{%20opacity:%201;fill:%20%2317535d%20}%20.s1%20{%20opacity:%20.99;fill:%20%23fab185%20}%20%3c/style%3e%3cg%20id='gentiq%20(7)'%3e%3cpath%20id='Path%201'%20fill-rule='evenodd'%20class='s0'%20d='m616.5%2012.22c19.25-0.09%2038.15%200.29%2042%200.84%203.85%200.54%2011.73%201.43%2017.5%201.98%205.77%200.55%2016.35%201.85%2023.5%202.91%207.15%201.05%2016.6%202.62%2021%203.49%204.4%200.88%209.8%202.02%2012%202.53%202.2%200.52%207.15%201.65%2011%202.5%203.85%200.86%208.58%202%2010.5%202.54%201.92%200.54%207.77%202.15%2013%203.6%205.23%201.44%2016.02%204.77%2024%207.4%207.98%202.63%2017.65%205.99%2021.5%207.48%203.85%201.48%2011.95%204.74%2018%207.24%206.05%202.5%2014.6%206.16%2019%208.14%204.4%201.98%2013.4%206.35%2020%209.72%206.6%203.36%2014.48%207.47%2017.5%209.11%203.02%201.65%2011.35%206.5%2018.5%2010.77%207.15%204.27%2018.17%2011.2%2024.49%2015.4%206.32%204.2%2012.17%208.16%2013%208.82%200.83%200.65%207.36%205.55%2014.51%2010.88%207.15%205.33%2013.23%209.97%2013.5%2010.31%200.27%200.34%202.73%202.42%205.45%204.62%202.72%202.2%205.43%204.45%206.02%205%200.59%200.55%204.89%204.35%209.55%208.45%204.67%204.1%2015.04%2014%2023.05%2022%208.02%208%2018.22%2018.6%2022.67%2023.55%204.46%204.95%2011.4%2013.07%2015.43%2018.04%204.03%204.97%2011.43%2014.42%2016.43%2021%205.01%206.58%2012.65%2017.36%2016.97%2023.96%204.33%206.6%208.56%2013.15%209.4%2014.57%200.84%201.41%204.08%206.81%207.19%2012%203.11%205.18%207.29%2012.36%209.29%2015.93%202%203.57%207.6%2014.6%2012.44%2024.5%204.84%209.9%2010.51%2022.05%2012.6%2027%202.08%204.95%204.36%2010.35%205.07%2012%200.71%201.65%202.26%205.48%203.44%208.5%201.19%203.02%204.44%2012.25%207.22%2020.5%202.79%208.25%205.42%2016.35%205.84%2018%200.43%201.65%201.72%206.15%202.87%2010%201.15%203.85%203.86%2014.43%206.03%2023.5%202.16%209.07%204.38%2019.2%204.94%2022.5%200.56%203.3%201.5%208.7%202.1%2012%200.59%203.3%201.68%2010.05%202.43%2015%200.74%204.95%201.85%2013.27%202.47%2018.5%200.61%205.23%201.56%2018.95%202.11%2030.5%200.55%2011.55%200.99%2034.61%200.99%2051.25%200%2019.16-0.37%2030.43-1%2030.75-0.55%200.27-1%202.64-1.01%205.25%200%202.61-0.43%207.45-0.96%2010.75-0.52%203.3-1.7%2011.17-2.62%2017.5-0.92%206.33-2.02%2013.52-2.44%2016-0.43%202.48-1.29%207.42-1.93%2011-0.63%203.58-2.7%2013.02-4.6%2021-1.9%207.98-3.93%2016.3-4.51%2018.5-0.58%202.2-2.41%208.5-4.05%2014-1.64%205.5-4.8%2015.4-7.01%2022-2.21%206.6-4.39%2012.9-4.85%2014-0.46%201.1-2.22%205.71-3.92%2010.25-1.71%204.54-3.44%208.24-3.85%208.22-0.41-0.02-2.55-1.5-4.75-3.29-2.2-1.8-6.25-4.85-9-6.79-2.75-1.94-9.95-6.45-16-10.03-6.05-3.58-14.83-8.34-19.5-10.57-4.67-2.23-10.64-5.01-13.25-6.18-2.61-1.16-8.91-3.51-14-5.21-5.09-1.71-10.71-3.51-12.5-4-1.79-0.5-4.94-1.38-7-1.96-2.06-0.58-6.9-1.73-10.75-2.54-3.85-0.82-9.47-1.94-12.5-2.48-3.02-0.54-10.9-1.64-17.5-2.44-6.6-0.81-18.52-1.46-26.5-1.45-7.98%200-20.13%200.68-27%201.5-6.88%200.81-13.85%201.75-15.5%202.08-1.65%200.32-7.27%201.43-12.5%202.47-5.23%201.04-12.65%202.83-16.5%203.98-3.85%201.16-9.02%202.67-11.5%203.38-2.48%200.7-9.45%203.31-15.5%205.8-6.05%202.49-14.6%206.3-19%208.46-4.4%202.17-12.05%206.39-17%209.38-4.95%203-13.5%208.66-19%2012.58-5.5%203.92-12.7%209.48-16%2012.36-3.3%202.88-8.88%207.99-12.41%2011.36-3.52%203.36-9.6%209.72-13.5%2014.12-3.9%204.4-7.32%208.23-7.59%208.5-0.27%200.27-2.09%202.52-4.04%205-1.94%202.48-4.39%205.85-5.43%207.5-1.04%201.65-2.38%203.47-2.96%204.05-0.59%200.58-3.12%204.4-5.63%208.5-2.5%204.1-5.89%209.7-7.53%2012.45-1.63%202.75-4.16%207.48-5.61%2010.5-1.45%203.02-4.03%208.42-5.73%2012-1.71%203.58-3.1%206.95-3.09%207.5%200%200.55-0.69%202.35-1.54%204-0.85%201.65-2.83%206.83-4.39%2011.5-1.56%204.67-4.24%2014.12-5.95%2021-1.71%206.87-4.01%2019.25-5.1%2027.5-1.42%2010.7-1.99%2020.73-1.99%2035%200%2014.2%200.58%2024.35%201.98%2035%201.09%208.25%203.53%2021.08%205.43%2028.5%201.9%207.42%204.63%2016.87%206.07%2021%201.44%204.12%203.03%208.4%203.54%209.5%200.5%201.1%201.87%204.47%203.03%207.5%201.16%203.03%204.23%209.78%206.82%2015%202.59%205.22%205.48%2010.62%206.42%2012%200.94%201.37%201.73%202.72%201.74%203%200.01%200.28-1.91%201.07-4.26%201.77-2.35%200.7-8.55%202.17-13.78%203.28-5.23%201.11-11.98%202.47-15%203.03-3.02%200.55-7.75%201.43-10.5%201.95-2.75%200.52-10.63%201.65-17.5%202.53-6.88%200.87-16.33%202-21%202.5-4.67%200.5-17.27%201.4-28%202.01-11.32%200.65-29.56%200.85-43.5%200.48-13.2-0.35-27.83-1.06-32.5-1.57-4.67-0.52-14.8-1.66-22.5-2.54-7.7-0.88-17.6-2.21-22-2.95-4.4-0.75-14.98-2.78-23.5-4.5-8.52-1.73-18.88-4.05-23-5.15-4.13-1.1-10.2-2.68-13.5-3.51-3.3-0.83-10.27-2.86-15.5-4.51-5.23-1.65-12.88-4.1-17-5.45-4.13-1.35-8.4-2.85-9.5-3.33-1.1-0.47-6.5-2.54-12-4.6-5.5-2.05-11.8-4.52-14-5.49-2.2-0.97-8.73-3.88-14.5-6.47-5.77-2.59-15.45-7.18-21.5-10.21-6.05-3.02-14.38-7.3-18.5-9.51-4.13-2.2-7.95-4.36-8.5-4.78-0.55-0.42-3.25-2.02-6-3.54-2.75-1.52-12.65-7.69-22-13.71-9.35-6.02-23.75-16.02-32-22.22-8.25-6.21-16.78-12.8-18.96-14.65-2.18-1.85-8.68-7.41-14.44-12.36-5.77-4.95-17.28-15.75-25.58-24-8.3-8.25-17.33-17.48-20.07-20.5-2.74-3.02-7.71-8.65-11.05-12.5-3.34-3.85-9.97-11.95-14.75-18-4.77-6.05-9.02-11.45-9.44-12-0.42-0.55-3.51-4.83-6.87-9.5-3.36-4.67-8.78-12.55-12.05-17.5-3.26-4.95-8.45-13.05-11.52-18-3.07-4.95-8.47-14.17-11.99-20.5-3.53-6.33-9.38-17.58-13-25-3.63-7.42-7.59-15.75-8.8-18.5-1.21-2.75-3.22-7.25-4.45-10-1.24-2.75-2.6-6.13-3.02-7.5-0.43-1.38-1.6-4.3-2.61-6.5-1.01-2.2-3.68-9.17-5.94-15.5-2.27-6.33-4.71-13.3-5.43-15.5-0.73-2.2-2.52-8.05-3.99-13-1.46-4.95-3.06-10.13-3.55-11.5-0.49-1.38-2.5-9.25-4.47-17.5-1.98-8.25-4.02-16.8-4.54-19-0.52-2.2-1.42-6.7-2-10-0.58-3.3-1.67-9.6-2.42-14-0.75-4.4-1.83-11.6-2.41-16-0.58-4.4-1.54-12.5-2.13-18-0.59-5.5-1.51-10.11-2.05-10.25-0.6-0.16-0.97-11.89-0.96-31%200-16.91%200.44-39.3%200.97-49.75%200.53-10.45%201.45-23.73%202.03-29.5%200.59-5.77%201.55-14.1%202.13-18.5%200.58-4.4%201.67-11.6%202.42-16%200.75-4.4%201.84-10.7%202.42-14%200.58-3.3%201.48-7.8%202-10%200.52-2.2%202.56-10.75%204.54-19%201.97-8.25%203.98-16.13%204.47-17.5%200.48-1.38%201.84-5.88%203.02-10%201.18-4.13%204.4-14.02%207.15-22%202.75-7.98%205.36-15.4%205.81-16.5%200.44-1.1%201.97-4.7%203.39-8%201.43-3.3%202.6-6.34%202.61-6.75%200.02-0.41%201.2-3.34%202.64-6.5%201.43-3.16%203.3-7.32%204.15-9.25%200.86-1.93%204.59-9.8%208.3-17.5%203.71-7.7%209.76-19.4%2013.45-26%203.68-6.6%209.22-16.05%2012.3-21%203.08-4.95%208.58-13.5%2012.22-19%203.64-5.5%207.72-11.57%209.05-13.5%201.34-1.93%204.43-6.2%206.87-9.5%202.43-3.3%207.79-10.28%2011.91-15.5%204.11-5.22%2010.67-13.1%2014.56-17.5%203.89-4.4%209.08-10.25%2011.53-13%202.44-2.75%2010.77-11.3%2018.5-19.01%207.73-7.7%2019.23-18.52%2025.55-24.04%206.32-5.51%2015.1-12.94%2019.5-16.49%204.4-3.56%2010.02-7.96%2012.5-9.77%202.48-1.82%207.43-5.45%2011-8.06%203.57-2.62%209.43-6.72%2013-9.11%203.57-2.39%208.3-5.57%2010.5-7.06%202.2-1.49%209.85-6.21%2017-10.48%207.15-4.28%2015.48-9.13%2018.5-10.78%203.02-1.66%2010.92-5.75%2017.53-9.1%206.62-3.36%2015.17-7.53%2019-9.27%203.84-1.75%2010.12-4.52%2013.97-6.17%203.85-1.66%2012.4-5.11%2019-7.67%206.6-2.56%2018.64-6.87%2026.75-9.58%208.11-2.7%2016.44-5.33%2018.5-5.85%202.06-0.52%207.12-1.9%2011.25-3.06%204.12-1.17%2010.43-2.8%2014-3.63%203.57-0.84%208.07-1.88%2010-2.32%201.93-0.45%207.1-1.54%2011.5-2.42%204.4-0.89%2010.25-2.05%2013-2.58%202.75-0.53%207.25-1.24%2010-1.57%202.75-0.34%207.25-1.02%2010-1.52%202.75-0.5%2010.4-1.45%2017-2.1%206.6-0.65%2016.95-1.48%2023-1.84%206.05-0.36%2026.75-0.72%2046-0.8zm-42.29%20288.46c-6.99%200.78-16.76%202.31-21.71%203.4-4.95%201.09-11.48%202.67-14.5%203.51-3.02%200.84-7.98%202.24-11%203.12-3.02%200.88-10.45%203.5-16.5%205.83-6.05%202.33-14.82%206-19.5%208.16-4.68%202.15-12.77%206.32-18%209.26-5.23%202.94-13.32%207.87-18%2010.95-4.68%203.09-11.2%207.62-14.5%2010.08-3.3%202.45-8.93%206.92-12.5%209.92-3.57%203.01-12.15%2011.12-19.05%2018.03-6.9%206.91-15.61%2016.38-19.34%2021.06-3.73%204.68-10.49%2014.13-15.01%2021-4.53%206.88-9.98%2015.65-12.11%2019.5-2.13%203.85-5.64%2010.6-7.79%2015-2.15%204.4-5.5%2011.82-7.43%2016.5-1.94%204.68-4.38%2011.2-5.43%2014.5-1.06%203.3-3.22%2010.5-4.81%2016-1.59%205.5-3.42%2012.7-4.06%2016-0.64%203.3-1.58%208.25-2.08%2011-0.5%202.75-1.58%209.95-2.39%2016-0.95%207.05-1.49%2019.36-1.49%2034.25-0.01%2012.79%200.45%2026.51%201.02%2030.5%200.56%203.99%201.5%2010.17%202.07%2013.75%200.58%203.58%201.73%209.88%202.57%2014%200.84%204.13%202.88%2012.23%204.53%2018%201.65%205.77%204.12%2013.88%205.5%2018%201.37%204.13%202.84%207.95%203.27%208.5%200.42%200.55%201.68%203.48%202.79%206.5%201.11%203.02%203.79%209.1%205.94%2013.5%202.15%204.4%205.66%2011.15%207.78%2015%202.13%203.85%207.59%2012.63%2012.14%2019.5%204.54%206.88%2011.3%2016.33%2015.02%2021%203.73%204.67%2012.09%2013.9%2018.58%2020.5%206.5%206.6%2014.62%2014.29%2018.05%2017.09%203.43%202.8%2010.05%207.98%2014.73%2011.51%204.68%203.53%2012.1%208.74%2016.5%2011.58%204.4%202.83%2010.02%206.3%2012.5%207.7%202.48%201.4%209.45%204.99%2015.5%207.97%206.05%202.98%2013.25%206.42%2016%207.65%202.75%201.23%2012.2%204.61%2021%207.5%208.8%202.9%2021.62%206.44%2028.5%207.89%206.87%201.44%2014.52%203.04%2017%203.55%202.48%200.51%2013.27%201.48%2024%202.15%2015.34%200.97%2023.66%200.97%2039%200.01%2010.73-0.67%2021.3-1.6%2023.5-2.08%202.2-0.47%206.7-1.37%2010-1.99%203.3-0.63%208.92-1.82%2012.5-2.66%203.58-0.84%2010.1-2.58%2014.5-3.87%204.4-1.29%2012.27-3.89%2017.5-5.78%205.23-1.89%2011.51-4.29%2013.96-5.33%202.46-1.04%2010.33-4.84%2017.5-8.44%207.17-3.61%2018.21-9.87%2024.54-13.92%206.33-4.04%2012.68-8.3%2014.12-9.44%201.45-1.15%203.87-2.99%205.39-4.09%201.53-1.1%203.56-2.67%204.52-3.5%200.97-0.83%204.51-3.75%207.88-6.5%203.37-2.75%2011.85-10.86%2018.86-18.02%207-7.16%2016.15-17.51%2020.34-23%204.19-5.49%2010.3-14.03%2013.6-18.98%203.29-4.95%207.48-11.7%209.3-15%201.83-3.3%205.43-10.27%208.02-15.5%202.58-5.23%205.41-11.08%206.28-13%200.88-1.92%202.57-5.98%203.75-9%201.18-3.02%203.02-8.2%204.08-11.5%201.07-3.3%203.22-10.5%204.78-16%201.56-5.5%203.34-12.02%203.96-14.5%200.61-2.48%201.6-7.42%202.18-11%200.59-3.58%201.51-9.65%202.04-13.5%200.54-3.85%201.34-13.98%201.79-22.5%200.44-8.52%200.44-22.25%200-30.5-0.45-8.25-1.25-18.15-1.79-22-0.53-3.85-1.46-9.92-2.05-13.5-0.59-3.58-2.01-10.33-3.14-15-1.14-4.67-2.44-9.62-2.89-11-0.45-1.37-1.84-5.87-3.08-10-1.24-4.12-3.56-10.87-5.15-15-1.59-4.12-3.6-9.07-4.47-11-0.87-1.93-3.71-7.77-6.31-13-2.59-5.23-5.55-11.07-6.56-13-1.01-1.93-3.99-6.87-6.62-11-2.63-4.12-7.45-11.32-10.7-16-3.25-4.68-9.5-12.77-13.89-18-4.39-5.23-13.1-14.45-19.36-20.5-6.26-6.05-15.21-14.06-19.88-17.8-4.68-3.74-10.92-8.47-13.88-10.5-2.96-2.04-9.26-6.13-14-9.1-4.74-2.97-13.12-7.77-18.62-10.66-5.5-2.89-14.5-7.13-20-9.42-5.5-2.28-10.9-4.56-12-5.06-1.1-0.49-6.05-2.24-11-3.88-4.95-1.65-11.02-3.49-13.5-4.09-2.48-0.6-9.23-2.16-15-3.47-5.77-1.3-15.9-3.11-22.5-4.02-6.81-0.93-20.87-1.79-32.5-1.97-11.27-0.17-22.66-0.08-25.29%200.21-2.63%200.29-10.51%201.16-17.5%201.94z'/%3e%3cpath%20id='Path%202'%20class='s1'%20d='m953.5%20831.1c-2.75%200.49-7.7%201.38-11%201.99-3.3%200.61-8.48%201.77-11.5%202.57-3.02%200.81-9.33%202.84-14%204.52-4.67%201.68-13%205.31-18.5%208.06-5.5%202.75-12.48%206.61-15.5%208.58-3.02%201.97-8.2%205.61-11.5%208.08-3.3%202.47-9.33%207.44-13.39%2011.05-4.07%203.6-10.64%2010.38-14.61%2015.05-3.96%204.67-10.02%2012.77-13.46%2018-3.44%205.22-7.84%2012.65-9.78%2016.5-1.94%203.85-5.1%2011.05-7.02%2016-1.92%204.95-4.35%2011.92-5.39%2015.5-1.04%203.58-2.57%209.65-3.39%2013.5-0.83%203.85-2%2013.3-2.61%2021-0.81%2010.28-0.8%2017.79%200.02%2028.25%200.62%207.84%202.22%2018.86%203.55%2024.5%201.33%205.64%203.42%2013.17%204.65%2016.75%201.22%203.58%204%2010.55%206.17%2015.5%202.17%204.95%206.32%2013.05%209.22%2018%202.91%204.95%207.71%2012.22%2010.66%2016.15%202.96%203.94%208.08%2010.19%2011.38%2013.89%203.3%203.7%2010.05%2010.13%2015%2014.28%204.95%204.15%2013.05%2010.21%2018%2013.47%204.95%203.25%2011.92%207.4%2015.5%209.2%203.58%201.81%2010.55%204.92%2015.5%206.91%204.95%201.99%2012.83%204.69%2017.5%206%204.67%201.3%209.85%202.69%2011.5%203.07%201.65%200.39%206.83%201.33%2011.5%202.1%205.11%200.84%2015.89%201.4%2027%201.4%2010.17%200%2020.08-0.41%2022-0.92%201.92-0.5%206.2-1.45%209.5-2.1%203.3-0.65%2010.27-2.42%2015.5-3.93%205.22-1.5%2013.55-4.41%2018.5-6.46%204.95-2.05%2013.05-5.96%2018-8.68%204.95-2.73%2013.5-8.3%2019-12.39%205.5-4.08%2013.97-11.38%2018.82-16.21%204.86-4.83%2012.1-13.06%2016.09-18.28%203.99-5.22%209.09-12.65%2011.32-16.5%202.23-3.85%205.93-10.83%208.21-15.5%202.28-4.67%205.68-13.22%207.55-19%201.87-5.78%203.86-12.3%204.41-14.5%200.55-2.2%201.7-8.39%202.55-13.75%200.98-6.14%201.55-16.31%201.54-27.5%200-12.91-0.53-20.88-1.94-29.25-1.06-6.33-3.1-15.33-4.52-20-1.43-4.67-3.03-9.29-3.56-10.25-0.53-0.96-0.97-2.2-0.97-2.75%200-0.55-0.86-2.91-1.92-5.25-1.06-2.34-2.98-6.5-4.28-9.25-1.29-2.75-4.32-8.38-6.72-12.5-2.41-4.13-5.99-9.75-7.98-12.5-1.98-2.75-4.5-6.1-5.6-7.45-1.1-1.35-4.03-4.71-6.5-7.48-2.47-2.76-5.63-6.17-7-7.56-1.38-1.39-5.65-5.28-9.5-8.64-3.85-3.36-11.5-9.16-17-12.89-5.5-3.73-14.3-8.85-19.55-11.38-5.26-2.53-10.88-5.15-12.5-5.82-1.62-0.68-6.33-2.39-10.45-3.8-4.13-1.42-10.65-3.26-14.5-4.09-3.85-0.84-10.83-2.16-15.5-2.94-5.29-0.88-15.11-1.38-26-1.32-9.63%200.05-19.75%200.49-22.5%200.97z'/%3e%3c/g%3e%3c/svg%3e", mi = _a;
3432
- export {
3433
- ea as $,
3434
- ia as A,
3435
- F as B,
3436
- Ga as C,
3437
- bt as D,
3438
- pe as E,
3439
- Ge as F,
3440
- _r as G,
3441
- Sr as H,
3442
- ai as I,
3443
- Dr as J,
3444
- mi as K,
3445
- wa as L,
3446
- ye as M,
3447
- Tr as N,
3448
- Pr as O,
3449
- Cr as P,
3450
- Wa as Q,
3451
- pr as R,
3452
- ba as S,
3453
- bo as T,
3454
- vs as U,
3455
- Qa as V,
3456
- Eo as W,
3457
- Oo as X,
3458
- qo as Y,
3459
- jo as Z,
3460
- oa as _,
3461
- Za as a,
3462
- Gr as a0,
3463
- Ur as a1,
3464
- ra as a2,
3465
- fa as a3,
3466
- ga as a4,
3467
- yo as a5,
3468
- ho as a6,
3469
- Jo as a7,
3470
- tn as a8,
3471
- yr as a9,
3472
- Hr as aa,
3473
- sa as ab,
3474
- na as ac,
3475
- gr as ad,
3476
- Br as ae,
3477
- pa as af,
3478
- Zo as ag,
3479
- he as ah,
3480
- Bt as ai,
3481
- Ft as aj,
3482
- Ka as ak,
3483
- Nr as al,
3484
- Le as am,
3485
- Be as an,
3486
- Fe as ao,
3487
- Va as ap,
3488
- Ja as aq,
3489
- Xa as ar,
3490
- mt as as,
3491
- Q as b,
3492
- p as c,
3493
- se as d,
3494
- eo as e,
3495
- ei as f,
3496
- ni as g,
3497
- ti as h,
3498
- si as i,
3499
- ri as j,
3500
- oi as k,
3501
- _o as l,
3502
- Ha as m,
3503
- ii as n,
3504
- li as o,
3505
- ci as p,
3506
- di as q,
3507
- bs as r,
3508
- ui as s,
3509
- Ve as t,
3510
- B as u,
3511
- Qe as v,
3512
- We as w,
3513
- aa as x,
3514
- Ya as y,
3515
- an as z
3516
- };