@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,1372 @@
1
+ import { jsx as t, jsxs as d, Fragment as x } from "react/jsx-runtime";
2
+ import { E as X, S as Oe, O, i$1 as _e, N as Be, p as ze, o as Ve, g as A, CARDS as C, renderDataAsList as V, pluralize as q, ABOUT_TITLE as Pe, MODEL_GPT4 as Fe, numberFormatter as $e, durationFormatter as ge, NA as Ge, ROLE_ASSISTANT as Ue, extractAverage as je, GPT4_MAX_TOKENS as Ke, ur as G, STATS as Ce, b as oe, j as D, x as ce, LOCAL_STORAGE_PREFIX as Q, LOCAL_STORAGE_SORT as Ye, ACTION_RESET as We, ACTION_RESTORE as Xe, truncate as Je, ACTION_SORT as ae, LOCAL_STORAGE_SEARCH as qe, G as Qe, ACTION_SEARCH as Ze, HISTORY_TITLE as et, LOCAL_STORAGE_CHAT_DETAILS as tt, LOCAL_STORAGE_LOCATION as rt, ACTION_LOCATION as de, getCurrentGeoLocation as at, convertLatitudeToDMS as st, convertLongitudeToDMS as nt, PROFILE_TITLE as ot, LOG_OUT as me } from "./index.C5AWMLF4.js";
3
+ import * as le from "react";
4
+ import ct, { useId as be, forwardRef as Ne, useState as y, useRef as P, useContext as M, useEffect as R, Suspense as lt, lazy as it } from "react";
5
+ import { g as dt, AppContext as U, serviceCall as ee, SERVICE_TYPES as te, HistoryContext as ye, E as Z, k as v, et as mt, at as ut, lt as se, J as H, ct as ht, st as pt, rt as ft } from "./useLocalStorage.DX6TGv84.js";
6
+ import S from "clsx";
7
+ import { useFloatingTree as Te, useFloatingNodeId as gt, useListItem as ke, useFloating as Ct, offset as bt, flip as Nt, shift as yt, autoUpdate as Tt, useClick as kt, useRole as St, useDismiss as wt, useListNavigation as xt, useTypeahead as Et, useInteractions as vt, useMergeRefs as Se, FloatingNode as At, FloatingList as It, FloatingPortal as Ht, FloatingFocusManager as Mt, FloatingTree as Rt } from "@floating-ui/react";
8
+ function Lt(e) {
9
+ const r = be();
10
+ return `${e}${r}`;
11
+ }
12
+ const Dt = ({
13
+ className: e,
14
+ headerClassName: r,
15
+ bodyClassName: a,
16
+ footerClassName: s,
17
+ spacing: o,
18
+ mode: n,
19
+ compact: l,
20
+ noBorder: i
21
+ }) => {
22
+ const m = S(
23
+ X,
24
+ e,
25
+ "rounded-md",
26
+ Oe(o),
27
+ {
28
+ "border-none": i,
29
+ "border-2": !i,
30
+ "p-4": !l,
31
+ "p-1 sm:p-2": l,
32
+ "border-border-accent bg-surface-darker text-copy-light": n === "darker",
33
+ "border-border-accent bg-surface-dark text-copy-light": n === "dark",
34
+ "border-border-dark bg-surface-lighter text-copy-dark": n === "light",
35
+ "border-border-dark bg-surface-lighter text-copy-dark dark:border-border-accent dark:bg-surface-dark dark:text-copy-light": n === "system",
36
+ "border-border-accent bg-surface-dark text-copy-light dark:border-border-dark dark:bg-surface-lighter dark:text-copy-dark": n === "alt-system"
37
+ }
38
+ ), h = r || S(`${X}__header mt-0 border-b-2`, {
39
+ "text-copy-light border-border-accent": n === "darker",
40
+ "border-border-accent": n === "dark",
41
+ "border-border-medium": n === "light",
42
+ "border-border-medium dark:border-border-accent": n === "system",
43
+ "border-border-accent dark:border-border-medium": n === "alt-system",
44
+ "mb-4": !l,
45
+ "mb-2": l
46
+ }), p = S(a), u = s || S(`${X}__footer pt-2`);
47
+ return {
48
+ wrapper: m,
49
+ header: h,
50
+ body: p,
51
+ footer: u
52
+ };
53
+ };
54
+ function Ot({
55
+ id: e,
56
+ content: r,
57
+ userAriaLabelledby: a,
58
+ className: s
59
+ }) {
60
+ return typeof r == "string" ? /* @__PURE__ */ t("h2", { id: e, className: s, children: r }) : a ? /* @__PURE__ */ t("div", { className: s, children: r }) : r ? /* @__PURE__ */ t("div", { className: s, id: e, children: r }) : null;
61
+ }
62
+ const F = ({
63
+ header: e,
64
+ headerClassName: r,
65
+ footer: a,
66
+ footerClassName: s,
67
+ children: o,
68
+ className: n,
69
+ bodyClassName: l,
70
+ "aria-labelledby": i,
71
+ spacing: m,
72
+ mode: h = "system",
73
+ compact: p = !1,
74
+ noBorder: u = !1,
75
+ ...T
76
+ }) => {
77
+ let f = null, b = null;
78
+ const c = typeof e == "string", w = Lt(X), k = Dt({
79
+ className: n,
80
+ headerClassName: r,
81
+ bodyClassName: l,
82
+ footerClassName: s,
83
+ spacing: m,
84
+ mode: h,
85
+ compact: p,
86
+ noBorder: u
87
+ });
88
+ return c ? (f = w, b = f) : !c && e && i ? (f = null, b = i) : !c && e && !i ? (f = w, b = f) : (f = null, b = i || null), /* @__PURE__ */ t("div", { className: k.wrapper, children: /* @__PURE__ */ d(
89
+ "section",
90
+ {
91
+ ...b && {
92
+ "aria-labelledby": b
93
+ },
94
+ className: k.body,
95
+ ...T,
96
+ children: [
97
+ /* @__PURE__ */ t(
98
+ Ot,
99
+ {
100
+ ...f && { id: f },
101
+ content: e,
102
+ className: k.header,
103
+ userAriaLabelledby: i
104
+ }
105
+ ),
106
+ /* @__PURE__ */ t("div", { children: o }),
107
+ a ? /* @__PURE__ */ t("div", { className: k.footer, children: a }) : null
108
+ ]
109
+ }
110
+ ) });
111
+ }, ie = le.createContext({
112
+ getItemProps: () => ({}),
113
+ activeIndex: null,
114
+ /* v8 ignore next 2 */
115
+ setActiveIndex: () => {
116
+ },
117
+ setHasFocusInside: () => {
118
+ },
119
+ isOpen: !1
120
+ }), ue = (e) => {
121
+ if (typeof e == "string")
122
+ return e;
123
+ if (typeof e == "function")
124
+ return e.displayName || e.name || "Component";
125
+ if (typeof e == "object" && e !== null && "type" in e) {
126
+ const r = e.type;
127
+ if (typeof r == "function" || typeof r == "object")
128
+ return r.displayName || r.name || "Component";
129
+ }
130
+ return "Element";
131
+ }, we = Ne(
132
+ ({
133
+ trigger: e,
134
+ children: r,
135
+ label: a = "Open menu",
136
+ defaultPlacement: s = "bottom-start",
137
+ onOpenChange: o,
138
+ spacing: n,
139
+ mode: l = "system",
140
+ focusMode: i = "system",
141
+ ...m
142
+ }, h) => {
143
+ const [p, u] = y(!1), [T, f] = y(!1), [b, c] = y(null), w = P([]), k = P([]), g = M(ie), N = Te(), E = gt(), _ = ke(), { floatingStyles: re, refs: Y, context: I } = Ct({
144
+ nodeId: E,
145
+ open: p,
146
+ onOpenChange: (z) => {
147
+ u(z), o == null || o(z);
148
+ },
149
+ placement: s,
150
+ strategy: "fixed",
151
+ middleware: [bt({ mainAxis: 10 }), Nt(), yt()],
152
+ whileElementsMounted: Tt
153
+ }), W = kt(I, {
154
+ event: "mousedown",
155
+ toggle: !0,
156
+ ignoreMouse: !1
157
+ }), B = St(I, { role: "menu" }), ve = wt(I, { bubbles: !0 }), Ae = xt(I, {
158
+ listRef: w,
159
+ activeIndex: b,
160
+ nested: !1,
161
+ onNavigate: c,
162
+ loop: !0
163
+ }), Ie = Et(I, {
164
+ listRef: k,
165
+ onMatch: p ? c : void 0,
166
+ activeIndex: b
167
+ }), { getReferenceProps: He, getFloatingProps: Me, getItemProps: Re } = vt([W, B, ve, Ae, Ie]), Le = ue(e) === "Button" || ue(e) === "ButtonIcon", De = ct.cloneElement(e, {
168
+ mode: l,
169
+ focusMode: i,
170
+ spacing: n,
171
+ noInternalClick: Le,
172
+ "aria-label": a,
173
+ "data-open": p ? "" : void 0,
174
+ "data-focus-inside": T ? "" : void 0,
175
+ ref: Se([Y.setReference, _.ref, h]),
176
+ ...He(
177
+ g.getItemProps({
178
+ ...m
179
+ })
180
+ )
181
+ });
182
+ return R(() => {
183
+ if (!N)
184
+ return;
185
+ function z() {
186
+ u(!1), o == null || o(!1);
187
+ }
188
+ return N.events.on("click", z), () => {
189
+ N.events.off("click", z);
190
+ };
191
+ }, [N, o]), R(() => {
192
+ p && N && N.events.emit("menuopen", { nodeId: E });
193
+ }, [N, p, E]), /* @__PURE__ */ d(At, { id: E, children: [
194
+ De,
195
+ /* @__PURE__ */ t(
196
+ ie.Provider,
197
+ {
198
+ value: {
199
+ activeIndex: b,
200
+ setActiveIndex: c,
201
+ getItemProps: Re,
202
+ setHasFocusInside: f,
203
+ isOpen: p
204
+ },
205
+ children: /* @__PURE__ */ t(It, { elementsRef: w, labelsRef: k, children: p && /* @__PURE__ */ t(Ht, { children: /* @__PURE__ */ t(
206
+ Mt,
207
+ {
208
+ context: I,
209
+ modal: !1,
210
+ initialFocus: 0,
211
+ returnFocus: !0,
212
+ children: /* @__PURE__ */ t(
213
+ "div",
214
+ {
215
+ ref: Y.setFloating,
216
+ className: "rounded-md bg-surface-light p-4 shadow-sm shadow-border-dark outline-none sm:p-2",
217
+ style: re,
218
+ ...Me(),
219
+ children: r
220
+ }
221
+ )
222
+ }
223
+ ) }) })
224
+ }
225
+ )
226
+ ] });
227
+ }
228
+ ), xe = Ne((e, r) => /* @__PURE__ */ t(Rt, { children: /* @__PURE__ */ t(we, { ...e, ref: r }) }));
229
+ xe.displayName = "Menu";
230
+ we.displayName = "MenuComponent";
231
+ const L = le.forwardRef(({ label: e, disabled: r, icon: a, ...s }, o) => {
232
+ const n = le.useContext(ie), l = ke({ label: r ? null : e }), i = Te();
233
+ return /* @__PURE__ */ d(
234
+ "button",
235
+ {
236
+ ...s,
237
+ ref: Se([l.ref, o]),
238
+ role: "menuitem",
239
+ className: "m-0 flex w-full rounded-md border border-transparent bg-none px-3 py-2 text-left text-base outline-none focus:border focus:border-border-medium focus:bg-surface-lighter focus:underline disabled:cursor-not-allowed disabled:text-copy-medium sm:py-1",
240
+ tabIndex: 0,
241
+ disabled: r,
242
+ ...n.getItemProps({
243
+ onClick(m) {
244
+ var h;
245
+ (h = s.onClick) == null || h.call(s, m), i == null || i.events.emit("click");
246
+ },
247
+ onFocus(m) {
248
+ var h;
249
+ (h = s.onFocus) == null || h.call(s, m), n.setHasFocusInside(!0);
250
+ }
251
+ }),
252
+ children: [
253
+ a,
254
+ e && /* @__PURE__ */ t("span", { className: "pl-2", children: e })
255
+ ]
256
+ }
257
+ );
258
+ });
259
+ L.displayName = "MenuItem";
260
+ const _t = ({ className: e, ...r }) => {
261
+ const a = S(e, "my-1 border-t border-border-medium");
262
+ return /* @__PURE__ */ t("div", { className: a, ...r });
263
+ }, Bt = ({
264
+ className: e,
265
+ viewBox: r,
266
+ spacing: a,
267
+ title: s,
268
+ monotone: o,
269
+ ...n
270
+ }) => /* @__PURE__ */ t(
271
+ dt,
272
+ {
273
+ defaultViewBox: "0 0 384 512",
274
+ defaultClassName: "size-5",
275
+ viewBox: r,
276
+ className: e,
277
+ spacing: a,
278
+ title: s || "Close",
279
+ ...n,
280
+ children: /* @__PURE__ */ t("path", { d: "M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3l105.4 105.3c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256l105.3-105.4z" })
281
+ }
282
+ ), J = "panel", ne = "messagebox", zt = ({
283
+ kind: e,
284
+ borderMode: r
285
+ }) => ({
286
+ main: S(
287
+ "prose prose-lighter flex flex-col bg-surface-medium md:max-w-2xl",
288
+ {
289
+ [`${_e} h-full min-h-[95%] w-full sm:h-auto sm:min-h-[10rem] sm:w-[95%] sm:rounded-lg sm:border-2`]: e === J,
290
+ [`${Be} w-[95%] rounded-lg border-2 sm:w-[50%]`]: e === ne,
291
+ "sm:border-border-dark": r === "dark" && e === J,
292
+ "sm:border-border-accent": r === "light" && e === J,
293
+ "border-border-dark": r === "dark" && e === ne,
294
+ "border-border-accent": r === "light" && e === ne
295
+ }
296
+ ),
297
+ content: "flex flex-grow flex-col py-2 sm:py-4 px-4",
298
+ footer: "flex flex-grow flex-col p-4",
299
+ header: "p-4 mb-0",
300
+ close: "p-4"
301
+ }), j = (e) => it(
302
+ () => import("./index.DruzEDnN.BqlYMlVQ.js").then((r) => ({
303
+ default: r[e]
304
+ }))
305
+ ), Vt = j("Modal"), Pt = j("ModalClose"), Ft = j("ModalContent"), $t = j("ModalDescription"), Gt = j("ModalHeading"), K = ({
306
+ open: e,
307
+ onOpenChange: r,
308
+ title: a,
309
+ children: s,
310
+ footer: o,
311
+ borderMode: n = "light",
312
+ kind: l = J
313
+ }) => {
314
+ const i = P(""), m = zt({ kind: l, borderMode: n });
315
+ return R(() => (e && (i.current = document.title, document.title = `${a} | ${i.current}`), () => {
316
+ e && (document.title = i.current);
317
+ }), [a, e]), /* @__PURE__ */ t(lt, { fallback: /* @__PURE__ */ t("div", {}), children: e && /* @__PURE__ */ t(Vt, { open: e, onOpenChange: r, children: /* @__PURE__ */ d(Ft, { className: m.main, children: [
318
+ /* @__PURE__ */ d("div", { className: "flex flex-row-reverse items-center justify-between", children: [
319
+ /* @__PURE__ */ t(
320
+ Pt,
321
+ {
322
+ className: m.close,
323
+ trigger: /* @__PURE__ */ t(
324
+ O,
325
+ {
326
+ mode: "dark",
327
+ focusMode: "light",
328
+ noBorder: !0,
329
+ label: "Close",
330
+ children: /* @__PURE__ */ t(Bt, {})
331
+ }
332
+ )
333
+ }
334
+ ),
335
+ /* @__PURE__ */ t(Gt, { className: m.header, children: a })
336
+ ] }),
337
+ /* @__PURE__ */ t($t, { className: m.content, children: s }),
338
+ o && /* @__PURE__ */ t("div", { className: m.footer, children: o })
339
+ ] }) }) });
340
+ }, Ut = () => S("peer", "h-6", "w-11", "rounded-full"), jt = ({
341
+ focusMode: e
342
+ }) => S(
343
+ "peer-focus:outline",
344
+ "peer-focus:outline-2",
345
+ "peer-focus:outline-offset-2",
346
+ {
347
+ "peer-focus:outline-focus-dark": e === "dark",
348
+ "peer-focus:outline-focus-light": e === "light",
349
+ "peer-focus:outline-focus-light dark:peer-focus:outline-focus-dark": e === "alt-system",
350
+ "peer-focus:outline-focus-dark dark:peer-focus:outline-focus-light": e === "system"
351
+ }
352
+ ), Kt = () => S(
353
+ "peer-checked:after:translate-x-full",
354
+ // background color when checked
355
+ "peer-checked:bg-violet-500",
356
+ // knob circle and border color when checked
357
+ "peer-checked:after:bg-white",
358
+ "peer-checked:after:border-white"
359
+ ), Yt = () => S(
360
+ "after:left-[2px]",
361
+ "after:top-[2px]",
362
+ "after:border",
363
+ "after:border-surface-light dark:after:border-surface-medium",
364
+ "after:bg-surface-light dark:after:bg-surface-medium",
365
+ "after:absolute",
366
+ "after:h-5",
367
+ "after:w-5",
368
+ "after:rounded-full",
369
+ "after:transition-all",
370
+ "after:content-['']"
371
+ ), Wt = ({
372
+ mode: e,
373
+ noBorder: r
374
+ }) => S({
375
+ border: !r,
376
+ "border-border-dark bg-surface-medium": e === "light",
377
+ "border-border-light bg-surface-darker": e === "dark",
378
+ "border-border-light bg-surface-darker dark:border-border-dark dark:bg-surface-medium": e === "alt-system",
379
+ "border-border-dark bg-surface-medium dark:border-border-light dark:bg-surface-darker": e === "system"
380
+ }), Xt = ({
381
+ mode: e,
382
+ labelHidden: r
383
+ }) => r ? "sr-only" : S("ml-2 text-sm", {
384
+ "text-copy-dark": e === "light",
385
+ "text-copy-lighter": e === "dark",
386
+ "text-copy-lighter dark:text-copy-dark": e === "alt-system",
387
+ "text-copy-dark dark:text-copy-lighter": e === "system"
388
+ }), Jt = ({ spacing: e }) => S(
389
+ ze,
390
+ "relative flex cursor-pointer items-center",
391
+ Ve(e)
392
+ ), qt = ({
393
+ mode: e,
394
+ focusMode: r,
395
+ labelHidden: a,
396
+ spacing: s,
397
+ noBorder: o
398
+ }) => ({
399
+ toggle: S(
400
+ Ut(),
401
+ Wt({ mode: e, noBorder: o }),
402
+ jt({ focusMode: r }),
403
+ Yt(),
404
+ Kt()
405
+ ),
406
+ label: Xt({ mode: e, labelHidden: a }),
407
+ input: "peer sr-only",
408
+ wrapper: Jt({ spacing: s })
409
+ }), Qt = ({
410
+ checked: e = !1,
411
+ onChange: r,
412
+ label: a,
413
+ labelHidden: s = !1,
414
+ name: o,
415
+ mode: n = "system",
416
+ focusMode: l = "system",
417
+ spacing: i,
418
+ noBorder: m = !1
419
+ }) => {
420
+ const h = qt({
421
+ mode: n,
422
+ focusMode: l,
423
+ labelHidden: s,
424
+ spacing: i,
425
+ noBorder: m
426
+ }), p = (u) => {
427
+ r == null || r(u.target.checked);
428
+ };
429
+ return /* @__PURE__ */ d("label", { className: h.wrapper, children: [
430
+ /* @__PURE__ */ t(
431
+ "input",
432
+ {
433
+ name: o,
434
+ checked: e,
435
+ type: "checkbox",
436
+ className: h.input,
437
+ onChange: p
438
+ }
439
+ ),
440
+ /* @__PURE__ */ t("div", { className: h.toggle }),
441
+ /* @__PURE__ */ t("span", { className: h.label, children: a })
442
+ ] });
443
+ }, Zt = ({
444
+ className: e,
445
+ viewBox: r,
446
+ spacing: a,
447
+ title: s,
448
+ monotone: o,
449
+ ...n
450
+ }) => /* @__PURE__ */ d(
451
+ A,
452
+ {
453
+ defaultViewBox: "0 0 512 512",
454
+ defaultClassName: "size-5",
455
+ viewBox: r,
456
+ className: e,
457
+ spacing: a,
458
+ title: s || "Back",
459
+ ...n,
460
+ children: [
461
+ /* @__PURE__ */ t(
462
+ "path",
463
+ {
464
+ opacity: o ? "1" : "0.4",
465
+ d: "M288.4 93.4c2.9-17.4 19.4-29.2 36.9-26.3C431.3 84.9 512 177 512 288c0 123.7-100.3 224-224 224C177 512 84.9 431.3 67.1 325.3c-2.9-17.4 8.8-33.9 26.3-36.9s33.9 8.8 36.9 26.3C142.9 390.4 208.8 448 288 448c88.4 0 160-71.6 160-160c0-79.2-57.6-145.1-133.3-157.8c-17.4-2.9-29.2-19.4-26.3-36.9z"
466
+ }
467
+ ),
468
+ /* @__PURE__ */ t("path", { d: "M32 0H192c17.7 0 32 14.3 32 32s-14.3 32-32 32H109.3L342.6 297.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L64 109.3V192c0 17.7-14.3 32-32 32s-32-14.3-32-32V32C0 14.3 14.3 0 32 0z" })
469
+ ]
470
+ }
471
+ ), er = ({
472
+ className: e,
473
+ viewBox: r,
474
+ spacing: a,
475
+ title: s,
476
+ monotone: o,
477
+ ...n
478
+ }) => /* @__PURE__ */ d(
479
+ A,
480
+ {
481
+ defaultViewBox: "0 0 448 512",
482
+ defaultClassName: "size-5",
483
+ viewBox: r,
484
+ className: e,
485
+ spacing: a,
486
+ title: s || "Chart",
487
+ ...n,
488
+ children: [
489
+ /* @__PURE__ */ t(
490
+ "path",
491
+ {
492
+ opacity: o ? "1" : "0.4",
493
+ d: "M160 80c0-26.5 21.5-48 48-48h32c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H208c-26.5 0-48-21.5-48-48V80z"
494
+ }
495
+ ),
496
+ /* @__PURE__ */ t("path", { d: "M368 96c-26.5 0-48 21.5-48 48V432c0 26.5 21.5 48 48 48h32c26.5 0 48-21.5 48-48V144c0-26.5-21.5-48-48-48H368zM48 224c-26.5 0-48 21.5-48 48V432c0 26.5 21.5 48 48 48H80c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48H48z" })
497
+ ]
498
+ }
499
+ ), tr = ({
500
+ className: e,
501
+ viewBox: r,
502
+ spacing: a,
503
+ title: s,
504
+ monotone: o,
505
+ ...n
506
+ }) => /* @__PURE__ */ d(
507
+ A,
508
+ {
509
+ defaultViewBox: "0 0 448 512",
510
+ defaultClassName: "size-5",
511
+ viewBox: r,
512
+ className: e,
513
+ spacing: a,
514
+ title: s || "Delete",
515
+ ...n,
516
+ children: [
517
+ /* @__PURE__ */ t(
518
+ "path",
519
+ {
520
+ opacity: o ? "1" : "0.4",
521
+ d: "M416 96H32V448c0 35.3 28.7 64 64 64H352c35.3 0 64-28.7 64-64V96zM144 176V400c0 8.8-7.2 16-16 16s-16-7.2-16-16V176c0-8.8 7.2-16 16-16s16 7.2 16 16zm96 0V400c0 8.8-7.2 16-16 16s-16-7.2-16-16V176c0-8.8 7.2-16 16-16s16 7.2 16 16zm96 0V400c0 8.8-7.2 16-16 16s-16-7.2-16-16V176c0-8.8 7.2-16 16-16s16 7.2 16 16z"
522
+ }
523
+ ),
524
+ /* @__PURE__ */ t("path", { d: "M163.8 0c-12.1 0-23.2 6.8-28.6 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8z" })
525
+ ]
526
+ }
527
+ ), rr = ({
528
+ className: e,
529
+ viewBox: r,
530
+ spacing: a,
531
+ title: s,
532
+ monotone: o,
533
+ ...n
534
+ }) => /* @__PURE__ */ d(
535
+ A,
536
+ {
537
+ defaultViewBox: "0 0 512 512",
538
+ defaultClassName: "size-5",
539
+ viewBox: r,
540
+ className: e,
541
+ spacing: a,
542
+ title: s || "History",
543
+ ...n,
544
+ children: [
545
+ /* @__PURE__ */ t(
546
+ "path",
547
+ {
548
+ opacity: o ? "1" : "0.4",
549
+ d: "M120.2 120.2C155 85.5 203 64 256 64c106 0 192 86 192 192s-86 192-192 192c-40.8 0-78.6-12.7-109.7-34.4c-14.5-10.1-34.4-6.6-44.6 7.9s-6.6 34.4 7.9 44.6C151.2 495 201.7 512 256 512c141.4 0 256-114.6 256-256S397.4 0 256 0C185.3 0 121.3 28.7 75 75L41 41C25.9 25.9 0 36.6 0 57.9V168c0 13.3 10.7 24 24 24H134.1c21.4 0 32.1-25.9 17-41l-30.8-30.8z"
550
+ }
551
+ ),
552
+ /* @__PURE__ */ t("path", { d: "M256 128c13.3 0 24 10.7 24 24v94.1l65 65c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-72-72c-4.5-4.5-7-10.6-7-17V152c0-13.3 10.7-24 24-24z" })
553
+ ]
554
+ }
555
+ ), ar = ({
556
+ className: e,
557
+ viewBox: r,
558
+ spacing: a,
559
+ title: s,
560
+ monotone: o,
561
+ ...n
562
+ }) => /* @__PURE__ */ d(
563
+ A,
564
+ {
565
+ defaultViewBox: "0 0 512 512",
566
+ defaultClassName: "size-5",
567
+ viewBox: r,
568
+ className: e,
569
+ spacing: a,
570
+ title: s || "Info",
571
+ ...n,
572
+ children: [
573
+ /* @__PURE__ */ t(
574
+ "path",
575
+ {
576
+ opacity: "0.4",
577
+ d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"
578
+ }
579
+ ),
580
+ /* @__PURE__ */ t("path", { d: "M256 128a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM192 248c0-13.3 10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h24V272H216c-13.3 0-24-10.7-24-24z" })
581
+ ]
582
+ }
583
+ ), sr = ({
584
+ className: e,
585
+ viewBox: r,
586
+ spacing: a,
587
+ title: s,
588
+ monotone: o,
589
+ ...n
590
+ }) => /* @__PURE__ */ d(
591
+ A,
592
+ {
593
+ defaultViewBox: "0 0 576 512",
594
+ defaultClassName: "size-5",
595
+ viewBox: r,
596
+ className: e,
597
+ spacing: a,
598
+ title: s || "Profile",
599
+ ...n,
600
+ children: [
601
+ /* @__PURE__ */ t(
602
+ "path",
603
+ {
604
+ opacity: "0.4",
605
+ d: "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H512c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm80 256h64c44.2 0 80 35.8 80 80c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16c0-44.2 35.8-80 80-80zm-32-96a64 64 0 1 1 128 0 64 64 0 1 1 -128 0zm256-32H496c8.8 0 16 7.2 16 16s-7.2 16-16 16H368c-8.8 0-16-7.2-16-16s7.2-16 16-16zm0 64H496c8.8 0 16 7.2 16 16s-7.2 16-16 16H368c-8.8 0-16-7.2-16-16s7.2-16 16-16zm0 64H496c8.8 0 16 7.2 16 16s-7.2 16-16 16H368c-8.8 0-16-7.2-16-16s7.2-16 16-16z"
606
+ }
607
+ ),
608
+ /* @__PURE__ */ t("path", { d: "M176 256a64 64 0 1 0 0-128 64 64 0 1 0 0 128zm-32 32c-44.2 0-80 35.8-80 80c0 8.8 7.2 16 16 16H272c8.8 0 16-7.2 16-16c0-44.2-35.8-80-80-80H144z" })
609
+ ]
610
+ }
611
+ ), he = ({
612
+ className: e,
613
+ viewBox: r,
614
+ spacing: a,
615
+ title: s,
616
+ monotone: o,
617
+ ...n
618
+ }) => /* @__PURE__ */ d(
619
+ A,
620
+ {
621
+ defaultViewBox: "0 0 512 512",
622
+ defaultClassName: "size-5",
623
+ viewBox: r,
624
+ className: e,
625
+ spacing: a,
626
+ title: s || "Refresh",
627
+ ...n,
628
+ children: [
629
+ /* @__PURE__ */ t(
630
+ "path",
631
+ {
632
+ className: "fa-secondary",
633
+ opacity: o ? "1" : "0.4",
634
+ d: "M80 396.9V448c0 17.7-14.3 32-32 32s-32-14.3-32-32V320c0-17.7 14.3-32 32-32H176c17.7 0 32 14.3 32 32s-14.3 32-32 32H125.6l17.2 17.1c62.5 62.5 163.8 62.5 226.3 0c17.5-17.5 30.1-38 37.8-59.8c5.9-16.7 24.2-25.4 40.8-19.5s25.4 24.2 19.5 40.8c-10.8 30.6-28.4 59.3-52.9 83.8c-87.5 87.5-229.3 87.5-316.7 0L80 396.9z"
635
+ }
636
+ ),
637
+ /* @__PURE__ */ t(
638
+ "path",
639
+ {
640
+ className: "fa-primary",
641
+ d: "M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160H336c-17.7 0-32 14.3-32 32s14.3 32 32 32H463.5c0 0 0 0 0 0h.4c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32s-32 14.3-32 32v51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5z"
642
+ }
643
+ )
644
+ ]
645
+ }
646
+ ), nr = ({
647
+ className: e,
648
+ viewBox: r,
649
+ spacing: a,
650
+ title: s,
651
+ monotone: o,
652
+ ...n
653
+ }) => /* @__PURE__ */ d(
654
+ A,
655
+ {
656
+ defaultViewBox: "0 0 512 512",
657
+ defaultClassName: "size-5",
658
+ viewBox: r,
659
+ className: e,
660
+ spacing: a,
661
+ title: s || "Restore",
662
+ ...n,
663
+ children: [
664
+ /* @__PURE__ */ t(
665
+ "path",
666
+ {
667
+ opacity: o ? "1" : "0.4",
668
+ d: "M208 64H432c8.8 0 16 7.2 16 16V304c0 8.8-7.2 16-16 16H416v64h16c44.2 0 80-35.8 80-80V80c0-44.2-35.8-80-80-80H208c-44.2 0-80 35.8-80 80V96h64V80c0-8.8 7.2-16 16-16z"
669
+ }
670
+ ),
671
+ /* @__PURE__ */ t("path", { d: "M64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H320c35.3 0 64-28.7 64-64V192c0-35.3-28.7-64-64-64H64zm32 64H288c17.7 0 32 14.3 32 32s-14.3 32-32 32H96c-17.7 0-32-14.3-32-32s14.3-32 32-32z" })
672
+ ]
673
+ }
674
+ ), or = ({
675
+ className: e,
676
+ viewBox: r,
677
+ spacing: a,
678
+ title: s,
679
+ monotone: o,
680
+ ...n
681
+ }) => /* @__PURE__ */ t(
682
+ A,
683
+ {
684
+ defaultViewBox: "0 0 448 512",
685
+ defaultClassName: "size-5",
686
+ viewBox: r,
687
+ className: e,
688
+ spacing: a,
689
+ title: s || "Settings",
690
+ ...n,
691
+ children: /* @__PURE__ */ t("path", { d: "M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z" })
692
+ }
693
+ );
694
+ function $(e) {
695
+ return be();
696
+ }
697
+ const cr = ({ stats: e }) => {
698
+ const r = (e == null ? void 0 : e.plugins) || [], a = (e == null ? void 0 : e.version) || "", s = (e == null ? void 0 : e.models) || [], o = $(), n = $();
699
+ return /* @__PURE__ */ d(x, { children: [
700
+ /* @__PURE__ */ t("div", { className: "mb-4", children: /* @__PURE__ */ t(
701
+ F,
702
+ {
703
+ header: C.ABOUT.TITLE_CLIENT,
704
+ className: "prose-dark dark:prose-lighter",
705
+ children: V(o, {
706
+ [C.ABOUT.VERSION]: "3.0.2",
707
+ [C.ABOUT.BUILD_TIMESTAMP]: "07/06/2024 03:19 PM EDT"
708
+ })
709
+ }
710
+ ) }),
711
+ /* @__PURE__ */ t(
712
+ F,
713
+ {
714
+ header: C.ABOUT.TITLE_SERVER,
715
+ className: "prose-dark dark:prose-lighter",
716
+ children: V(n, {
717
+ [C.ABOUT.VERSION]: a,
718
+ [q(C.ABOUT.ENGINE, s.length)]: /* @__PURE__ */ t(x, { children: s.map((l) => /* @__PURE__ */ t("div", { className: "text-right", children: l }, l)) }),
719
+ [q(C.ABOUT.PLUGIN, r.length)]: /* @__PURE__ */ t(x, { children: r.map((l) => /* @__PURE__ */ t("div", { className: "text-right", children: l }, l)) })
720
+ })
721
+ }
722
+ )
723
+ ] });
724
+ }, lr = ({
725
+ open: e,
726
+ onOpenChange: r
727
+ }) => {
728
+ const { serverStats: a } = M(U);
729
+ return /* @__PURE__ */ t(K, { open: e, onOpenChange: r, title: Pe, children: /* @__PURE__ */ t(cr, { stats: a }) });
730
+ }, ir = (e) => ge(e), dr = (e) => {
731
+ if (!e || e.length === 0)
732
+ return Ge;
733
+ const r = e.filter(
734
+ (a) => {
735
+ var s, o;
736
+ return ((s = a == null ? void 0 : a.message) == null ? void 0 : s.role) === Ue && typeof ((o = a == null ? void 0 : a.message) == null ? void 0 : o.processingTime) == "number";
737
+ }
738
+ ).map((a) => a.message.processingTime);
739
+ return je({
740
+ data: r,
741
+ formatter: ir
742
+ });
743
+ }, mr = ({
744
+ isAuthenticated: e,
745
+ stats: r
746
+ }) => {
747
+ const { state: a } = M(U), s = Ke - Number(a == null ? void 0 : a.usage), o = $(), n = $();
748
+ return e ? /* @__PURE__ */ d(x, { children: [
749
+ a && a.messages.length > 0 && /* @__PURE__ */ t("div", { className: "mb-4", children: /* @__PURE__ */ t(
750
+ F,
751
+ {
752
+ header: C.CURRENT_STATISTICS.TITLE,
753
+ className: "prose-dark dark:prose-lighter",
754
+ children: V(o, {
755
+ [C.CURRENT_STATISTICS.MODEL_NAME]: (a == null ? void 0 : a.model) || Fe,
756
+ [C.CURRENT_STATISTICS.TOKENS_USED]: a == null ? void 0 : a.usage,
757
+ [C.CURRENT_STATISTICS.REMAINING_TOKENS]: $e.format(s),
758
+ [C.CURRENT_STATISTICS.PROCESSING_TIME]: dr(a == null ? void 0 : a.messages)
759
+ })
760
+ }
761
+ ) }),
762
+ /* @__PURE__ */ t(
763
+ F,
764
+ {
765
+ header: C.MAIN_STATISTICS.TITLE,
766
+ className: "prose-dark dark:prose-lighter",
767
+ children: V(n, {
768
+ [q(C.MAIN_STATISTICS.TOTAL, r.totalChats)]: r.totalChats,
769
+ [C.MAIN_STATISTICS.PROCESSING_TIME]: ge(
770
+ r.averageProcessingTimes
771
+ )
772
+ })
773
+ }
774
+ )
775
+ ] }) : null;
776
+ }, ur = ({
777
+ open: e,
778
+ onOpenChange: r
779
+ }) => {
780
+ const [a, s] = y({
781
+ averageProcessingTimes: 0,
782
+ totalChats: 0
783
+ }), { isAuthenticated: o, getAccessToken: n, user: l } = G();
784
+ return R(() => {
785
+ !e || !l || (async () => {
786
+ try {
787
+ const i = await ee({
788
+ accessToken: await n(),
789
+ type: te.GET_CHATS_STATS,
790
+ params: {
791
+ userId: l.username
792
+ }
793
+ });
794
+ i.status === 200 && s(i.data);
795
+ } catch {
796
+ }
797
+ })();
798
+ }, [e, n, l]), /* @__PURE__ */ t(K, { open: e, onOpenChange: r, title: Ce, children: /* @__PURE__ */ t(mr, { isAuthenticated: o, stats: a }) });
799
+ }, Ee = ({
800
+ showConfirmation: e,
801
+ setShowConfirmation: r,
802
+ action: a,
803
+ children: s,
804
+ customStrings: o
805
+ }) => /* @__PURE__ */ t(
806
+ K,
807
+ {
808
+ kind: "messagebox",
809
+ open: e,
810
+ onOpenChange: r,
811
+ title: o.title,
812
+ footer: /* @__PURE__ */ d(oe, { columnGap: 2, alignHorizontal: "flex-end", children: [
813
+ /* @__PURE__ */ t(D, { children: /* @__PURE__ */ t(
814
+ ce,
815
+ {
816
+ mode: "dark",
817
+ variant: "secondary",
818
+ focusMode: "light",
819
+ onClick: () => {
820
+ r(!1);
821
+ },
822
+ children: o.cancelAction
823
+ }
824
+ ) }),
825
+ /* @__PURE__ */ t(D, { children: /* @__PURE__ */ t(
826
+ ce,
827
+ {
828
+ mode: "dark",
829
+ variant: "danger",
830
+ focusMode: "light",
831
+ onClick: () => {
832
+ r(!1), a();
833
+ },
834
+ children: o.confirmAction
835
+ }
836
+ ) })
837
+ ] }),
838
+ children: s
839
+ }
840
+ );
841
+ var hr = typeof window < "u", pr = function(e, r) {
842
+ return hr ? window.matchMedia(e).matches : (process.env.NODE_ENV !== "production" && console.warn("`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches."), !1);
843
+ }, fr = function(e, r) {
844
+ var a = y(pr(e)), s = a[0], o = a[1];
845
+ return R(function() {
846
+ var n = !0, l = window.matchMedia(e), i = function() {
847
+ n && o(!!l.matches);
848
+ };
849
+ return l.addEventListener("change", i), o(l.matches), function() {
850
+ n = !1, l.removeEventListener("change", i);
851
+ };
852
+ }, [e]), s;
853
+ };
854
+ const gr = async (e, r, a, s) => {
855
+ try {
856
+ const o = await ee({
857
+ accessToken: s,
858
+ type: te.GET_CHAT,
859
+ params: {
860
+ id: e.id
861
+ }
862
+ });
863
+ o.status === 200 && (r({
864
+ type: We
865
+ }), r({
866
+ type: Xe,
867
+ payload: {
868
+ id: e.id,
869
+ model: o.data.model,
870
+ usage: o.data.usage,
871
+ messages: o.data.messages
872
+ }
873
+ }), a(!1));
874
+ } catch {
875
+ }
876
+ }, pe = (e) => {
877
+ const r = e[0];
878
+ return Je(r == null ? void 0 : r.content, 100);
879
+ }, Cr = ({
880
+ filteredHistory: e,
881
+ setFilteredHistory: r,
882
+ setFullHistory: a,
883
+ dispatch: s,
884
+ onOpenChange: o
885
+ }) => {
886
+ var k;
887
+ const { user: n, getAccessToken: l } = G(), i = P({
888
+ id: 0,
889
+ timestamp: "",
890
+ message: ""
891
+ }), [m, h] = y(!1), p = fr("(min-width: 480px)"), { state: u, dispatch: T } = M(ye), [, f] = Z({
892
+ key: Q + Ye,
893
+ initialValue: u.sortDirection
894
+ }), b = e.data.sort(
895
+ (g, N) => {
896
+ switch (u.sortedCell) {
897
+ case "timestamp":
898
+ if (u.sortDirection === v.ASC)
899
+ return new Date(g[u.sortedCell]).getTime() - new Date(N[u.sortedCell]).getTime();
900
+ if (u.sortDirection === v.DESC)
901
+ return new Date(N[u.sortedCell]).getTime() - new Date(g[u.sortedCell]).getTime();
902
+ break;
903
+ default:
904
+ return 0;
905
+ }
906
+ return 0;
907
+ }
908
+ ), c = (g) => {
909
+ switch (u.sortDirection) {
910
+ case !1:
911
+ f(v.ASC), T({
912
+ type: ae,
913
+ payload: {
914
+ sortedCell: g,
915
+ sortDirection: v.ASC
916
+ }
917
+ });
918
+ break;
919
+ case v.ASC:
920
+ f(v.DESC), T({
921
+ type: ae,
922
+ payload: {
923
+ sortedCell: g,
924
+ sortDirection: v.DESC
925
+ }
926
+ });
927
+ break;
928
+ default:
929
+ f(v.ASC), T({
930
+ type: ae,
931
+ payload: {
932
+ sortedCell: g,
933
+ sortDirection: v.ASC
934
+ }
935
+ });
936
+ break;
937
+ }
938
+ };
939
+ return /* @__PURE__ */ d(x, { children: [
940
+ /* @__PURE__ */ d(
941
+ Ee,
942
+ {
943
+ showConfirmation: m,
944
+ setShowConfirmation: h,
945
+ action: async () => {
946
+ const g = i.current;
947
+ try {
948
+ const N = await ee({
949
+ accessToken: await l(),
950
+ type: te.DELETE_CHAT,
951
+ params: {
952
+ userId: (n == null ? void 0 : n.username) || "",
953
+ id: g.id
954
+ }
955
+ });
956
+ N.status === 200 && (a(N.data), r({ data: N.data }));
957
+ } catch {
958
+ }
959
+ },
960
+ customStrings: {
961
+ confirmAction: "Delete",
962
+ cancelAction: "Cancel",
963
+ title: "Delete chat"
964
+ },
965
+ children: [
966
+ /* @__PURE__ */ t("p", { className: "m-0", children: "Are you sure you want to delete the following chat:" }),
967
+ /* @__PURE__ */ d("ul", { className: "m-0", children: [
968
+ /* @__PURE__ */ d("li", { children: [
969
+ "Timestamp:",
970
+ " ",
971
+ /* @__PURE__ */ t("span", { className: "text-lg", children: i.current && i.current.timestamp })
972
+ ] }),
973
+ /* @__PURE__ */ d("li", { children: [
974
+ "First message:",
975
+ " ",
976
+ /* @__PURE__ */ t("span", { className: "text-lg", children: (k = i.current) == null ? void 0 : k.message })
977
+ ] })
978
+ ] })
979
+ ]
980
+ }
981
+ ),
982
+ /* @__PURE__ */ d(mt, { stickyHeader: !0, stickyFooter: !0, wrapperClassName: "max-h-[60vh]", children: [
983
+ /* @__PURE__ */ t(ut, { children: /* @__PURE__ */ d(se, { children: [
984
+ p && /* @__PURE__ */ t(H, { className: "sr-only", children: "Row" }),
985
+ /* @__PURE__ */ t(
986
+ ht,
987
+ {
988
+ cellId: "timestamp",
989
+ align: "left",
990
+ sortDirection: u.sortDirection,
991
+ sortedCell: u.sortedCell,
992
+ onClick: () => {
993
+ c("timestamp");
994
+ },
995
+ children: "Date"
996
+ }
997
+ ),
998
+ /* @__PURE__ */ t(H, { children: "First message" }),
999
+ /* @__PURE__ */ t(H, { className: "text-right", children: "Actions" })
1000
+ ] }) }),
1001
+ /* @__PURE__ */ t(pt, { children: b.map((g, N) => {
1002
+ var E;
1003
+ return ((E = g == null ? void 0 : g.messages) == null ? void 0 : E.length) > 0 ? /* @__PURE__ */ d(se, { children: [
1004
+ p && /* @__PURE__ */ t(H, { children: N + 1 }),
1005
+ /* @__PURE__ */ t(
1006
+ H,
1007
+ {
1008
+ component: "th",
1009
+ scope: "row",
1010
+ className: "font-medium text-gray-400 sm:whitespace-nowrap",
1011
+ children: g.timestamp
1012
+ }
1013
+ ),
1014
+ /* @__PURE__ */ t(H, { className: "max-w-[100px] text-white sm:max-w-full", children: pe(g.messages) }),
1015
+ /* @__PURE__ */ t(H, { children: /* @__PURE__ */ d("div", { className: "flex justify-end gap-2", children: [
1016
+ /* @__PURE__ */ t(
1017
+ O,
1018
+ {
1019
+ focusMode: "alt-system",
1020
+ noBorder: !0,
1021
+ label: "Restore chat",
1022
+ onClick: async () => {
1023
+ const _ = await l();
1024
+ gr(
1025
+ g,
1026
+ s,
1027
+ o,
1028
+ _
1029
+ );
1030
+ },
1031
+ children: /* @__PURE__ */ t(nr, { className: "h-3 w-3", monotone: !0 })
1032
+ }
1033
+ ),
1034
+ /* @__PURE__ */ t(
1035
+ O,
1036
+ {
1037
+ focusMode: "alt-system",
1038
+ noBorder: !0,
1039
+ label: "Delete chat",
1040
+ onClick: () => {
1041
+ i.current = {
1042
+ id: g.id,
1043
+ timestamp: g.timestamp,
1044
+ message: pe(g.messages)
1045
+ }, h(!m);
1046
+ },
1047
+ children: /* @__PURE__ */ t("div", { className: "text-red-400", children: /* @__PURE__ */ t(tr, { className: "h-3 w-3", monotone: !0 }) })
1048
+ }
1049
+ )
1050
+ ] }) })
1051
+ ] }, `${C.HISTORY.TITLE}-${g.id}-${N}`) : null;
1052
+ }) }),
1053
+ /* @__PURE__ */ t(ft, { children: /* @__PURE__ */ t(se, { children: /* @__PURE__ */ t(H, { colSpan: 4, children: /* @__PURE__ */ t("div", { children: q(
1054
+ `${e.data.length} chat`,
1055
+ e.data.length
1056
+ ) }) }) }) })
1057
+ ] })
1058
+ ] });
1059
+ };
1060
+ function fe(e, r) {
1061
+ return e.filter(
1062
+ (a) => a.messages.some(
1063
+ (s) => s.content !== null && s.content.toLowerCase().includes(r.toLowerCase())
1064
+ )
1065
+ );
1066
+ }
1067
+ const br = ({
1068
+ onOpenChange: e,
1069
+ historyData: r
1070
+ }) => {
1071
+ const { isAuthenticated: a } = G(), s = P(null), { dispatch: o } = M(U), { state: n, dispatch: l } = M(ye), [, i] = Z({
1072
+ key: Q + qe,
1073
+ initialValue: n.searchString
1074
+ }), [m, h] = y(r), [p, u] = y({
1075
+ data: m
1076
+ }), T = (c) => {
1077
+ const w = fe(m, c);
1078
+ u({
1079
+ data: w
1080
+ }), i(c), l({
1081
+ type: Ze,
1082
+ payload: { searchString: c }
1083
+ });
1084
+ }, f = (c) => {
1085
+ T(c.target.value);
1086
+ }, b = async (c) => {
1087
+ c.preventDefault();
1088
+ };
1089
+ return R(() => {
1090
+ const c = fe(
1091
+ m,
1092
+ n.searchString
1093
+ );
1094
+ u({
1095
+ data: c
1096
+ });
1097
+ }, [m, n.searchString]), a ? p && p.data && /* @__PURE__ */ d(x, { children: [
1098
+ /* @__PURE__ */ t("form", { autoComplete: "off", onSubmit: b, children: /* @__PURE__ */ t(
1099
+ Qe,
1100
+ {
1101
+ ref: s,
1102
+ defaultValue: n.searchString,
1103
+ focusMode: "light",
1104
+ name: "Search",
1105
+ label: "Search",
1106
+ onChange: f,
1107
+ spacing: { t: 2, b: 2 },
1108
+ ...n.searchString && {
1109
+ rightElement: /* @__PURE__ */ t(
1110
+ ce,
1111
+ {
1112
+ disabled: !n.searchString,
1113
+ mode: "dark",
1114
+ noBorder: !0,
1115
+ size: "small",
1116
+ onClick: () => {
1117
+ var c;
1118
+ T(""), (c = s.current) != null && c.value && (s.current.value = "", s.current.focus());
1119
+ },
1120
+ children: "Reset"
1121
+ }
1122
+ )
1123
+ }
1124
+ }
1125
+ ) }),
1126
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-2 sm:flex-row", children: /* @__PURE__ */ t(
1127
+ Cr,
1128
+ {
1129
+ filteredHistory: p,
1130
+ setFilteredHistory: u,
1131
+ setFullHistory: h,
1132
+ dispatch: o,
1133
+ onOpenChange: e
1134
+ }
1135
+ ) })
1136
+ ] }) : null;
1137
+ }, Nr = ({
1138
+ open: e,
1139
+ onOpenChange: r,
1140
+ historyData: a
1141
+ }) => /* @__PURE__ */ t(K, { open: e, onOpenChange: r, title: et, children: /* @__PURE__ */ t(br, { onOpenChange: r, historyData: a }) }), yr = () => {
1142
+ const { isAuthenticated: e, user: r } = G(), [a, s] = Z({
1143
+ key: Q + tt,
1144
+ initialValue: !1
1145
+ }), [, o, n] = Z({
1146
+ key: Q + rt,
1147
+ initialValue: { latitude: 0, longitude: 0, accuracy: 0 }
1148
+ }), [l, i] = y(!0), m = $(), { state: h, dispatch: p } = M(U), u = (r == null ? void 0 : r.username) || "", T = (c) => {
1149
+ s(c);
1150
+ }, f = async () => {
1151
+ i(!1), n(), p({
1152
+ type: de,
1153
+ payload: {
1154
+ location: {
1155
+ latitude: 0,
1156
+ longitude: 0,
1157
+ accuracy: 0
1158
+ }
1159
+ }
1160
+ });
1161
+ const c = await at();
1162
+ o(c), p({
1163
+ type: de,
1164
+ payload: {
1165
+ location: c
1166
+ }
1167
+ });
1168
+ };
1169
+ R(() => {
1170
+ let c;
1171
+ return l || (c = window.setTimeout(() => {
1172
+ i(!0);
1173
+ }, 3e3)), () => {
1174
+ clearTimeout(c);
1175
+ };
1176
+ }, [l]);
1177
+ const b = (c) => {
1178
+ if (c != null && c.city && (c != null && c.country) && (c != null && c.region))
1179
+ return /* @__PURE__ */ t(x, { children: /* @__PURE__ */ d(oe, { alignVertical: "center", columnGap: 4, children: [
1180
+ /* @__PURE__ */ d(D, { children: [
1181
+ /* @__PURE__ */ d("div", { className: "text-right", children: [
1182
+ c.city,
1183
+ ", ",
1184
+ c.region
1185
+ ] }),
1186
+ /* @__PURE__ */ t("div", { className: "text-right", children: c.country })
1187
+ ] }),
1188
+ /* @__PURE__ */ t(D, { children: /* @__PURE__ */ t(
1189
+ O,
1190
+ {
1191
+ disabled: !l,
1192
+ size: "small",
1193
+ className: "mt-2",
1194
+ onClick: f,
1195
+ children: /* @__PURE__ */ t(he, { className: "size-3", monotone: !0 })
1196
+ }
1197
+ ) })
1198
+ ] }) });
1199
+ const w = st(c == null ? void 0 : c.latitude), k = nt(c == null ? void 0 : c.longitude);
1200
+ return /* @__PURE__ */ t(x, { children: /* @__PURE__ */ d(oe, { alignVertical: "center", columnGap: 4, children: [
1201
+ /* @__PURE__ */ d(D, { children: [
1202
+ /* @__PURE__ */ t("div", { children: w }),
1203
+ /* @__PURE__ */ t("div", { children: k })
1204
+ ] }),
1205
+ /* @__PURE__ */ t(D, { children: /* @__PURE__ */ t(
1206
+ O,
1207
+ {
1208
+ size: "small",
1209
+ className: "mt-2",
1210
+ onClick: f,
1211
+ children: /* @__PURE__ */ t(he, { className: "size-3", monotone: !0 })
1212
+ }
1213
+ ) })
1214
+ ] }) });
1215
+ };
1216
+ return e && u ? /* @__PURE__ */ t(
1217
+ F,
1218
+ {
1219
+ header: C.PREFERENCES.TITLE,
1220
+ className: "prose-dark dark:prose-lighter",
1221
+ children: V(m, {
1222
+ [C.PREFERENCES.NAME]: u,
1223
+ // [CARDS.PREFERENCES.EMAIL]: endUser.email,
1224
+ [C.PREFERENCES.ENGINE_DETAILS]: /* @__PURE__ */ t(
1225
+ Qt,
1226
+ {
1227
+ noBorder: !0,
1228
+ labelHidden: !0,
1229
+ label: C.PREFERENCES.ENGINE_DETAILS,
1230
+ name: C.PREFERENCES.ENGINE_DETAILS,
1231
+ onChange: T,
1232
+ checked: a
1233
+ }
1234
+ ),
1235
+ [C.PREFERENCES.LOCATION]: b(h == null ? void 0 : h.location)
1236
+ })
1237
+ }
1238
+ ) : null;
1239
+ }, Tr = ({
1240
+ open: e,
1241
+ onOpenChange: r
1242
+ }) => /* @__PURE__ */ t(K, { open: e, onOpenChange: r, title: ot, children: /* @__PURE__ */ t(yr, {}) }), Ar = () => {
1243
+ const { state: e } = M(U), [r, a] = y(!1), [s, o] = y(!1), [n, l] = y(!1), [i, m] = y(!1), [h, p] = y([]), [u, T] = y(!1), [f, b] = y({
1244
+ done: !1,
1245
+ progress: !1,
1246
+ timestamp: Date.now()
1247
+ }), { logout: c, getAccessToken: w, user: k } = G(), g = () => {
1248
+ a(!r);
1249
+ }, N = () => {
1250
+ o(!s);
1251
+ }, E = () => {
1252
+ l(!n);
1253
+ }, _ = () => {
1254
+ m(!i);
1255
+ }, re = async (I) => {
1256
+ const W = Date.now();
1257
+ if (I && !(!k || !e || f.progress || f.done === !0 && W - f.timestamp < 5e3)) {
1258
+ b({
1259
+ done: !0,
1260
+ progress: !0,
1261
+ timestamp: W
1262
+ });
1263
+ try {
1264
+ const B = await ee({
1265
+ accessToken: await w(),
1266
+ type: te.GET_CHATS,
1267
+ params: {
1268
+ userId: k.username
1269
+ }
1270
+ });
1271
+ B.status === 200 && (p(B.data), b({
1272
+ done: !0,
1273
+ progress: !1,
1274
+ timestamp: Date.now()
1275
+ }));
1276
+ } catch {
1277
+ b({
1278
+ done: !0,
1279
+ progress: !1,
1280
+ timestamp: Date.now()
1281
+ });
1282
+ }
1283
+ }
1284
+ }, Y = () => {
1285
+ T(!u);
1286
+ };
1287
+ return /* @__PURE__ */ d(x, { children: [
1288
+ /* @__PURE__ */ t(
1289
+ Ee,
1290
+ {
1291
+ showConfirmation: u,
1292
+ setShowConfirmation: T,
1293
+ action: c,
1294
+ customStrings: {
1295
+ confirmAction: me,
1296
+ cancelAction: "Cancel",
1297
+ title: me
1298
+ },
1299
+ children: /* @__PURE__ */ t("p", { children: "Are you sure you want to log out?" })
1300
+ }
1301
+ ),
1302
+ /* @__PURE__ */ t(Tr, { open: r, onOpenChange: a }),
1303
+ /* @__PURE__ */ t(ur, { open: s, onOpenChange: o }),
1304
+ /* @__PURE__ */ t(
1305
+ Nr,
1306
+ {
1307
+ open: n,
1308
+ onOpenChange: l,
1309
+ historyData: h
1310
+ }
1311
+ ),
1312
+ /* @__PURE__ */ t(lr, { open: i, onOpenChange: m }),
1313
+ /* @__PURE__ */ t("div", { className: "relative", children: /* @__PURE__ */ t("div", { className: "absolute bottom-[-28px] right-[-7px]", children: /* @__PURE__ */ d(
1314
+ xe,
1315
+ {
1316
+ mode: "dark",
1317
+ focusMode: "light",
1318
+ trigger: /* @__PURE__ */ t(O, { children: /* @__PURE__ */ t(or, {}) }),
1319
+ defaultPlacement: "bottom-end",
1320
+ onOpenChange: re,
1321
+ children: [
1322
+ /* @__PURE__ */ t(
1323
+ L,
1324
+ {
1325
+ label: "Profile",
1326
+ onClick: g,
1327
+ icon: /* @__PURE__ */ t(sr, {})
1328
+ }
1329
+ ),
1330
+ /* @__PURE__ */ t(
1331
+ L,
1332
+ {
1333
+ label: Ce,
1334
+ onClick: N,
1335
+ icon: /* @__PURE__ */ t(er, {})
1336
+ }
1337
+ ),
1338
+ /* @__PURE__ */ t(
1339
+ L,
1340
+ {
1341
+ label: "History",
1342
+ onClick: E,
1343
+ icon: /* @__PURE__ */ t(rr, {})
1344
+ }
1345
+ ),
1346
+ /* @__PURE__ */ t(
1347
+ L,
1348
+ {
1349
+ label: "About",
1350
+ onClick: _,
1351
+ icon: /* @__PURE__ */ t(ar, {})
1352
+ }
1353
+ ),
1354
+ e && e.id && !e.isComponent && /* @__PURE__ */ d(x, { children: [
1355
+ /* @__PURE__ */ t(_t, {}),
1356
+ /* @__PURE__ */ t(
1357
+ L,
1358
+ {
1359
+ label: "Log out",
1360
+ onClick: Y,
1361
+ icon: /* @__PURE__ */ t("div", { className: "text-red-700", children: /* @__PURE__ */ t(Zt, { monotone: !0 }) })
1362
+ }
1363
+ )
1364
+ ] })
1365
+ ]
1366
+ }
1367
+ ) }) })
1368
+ ] });
1369
+ };
1370
+ export {
1371
+ Ar as default
1372
+ };