@versini/sassysaint 1.0.4 → 1.0.5

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