@versini/sassysaint 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,866 +0,0 @@
1
- import { jsxs as E, jsx as n, Fragment as ye } from "react/jsx-runtime";
2
- import { O as Be, s as Ve, S as De, f$1 as $e, M as ze, U as Ue, r as Fe, o as Pe, n as fe, l as Ge, a as Y, isLastMessageFromRole as he, x as xe, CANCEL as je, CLEAR as qe, ACTION_RESET as be, ROLE_ASSISTANT as M, ROLE_INTERNAL as Z, ROLE_USER as K, qr as ee, ROLE_SYSTEM as We, ROLE_HIDDEN as Ye, MODEL_GPT4 as ke, STATS_SEPARATOR as le, ACTION_MODEL as Ce, ACTION_MESSAGE as V, TYPE_QUESTION as Je, SEND as Qe, ACTION_STREAMING as Te, ERROR_MESSAGE as Xe, getMessageContaintWrapperClass as Ke, MessagesContainerHeader as Ze, ACTION_SEARCH as er, ACTION_SORT as rr, ACTION_RESTORE as tr, ACTION_LOCATION as B, getCurrentGeoLocation as or, c as sr, AppFooter as ar, LOCAL_STORAGE_PREFIX as J, LOCAL_STORAGE_SEARCH as nr, LOCAL_STORAGE_SORT as lr, LOCAL_STORAGE_LOCATION as cr } from "./index.iWfWxGn2.js";
3
- import { g as ve, AppContext as P, restCall as ir, E as Q, serviceCall as ce, SERVICE_TYPES as ie, HistoryContext as dr, k as ur } from "./useLocalStorage.ChFZVshd.js";
4
- import pr, { useState as I, useEffect as S, useRef as x, useLayoutEffect as z, useContext as re, lazy as mr, Suspense as de, useReducer as ue, useCallback as gr } from "react";
5
- import g from "clsx";
6
- const yr = ({
7
- className: e,
8
- viewBox: r,
9
- spacing: o,
10
- title: t,
11
- monotone: s,
12
- ...a
13
- }) => /* @__PURE__ */ E(
14
- ve,
15
- {
16
- defaultViewBox: "0 0 448 512",
17
- defaultClassName: "size-5",
18
- viewBox: r,
19
- className: e,
20
- spacing: o,
21
- title: t || "Copied",
22
- ...a,
23
- children: [
24
- /* @__PURE__ */ n(
25
- "path",
26
- {
27
- opacity: "0.4",
28
- d: "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zM337 209L209 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L303 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"
29
- }
30
- ),
31
- /* @__PURE__ */ n("path", { d: "M337 175c9.4 9.4 9.4 24.6 0 33.9L209 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L303 175c9.4-9.4 24.6-9.4 33.9 0z" })
32
- ]
33
- }
34
- ), fr = ({
35
- className: e,
36
- viewBox: r,
37
- spacing: o,
38
- title: t,
39
- monotone: s,
40
- ...a
41
- }) => /* @__PURE__ */ n(
42
- ve,
43
- {
44
- defaultViewBox: "0 0 512 512",
45
- defaultClassName: "size-5",
46
- viewBox: r,
47
- className: e,
48
- spacing: o,
49
- title: t || "Copy",
50
- ...a,
51
- children: /* @__PURE__ */ n("path", { d: "M64 464H288c8.8 0 16-7.2 16-16V384h48v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V224c0-35.3 28.7-64 64-64h64v48H64c-8.8 0-16 7.2-16 16V448c0 8.8 7.2 16 16 16zM224 304H448c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H224c-8.8 0-16 7.2-16 16V288c0 8.8 7.2 16 16 16zm-64-16V64c0-35.3 28.7-64 64-64H448c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H224c-35.3 0-64-28.7-64-64z" })
52
- }
53
- ), hr = () => "p-4 sm:max-w-md md:max-w-2xl", xr = ({ kind: e }) => g({
54
- "bg-surface-lighter dark:bg-surface-dark": e === "left",
55
- "bg-surface-accent": e === "right"
56
- }), br = ({ kind: e }) => g(
57
- "prose prose-dark dark:prose-lighter prose-p:my-3 prose-blockquote:my-3 prose-ol:my-3 prose-ul:my-3 prose-ul:prose-li:marker:text-black",
58
- {
59
- "text-copy-lighter": e === "right"
60
- }
61
- ), kr = ({ kind: e }) => g("rounded-b-xl", {
62
- "rounded-tr-xl": e === "left",
63
- "rounded-tl-xl": e === "right"
64
- }), Cr = ({
65
- kind: e,
66
- className: r,
67
- spacing: o
68
- }) => {
69
- const t = g(
70
- r,
71
- Ve,
72
- "flex items-start",
73
- De(o),
74
- {
75
- "flex-row-reverse": e === "right"
76
- }
77
- ), s = g(
78
- "flex flex-col empty:hidden",
79
- hr(),
80
- br({ kind: e }),
81
- xr({ kind: e }),
82
- kr({ kind: e })
83
- ), a = "pr-2 pt-1 text-end text-xs text-copy-light", l = g("flex flex-col-reverse gap-2 sm:flex-row", {
84
- "ml-2": e === "left",
85
- "mr-2": e === "right"
86
- });
87
- return {
88
- wrapper: t,
89
- main: s,
90
- footer: a,
91
- copyButton: l
92
- };
93
- }, Tr = ({
94
- children: e,
95
- kind: r = "left",
96
- className: o,
97
- footer: t,
98
- rawFooter: s,
99
- copyToClipboard: a,
100
- copyToClipboardFocusMode: l = "system",
101
- copyToClipboardMode: h = "system",
102
- spacing: c
103
- }) => {
104
- const [y, i] = I(!1), u = Cr({ kind: r, className: o, spacing: c }), b = !!a && (typeof a == "function" || typeof a == "string" || typeof e == "string"), v = () => {
105
- i(!0), typeof a == "function" ? a(e) : typeof a == "string" ? navigator.clipboard.writeText(a) : typeof e == "string" && navigator.clipboard.writeText(e);
106
- };
107
- return S(() => {
108
- let d;
109
- return y && (d = window.setTimeout(() => {
110
- i(!1);
111
- }, 3e3)), () => {
112
- clearTimeout(d);
113
- };
114
- }, [y]), /* @__PURE__ */ E("div", { className: u.wrapper, children: [
115
- /* @__PURE__ */ E("div", { children: [
116
- /* @__PURE__ */ n("div", { className: u.main, children: e }),
117
- t && Object.keys(t).map((d) => t[d] ? /* @__PURE__ */ n("div", { className: "prose-p:m-0", children: /* @__PURE__ */ E("p", { className: u.footer, children: [
118
- d,
119
- ": ",
120
- t[d]
121
- ] }) }, `-${d}`) : null),
122
- s && s
123
- ] }),
124
- b && /* @__PURE__ */ n("div", { className: u.copyButton, children: /* @__PURE__ */ n(
125
- Be,
126
- {
127
- noBorder: !0,
128
- noBackground: !0,
129
- size: "small",
130
- mode: h,
131
- focusMode: l,
132
- label: y ? "Copied to clipboard" : "Copy to clipboard",
133
- onClick: v,
134
- disabled: y,
135
- children: y ? /* @__PURE__ */ n(yr, { className: "size-3" }) : /* @__PURE__ */ n(fr, { className: "size-3" })
136
- }
137
- ) })
138
- ] });
139
- };
140
- function vr({
141
- value: e,
142
- defaultValue: r,
143
- finalValue: o,
144
- onChange: t = () => {
145
- }
146
- }) {
147
- const [s, a] = I(
148
- r !== void 0 ? r : o
149
- );
150
- return e !== void 0 ? [e, t, !0] : [s, (l) => {
151
- a(l), t == null || t(l);
152
- }, !1];
153
- }
154
- const Nr = () => "rounded-md text-base h-20 min-h-[80px] resize-none overflow-hidden px-4 py-7", Ar = ({
155
- mode: e
156
- }) => g({
157
- "bg-surface-darker text-copy-lighter caret-copy-light": e === "dark",
158
- "bg-surface-lighter text-copy-dark caret-copy-dark": e === "light",
159
- "bg-surface-lighter text-copy-dark caret-copy-dark dark:bg-surface-darker dark:text-copy-lighter dark:caret-copy-light": e === "system",
160
- "bg-surface-darker text-copy-lighter caret-copy-light dark:bg-surface-lighter dark:text-copy-dark dark:caret-copy-dark": e === "alt-system"
161
- }), Er = ({
162
- focusMode: e
163
- }) => g("focus:outline focus:outline-2 focus:outline-offset-2", {
164
- "focus:outline-focus-dark": e === "dark",
165
- "focus:outline-focus-light": e === "light",
166
- "focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
167
- "focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
168
- }), Or = ({
169
- noBorder: e,
170
- error: r
171
- }) => g("border-2", {
172
- "border-border-dark": !e && !r,
173
- "focus:border-border-dark": !e && r,
174
- "border-border-error-dark": !e && r,
175
- "border-transparent": e
176
- }), Sr = ({
177
- disabled: e,
178
- raw: r,
179
- error: o,
180
- mode: t
181
- }) => {
182
- if (r)
183
- return "";
184
- if (e)
185
- return g("absolute px-2 cursor-not-allowed opacity-50 font-medium");
186
- if (!o)
187
- return g("absolute px-2 cursor-text font-medium", {
188
- "text-copy-medium": t === "dark",
189
- "text-copy-dark": t === "light",
190
- "text-copy-dark dark:text-copy-medium": t === "system",
191
- "text-copy-medium dark:text-copy-dark": t === "alt-system"
192
- });
193
- if (o)
194
- return g("absolute px-2 cursor-text font-medium", {
195
- "text-copy-medium": t === "dark",
196
- "text-copy-error-dark": t === "light",
197
- "text-copy-error-dark dark:text-copy-error-light": t === "system",
198
- "text-copy-medium dark:text-copy-error-dark": t === "alt-system"
199
- });
200
- }, wr = ({
201
- error: e,
202
- raw: r,
203
- mode: o,
204
- disabled: t
205
- }) => {
206
- if (r)
207
- return "";
208
- if (t)
209
- return g(
210
- Y,
211
- "absolute px-2 cursor-not-allowed opacity-50 font-medium"
212
- );
213
- if (!e)
214
- return g(Y, "absolute px-2 font-medium", {
215
- "text-copy-medium": o === "dark",
216
- "text-copy-dark": o === "light",
217
- "text-copy-dark dark:text-copy-medium": o === "system",
218
- "text-copy-medium dark:text-copy-dark": o === "alt-system"
219
- });
220
- if (e)
221
- return g(Y, "absolute px-2 font-medium", {
222
- "text-copy-error-light": o === "dark",
223
- "text-copy-error-dark": o === "light",
224
- "text-copy-error-dark dark:text-copy-error-light": o === "system",
225
- "dark:text-copy-error-dark text-copy-error-light": o === "alt-system"
226
- });
227
- }, Lr = ({
228
- className: e,
229
- textAreaClassName: r,
230
- raw: o,
231
- focusMode: t,
232
- disabled: s,
233
- noBorder: a,
234
- error: l,
235
- spacing: h,
236
- mode: c
237
- }) => {
238
- const y = o ? e : g(
239
- "relative flex w-full flex-col justify-center",
240
- Fe,
241
- e,
242
- Pe(h)
243
- ), i = o ? g(r) : g(
244
- fe,
245
- r,
246
- Nr(),
247
- Ar({ mode: c }),
248
- Er({ focusMode: t }),
249
- Or({
250
- noBorder: a,
251
- error: l
252
- }),
253
- {
254
- "disabled:cursor-not-allowed disabled:opacity-50": s
255
- }
256
- ), u = o ? void 0 : "sr-only", b = Sr({
257
- disabled: s,
258
- raw: o,
259
- error: l,
260
- mode: c
261
- }), v = wr({
262
- error: l,
263
- raw: o,
264
- mode: c,
265
- disabled: s
266
- }), d = o ? void 0 : g(Ge, "absolute");
267
- return {
268
- wrapper: y,
269
- textArea: i,
270
- accessibleLabel: u,
271
- visibleLabel: b,
272
- helperText: v,
273
- rightElement: d
274
- };
275
- }, Rr = ({
276
- scrollHeight: e,
277
- currentHeight: r,
278
- currentLabelOffset: o = 0,
279
- currentHelperTextOffset: t = 0
280
- }) => {
281
- let s, a;
282
- if (e > 0 && e !== r) {
283
- const l = e - r, h = Math.abs(l / 24);
284
- s = o + -1 * Math.sign(l) * (12 * h), a = t + Math.sign(l) * (12 * h);
285
- }
286
- return {
287
- labelOffset: s,
288
- helperTextOffset: a,
289
- scrollHeight: e
290
- };
291
- }, Ne = pr.forwardRef(
292
- ({
293
- id: e,
294
- name: r,
295
- label: o,
296
- error: t = !1,
297
- raw: s = !1,
298
- className: a,
299
- textAreaClassName: l,
300
- mode: h = "system",
301
- focusMode: c = "system",
302
- value: y,
303
- defaultValue: i,
304
- disabled: u = !1,
305
- noBorder: b = !1,
306
- labelId: v,
307
- helperText: d = "",
308
- helperTextOnFocus: w = !1,
309
- rightElement: T,
310
- onChange: p,
311
- onFocus: C,
312
- onBlur: L,
313
- spacing: N,
314
- ...D
315
- }, m) => {
316
- const A = x(null), Ee = $e([m, A]), $ = x(null), G = x(80), oe = x(-25), _ = x(null), se = x(30), j = x(null), H = ze({ id: e, prefix: `${fe}-` }), [Oe, Se] = I(0), [we, ae] = I(
317
- !!(!w && d)
318
- ), Le = `${r} error, ${d}`, R = Lr({
319
- className: a,
320
- textAreaClassName: l,
321
- error: t,
322
- raw: s,
323
- focusMode: c,
324
- disabled: u,
325
- noBorder: b,
326
- spacing: N,
327
- mode: h
328
- }), [O, Re] = vr({
329
- value: y,
330
- defaultValue: i,
331
- onChange: (k) => {
332
- p && p({
333
- target: {
334
- value: k
335
- }
336
- });
337
- }
338
- }), Me = (k) => {
339
- Re(k.target.value);
340
- }, Ie = (k) => {
341
- w && d && ae(!0), C && C(k);
342
- }, _e = (k) => {
343
- w && d && !O && ae(!1), L && L(k);
344
- };
345
- return z(() => {
346
- !s && T && $.current && $.current.offsetWidth > 0 && Se($.current.offsetWidth + 18 + 10);
347
- }, [T, s]), z(() => {
348
- s || A && A.current && O !== void 0 && (A.current.style.height = "inherit", A.current.style.height = A.current.scrollHeight + "px");
349
- }, [O, s]), z(() => {
350
- s || setTimeout(() => {
351
- var k;
352
- (k = _ == null ? void 0 : _.current) == null || k.style.setProperty(
353
- "--av-text-area-wrapper-transition",
354
- O ? "none" : "all 0.2s ease-out"
355
- );
356
- }, 0);
357
- }, [O, s]), z(() => {
358
- var k, ne;
359
- if (!s && A && A.current && O !== void 0) {
360
- const { labelOffset: q, helperTextOffset: W, scrollHeight: He } = Rr({
361
- scrollHeight: A.current.scrollHeight,
362
- currentHeight: G.current,
363
- currentLabelOffset: oe.current,
364
- currentHelperTextOffset: se.current
365
- });
366
- q && (oe.current = q, (k = _ == null ? void 0 : _.current) == null || k.style.setProperty(
367
- "--av-text-area-label",
368
- `${q}px`
369
- )), W && (se.current = W, (ne = j == null ? void 0 : j.current) == null || ne.style.setProperty(
370
- "--av-text-area-helper-text",
371
- `${W}px`
372
- )), G.current = He || G.current;
373
- }
374
- }, [O, s]), /* @__PURE__ */ E("div", { className: R.wrapper, children: [
375
- /* @__PURE__ */ n(
376
- "label",
377
- {
378
- htmlFor: H,
379
- id: v,
380
- className: R.accessibleLabel,
381
- children: o
382
- }
383
- ),
384
- /* @__PURE__ */ n(
385
- "textarea",
386
- {
387
- ref: Ee,
388
- id: H,
389
- name: r,
390
- disabled: u,
391
- placeholder: s ? void 0 : " ",
392
- className: R.textArea,
393
- rows: 1,
394
- ...d && { "aria-describedby": `${H}-helper` },
395
- ...t && { "aria-invalid": "true" },
396
- ...T && !s && { style: { paddingRight: Oe } },
397
- value: O,
398
- onChange: Me,
399
- onFocus: Ie,
400
- onBlur: _e,
401
- ...D
402
- }
403
- ),
404
- !s && /* @__PURE__ */ n(
405
- "label",
406
- {
407
- ref: _,
408
- "aria-hidden": !0,
409
- htmlFor: H,
410
- className: R.visibleLabel,
411
- children: o
412
- }
413
- ),
414
- we && /* @__PURE__ */ n(
415
- "div",
416
- {
417
- ref: j,
418
- id: `${H}-helper`,
419
- className: R.helperText,
420
- children: d
421
- }
422
- ),
423
- T && /* @__PURE__ */ n(
424
- "div",
425
- {
426
- ref: $,
427
- className: R.rightElement,
428
- children: T
429
- }
430
- ),
431
- t && d && /* @__PURE__ */ n(Ue, { politeness: "polite", clearAnnouncementDelay: 500, children: Le })
432
- ] });
433
- }
434
- );
435
- Ne.displayName = "TextArea";
436
- var f = [];
437
- for (var X = 0; X < 256; ++X)
438
- f.push((X + 256).toString(16).slice(1));
439
- function Mr(e, r = 0) {
440
- return (f[e[r + 0]] + f[e[r + 1]] + f[e[r + 2]] + f[e[r + 3]] + "-" + f[e[r + 4]] + f[e[r + 5]] + "-" + f[e[r + 6]] + f[e[r + 7]] + "-" + f[e[r + 8]] + f[e[r + 9]] + "-" + f[e[r + 10]] + f[e[r + 11]] + f[e[r + 12]] + f[e[r + 13]] + f[e[r + 14]] + f[e[r + 15]]).toLowerCase();
441
- }
442
- var U, Ir = new Uint8Array(16);
443
- function _r() {
444
- if (!U && (U = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !U))
445
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
446
- return U(Ir);
447
- }
448
- var Hr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
449
- const pe = {
450
- randomUUID: Hr
451
- };
452
- function te(e, r, o) {
453
- if (pe.randomUUID && !r && !e)
454
- return pe.randomUUID();
455
- e = e || {};
456
- var t = e.random || (e.rng || _r)();
457
- return t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, Mr(t);
458
- }
459
- const Br = () => {
460
- const { dispatch: e, state: r } = re(P), o = "mt-2 flex justify-center rounded-md", t = x(null), s = x(!1), a = (l) => {
461
- l.preventDefault(), e({
462
- type: be
463
- });
464
- };
465
- return S(() => {
466
- (r == null ? void 0 : r.streaming) === !0 && !s.current && t.current && (s.current = !0, t.current.focus()), (r == null ? void 0 : r.streaming) === !1 && (s.current = !1);
467
- }, [r]), he(M, r) ? /* @__PURE__ */ n("div", { className: o, children: /* @__PURE__ */ n(
468
- xe,
469
- {
470
- ref: t,
471
- noBorder: !0,
472
- onClick: a,
473
- mode: "dark",
474
- focusMode: "light",
475
- children: r != null && r.streaming ? je : qe
476
- }
477
- ) }) : null;
478
- }, me = mr(() => import("./LazyMessageAssistant.C7EB2M7r.js").then((e) => e.LazyMessageAssistant)), Vr = () => {
479
- const { state: e } = re(P);
480
- return /* @__PURE__ */ E(ye, { children: [
481
- e && e.messages.length > 0 && e.messages.map((r, o) => {
482
- const { role: t, content: s, name: a, processingTime: l } = r.message;
483
- return (t === M || t === Z) && s ? /* @__PURE__ */ n(de, { fallback: /* @__PURE__ */ n("span", {}), children: /* @__PURE__ */ n(
484
- me,
485
- {
486
- name: a,
487
- processingTime: l,
488
- children: s
489
- }
490
- ) }, `${o}-${t}`) : t === K && s ? /* @__PURE__ */ n(
491
- Tr,
492
- {
493
- kind: "right",
494
- copyToClipboard: s,
495
- copyToClipboardFocusMode: "light",
496
- children: s
497
- },
498
- `${o}-${t}`
499
- ) : null;
500
- }),
501
- he(K, e) && /* @__PURE__ */ n(de, { fallback: /* @__PURE__ */ n("span", {}), children: /* @__PURE__ */ n(me, { loading: !0 }) })
502
- ] });
503
- }, F = (e, r) => {
504
- e({
505
- type: Te,
506
- payload: {
507
- streaming: r
508
- }
509
- });
510
- }, ge = (e) => {
511
- F(e, !1), e({
512
- type: V,
513
- payload: {
514
- message: {
515
- role: Z,
516
- content: Xe
517
- }
518
- }
519
- });
520
- }, Dr = () => {
521
- const { state: e, dispatch: r } = re(P), [o, t] = I(""), { getAccessToken: s, user: a } = ee(), l = x(!1), h = x(null), c = x(
522
- null
523
- );
524
- S(() => {
525
- (async () => {
526
- var u;
527
- if (!e || e.messages.length === 0) {
528
- (u = c == null ? void 0 : c.current) == null || u.cancel();
529
- return;
530
- }
531
- const i = e.messages[e.messages.length - 1];
532
- if (!(e.messages.length === 0 || i.message.role === M || i.message.role === We || i.message.role === Z || i.message.role === Ye))
533
- try {
534
- const b = await ir({
535
- accessToken: await s(),
536
- name: "generate",
537
- data: {
538
- messages: e.messages,
539
- model: ke,
540
- user: (a == null ? void 0 : a.username) || "",
541
- id: e.id,
542
- location: e.location,
543
- usage: e.usage
544
- }
545
- });
546
- if (b && b.ok) {
547
- const v = te();
548
- c.current = b.body.getReader();
549
- const d = new TextDecoder();
550
- for (; ; ) {
551
- F(r, !0);
552
- const { done: w, value: T } = await c.current.read();
553
- if (w) {
554
- F(r, !1);
555
- break;
556
- }
557
- const p = d.decode(T, { stream: !0 }), C = p.indexOf(le);
558
- if (C !== -1) {
559
- const L = p.substring(0, C), N = JSON.parse(
560
- p.substring(C + le.length)
561
- );
562
- r({
563
- type: Ce,
564
- payload: {
565
- model: N.model,
566
- usage: N.usage
567
- }
568
- }), r({
569
- type: V,
570
- payload: {
571
- message: {
572
- content: L,
573
- role: M,
574
- messageId: v,
575
- processingTime: N.processingTime,
576
- name: N.name
577
- }
578
- }
579
- }), F(r, !1);
580
- break;
581
- } else
582
- r({
583
- type: V,
584
- payload: {
585
- message: {
586
- content: p,
587
- role: M,
588
- messageId: v
589
- }
590
- }
591
- });
592
- }
593
- } else
594
- ge(r);
595
- } catch (b) {
596
- console.error(b), ge(r);
597
- }
598
- })();
599
- }, [e == null ? void 0 : e.messages]);
600
- const y = async (i) => {
601
- i.preventDefault(), r({
602
- type: V,
603
- payload: {
604
- message: {
605
- role: K,
606
- content: o
607
- }
608
- }
609
- }), t("");
610
- };
611
- return S(() => {
612
- (e == null ? void 0 : e.streaming) === !1 && !l.current && h.current && (l.current = !0, h.current.focus()), (e == null ? void 0 : e.streaming) === !0 && l.current === !0 && (l.current = !1);
613
- }, [e]), /* @__PURE__ */ n("form", { className: "mt-2", onSubmit: y, children: /* @__PURE__ */ n(
614
- Ne,
615
- {
616
- mode: "dark",
617
- focusMode: "light",
618
- ref: h,
619
- name: "chat-input",
620
- label: Je,
621
- helperText: "Press ENTER to add a new line",
622
- helperTextOnFocus: !0,
623
- required: !0,
624
- value: o,
625
- onChange: (i) => t(i.target.value),
626
- rightElement: /* @__PURE__ */ n(
627
- xe,
628
- {
629
- disabled: e == null ? void 0 : e.streaming,
630
- noBorder: !0,
631
- type: "submit",
632
- mode: "light",
633
- focusMode: "light",
634
- children: Qe
635
- }
636
- )
637
- }
638
- ) });
639
- }, $r = () => {
640
- const { isAuthenticated: e } = ee(), r = Ke(e);
641
- return /* @__PURE__ */ E(ye, { children: [
642
- /* @__PURE__ */ E("div", { className: r, children: [
643
- /* @__PURE__ */ n(Ze, {}),
644
- /* @__PURE__ */ n(Vr, {})
645
- ] }),
646
- /* @__PURE__ */ n(Br, {}),
647
- /* @__PURE__ */ n(Dr, {})
648
- ] });
649
- }, zr = (e, r) => (r == null ? void 0 : r.type) === er ? {
650
- searchString: r.payload.searchString,
651
- sortedCell: e.sortedCell,
652
- sortDirection: e.sortDirection
653
- } : (r == null ? void 0 : r.type) === rr ? {
654
- searchString: e.searchString,
655
- sortedCell: r.payload.sortedCell,
656
- sortDirection: r.payload.sortDirection
657
- } : e, Ur = (e, r) => {
658
- if ((r == null ? void 0 : r.type) === tr) {
659
- const o = r.payload.messages.map((t) => ({
660
- message: {
661
- role: t.role,
662
- content: t.content,
663
- name: t.name,
664
- processingTime: t.processingTime
665
- }
666
- }));
667
- return {
668
- id: r.payload.id,
669
- model: r.payload.model,
670
- usage: r.payload.usage,
671
- location: e.location,
672
- isComponent: e.isComponent,
673
- messages: o
674
- };
675
- }
676
- if ((r == null ? void 0 : r.type) === V) {
677
- const o = r.payload.message.role, t = r.payload.message.content, s = r.payload.message.name, a = r.payload.message.processingTime, l = r.payload.message.messageId;
678
- if (o !== "") {
679
- const h = {
680
- role: o,
681
- content: t,
682
- name: s,
683
- processingTime: a,
684
- messageId: l
685
- };
686
- if (o === M) {
687
- const c = e.messages.findIndex(
688
- (y) => y.message.messageId === l
689
- );
690
- if (c !== -1) {
691
- const y = e.messages.map((i, u) => u === c ? {
692
- message: {
693
- ...i.message,
694
- content: `${i.message.content}${t}`,
695
- processingTime: a,
696
- name: s
697
- }
698
- } : i);
699
- return {
700
- id: e.id,
701
- model: e.model,
702
- usage: e.usage,
703
- location: e.location,
704
- isComponent: e.isComponent,
705
- messages: y
706
- };
707
- }
708
- }
709
- return {
710
- id: e.id,
711
- model: e.model,
712
- usage: e.usage,
713
- location: e.location,
714
- isComponent: e.isComponent,
715
- messages: [
716
- ...e.messages,
717
- {
718
- message: h
719
- }
720
- ]
721
- };
722
- }
723
- }
724
- return (r == null ? void 0 : r.type) === be ? {
725
- id: te(),
726
- model: e.model,
727
- usage: 0,
728
- messages: [],
729
- location: e.location,
730
- isComponent: e.isComponent
731
- } : (r == null ? void 0 : r.type) === Ce ? {
732
- id: e.id,
733
- model: r.payload.model,
734
- usage: r.payload.usage,
735
- messages: e.messages,
736
- location: e.location,
737
- isComponent: e.isComponent
738
- } : (r == null ? void 0 : r.type) === B ? {
739
- id: e.id,
740
- model: e.model,
741
- usage: e.usage,
742
- messages: e.messages,
743
- location: r.payload.location,
744
- isComponent: e.isComponent
745
- } : (r == null ? void 0 : r.type) === Te ? {
746
- ...e,
747
- streaming: r.payload.streaming
748
- } : e;
749
- };
750
- function Ae({ isComponent: e = !1 }) {
751
- const r = x(!1), o = x(!1), t = x(!1), { isAuthenticated: s, getAccessToken: a } = ee(), [l] = Q({
752
- key: J + nr,
753
- initialValue: ""
754
- }), [h] = Q({
755
- key: J + lr,
756
- initialValue: ur.ASC
757
- }), [c, y] = Q({
758
- key: J + cr,
759
- initialValue: { latitude: 0, longitude: 0, accuracy: 0 }
760
- }), [i, u] = ue(Ur, {
761
- id: te(),
762
- model: ke,
763
- usage: 0,
764
- messages: [],
765
- isComponent: e
766
- }), [b, v] = ue(zr, {
767
- searchString: l,
768
- sortedCell: "timestamp",
769
- sortDirection: h
770
- }), [d, w] = I({
771
- version: "",
772
- models: [],
773
- plugins: []
774
- }), T = gr(() => {
775
- u({
776
- type: B,
777
- payload: {
778
- location: {
779
- ...c,
780
- city: "N/A"
781
- }
782
- }
783
- });
784
- }, [c]);
785
- return S(() => {
786
- d.version !== "" || t.current || (async () => {
787
- try {
788
- t.current = !0;
789
- const p = await ce({
790
- accessToken: await a(),
791
- type: ie.ABOUT
792
- });
793
- t.current = !1, p.status === 200 && w(p.data);
794
- } catch {
795
- }
796
- })();
797
- }, [d, a]), S(() => {
798
- s && (r.current || ((!c || c.accuracy === 0) && (r.current = !0, (async () => {
799
- const p = await or();
800
- y(p), u({
801
- type: B,
802
- payload: {
803
- location: p
804
- }
805
- });
806
- })()), c && c.accuracy !== 0 && !i.location && u({
807
- type: B,
808
- payload: {
809
- location: c
810
- }
811
- })));
812
- }, [s, c, y, i.location]), S(() => {
813
- !i.location || i.location.accuracy === 0 || i.location.city || i.location.displayName || o.current || (async () => {
814
- var p, C, L, N, D;
815
- o.current = !0;
816
- try {
817
- const m = await ce({
818
- accessToken: await a(),
819
- type: ie.GET_LOCATION,
820
- params: {
821
- latitude: c.latitude,
822
- longitude: c.longitude
823
- }
824
- });
825
- o.current = !1, m.status !== 200 || ((p = m == null ? void 0 : m.errors) == null ? void 0 : p.length) > 0 ? T() : u({
826
- type: B,
827
- payload: {
828
- location: {
829
- ...c,
830
- country: (C = m == null ? void 0 : m.data) == null ? void 0 : C.country,
831
- state: (L = m == null ? void 0 : m.data) == null ? void 0 : L.state,
832
- city: ((N = m == null ? void 0 : m.data) == null ? void 0 : N.city) || "N/A",
833
- displayName: (D = m == null ? void 0 : m.data) == null ? void 0 : D.displayName
834
- }
835
- }
836
- });
837
- } catch {
838
- T();
839
- }
840
- })();
841
- }, [i, c, a, T]), S(() => {
842
- var p;
843
- (p = document.getElementById("logo")) == null || p.classList.add("fadeOut"), setTimeout(() => {
844
- var C;
845
- (C = document.getElementById("root")) == null || C.classList.replace("app-hidden", "fadeIn");
846
- }, 500);
847
- }), /* @__PURE__ */ n(P.Provider, { value: { state: i, dispatch: u, serverStats: d }, children: /* @__PURE__ */ E(
848
- dr.Provider,
849
- {
850
- value: {
851
- state: b,
852
- dispatch: v
853
- },
854
- children: [
855
- /* @__PURE__ */ n(sr, { children: /* @__PURE__ */ n($r, {}) }),
856
- /* @__PURE__ */ n(ar, { serverStats: d })
857
- ]
858
- }
859
- ) });
860
- }
861
- Ae.displayName = "App";
862
- const Wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Ae }, Symbol.toStringTag, { value: "Module" }));
863
- export {
864
- Wr as App,
865
- Tr as T
866
- };