@versini/sassysaint 0.0.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.
@@ -0,0 +1,867 @@
1
+ import { jsxs as S, jsx as a, Fragment as me } from "react/jsx-runtime";
2
+ import { O as Ve, s as Be, S as De, f$1 as $e, M as ze, U as Ue, r as Fe, o as Pe, n as ge, l as Ge, a as W, isLastMessageFromRole as ye, x as fe, CANCEL as je, CLEAR as We, ACTION_RESET as he, ROLE_ASSISTANT as L, ROLE_INTERNAL as X, ROLE_USER as Q, ur as K, ROLE_SYSTEM as Ye, ROLE_HIDDEN as qe, MODEL_GPT4 as xe, STATS_SEPARATOR as ae, ACTION_MODEL as be, ACTION_MESSAGE as H, TYPE_QUESTION as Je, SEND as Qe, ACTION_STREAMING as ke, 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 _, getCurrentGeoLocation as or, c as sr, AppFooter as ar, LOCAL_STORAGE_PREFIX as Y, LOCAL_STORAGE_SEARCH as nr, LOCAL_STORAGE_SORT as lr, LOCAL_STORAGE_LOCATION as cr } from "./index.C5AWMLF4.js";
3
+ import { g as Ce, AppContext as U, restCall as ir, E as q, serviceCall as ne, SERVICE_TYPES as le, HistoryContext as dr, k as ur } from "./useLocalStorage.DX6TGv84.js";
4
+ import pr, { useState as R, useEffect as N, useRef as x, useLayoutEffect as D, useContext as Z, lazy as mr, Suspense as ce, useReducer as ie, useCallback as gr } from "react";
5
+ import y from "clsx";
6
+ const yr = ({
7
+ className: e,
8
+ viewBox: r,
9
+ spacing: o,
10
+ title: t,
11
+ monotone: s,
12
+ ...n
13
+ }) => /* @__PURE__ */ S(
14
+ Ce,
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
+ ...n,
23
+ children: [
24
+ /* @__PURE__ */ a(
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__ */ a("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
+ ...n
41
+ }) => /* @__PURE__ */ a(
42
+ Ce,
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
+ ...n,
51
+ children: /* @__PURE__ */ a("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 }) => y({
54
+ "bg-surface-lighter dark:bg-surface-dark": e === "left",
55
+ "bg-surface-accent": e === "right"
56
+ }), br = ({ kind: e }) => y(
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 }) => y("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 = y(
70
+ r,
71
+ Be,
72
+ "flex items-start",
73
+ De(o),
74
+ {
75
+ "flex-row-reverse": e === "right"
76
+ }
77
+ ), s = y(
78
+ "flex flex-col empty:hidden",
79
+ hr(),
80
+ br({ kind: e }),
81
+ xr({ kind: e }),
82
+ kr({ kind: e })
83
+ ), n = "pr-2 pt-1 text-end text-xs text-copy-light", l = y("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: n,
91
+ copyButton: l
92
+ };
93
+ }, Tr = ({
94
+ children: e,
95
+ kind: r = "left",
96
+ className: o,
97
+ footer: t,
98
+ rawFooter: s,
99
+ copyToClipboard: n,
100
+ copyToClipboardFocusMode: l = "system",
101
+ copyToClipboardMode: c = "system",
102
+ spacing: g
103
+ }) => {
104
+ const [u, i] = R(!1), h = Cr({ kind: r, className: o, spacing: g }), b = !!n && (typeof n == "function" || typeof n == "string" || typeof e == "string"), k = () => {
105
+ i(!0), typeof n == "function" ? n(e) : typeof n == "string" ? navigator.clipboard.writeText(n) : typeof e == "string" && navigator.clipboard.writeText(e);
106
+ };
107
+ return N(() => {
108
+ let p;
109
+ return u && (p = window.setTimeout(() => {
110
+ i(!1);
111
+ }, 3e3)), () => {
112
+ clearTimeout(p);
113
+ };
114
+ }, [u]), /* @__PURE__ */ S("div", { className: h.wrapper, children: [
115
+ /* @__PURE__ */ S("div", { children: [
116
+ /* @__PURE__ */ a("div", { className: h.main, children: e }),
117
+ t && Object.keys(t).map((p) => t[p] ? /* @__PURE__ */ a("div", { className: "prose-p:m-0", children: /* @__PURE__ */ S("p", { className: h.footer, children: [
118
+ p,
119
+ ": ",
120
+ t[p]
121
+ ] }) }, `-${p}`) : null),
122
+ s && s
123
+ ] }),
124
+ b && /* @__PURE__ */ a("div", { className: h.copyButton, children: /* @__PURE__ */ a(
125
+ Ve,
126
+ {
127
+ noBorder: !0,
128
+ noBackground: !0,
129
+ size: "small",
130
+ mode: c,
131
+ focusMode: l,
132
+ label: u ? "Copied to clipboard" : "Copy to clipboard",
133
+ onClick: k,
134
+ disabled: u,
135
+ children: u ? /* @__PURE__ */ a(yr, { className: "size-3" }) : /* @__PURE__ */ a(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, n] = R(
148
+ r !== void 0 ? r : o
149
+ );
150
+ return e !== void 0 ? [e, t, !0] : [s, (l) => {
151
+ n(l), t == null || t(l);
152
+ }, !1];
153
+ }
154
+ const Sr = () => "rounded-md text-base h-20 min-h-[80px] resize-none overflow-hidden px-4 py-7", Er = ({
155
+ mode: e
156
+ }) => y({
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
+ }), Nr = ({
162
+ focusMode: e
163
+ }) => y("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
+ }) => y("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
+ }), Ar = ({
177
+ disabled: e,
178
+ raw: r,
179
+ error: o,
180
+ mode: t
181
+ }) => {
182
+ if (r)
183
+ return "";
184
+ if (e)
185
+ return y("absolute px-2 cursor-not-allowed opacity-50 font-medium");
186
+ if (!o)
187
+ return y("absolute px-2 cursor-text font-medium", {
188
+ "text-copy-lighter": t === "dark",
189
+ "text-copy-dark": t === "light",
190
+ "text-copy-dark dark:text-copy-lighter": t === "system",
191
+ "text-copy-lighter dark:text-copy-dark": t === "alt-system"
192
+ });
193
+ if (o)
194
+ return y("absolute px-2 cursor-text font-medium", {
195
+ "text-copy-lighter": t === "dark",
196
+ "text-copy-error-dark": t === "light",
197
+ "text-copy-error-dark dark:text-copy-error-light": t === "system",
198
+ "text-copy-lighter 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 y(
210
+ W,
211
+ "absolute px-2 cursor-not-allowed opacity-50 font-medium"
212
+ );
213
+ if (!e)
214
+ return y(W, "absolute px-2 font-medium", {
215
+ "text-copy-lighter": o === "dark",
216
+ "text-copy-dark": o === "light",
217
+ "text-copy-dark dark:text-copy-lighter": o === "system",
218
+ "text-copy-lighter dark:text-copy-dark": o === "alt-system"
219
+ });
220
+ if (e)
221
+ return y(W, "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: n,
234
+ error: l,
235
+ spacing: c,
236
+ mode: g
237
+ }) => {
238
+ const u = o ? e : y(
239
+ "relative flex w-full flex-col justify-center",
240
+ Fe,
241
+ e,
242
+ Pe(c)
243
+ ), i = o ? y(r) : y(
244
+ ge,
245
+ r,
246
+ Sr(),
247
+ Er({ mode: g }),
248
+ Nr({ focusMode: t }),
249
+ Or({
250
+ noBorder: n,
251
+ error: l
252
+ }),
253
+ {
254
+ "disabled:cursor-not-allowed disabled:opacity-50": s
255
+ }
256
+ ), h = o ? void 0 : "sr-only", b = Ar({
257
+ disabled: s,
258
+ raw: o,
259
+ error: l,
260
+ mode: g
261
+ }), k = wr({
262
+ error: l,
263
+ raw: o,
264
+ mode: g,
265
+ disabled: s
266
+ }), p = o ? void 0 : y(Ge, "absolute");
267
+ return {
268
+ wrapper: u,
269
+ textArea: i,
270
+ accessibleLabel: h,
271
+ visibleLabel: b,
272
+ helperText: k,
273
+ rightElement: p
274
+ };
275
+ }, Rr = ({
276
+ scrollHeight: e,
277
+ currentHeight: r,
278
+ currentLabelOffset: o = 0,
279
+ currentHelperTextOffset: t = 0
280
+ }) => {
281
+ let s, n;
282
+ if (e > 0 && e !== r) {
283
+ const l = e - r, c = Math.abs(l / 24);
284
+ s = o + -1 * Math.sign(l) * (12 * c), n = t + Math.sign(l) * (12 * c);
285
+ }
286
+ return {
287
+ labelOffset: s,
288
+ helperTextOffset: n,
289
+ scrollHeight: e
290
+ };
291
+ }, Te = pr.forwardRef(
292
+ ({
293
+ id: e,
294
+ name: r,
295
+ label: o,
296
+ error: t = !1,
297
+ raw: s = !1,
298
+ className: n,
299
+ textAreaClassName: l,
300
+ mode: c = "system",
301
+ focusMode: g = "system",
302
+ value: u,
303
+ defaultValue: i,
304
+ disabled: h = !1,
305
+ noBorder: b = !1,
306
+ labelId: k,
307
+ helperText: p = "",
308
+ helperTextOnFocus: T = !1,
309
+ rightElement: m,
310
+ onChange: d,
311
+ onFocus: O,
312
+ onBlur: V,
313
+ spacing: A,
314
+ ...Se
315
+ }, Ee) => {
316
+ const v = x(null), Ne = $e([Ee, v]), B = x(null), F = x(80), re = x(-25), M = x(null), te = x(30), P = x(null), I = ze({ id: e, prefix: `${ge}-` }), [Oe, Ae] = R(0), [we, oe] = R(
317
+ !!(!T && p)
318
+ ), Le = `${r} error, ${p}`, w = Lr({
319
+ className: n,
320
+ textAreaClassName: l,
321
+ error: t,
322
+ raw: s,
323
+ focusMode: g,
324
+ disabled: h,
325
+ noBorder: b,
326
+ spacing: A,
327
+ mode: c
328
+ }), [E, Re] = vr({
329
+ value: u,
330
+ defaultValue: i,
331
+ onChange: (C) => {
332
+ d && d({
333
+ target: {
334
+ value: C
335
+ }
336
+ });
337
+ }
338
+ }), Me = (C) => {
339
+ Re(C.target.value);
340
+ }, Ie = (C) => {
341
+ T && p && oe(!0), O && O(C);
342
+ }, _e = (C) => {
343
+ T && p && !E && oe(!1), V && V(C);
344
+ };
345
+ return D(() => {
346
+ !s && m && B.current && B.current.offsetWidth > 0 && Ae(B.current.offsetWidth + 18 + 10);
347
+ }, [m, s]), D(() => {
348
+ s || v && v.current && E !== void 0 && (v.current.style.height = "inherit", v.current.style.height = v.current.scrollHeight + "px");
349
+ }, [E, s]), D(() => {
350
+ s || setTimeout(() => {
351
+ var C;
352
+ (C = M == null ? void 0 : M.current) == null || C.style.setProperty(
353
+ "--av-text-area-wrapper-transition",
354
+ E ? "none" : "all 0.2s ease-out"
355
+ );
356
+ }, 0);
357
+ }, [E, s]), D(() => {
358
+ var C, se;
359
+ if (!s && v && v.current && E !== void 0) {
360
+ const { labelOffset: G, helperTextOffset: j, scrollHeight: He } = Rr({
361
+ scrollHeight: v.current.scrollHeight,
362
+ currentHeight: F.current,
363
+ currentLabelOffset: re.current,
364
+ currentHelperTextOffset: te.current
365
+ });
366
+ G && (re.current = G, (C = M == null ? void 0 : M.current) == null || C.style.setProperty(
367
+ "--av-text-area-label",
368
+ `${G}px`
369
+ )), j && (te.current = j, (se = P == null ? void 0 : P.current) == null || se.style.setProperty(
370
+ "--av-text-area-helper-text",
371
+ `${j}px`
372
+ )), F.current = He || F.current;
373
+ }
374
+ }, [E, s]), /* @__PURE__ */ S("div", { className: w.wrapper, children: [
375
+ /* @__PURE__ */ a(
376
+ "label",
377
+ {
378
+ htmlFor: I,
379
+ id: k,
380
+ className: w.accessibleLabel,
381
+ children: o
382
+ }
383
+ ),
384
+ /* @__PURE__ */ a(
385
+ "textarea",
386
+ {
387
+ ref: Ne,
388
+ id: I,
389
+ name: r,
390
+ disabled: h,
391
+ placeholder: s ? void 0 : " ",
392
+ className: w.textArea,
393
+ rows: 1,
394
+ ...p && { "aria-describedby": `${I}-helper` },
395
+ ...t && { "aria-invalid": "true" },
396
+ ...m && !s && { style: { paddingRight: Oe } },
397
+ value: E,
398
+ onChange: Me,
399
+ onFocus: Ie,
400
+ onBlur: _e,
401
+ ...Se
402
+ }
403
+ ),
404
+ !s && /* @__PURE__ */ a(
405
+ "label",
406
+ {
407
+ ref: M,
408
+ "aria-hidden": !0,
409
+ htmlFor: I,
410
+ className: w.visibleLabel,
411
+ children: o
412
+ }
413
+ ),
414
+ we && /* @__PURE__ */ a(
415
+ "div",
416
+ {
417
+ ref: P,
418
+ id: `${I}-helper`,
419
+ className: w.helperText,
420
+ children: p
421
+ }
422
+ ),
423
+ m && /* @__PURE__ */ a(
424
+ "div",
425
+ {
426
+ ref: B,
427
+ className: w.rightElement,
428
+ children: m
429
+ }
430
+ ),
431
+ t && p && /* @__PURE__ */ a(Ue, { politeness: "polite", clearAnnouncementDelay: 500, children: Le })
432
+ ] });
433
+ }
434
+ );
435
+ Te.displayName = "TextArea";
436
+ var f = [];
437
+ for (var J = 0; J < 256; ++J)
438
+ f.push((J + 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 $, Ir = new Uint8Array(16);
443
+ function _r() {
444
+ if (!$ && ($ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !$))
445
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
446
+ return $(Ir);
447
+ }
448
+ var Hr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
449
+ const de = {
450
+ randomUUID: Hr
451
+ };
452
+ function ee(e, r, o) {
453
+ if (de.randomUUID && !r && !e)
454
+ return de.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 Vr = () => {
460
+ const { dispatch: e, state: r } = Z(U), o = "mt-2 flex justify-center rounded-md", t = x(null), s = x(!1), n = (l) => {
461
+ l.preventDefault(), e({
462
+ type: he
463
+ });
464
+ };
465
+ return N(() => {
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]), ye(L, r) ? /* @__PURE__ */ a("div", { className: o, children: /* @__PURE__ */ a(
468
+ fe,
469
+ {
470
+ ref: t,
471
+ noBorder: !0,
472
+ onClick: n,
473
+ mode: "dark",
474
+ focusMode: "light",
475
+ children: r != null && r.streaming ? je : We
476
+ }
477
+ ) }) : null;
478
+ }, ue = mr(() => import("./LazyMessageAssistant.BarQNBL-.js").then((e) => e.LazyMessageAssistant)), Br = () => {
479
+ const { state: e } = Z(U);
480
+ return /* @__PURE__ */ S(me, { children: [
481
+ e && e.messages.length > 0 && e.messages.map((r, o) => {
482
+ const { role: t, content: s, name: n, processingTime: l } = r.message;
483
+ return (t === L || t === X) && s ? /* @__PURE__ */ a(ce, { fallback: /* @__PURE__ */ a("span", {}), children: /* @__PURE__ */ a(
484
+ ue,
485
+ {
486
+ name: n,
487
+ processingTime: l,
488
+ children: s
489
+ }
490
+ ) }, `${o}-${t}`) : t === Q && s ? /* @__PURE__ */ a(
491
+ Tr,
492
+ {
493
+ kind: "right",
494
+ copyToClipboard: s,
495
+ copyToClipboardFocusMode: "light",
496
+ children: s
497
+ },
498
+ `${o}-${t}`
499
+ ) : null;
500
+ }),
501
+ ye(Q, e) && /* @__PURE__ */ a(ce, { fallback: /* @__PURE__ */ a("span", {}), children: /* @__PURE__ */ a(ue, { loading: !0 }) })
502
+ ] });
503
+ }, z = (e, r) => {
504
+ e({
505
+ type: ke,
506
+ payload: {
507
+ streaming: r
508
+ }
509
+ });
510
+ }, pe = (e) => {
511
+ z(e, !1), e({
512
+ type: H,
513
+ payload: {
514
+ message: {
515
+ role: X,
516
+ content: Xe
517
+ }
518
+ }
519
+ });
520
+ }, Dr = () => {
521
+ const { state: e, dispatch: r } = Z(U), [o, t] = R(""), { getAccessToken: s, user: n } = K(), l = x(!1), c = x(null), g = x(
522
+ null
523
+ );
524
+ N(() => {
525
+ (async () => {
526
+ var h;
527
+ if (!e || e.messages.length === 0) {
528
+ (h = g == null ? void 0 : g.current) == null || h.cancel();
529
+ return;
530
+ }
531
+ const i = e.messages[e.messages.length - 1];
532
+ if (!(e.messages.length === 0 || i.message.role === L || i.message.role === Ye || i.message.role === X || i.message.role === qe))
533
+ try {
534
+ const b = await ir({
535
+ accessToken: await s(),
536
+ name: "generate",
537
+ data: {
538
+ messages: e.messages,
539
+ model: xe,
540
+ user: (n == null ? void 0 : n.username) || "",
541
+ id: e.id,
542
+ location: e.location,
543
+ usage: e.usage
544
+ }
545
+ });
546
+ if (b && b.ok) {
547
+ const k = ee();
548
+ g.current = b.body.getReader();
549
+ const p = new TextDecoder();
550
+ for (; ; ) {
551
+ z(r, !0);
552
+ const { done: T, value: m } = await g.current.read();
553
+ if (T) {
554
+ z(r, !1);
555
+ break;
556
+ }
557
+ const d = p.decode(m, { stream: !0 }), O = d.indexOf(ae);
558
+ if (O !== -1) {
559
+ const V = d.substring(0, O), A = JSON.parse(
560
+ d.substring(O + ae.length)
561
+ );
562
+ r({
563
+ type: be,
564
+ payload: {
565
+ model: A.model,
566
+ usage: A.usage
567
+ }
568
+ }), r({
569
+ type: H,
570
+ payload: {
571
+ message: {
572
+ content: V,
573
+ role: L,
574
+ messageId: k,
575
+ processingTime: A.processingTime,
576
+ name: A.name
577
+ }
578
+ }
579
+ }), z(r, !1);
580
+ break;
581
+ } else
582
+ r({
583
+ type: H,
584
+ payload: {
585
+ message: {
586
+ content: d,
587
+ role: L,
588
+ messageId: k
589
+ }
590
+ }
591
+ });
592
+ }
593
+ } else
594
+ pe(r);
595
+ } catch (b) {
596
+ console.error(b), pe(r);
597
+ }
598
+ })();
599
+ }, [e == null ? void 0 : e.messages]);
600
+ const u = async (i) => {
601
+ i.preventDefault(), r({
602
+ type: H,
603
+ payload: {
604
+ message: {
605
+ role: Q,
606
+ content: o
607
+ }
608
+ }
609
+ }), t("");
610
+ };
611
+ return N(() => {
612
+ (e == null ? void 0 : e.streaming) === !1 && !l.current && c.current && (l.current = !0, c.current.focus()), (e == null ? void 0 : e.streaming) === !0 && l.current === !0 && (l.current = !1);
613
+ }, [e]), /* @__PURE__ */ a("form", { className: "mt-2", onSubmit: u, children: /* @__PURE__ */ a(
614
+ Te,
615
+ {
616
+ mode: "dark",
617
+ focusMode: "light",
618
+ ref: c,
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__ */ a(
627
+ fe,
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 } = K(), r = Ke(e);
641
+ return /* @__PURE__ */ S(me, { children: [
642
+ /* @__PURE__ */ S("div", { className: r, children: [
643
+ /* @__PURE__ */ a(Ze, {}),
644
+ /* @__PURE__ */ a(Br, {})
645
+ ] }),
646
+ /* @__PURE__ */ a(Vr, {}),
647
+ /* @__PURE__ */ a(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) === H) {
677
+ const o = r.payload.message.role, t = r.payload.message.content, s = r.payload.message.name, n = r.payload.message.processingTime, l = r.payload.message.messageId;
678
+ if (o !== "") {
679
+ const c = {
680
+ role: o,
681
+ content: t,
682
+ name: s,
683
+ processingTime: n,
684
+ messageId: l
685
+ };
686
+ if (o === L) {
687
+ const g = e.messages.findIndex(
688
+ (u) => u.message.messageId === l
689
+ );
690
+ if (g !== -1) {
691
+ const u = e.messages.map((i, h) => h === g ? {
692
+ message: {
693
+ ...i.message,
694
+ content: `${i.message.content}${t}`,
695
+ processingTime: n,
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: u
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: c
719
+ }
720
+ ]
721
+ };
722
+ }
723
+ }
724
+ return (r == null ? void 0 : r.type) === he ? {
725
+ id: ee(),
726
+ model: e.model,
727
+ usage: 0,
728
+ messages: [],
729
+ location: e.location,
730
+ isComponent: e.isComponent
731
+ } : (r == null ? void 0 : r.type) === be ? {
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) === _ ? {
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) === ke ? {
746
+ ...e,
747
+ streaming: r.payload.streaming
748
+ } : e;
749
+ };
750
+ function ve({ isComponent: e = !1 }) {
751
+ const r = x(!1), o = x(!1), { isAuthenticated: t, getAccessToken: s } = K(), [n] = q({
752
+ key: Y + nr,
753
+ initialValue: ""
754
+ }), [l] = q({
755
+ key: Y + lr,
756
+ initialValue: ur.ASC
757
+ }), [c, g] = q({
758
+ key: Y + cr,
759
+ initialValue: { latitude: 0, longitude: 0, accuracy: 0 }
760
+ }), [u, i] = ie(Ur, {
761
+ id: ee(),
762
+ model: xe,
763
+ usage: 0,
764
+ messages: [],
765
+ isComponent: e
766
+ }), [h, b] = ie(zr, {
767
+ searchString: n,
768
+ sortedCell: "timestamp",
769
+ sortDirection: l
770
+ }), [k, p] = R({
771
+ version: "",
772
+ models: [],
773
+ plugins: []
774
+ }), T = gr(() => {
775
+ i({
776
+ type: _,
777
+ payload: {
778
+ location: {
779
+ ...c,
780
+ city: "N/A"
781
+ }
782
+ }
783
+ });
784
+ }, [c]);
785
+ return N(() => {
786
+ k.version !== "" || o.current || (async () => {
787
+ try {
788
+ o.current = !0;
789
+ const m = await ne({
790
+ accessToken: await s(),
791
+ type: le.ABOUT
792
+ });
793
+ o.current = !1, m.status === 200 && p(m.data);
794
+ } catch {
795
+ }
796
+ })();
797
+ }, [k, s]), N(() => {
798
+ t && ((!c || c.accuracy === 0) && (async () => {
799
+ const m = await or();
800
+ g(m), i({
801
+ type: _,
802
+ payload: {
803
+ location: m
804
+ }
805
+ });
806
+ })(), c && c.accuracy !== 0 && !u.location && i({
807
+ type: _,
808
+ payload: {
809
+ location: c
810
+ }
811
+ }));
812
+ }, [t, c, g, u.location]), N(() => {
813
+ !u.location || u.location.accuracy === 0 || u.location.city || r.current || (async () => {
814
+ var m;
815
+ r.current = !0;
816
+ try {
817
+ const d = await ne({
818
+ accessToken: await s(),
819
+ type: le.GET_LOCATION,
820
+ params: {
821
+ latitude: c.latitude,
822
+ longitude: c.longitude
823
+ }
824
+ });
825
+ r.current = !1, d.status !== 200 || ((m = d == null ? void 0 : d.errors) == null ? void 0 : m.length) > 0 || !d.data || !d.data.city || !d.data.region || !d.data.country ? T() : i({
826
+ type: _,
827
+ payload: {
828
+ location: {
829
+ ...c,
830
+ city: d.data.city,
831
+ region: d.data.region,
832
+ regionShort: d.data.regionShort,
833
+ country: d.data.country,
834
+ countryShort: d.data.countryShort
835
+ }
836
+ }
837
+ });
838
+ } catch {
839
+ T();
840
+ }
841
+ })();
842
+ }, [u, c, s, T]), N(() => {
843
+ var m;
844
+ (m = document.getElementById("logo")) == null || m.classList.add("fadeOut"), setTimeout(() => {
845
+ var d;
846
+ (d = document.getElementById("root")) == null || d.classList.replace("app-hidden", "fadeIn");
847
+ }, 500);
848
+ }), /* @__PURE__ */ a(U.Provider, { value: { state: u, dispatch: i, serverStats: k }, children: /* @__PURE__ */ S(
849
+ dr.Provider,
850
+ {
851
+ value: {
852
+ state: h,
853
+ dispatch: b
854
+ },
855
+ children: [
856
+ /* @__PURE__ */ a(sr, { children: /* @__PURE__ */ a($r, {}) }),
857
+ /* @__PURE__ */ a(ar, { serverStats: k })
858
+ ]
859
+ }
860
+ ) });
861
+ }
862
+ ve.displayName = "App";
863
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: ve }, Symbol.toStringTag, { value: "Module" }));
864
+ export {
865
+ Yr as App,
866
+ Tr as T
867
+ };