gentiq 0.7.29 → 0.7.30
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.
- package/README.md +6 -1
- package/dist/{checkbox-BNiSskM4.js → checkbox-DllHCh8Z.js} +540 -506
- package/dist/gentiq-admin.es.js +821 -801
- package/dist/gentiq-index.es.js +263 -257
- package/dist/gentiq.css +1 -1
- package/dist/src/lib/errors.d.ts +2 -1
- package/dist/src/locales/en.json.d.ts +3 -0
- package/dist/src/locales/fa.json.d.ts +3 -0
- package/dist/src/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/gentiq-index.es.js
CHANGED
|
@@ -4,23 +4,23 @@ import { useState as S, useMemo as $, useEffect as j, useRef as te, useCallback
|
|
|
4
4
|
import { QueryClient as Ye, QueryClientProvider as Ze, useQueryClient as pe, useQuery as et, useInfiniteQuery as tt } from "@tanstack/react-query";
|
|
5
5
|
import { I18nextProvider as at, useTranslation as ce } from "react-i18next";
|
|
6
6
|
import { Trans as Ya, Translation as Za, useTranslation as er, withTranslation as tr } from "react-i18next";
|
|
7
|
-
import { g as rt, u as
|
|
8
|
-
import { N as rr, O as nr, P as sr, Q as or, R as ir, U as lr, V as cr, W as dr, X as ur, Y as mr, Z as hr, _ as pr, $ as gr } from "./checkbox-
|
|
9
|
-
import { Loader2Icon as vt, OctagonXIcon as xt, TriangleAlertIcon as yt, InfoIcon as wt, CircleCheckIcon as Nt, XIcon as kt, PanelLeftIcon as _t, Layers as Me, User as Ct, ShieldCheck as St, Settings as Ne, Smartphone as Pt, Lock as Tt, Save as Mt, Sun as
|
|
10
|
-
import { useTheme as
|
|
11
|
-
import { Toaster as
|
|
7
|
+
import { g as rt, u as I, d as nt, C as Fe, T as st, a as re, b as je, j as be, G as Pe, c as le, e as v, f as ot, h as Oe, i as $e, k as Be, l as Ue, B as Z, m as Ke, n as he, D as He, o as it, p as Ve, L as Q, I as X, S as ve, q as xe, r as ye, s as we, t as me, v as lt, w as Te, x as ct, y as dt, z as ut, A as de, E as mt, F as ht, H as pt, J as gt, K as ft, M as bt } from "./checkbox-DllHCh8Z.js";
|
|
8
|
+
import { N as rr, O as nr, P as sr, Q as or, R as ir, U as lr, V as cr, W as dr, X as ur, Y as mr, Z as hr, _ as pr, $ as gr } from "./checkbox-DllHCh8Z.js";
|
|
9
|
+
import { Loader2Icon as vt, OctagonXIcon as xt, TriangleAlertIcon as yt, InfoIcon as wt, CircleCheckIcon as Nt, XIcon as kt, PanelLeftIcon as _t, Layers as Me, User as Ct, ShieldCheck as St, Settings as Ne, Smartphone as Pt, Lock as Tt, Save as Mt, Sun as It, Moon as Dt, Monitor as Et, Zap as Ie, Globe as At, Coins as Lt, LogOut as zt, CirclePlus as Rt, Plus as qt, Search as Ft, Check as jt, X as Ot, Pin as De, MoreVertical as $t, PinOff as Bt, Share2 as Ut, Pencil as Kt, Trash as Ht } from "lucide-react";
|
|
10
|
+
import { useTheme as Vt } from "next-themes";
|
|
11
|
+
import { Toaster as Qt, toast as J } from "sonner";
|
|
12
12
|
import { useChat as Gt } from "@ai-sdk/react";
|
|
13
13
|
import { DefaultChatTransport as Wt } from "ai";
|
|
14
|
-
import { useLocation as
|
|
14
|
+
import { useLocation as Qe, useNavigate as _e, Navigate as Xt, useParams as Jt } from "react-router-dom";
|
|
15
15
|
import { nanoid as ue } from "nanoid";
|
|
16
16
|
import { Slot as Yt } from "@radix-ui/react-slot";
|
|
17
17
|
import { cva as Zt } from "class-variance-authority";
|
|
18
18
|
import "@radix-ui/react-separator";
|
|
19
19
|
import * as se from "@radix-ui/react-dialog";
|
|
20
20
|
const ea = ({ ...a }) => {
|
|
21
|
-
const { theme: t = "system" } =
|
|
21
|
+
const { theme: t = "system" } = Vt();
|
|
22
22
|
return /* @__PURE__ */ e(
|
|
23
|
-
|
|
23
|
+
Qt,
|
|
24
24
|
{
|
|
25
25
|
theme: t,
|
|
26
26
|
className: "toaster group",
|
|
@@ -45,23 +45,23 @@ function Ha({
|
|
|
45
45
|
children: a,
|
|
46
46
|
api: t,
|
|
47
47
|
app: o,
|
|
48
|
-
i18n:
|
|
48
|
+
i18n: m,
|
|
49
49
|
components: c,
|
|
50
50
|
history: d,
|
|
51
51
|
welcome: p,
|
|
52
52
|
threadActions: g,
|
|
53
|
-
composer:
|
|
53
|
+
composer: h,
|
|
54
54
|
theme: k,
|
|
55
55
|
disclaimer: x,
|
|
56
56
|
settings: N
|
|
57
57
|
}) {
|
|
58
58
|
const [i, T] = S(null), P = $(
|
|
59
|
-
() =>
|
|
59
|
+
() => m?.instance ?? rt,
|
|
60
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
-
[
|
|
61
|
+
[m?.instance]
|
|
62
62
|
), z = t || {};
|
|
63
63
|
j(() => {
|
|
64
|
-
|
|
64
|
+
I.getAppConfig().then((u) => T(u)).catch((u) => console.debug("Gentiq: No dynamic settings available or fetch failed", u));
|
|
65
65
|
}, []), j(() => {
|
|
66
66
|
i?.app_name && (document.title = P.t(i.app_name));
|
|
67
67
|
}, [i, P]);
|
|
@@ -75,7 +75,9 @@ function Ha({
|
|
|
75
75
|
...u,
|
|
76
76
|
name: (i.app_name ? P.t(i.app_name) : null) || u.name,
|
|
77
77
|
adminTitle: (i.admin_title ? P.t(i.admin_title) : null) || u.adminTitle,
|
|
78
|
+
version: i.app_version || u.version,
|
|
78
79
|
showSettings: i.show_settings ?? u.showSettings,
|
|
80
|
+
showVersionInSettings: i.show_version_in_settings ?? u.showVersionInSettings,
|
|
79
81
|
showToolDetails: i.show_tool_details ?? u.showToolDetails,
|
|
80
82
|
disableSignup: i.disable_signup ?? u.disableSignup,
|
|
81
83
|
disableAuthPage: i.disable_auth_page ?? u.disableAuthPage,
|
|
@@ -90,7 +92,7 @@ function Ha({
|
|
|
90
92
|
} : p, [p, i]), y = $(() => {
|
|
91
93
|
const u = i?.disclaimer || x;
|
|
92
94
|
return u && P.t(u);
|
|
93
|
-
}, [x, i, P]),
|
|
95
|
+
}, [x, i, P]), f = $(() => i ? {
|
|
94
96
|
...d,
|
|
95
97
|
enabled: i.history_enabled ?? d?.enabled,
|
|
96
98
|
showDelete: i.history_show_delete ?? d?.showDelete,
|
|
@@ -102,12 +104,12 @@ function Ha({
|
|
|
102
104
|
feedback: i.thread_actions_feedback ?? g?.feedback,
|
|
103
105
|
retry: i.thread_actions_retry ?? g?.retry
|
|
104
106
|
} : g, [g, i]), B = $(() => i ? {
|
|
105
|
-
...
|
|
107
|
+
...h,
|
|
106
108
|
attachments: {
|
|
107
|
-
...
|
|
108
|
-
enabled: i.composer_attachments ??
|
|
109
|
+
...h?.attachments,
|
|
110
|
+
enabled: i.composer_attachments ?? h?.attachments?.enabled
|
|
109
111
|
}
|
|
110
|
-
} :
|
|
112
|
+
} : h, [h, i]), W = $(() => i ? {
|
|
111
113
|
...N,
|
|
112
114
|
sections: {
|
|
113
115
|
...N?.sections,
|
|
@@ -148,13 +150,13 @@ function Ha({
|
|
|
148
150
|
}
|
|
149
151
|
}), []);
|
|
150
152
|
j(() => {
|
|
151
|
-
|
|
153
|
+
I.init({
|
|
152
154
|
api: z,
|
|
153
155
|
app: K
|
|
154
156
|
});
|
|
155
157
|
}, [K]);
|
|
156
|
-
const
|
|
157
|
-
R !==
|
|
158
|
+
const D = te(null), R = m?.resources;
|
|
159
|
+
R !== D.current && (D.current = R, R && Object.entries(R).forEach(([u, E]) => {
|
|
158
160
|
Object.entries(E).forEach(([l, w]) => {
|
|
159
161
|
P.addResourceBundle(u, l, w, !0, !0);
|
|
160
162
|
});
|
|
@@ -165,24 +167,24 @@ function Ha({
|
|
|
165
167
|
P.addResourceBundle(u, l, w, !0, !0);
|
|
166
168
|
});
|
|
167
169
|
}));
|
|
168
|
-
const q = te(null),
|
|
169
|
-
return
|
|
170
|
+
const q = te(null), b = m?.instance;
|
|
171
|
+
return b && b !== q.current && (q.current = b, Object.entries(nt).forEach(([u, E]) => {
|
|
170
172
|
Object.entries(E).forEach(([l, w]) => {
|
|
171
|
-
|
|
173
|
+
b.hasResourceBundle(u, l) || b.addResourceBundle(u, l, w, !0, !1);
|
|
172
174
|
});
|
|
173
175
|
})), /* @__PURE__ */ e(at, { i18n: P, children: /* @__PURE__ */ r(Ze, { client: O, children: [
|
|
174
176
|
/* @__PURE__ */ r(
|
|
175
177
|
Fe,
|
|
176
178
|
{
|
|
177
179
|
components: c,
|
|
178
|
-
history:
|
|
180
|
+
history: f,
|
|
179
181
|
welcome: C,
|
|
180
182
|
threadActions: L,
|
|
181
183
|
composer: B,
|
|
182
184
|
theme: k,
|
|
183
185
|
disclaimer: y,
|
|
184
186
|
app: K,
|
|
185
|
-
i18n:
|
|
187
|
+
i18n: m,
|
|
186
188
|
settings: W,
|
|
187
189
|
children: [
|
|
188
190
|
/* @__PURE__ */ e(ta, {}),
|
|
@@ -204,26 +206,26 @@ function ta() {
|
|
|
204
206
|
}, [a?.favicon]), null;
|
|
205
207
|
}
|
|
206
208
|
function Ce() {
|
|
207
|
-
const a =
|
|
208
|
-
const p = a.pathname, g = p.endsWith("/") && p !== "/" ? p.slice(0, -1) : p,
|
|
209
|
-
if (g === (
|
|
210
|
-
if (p.startsWith(
|
|
211
|
-
let k = p.slice(
|
|
209
|
+
const a = Qe(), t = _e(), m = I.getConfig().app?.basePath || "/", c = $(() => {
|
|
210
|
+
const p = a.pathname, g = p.endsWith("/") && p !== "/" ? p.slice(0, -1) : p, h = m.endsWith("/") && m !== "/" ? m.slice(0, -1) : m;
|
|
211
|
+
if (g === (h || "/")) return "/";
|
|
212
|
+
if (p.startsWith(h) && h !== "/") {
|
|
213
|
+
let k = p.slice(h.length);
|
|
212
214
|
return k.startsWith("/") || (k = "/" + k), k;
|
|
213
215
|
}
|
|
214
|
-
return
|
|
215
|
-
}, [a.pathname,
|
|
216
|
-
t(be(
|
|
217
|
-
}, [t,
|
|
216
|
+
return h === "/" ? p : "/";
|
|
217
|
+
}, [a.pathname, m]), d = Y((p) => {
|
|
218
|
+
t(be(m, p || "/"), { replace: !1 });
|
|
219
|
+
}, [t, m]);
|
|
218
220
|
return [c, d];
|
|
219
221
|
}
|
|
220
222
|
function aa({ onFinish: a } = {}) {
|
|
221
|
-
const { t } = ce(["chat", "errors"]), o = pe(),
|
|
223
|
+
const { t } = ce(["chat", "errors"]), o = pe(), m = I.getConfig(), c = m.app?.cacheNamespace || "gentiq", [d, p] = Ce(), [g, h] = S(() => ue()), k = te(/* @__PURE__ */ new Set());
|
|
222
224
|
j(() => {
|
|
223
|
-
d === "/" ?
|
|
225
|
+
d === "/" ? h(ue()) : g && d !== `/${g}` && h(ue());
|
|
224
226
|
}, [d]);
|
|
225
|
-
const x = $(() => d === "/" ? g : d.replace(/^\//, ""), [d, g]), N = Y((
|
|
226
|
-
k.current.forEach((
|
|
227
|
+
const x = $(() => d === "/" ? g : d.replace(/^\//, ""), [d, g]), N = Y((b) => (k.current.add(b), b), []), i = Y(() => {
|
|
228
|
+
k.current.forEach((b) => URL.revokeObjectURL(b)), k.current.clear();
|
|
227
229
|
}, []);
|
|
228
230
|
j(() => () => i(), [i]);
|
|
229
231
|
const {
|
|
@@ -235,14 +237,14 @@ function aa({ onFinish: a } = {}) {
|
|
|
235
237
|
queryFn: async () => {
|
|
236
238
|
if (d === "/") return [];
|
|
237
239
|
if (d === `/${g}`) return [];
|
|
238
|
-
const
|
|
239
|
-
return !
|
|
240
|
-
|
|
240
|
+
const b = await I.getThreadMessages(x);
|
|
241
|
+
return !b.items || !Array.isArray(b.items) ? [] : Promise.all(
|
|
242
|
+
b.items.map(async (u) => {
|
|
241
243
|
const E = typeof u.content == "string" ? u.content : u.content?.text || JSON.stringify(u.content), w = [...Array.isArray(u.parts) && u.parts.length > 0 ? u.parts : [{ type: "text", text: E }]].sort((_, M) => _.type === "file" && M.type !== "file" ? -1 : _.type !== "file" && M.type === "file" ? 1 : 0), H = await Promise.all(
|
|
242
244
|
w.map(async (_) => {
|
|
243
245
|
if (_.type === "file" && _.object_name && !_.url)
|
|
244
246
|
try {
|
|
245
|
-
const M = await
|
|
247
|
+
const M = await I.getAttachmentBlobUrl(_.object_name);
|
|
246
248
|
return { ..._, url: N(M), mediaType: _.mediaType || _.media_type };
|
|
247
249
|
} catch (M) {
|
|
248
250
|
return console.warn("Load attachment failed:", _.object_name, M), { ..._, mediaType: _.mediaType || _.media_type };
|
|
@@ -263,13 +265,13 @@ function aa({ onFinish: a } = {}) {
|
|
|
263
265
|
staleTime: 5e3
|
|
264
266
|
// Keep history fresh for 5 seconds
|
|
265
267
|
}), K = $(() => new Wt({
|
|
266
|
-
api:
|
|
267
|
-
fetch: async (
|
|
268
|
-
const E = new Headers(u?.headers), l =
|
|
268
|
+
api: I.getEndpoint("chat", "/chat"),
|
|
269
|
+
fetch: async (b, u) => {
|
|
270
|
+
const E = new Headers(u?.headers), l = I.getHeaders();
|
|
269
271
|
Object.entries(l).forEach(([M, G]) => {
|
|
270
272
|
E.set(M, G);
|
|
271
273
|
}), E.set("X-Thread-Id", x);
|
|
272
|
-
const w =
|
|
274
|
+
const w = m.api?.basePath || "/api", H = typeof b == "string" && !b.startsWith("http") ? `${w}${b.startsWith("/") ? b : "/" + b}` : b, _ = await fetch(H, { ...u, headers: E });
|
|
273
275
|
if (!_.ok) {
|
|
274
276
|
const M = await _.json().catch(() => ({}));
|
|
275
277
|
if (M.error && (typeof M.error.code == "string" || typeof M.error.message == "string"))
|
|
@@ -285,13 +287,13 @@ function aa({ onFinish: a } = {}) {
|
|
|
285
287
|
}
|
|
286
288
|
return _;
|
|
287
289
|
}
|
|
288
|
-
}), [x,
|
|
290
|
+
}), [x, m.api?.basePath]), C = Y(() => {
|
|
289
291
|
L("ready"), o.invalidateQueries({ queryKey: [c, "conversations"] }), a?.();
|
|
290
292
|
}, [o, a, c]), y = Gt({
|
|
291
293
|
id: x,
|
|
292
294
|
onFinish: C,
|
|
293
295
|
transport: K
|
|
294
|
-
}), [
|
|
296
|
+
}), [f, L] = S("idle"), [B, W] = S(null), O = Y(() => {
|
|
295
297
|
W(null);
|
|
296
298
|
}, []);
|
|
297
299
|
j(() => {
|
|
@@ -303,24 +305,24 @@ function aa({ onFinish: a } = {}) {
|
|
|
303
305
|
L("idle");
|
|
304
306
|
return;
|
|
305
307
|
}
|
|
306
|
-
const
|
|
307
|
-
P && !
|
|
308
|
+
const b = d === `/${g}`;
|
|
309
|
+
P && !b ? L("loading-history") : z || B || y.error ? L("error") : y.status === "streaming" || y.status === "submitted" ? L(y.status) : L("ready");
|
|
308
310
|
}, [P, z, y.status, B, y.error, d, g]), j(() => () => {
|
|
309
311
|
y.stop();
|
|
310
312
|
}, [x, y.stop]);
|
|
311
|
-
const
|
|
313
|
+
const D = te(/* @__PURE__ */ new Set()), R = $(() => y.messages.filter((b) => b.role === "assistant"), [y.messages]);
|
|
312
314
|
j(() => {
|
|
313
|
-
let
|
|
315
|
+
let b = !1;
|
|
314
316
|
for (const u of R) {
|
|
315
|
-
if (
|
|
317
|
+
if (D.current.has(u.id)) continue;
|
|
316
318
|
const E = u.parts.find((l) => l.type === "data-title");
|
|
317
|
-
E && E.data?.[0]?.title && (
|
|
319
|
+
E && E.data?.[0]?.title && (D.current.add(u.id), b = !0);
|
|
318
320
|
}
|
|
319
|
-
|
|
321
|
+
b && o.invalidateQueries({ queryKey: [c, "conversations"] });
|
|
320
322
|
}, [R, o, c]);
|
|
321
|
-
const A = Y(async (
|
|
322
|
-
const E = d === "/", l =
|
|
323
|
-
if (!(!l && (!u || u.length === 0)) && !(
|
|
323
|
+
const A = Y(async (b, u) => {
|
|
324
|
+
const E = d === "/", l = b.trim();
|
|
325
|
+
if (!(!l && (!u || u.length === 0)) && !(f === "loading-history" || f === "streaming" || f === "submitted")) {
|
|
324
326
|
if (y.stop(), E) {
|
|
325
327
|
p(`/${x}`);
|
|
326
328
|
const w = l || t("attach_file"), H = w.length > 30 ? w.slice(0, 30) + "..." : w;
|
|
@@ -344,13 +346,13 @@ function aa({ onFinish: a } = {}) {
|
|
|
344
346
|
W(new Error(H)), L("error");
|
|
345
347
|
}
|
|
346
348
|
}
|
|
347
|
-
}, [y, p, d, x, t, o,
|
|
349
|
+
}, [y, p, d, x, t, o, f, c]), U = Y(() => {
|
|
348
350
|
y.stop(), L("ready"), o.invalidateQueries({ queryKey: [c, "conversations"] });
|
|
349
351
|
}, [y.stop, o, c]), q = $(() => {
|
|
350
352
|
if (B) return B;
|
|
351
353
|
if (y.error) {
|
|
352
|
-
const
|
|
353
|
-
return new Error(
|
|
354
|
+
const b = le(y.error, t);
|
|
355
|
+
return new Error(b);
|
|
354
356
|
}
|
|
355
357
|
return null;
|
|
356
358
|
}, [B, y.error, t]);
|
|
@@ -360,19 +362,19 @@ function aa({ onFinish: a } = {}) {
|
|
|
360
362
|
stop: U,
|
|
361
363
|
clearError: O,
|
|
362
364
|
error: q,
|
|
363
|
-
status:
|
|
365
|
+
status: f,
|
|
364
366
|
// Cast to any to satisfy Chat.tsx expectations of AI SDK statuses
|
|
365
|
-
isLoadingHistory:
|
|
366
|
-
isErrorHistory:
|
|
367
|
+
isLoadingHistory: f === "loading-history",
|
|
368
|
+
isErrorHistory: f === "error" || !!q || z,
|
|
367
369
|
conversationId: d
|
|
368
|
-
}), [y, A, U, O, q,
|
|
370
|
+
}), [y, A, U, O, q, f, z, d]);
|
|
369
371
|
}
|
|
370
372
|
function ra({ classNames: a = {}, disclaimer: t }) {
|
|
371
|
-
const { t: o, i18n:
|
|
373
|
+
const { t: o, i18n: m } = ce(["chat", "translation"]), c = aa(), { messages: d, status: p, regenerate: g, error: h, clearError: k, stop: x, isLoadingHistory: N, conversationId: i, sendMessage: T } = c, { MessageList: P, PromptInput: z, disclaimer: K } = re(), C = t ?? K, y = m.exists("chat:disclaimer") ? o("chat:disclaimer") : null, f = typeof C == "string" ? o(C) : C ?? y, [L, B] = S(null), W = te(p);
|
|
372
374
|
Je(() => {
|
|
373
|
-
|
|
374
|
-
}, [i, k,
|
|
375
|
-
const O = d[d.length - 1],
|
|
375
|
+
h && k();
|
|
376
|
+
}, [i, k, h]);
|
|
377
|
+
const O = d[d.length - 1], D = O?.role === "assistant" && (p === "ready" || O.parts.some((A) => A.type === "data-chat-finished"));
|
|
376
378
|
j(() => {
|
|
377
379
|
p === "error" && W.current !== "error" && L !== i ? B(i) : p === "submitted" && L !== null && B(null), W.current = p;
|
|
378
380
|
}, [p, i]);
|
|
@@ -384,7 +386,7 @@ function ra({ classNames: a = {}, disclaimer: t }) {
|
|
|
384
386
|
messages: d,
|
|
385
387
|
status: p,
|
|
386
388
|
isLoadingHistory: N,
|
|
387
|
-
error: R ?
|
|
389
|
+
error: R ? h : null,
|
|
388
390
|
conversationId: i,
|
|
389
391
|
regen: (A) => g({ messageId: A }),
|
|
390
392
|
onSuggestionClick: (A) => T(A),
|
|
@@ -398,16 +400,16 @@ function ra({ classNames: a = {}, disclaimer: t }) {
|
|
|
398
400
|
{
|
|
399
401
|
onSend: T,
|
|
400
402
|
status: p,
|
|
401
|
-
isLastMessageFinished:
|
|
403
|
+
isLastMessageFinished: D,
|
|
402
404
|
stop: x,
|
|
403
405
|
isErrorVisible: R,
|
|
404
406
|
conversationId: i,
|
|
405
|
-
className: v("pointer-events-auto", a.inputArea,
|
|
407
|
+
className: v("pointer-events-auto", a.inputArea, f && "pb-0 md:pb-0")
|
|
406
408
|
}
|
|
407
409
|
),
|
|
408
|
-
|
|
410
|
+
f && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
|
|
409
411
|
/* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 top-[-20px] bg-background/80 backdrop-blur-sm [mask-image:linear-gradient(to_top,black_60%,transparent)] pointer-events-none -z-10" }),
|
|
410
|
-
/* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children:
|
|
412
|
+
/* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: f })
|
|
411
413
|
] })
|
|
412
414
|
] })
|
|
413
415
|
] });
|
|
@@ -416,33 +418,33 @@ const na = ({
|
|
|
416
418
|
components: a,
|
|
417
419
|
history: t,
|
|
418
420
|
welcome: o,
|
|
419
|
-
threadActions:
|
|
421
|
+
threadActions: m,
|
|
420
422
|
composer: c,
|
|
421
423
|
theme: d,
|
|
422
424
|
disclaimer: p,
|
|
423
425
|
...g
|
|
424
426
|
}) => {
|
|
425
|
-
const
|
|
426
|
-
...
|
|
427
|
+
const h = re(), k = $(() => ({
|
|
428
|
+
...h,
|
|
427
429
|
...a,
|
|
428
430
|
toolComponents: {
|
|
429
|
-
...
|
|
431
|
+
...h.toolComponents,
|
|
430
432
|
...a?.toolComponents
|
|
431
433
|
}
|
|
432
|
-
}), [
|
|
434
|
+
}), [h, a]);
|
|
433
435
|
return /* @__PURE__ */ e(
|
|
434
436
|
Fe,
|
|
435
437
|
{
|
|
436
438
|
components: k,
|
|
437
|
-
history: t ??
|
|
438
|
-
welcome: o ??
|
|
439
|
-
threadActions:
|
|
440
|
-
composer: c ??
|
|
441
|
-
theme: d ??
|
|
442
|
-
disclaimer: p ??
|
|
443
|
-
app:
|
|
444
|
-
i18n:
|
|
445
|
-
settings:
|
|
439
|
+
history: t ?? h.history,
|
|
440
|
+
welcome: o ?? h.welcome,
|
|
441
|
+
threadActions: m ?? h.threadActions,
|
|
442
|
+
composer: c ?? h.composer,
|
|
443
|
+
theme: d ?? h.theme,
|
|
444
|
+
disclaimer: p ?? h.disclaimer,
|
|
445
|
+
app: h.app,
|
|
446
|
+
i18n: h.i18n,
|
|
447
|
+
settings: h.settings,
|
|
446
448
|
children: /* @__PURE__ */ e(ra, { ...g })
|
|
447
449
|
}
|
|
448
450
|
);
|
|
@@ -470,7 +472,7 @@ function la({
|
|
|
470
472
|
className: a,
|
|
471
473
|
children: t,
|
|
472
474
|
side: o = "right",
|
|
473
|
-
...
|
|
475
|
+
...m
|
|
474
476
|
}) {
|
|
475
477
|
return /* @__PURE__ */ r(oa, { children: [
|
|
476
478
|
/* @__PURE__ */ e(ia, {}),
|
|
@@ -486,7 +488,7 @@ function la({
|
|
|
486
488
|
o === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
|
|
487
489
|
a
|
|
488
490
|
),
|
|
489
|
-
...
|
|
491
|
+
...m,
|
|
490
492
|
children: [
|
|
491
493
|
t,
|
|
492
494
|
/* @__PURE__ */ r(se.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
|
|
@@ -532,12 +534,12 @@ function va({
|
|
|
532
534
|
defaultOpen: a = !0,
|
|
533
535
|
open: t,
|
|
534
536
|
onOpenChange: o,
|
|
535
|
-
className:
|
|
537
|
+
className: m,
|
|
536
538
|
style: c,
|
|
537
539
|
children: d,
|
|
538
540
|
...p
|
|
539
541
|
}) {
|
|
540
|
-
const g = ot(), [
|
|
542
|
+
const g = ot(), [h, k] = ne.useState(!1), [x, N] = ne.useState(a), i = t ?? x, T = ne.useCallback(
|
|
541
543
|
(C) => {
|
|
542
544
|
const y = typeof C == "function" ? C(i) : C;
|
|
543
545
|
o ? o(y) : N(y), document.cookie = `${ma}=${y}; path=/; max-age=${ha}`;
|
|
@@ -560,11 +562,11 @@ function va({
|
|
|
560
562
|
open: i,
|
|
561
563
|
setOpen: T,
|
|
562
564
|
isMobile: g,
|
|
563
|
-
openMobile:
|
|
565
|
+
openMobile: h,
|
|
564
566
|
setOpenMobile: k,
|
|
565
567
|
toggleSidebar: P
|
|
566
568
|
}),
|
|
567
|
-
[z, i, T, g,
|
|
569
|
+
[z, i, T, g, h, k, P]
|
|
568
570
|
);
|
|
569
571
|
return /* @__PURE__ */ e(Ge.Provider, { value: K, children: /* @__PURE__ */ e(Oe, { delayDuration: 0, children: /* @__PURE__ */ e(
|
|
570
572
|
"div",
|
|
@@ -575,7 +577,7 @@ function va({
|
|
|
575
577
|
"--sidebar-width-icon": fa,
|
|
576
578
|
...c
|
|
577
579
|
},
|
|
578
|
-
className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
|
|
580
|
+
className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", m),
|
|
579
581
|
...p,
|
|
580
582
|
children: d
|
|
581
583
|
}
|
|
@@ -585,20 +587,20 @@ function xa({
|
|
|
585
587
|
side: a = "left",
|
|
586
588
|
variant: t = "sidebar",
|
|
587
589
|
collapsible: o = "offcanvas",
|
|
588
|
-
className:
|
|
590
|
+
className: m,
|
|
589
591
|
children: c,
|
|
590
592
|
...d
|
|
591
593
|
}) {
|
|
592
|
-
const { isMobile: p, state: g, openMobile:
|
|
594
|
+
const { isMobile: p, state: g, openMobile: h, setOpenMobile: k } = ge();
|
|
593
595
|
return o === "none" ? /* @__PURE__ */ e(
|
|
594
596
|
"div",
|
|
595
597
|
{
|
|
596
598
|
"data-slot": "sidebar",
|
|
597
|
-
className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
|
|
599
|
+
className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", m),
|
|
598
600
|
...d,
|
|
599
601
|
children: c
|
|
600
602
|
}
|
|
601
|
-
) : p ? /* @__PURE__ */ e(sa, { open:
|
|
603
|
+
) : p ? /* @__PURE__ */ e(sa, { open: h, onOpenChange: k, ...d, children: /* @__PURE__ */ r(
|
|
602
604
|
la,
|
|
603
605
|
{
|
|
604
606
|
onOpenAutoFocus: (x) => x.preventDefault(),
|
|
@@ -649,7 +651,7 @@ function xa({
|
|
|
649
651
|
a === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
650
652
|
// Adjust the padding for floating and inset variants.
|
|
651
653
|
t === "floating" || t === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
652
|
-
|
|
654
|
+
m
|
|
653
655
|
),
|
|
654
656
|
...d,
|
|
655
657
|
children: /* @__PURE__ */ e(
|
|
@@ -668,7 +670,7 @@ function xa({
|
|
|
668
670
|
);
|
|
669
671
|
}
|
|
670
672
|
function ya({ className: a, onClick: t, ...o }) {
|
|
671
|
-
const { toggleSidebar:
|
|
673
|
+
const { toggleSidebar: m } = ge();
|
|
672
674
|
return /* @__PURE__ */ r(
|
|
673
675
|
Z,
|
|
674
676
|
{
|
|
@@ -678,7 +680,7 @@ function ya({ className: a, onClick: t, ...o }) {
|
|
|
678
680
|
size: "icon",
|
|
679
681
|
className: v("size-7", a),
|
|
680
682
|
onClick: (c) => {
|
|
681
|
-
t?.(c),
|
|
683
|
+
t?.(c), m();
|
|
682
684
|
},
|
|
683
685
|
...o,
|
|
684
686
|
children: [
|
|
@@ -781,19 +783,19 @@ function ze({
|
|
|
781
783
|
asChild: a = !1,
|
|
782
784
|
isActive: t = !1,
|
|
783
785
|
variant: o = "default",
|
|
784
|
-
size:
|
|
786
|
+
size: m = "default",
|
|
785
787
|
tooltip: c,
|
|
786
788
|
className: d,
|
|
787
789
|
...p
|
|
788
790
|
}) {
|
|
789
|
-
const g = a ? Yt : "button", { isMobile:
|
|
791
|
+
const g = a ? Yt : "button", { isMobile: h, state: k } = ge(), x = /* @__PURE__ */ e(
|
|
790
792
|
g,
|
|
791
793
|
{
|
|
792
794
|
"data-slot": "sidebar-menu-button",
|
|
793
795
|
"data-sidebar": "menu-button",
|
|
794
|
-
"data-size":
|
|
796
|
+
"data-size": m,
|
|
795
797
|
"data-active": t,
|
|
796
|
-
className: v(_a({ variant: o, size:
|
|
798
|
+
className: v(_a({ variant: o, size: m }), d),
|
|
797
799
|
...p
|
|
798
800
|
}
|
|
799
801
|
);
|
|
@@ -801,23 +803,23 @@ function ze({
|
|
|
801
803
|
children: c
|
|
802
804
|
}), /* @__PURE__ */ r($e, { children: [
|
|
803
805
|
/* @__PURE__ */ e(Be, { asChild: !0, children: x }),
|
|
804
|
-
/* @__PURE__ */ e(Ue, { side: "right", align: "center", hidden: k !== "collapsed" ||
|
|
806
|
+
/* @__PURE__ */ e(Ue, { side: "right", align: "center", hidden: k !== "collapsed" || h, ...c })
|
|
805
807
|
] })) : x;
|
|
806
808
|
}
|
|
807
809
|
function Ca({ trigger: a }) {
|
|
808
|
-
const { t, i18n: o } = ce(["settings", "translation"]), { app:
|
|
810
|
+
const { t, i18n: o } = ce(["settings", "translation"]), { app: m, settings: c } = re(), { theme: d, setTheme: p, accent: g, setAccent: h, radius: k, setRadius: x } = Ke(), [N, i] = S(null), [T, P] = S(!1), z = te(null), K = $(() => [
|
|
809
811
|
{ id: "general", label: t("sections.general", "General"), icon: Me },
|
|
810
812
|
{ id: "profile", label: t("sections.profile", "Profile"), icon: Ct },
|
|
811
813
|
{ id: "account", label: t("sections.account", "Account"), icon: St }
|
|
812
814
|
].filter((F) => {
|
|
813
815
|
const n = c?.sections?.[F.id];
|
|
814
816
|
return (n?.mode ?? (n?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
|
|
815
|
-
}), [t, c]), [C, y] = S(K[0]?.id || "general"),
|
|
816
|
-
const
|
|
817
|
-
return
|
|
818
|
-
}, [c]), [L, B] = S(""), [W, O] = S(""), [
|
|
817
|
+
}), [t, c]), [C, y] = S(K[0]?.id || "general"), f = Y((s, F, n = "editable") => {
|
|
818
|
+
const V = c?.sections?.[s]?.fields;
|
|
819
|
+
return V && V[F] || n;
|
|
820
|
+
}, [c]), [L, B] = S(""), [W, O] = S(""), [D, R] = S(""), [A, U] = S(""), q = $(() => m?.userMetadataFields?.filter((s) => s.showInProfile) || [], [m?.userMetadataFields]), [b, u] = S({}), [E, l] = S(!1), w = o.language === "fa", H = w ? "text-right" : "text-left", _ = Y(async () => {
|
|
819
821
|
try {
|
|
820
|
-
const s = await
|
|
822
|
+
const s = await I.getMe();
|
|
821
823
|
i(s), B(s.name || ""), O(s.surname || ""), R(s.phone || "");
|
|
822
824
|
const F = {};
|
|
823
825
|
q.forEach((n) => {
|
|
@@ -834,31 +836,31 @@ function Ca({ trigger: a }) {
|
|
|
834
836
|
}
|
|
835
837
|
(z.current === null || C === "account") && _(), z.current = C;
|
|
836
838
|
}, [T, C, _]), j(() => {
|
|
837
|
-
const s = { ...
|
|
839
|
+
const s = { ...b };
|
|
838
840
|
let F = !1;
|
|
839
841
|
q.forEach((n) => {
|
|
840
|
-
n.condition && !he(n.condition,
|
|
842
|
+
n.condition && !he(n.condition, b) && s[n.key] !== void 0 && (delete s[n.key], F = !0);
|
|
841
843
|
}), F && u(s);
|
|
842
|
-
}, [
|
|
844
|
+
}, [b, q]);
|
|
843
845
|
const M = async () => {
|
|
844
846
|
l(!0);
|
|
845
847
|
try {
|
|
846
|
-
const s = { name: L, surname: W, phone:
|
|
847
|
-
A && (s.password = A), await
|
|
848
|
+
const s = { name: L, surname: W, phone: D, metadata: b };
|
|
849
|
+
A && (s.password = A), await I.updateMe(s), J.success(t("profile.success", "Profile updated successfully")), U(""), _();
|
|
848
850
|
} catch (s) {
|
|
849
851
|
J.error(le(s, t));
|
|
850
852
|
} finally {
|
|
851
853
|
l(!1);
|
|
852
854
|
}
|
|
853
855
|
}, G = () => {
|
|
854
|
-
window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (
|
|
856
|
+
window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (I.clearToken(), window.location.reload());
|
|
855
857
|
}, ae = (s) => {
|
|
856
858
|
o.changeLanguage(s);
|
|
857
859
|
}, ee = N ? Math.max(0, Math.min(100, N.balance.tokens / (N.balance.token_limit || 1) * 100)) : 0, oe = N ? Math.max(0, Math.min(100, N.balance.requests / (N.balance.request_limit || 1) * 100)) : 0;
|
|
858
860
|
return /* @__PURE__ */ r(He, { open: T, onOpenChange: P, children: [
|
|
859
861
|
/* @__PURE__ */ e(it, { asChild: !0, children: a || /* @__PURE__ */ e(Z, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5" }) }) }),
|
|
860
862
|
/* @__PURE__ */ e(
|
|
861
|
-
|
|
863
|
+
Ve,
|
|
862
864
|
{
|
|
863
865
|
dir: w ? "rtl" : "ltr",
|
|
864
866
|
className: v(
|
|
@@ -899,52 +901,52 @@ function Ca({ trigger: a }) {
|
|
|
899
901
|
] }),
|
|
900
902
|
/* @__PURE__ */ r("div", { className: "grid gap-6", children: [
|
|
901
903
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
|
|
902
|
-
|
|
903
|
-
/* @__PURE__ */ e(
|
|
904
|
+
f("profile", "name") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", f("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
905
|
+
/* @__PURE__ */ e(Q, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
|
|
904
906
|
/* @__PURE__ */ e(
|
|
905
907
|
X,
|
|
906
908
|
{
|
|
907
909
|
id: "name",
|
|
908
910
|
value: L,
|
|
909
911
|
onChange: (s) => B(s.target.value),
|
|
910
|
-
disabled:
|
|
912
|
+
disabled: f("profile", "name") === "faded",
|
|
911
913
|
className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", H)
|
|
912
914
|
}
|
|
913
915
|
)
|
|
914
916
|
] }),
|
|
915
|
-
|
|
916
|
-
/* @__PURE__ */ e(
|
|
917
|
+
f("profile", "surname") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", f("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
918
|
+
/* @__PURE__ */ e(Q, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
|
|
917
919
|
/* @__PURE__ */ e(
|
|
918
920
|
X,
|
|
919
921
|
{
|
|
920
922
|
id: "surname",
|
|
921
923
|
value: W,
|
|
922
924
|
onChange: (s) => O(s.target.value),
|
|
923
|
-
disabled:
|
|
925
|
+
disabled: f("profile", "surname") === "faded",
|
|
924
926
|
className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", H)
|
|
925
927
|
}
|
|
926
928
|
)
|
|
927
929
|
] })
|
|
928
930
|
] }),
|
|
929
|
-
|
|
930
|
-
/* @__PURE__ */ e(
|
|
931
|
+
f("profile", "phone") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", f("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
932
|
+
/* @__PURE__ */ e(Q, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
|
|
931
933
|
/* @__PURE__ */ r("div", { className: "relative", children: [
|
|
932
934
|
/* @__PURE__ */ e(Pt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
|
|
933
935
|
/* @__PURE__ */ e(
|
|
934
936
|
X,
|
|
935
937
|
{
|
|
936
938
|
id: "phone",
|
|
937
|
-
value:
|
|
939
|
+
value: D,
|
|
938
940
|
onChange: (s) => R(s.target.value),
|
|
939
|
-
disabled:
|
|
941
|
+
disabled: f("profile", "phone") === "faded",
|
|
940
942
|
className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
|
|
941
943
|
dir: "ltr"
|
|
942
944
|
}
|
|
943
945
|
)
|
|
944
946
|
] })
|
|
945
947
|
] }),
|
|
946
|
-
|
|
947
|
-
/* @__PURE__ */ e(
|
|
948
|
+
f("profile", "password") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", f("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
949
|
+
/* @__PURE__ */ e(Q, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
|
|
948
950
|
/* @__PURE__ */ r("div", { className: "relative", children: [
|
|
949
951
|
/* @__PURE__ */ e(Tt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
|
|
950
952
|
/* @__PURE__ */ e(
|
|
@@ -954,7 +956,7 @@ function Ca({ trigger: a }) {
|
|
|
954
956
|
type: "password",
|
|
955
957
|
value: A,
|
|
956
958
|
onChange: (s) => U(s.target.value),
|
|
957
|
-
disabled:
|
|
959
|
+
disabled: f("profile", "password") === "faded",
|
|
958
960
|
placeholder: t("profile.password_placeholder", "Leave empty to keep current"),
|
|
959
961
|
className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
|
|
960
962
|
dir: "ltr"
|
|
@@ -963,14 +965,14 @@ function Ca({ trigger: a }) {
|
|
|
963
965
|
] })
|
|
964
966
|
] }),
|
|
965
967
|
q.map((s) => {
|
|
966
|
-
const F =
|
|
967
|
-
return F === "hidden" || !he(s.condition,
|
|
968
|
-
/* @__PURE__ */ e(
|
|
968
|
+
const F = f("profile", s.key, s.mode || "editable");
|
|
969
|
+
return F === "hidden" || !he(s.condition, b) ? null : /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200", F === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
970
|
+
/* @__PURE__ */ e(Q, { htmlFor: `profile-${s.key}`, className: "px-1", children: t(s.label) }),
|
|
969
971
|
s.type === "select" ? /* @__PURE__ */ r(
|
|
970
972
|
ve,
|
|
971
973
|
{
|
|
972
|
-
value: String(
|
|
973
|
-
onValueChange: (n) => u({ ...
|
|
974
|
+
value: String(b[s.key] || ""),
|
|
975
|
+
onValueChange: (n) => u({ ...b, [s.key]: n }),
|
|
974
976
|
disabled: F === "faded",
|
|
975
977
|
dir: w ? "rtl" : "ltr",
|
|
976
978
|
children: [
|
|
@@ -984,21 +986,21 @@ function Ca({ trigger: a }) {
|
|
|
984
986
|
{
|
|
985
987
|
id: `profile-${s.key}`,
|
|
986
988
|
type: "checkbox",
|
|
987
|
-
checked: !!
|
|
989
|
+
checked: !!b[s.key],
|
|
988
990
|
disabled: F === "faded",
|
|
989
|
-
onChange: (n) => u({ ...
|
|
991
|
+
onChange: (n) => u({ ...b, [s.key]: n.target.checked }),
|
|
990
992
|
className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
|
|
991
993
|
}
|
|
992
994
|
),
|
|
993
|
-
/* @__PURE__ */ e(
|
|
995
|
+
/* @__PURE__ */ e(Q, { htmlFor: `profile-${s.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(s.placeholder || s.label) })
|
|
994
996
|
] }) : /* @__PURE__ */ e(
|
|
995
997
|
X,
|
|
996
998
|
{
|
|
997
999
|
id: `profile-${s.key}`,
|
|
998
1000
|
type: s.type,
|
|
999
|
-
value:
|
|
1001
|
+
value: b[s.key] || "",
|
|
1000
1002
|
disabled: F === "faded",
|
|
1001
|
-
onChange: (n) => u({ ...
|
|
1003
|
+
onChange: (n) => u({ ...b, [s.key]: n.target.value }),
|
|
1002
1004
|
placeholder: t(s.placeholder || ""),
|
|
1003
1005
|
className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", H)
|
|
1004
1006
|
}
|
|
@@ -1025,8 +1027,8 @@ function Ca({ trigger: a }) {
|
|
|
1025
1027
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("general.subtitle", "Configure look and feel and language.") })
|
|
1026
1028
|
] }),
|
|
1027
1029
|
/* @__PURE__ */ r("div", { className: "space-y-8", children: [
|
|
1028
|
-
|
|
1029
|
-
/* @__PURE__ */ r(
|
|
1030
|
+
f("general", "theme") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", f("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
1031
|
+
/* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
|
|
1030
1032
|
/* @__PURE__ */ e(Me, { className: "h-4 w-4 text-primary" }),
|
|
1031
1033
|
t("general.theme", "Theme")
|
|
1032
1034
|
] }),
|
|
@@ -1035,13 +1037,13 @@ function Ca({ trigger: a }) {
|
|
|
1035
1037
|
"button",
|
|
1036
1038
|
{
|
|
1037
1039
|
onClick: () => p("light"),
|
|
1038
|
-
disabled:
|
|
1040
|
+
disabled: f("general", "theme") === "faded",
|
|
1039
1041
|
className: v(
|
|
1040
1042
|
"flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
|
|
1041
1043
|
d === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
|
|
1042
1044
|
),
|
|
1043
1045
|
children: [
|
|
1044
|
-
/* @__PURE__ */ e(
|
|
1046
|
+
/* @__PURE__ */ e(It, { className: "h-4 w-4" }),
|
|
1045
1047
|
/* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.light", "Light") })
|
|
1046
1048
|
]
|
|
1047
1049
|
}
|
|
@@ -1050,13 +1052,13 @@ function Ca({ trigger: a }) {
|
|
|
1050
1052
|
"button",
|
|
1051
1053
|
{
|
|
1052
1054
|
onClick: () => p("dark"),
|
|
1053
|
-
disabled:
|
|
1055
|
+
disabled: f("general", "theme") === "faded",
|
|
1054
1056
|
className: v(
|
|
1055
1057
|
"flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
|
|
1056
1058
|
d === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
|
|
1057
1059
|
),
|
|
1058
1060
|
children: [
|
|
1059
|
-
/* @__PURE__ */ e(
|
|
1061
|
+
/* @__PURE__ */ e(Dt, { className: "h-4 w-4" }),
|
|
1060
1062
|
/* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.dark", "Dark") })
|
|
1061
1063
|
]
|
|
1062
1064
|
}
|
|
@@ -1065,7 +1067,7 @@ function Ca({ trigger: a }) {
|
|
|
1065
1067
|
"button",
|
|
1066
1068
|
{
|
|
1067
1069
|
onClick: () => p("system"),
|
|
1068
|
-
disabled:
|
|
1070
|
+
disabled: f("general", "theme") === "faded",
|
|
1069
1071
|
className: v(
|
|
1070
1072
|
"flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
|
|
1071
1073
|
d === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
|
|
@@ -1078,9 +1080,9 @@ function Ca({ trigger: a }) {
|
|
|
1078
1080
|
)
|
|
1079
1081
|
] })
|
|
1080
1082
|
] }),
|
|
1081
|
-
|
|
1082
|
-
/* @__PURE__ */ r(
|
|
1083
|
-
/* @__PURE__ */ e(
|
|
1083
|
+
f("general", "accent") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", f("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
1084
|
+
/* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
|
|
1085
|
+
/* @__PURE__ */ e(Ie, { className: "h-4 w-4 text-primary" }),
|
|
1084
1086
|
t("general.accent", "Accent Color")
|
|
1085
1087
|
] }),
|
|
1086
1088
|
/* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
|
|
@@ -1105,8 +1107,8 @@ function Ca({ trigger: a }) {
|
|
|
1105
1107
|
return /* @__PURE__ */ e(
|
|
1106
1108
|
"button",
|
|
1107
1109
|
{
|
|
1108
|
-
onClick: () =>
|
|
1109
|
-
disabled:
|
|
1110
|
+
onClick: () => h(s),
|
|
1111
|
+
disabled: f("general", "accent") === "faded",
|
|
1110
1112
|
className: v(
|
|
1111
1113
|
"h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
|
|
1112
1114
|
F ? "border-foreground" : "border-transparent"
|
|
@@ -1117,8 +1119,8 @@ function Ca({ trigger: a }) {
|
|
|
1117
1119
|
);
|
|
1118
1120
|
}) })
|
|
1119
1121
|
] }),
|
|
1120
|
-
|
|
1121
|
-
/* @__PURE__ */ r(
|
|
1122
|
+
f("general", "radius") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", f("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
|
|
1123
|
+
/* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
|
|
1122
1124
|
/* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
|
|
1123
1125
|
t("general.radius", "Rounded Corners")
|
|
1124
1126
|
] }),
|
|
@@ -1131,7 +1133,7 @@ function Ca({ trigger: a }) {
|
|
|
1131
1133
|
"button",
|
|
1132
1134
|
{
|
|
1133
1135
|
onClick: () => x(s.value),
|
|
1134
|
-
disabled:
|
|
1136
|
+
disabled: f("general", "radius") === "faded",
|
|
1135
1137
|
className: v(
|
|
1136
1138
|
"flex-1 py-2 rounded-xl transition-all text-sm font-medium",
|
|
1137
1139
|
F ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
|
|
@@ -1142,8 +1144,8 @@ function Ca({ trigger: a }) {
|
|
|
1142
1144
|
);
|
|
1143
1145
|
}) })
|
|
1144
1146
|
] }),
|
|
1145
|
-
|
|
1146
|
-
/* @__PURE__ */ r(
|
|
1147
|
+
f("general", "language") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", f("general", "language") === "faded" && "opacity-50"), children: [
|
|
1148
|
+
/* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
|
|
1147
1149
|
/* @__PURE__ */ e(At, { className: "h-4 w-4 text-primary" }),
|
|
1148
1150
|
t("general.language", "Language")
|
|
1149
1151
|
] }),
|
|
@@ -1152,7 +1154,7 @@ function Ca({ trigger: a }) {
|
|
|
1152
1154
|
{
|
|
1153
1155
|
value: o.language,
|
|
1154
1156
|
onValueChange: ae,
|
|
1155
|
-
disabled:
|
|
1157
|
+
disabled: f("general", "language") === "faded",
|
|
1156
1158
|
dir: w ? "rtl" : "ltr",
|
|
1157
1159
|
children: [
|
|
1158
1160
|
/* @__PURE__ */ e(xe, { className: "w-full bg-muted/50 rounded-2xl border-border/40 h-11 focus:ring-primary/20", children: /* @__PURE__ */ e(ye, { placeholder: t("general.language_placeholder", "Select language") }) }),
|
|
@@ -1178,8 +1180,8 @@ function Ca({ trigger: a }) {
|
|
|
1178
1180
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("account.subtitle", "Monitor your quotas and manage your session.") })
|
|
1179
1181
|
] }),
|
|
1180
1182
|
/* @__PURE__ */ r("div", { className: "space-y-6", children: [
|
|
1181
|
-
|
|
1182
|
-
/* @__PURE__ */ r(
|
|
1183
|
+
f("account", "balance") !== "hidden" && /* @__PURE__ */ r("div", { className: v("p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6", f("account", "balance") === "faded" && "opacity-50"), children: [
|
|
1184
|
+
/* @__PURE__ */ r(Q, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
|
|
1183
1185
|
/* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
|
|
1184
1186
|
t("account.balance", "Current Balance")
|
|
1185
1187
|
] }),
|
|
@@ -1206,7 +1208,7 @@ function Ca({ trigger: a }) {
|
|
|
1206
1208
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
1207
1209
|
/* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
|
|
1208
1210
|
/* @__PURE__ */ r("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
|
|
1209
|
-
/* @__PURE__ */ e(
|
|
1211
|
+
/* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
|
|
1210
1212
|
t("account.requests", "Requests")
|
|
1211
1213
|
] }),
|
|
1212
1214
|
/* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
|
|
@@ -1228,18 +1230,18 @@ function Ca({ trigger: a }) {
|
|
|
1228
1230
|
] })
|
|
1229
1231
|
] }),
|
|
1230
1232
|
/* @__PURE__ */ r("div", { className: "pt-2 flex flex-col gap-3", children: [
|
|
1231
|
-
N?.balance.updated_at &&
|
|
1233
|
+
N?.balance.updated_at && f("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
|
|
1232
1234
|
t("account.last_recharge", "Last balance update on"),
|
|
1233
1235
|
": ",
|
|
1234
1236
|
new Date(N.balance.updated_at).toLocaleDateString(o.language)
|
|
1235
1237
|
] }),
|
|
1236
|
-
|
|
1238
|
+
f("account", "logout") !== "hidden" && /* @__PURE__ */ r(
|
|
1237
1239
|
Z,
|
|
1238
1240
|
{
|
|
1239
1241
|
variant: "destructive",
|
|
1240
1242
|
onClick: G,
|
|
1241
|
-
disabled:
|
|
1242
|
-
className: v("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]",
|
|
1243
|
+
disabled: f("account", "logout") === "faded",
|
|
1244
|
+
className: v("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]", f("account", "logout") === "faded" && "opacity-50 pointer-events-none"),
|
|
1243
1245
|
children: [
|
|
1244
1246
|
/* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
|
|
1245
1247
|
t("account.logout", "Logout from Account")
|
|
@@ -1249,20 +1251,24 @@ function Ca({ trigger: a }) {
|
|
|
1249
1251
|
] })
|
|
1250
1252
|
] })
|
|
1251
1253
|
] })
|
|
1252
|
-
] }) })
|
|
1254
|
+
] }) }),
|
|
1255
|
+
m?.showVersionInSettings !== !1 && m?.version && f("general", "version") !== "hidden" && /* @__PURE__ */ e("div", { className: v("shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80", f("general", "version", "faded") === "faded" && "opacity-70"), children: /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground text-center", dir: "ltr", children: /* @__PURE__ */ r("span", { className: "font-mono text-foreground/75", children: [
|
|
1256
|
+
"v",
|
|
1257
|
+
m.version
|
|
1258
|
+
] }) }) })
|
|
1253
1259
|
] })
|
|
1254
1260
|
}
|
|
1255
1261
|
)
|
|
1256
1262
|
] });
|
|
1257
1263
|
}
|
|
1258
1264
|
function We({ hideActions: a = !1 }) {
|
|
1259
|
-
const [, t] = Ce(), { t: o } = ce(["sidebar", "chat"]), { history:
|
|
1265
|
+
const [, t] = Ce(), { t: o } = ce(["sidebar", "chat"]), { history: m, app: c } = re(), { theme: d } = Ke(), p = !a && (m?.enabled ?? !0), [g, h] = S("light");
|
|
1260
1266
|
j(() => {
|
|
1261
1267
|
if (d === "system") {
|
|
1262
1268
|
const N = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1263
|
-
|
|
1269
|
+
h(N ? "dark" : "light");
|
|
1264
1270
|
} else
|
|
1265
|
-
|
|
1271
|
+
h(d);
|
|
1266
1272
|
}, [d]);
|
|
1267
1273
|
const k = $(() => c?.logo ? typeof c.logo == "string" ? c.logo : g === "dark" ? c.logo.dark : c.logo.light : lt, [c?.logo, g]), x = c?.name || "Gentiq";
|
|
1268
1274
|
return /* @__PURE__ */ r("header", { className: "relative flex items-center justify-between px-3 md:px-4 h-14 sticky top-0 z-40 w-full glass border-b border-border/30 transition-all duration-300", children: [
|
|
@@ -1311,20 +1317,20 @@ function We({ hideActions: a = !1 }) {
|
|
|
1311
1317
|
}
|
|
1312
1318
|
const Re = 20;
|
|
1313
1319
|
function Sa() {
|
|
1314
|
-
const t =
|
|
1320
|
+
const t = I.getConfig().app?.cacheNamespace || "gentiq";
|
|
1315
1321
|
return tt({
|
|
1316
1322
|
queryKey: [t, "conversations"],
|
|
1317
1323
|
queryFn: async ({ pageParam: o = 0 }) => {
|
|
1318
|
-
const
|
|
1324
|
+
const m = await I.getHistory(o, Re);
|
|
1319
1325
|
return {
|
|
1320
|
-
threads:
|
|
1326
|
+
threads: m.threads.map((c) => ({
|
|
1321
1327
|
id: `/${c.id}`,
|
|
1322
1328
|
firstMessage: c.title || c.firstMessage || "Chat",
|
|
1323
1329
|
timestamp: new Date(c.created_at).getTime(),
|
|
1324
1330
|
pinned: !!c.pinned
|
|
1325
1331
|
})),
|
|
1326
1332
|
nextSkip: o + Re,
|
|
1327
|
-
hasMore: o +
|
|
1333
|
+
hasMore: o + m.threads.length < (m.total_count ?? 0)
|
|
1328
1334
|
};
|
|
1329
1335
|
},
|
|
1330
1336
|
initialPageParam: 0,
|
|
@@ -1333,26 +1339,26 @@ function Sa() {
|
|
|
1333
1339
|
// 5 minutes
|
|
1334
1340
|
});
|
|
1335
1341
|
}
|
|
1336
|
-
async function Pa(a, t, o,
|
|
1337
|
-
const d =
|
|
1342
|
+
async function Pa(a, t, o, m) {
|
|
1343
|
+
const d = I.getConfig().app?.cacheNamespace || "gentiq";
|
|
1338
1344
|
try {
|
|
1339
|
-
await
|
|
1345
|
+
await I.deleteThread(a), t.invalidateQueries({ queryKey: [d, "conversations"] }), m === a && o("/");
|
|
1340
1346
|
} catch (p) {
|
|
1341
1347
|
console.error("Failed to delete conversation:", p), J.error("Failed to delete conversation");
|
|
1342
1348
|
}
|
|
1343
1349
|
}
|
|
1344
1350
|
function Ta({ side: a = "left" }) {
|
|
1345
|
-
const { t, i18n: o } = ce(["sidebar", "translation"]), { setOpenMobile:
|
|
1351
|
+
const { t, i18n: o } = ce(["sidebar", "translation"]), { setOpenMobile: m, isMobile: c } = ge(), {
|
|
1346
1352
|
data: d,
|
|
1347
1353
|
fetchNextPage: p,
|
|
1348
1354
|
hasNextPage: g,
|
|
1349
|
-
isFetchingNextPage:
|
|
1355
|
+
isFetchingNextPage: h,
|
|
1350
1356
|
isLoading: k
|
|
1351
|
-
} = Sa(), { history: x, app: N } = re(), i = N?.basePath || "/", T = x?.enabled ?? !1, P = d?.pages.flatMap((n) => n.threads) ?? [], [z, K] = Ce(), C = pe(), y = te(null),
|
|
1357
|
+
} = Sa(), { history: x, app: N } = re(), i = N?.basePath || "/", T = x?.enabled ?? !1, P = d?.pages.flatMap((n) => n.threads) ?? [], [z, K] = Ce(), C = pe(), y = te(null), f = Y(
|
|
1352
1358
|
(n) => {
|
|
1353
|
-
y.current && (y.current.disconnect(), y.current = null), n && g && !
|
|
1354
|
-
(
|
|
1355
|
-
|
|
1359
|
+
y.current && (y.current.disconnect(), y.current = null), n && g && !h && (y.current = new IntersectionObserver(
|
|
1360
|
+
(V) => {
|
|
1361
|
+
V[0].isIntersecting && p();
|
|
1356
1362
|
},
|
|
1357
1363
|
{
|
|
1358
1364
|
threshold: 0,
|
|
@@ -1360,20 +1366,20 @@ function Ta({ side: a = "left" }) {
|
|
|
1360
1366
|
}
|
|
1361
1367
|
), y.current.observe(n));
|
|
1362
1368
|
},
|
|
1363
|
-
[g, p,
|
|
1364
|
-
), B =
|
|
1365
|
-
n.button !== 0 || n.metaKey || n.ctrlKey || (n.preventDefault(), K(
|
|
1366
|
-
}, [K, c,
|
|
1369
|
+
[g, p, h]
|
|
1370
|
+
), B = I.getConfig().app?.cacheNamespace || "gentiq", [W, O] = S(!1), [D, R] = S(null), [A, U] = S(""), [q, b] = S(null), [u, E] = S(""), l = te(null), w = Y((n, V) => {
|
|
1371
|
+
n.button !== 0 || n.metaKey || n.ctrlKey || (n.preventDefault(), K(V), c && m(!1));
|
|
1372
|
+
}, [K, c, m]), H = P.filter(
|
|
1367
1373
|
(n) => n.firstMessage?.toLowerCase().includes(A.toLowerCase())
|
|
1368
|
-
).sort((n,
|
|
1374
|
+
).sort((n, V) => n.pinned && !V.pinned ? -1 : !n.pinned && V.pinned ? 1 : V.timestamp - n.timestamp), _ = async (n) => {
|
|
1369
1375
|
try {
|
|
1370
|
-
await
|
|
1376
|
+
await I.pinThread(n.id.replace(/^\//, ""), !n.pinned), C.invalidateQueries({ queryKey: [B, "conversations"] }), J.success(n.pinned ? t("unpinned_success") : t("pinned_success"));
|
|
1371
1377
|
} catch {
|
|
1372
1378
|
J.error(t("pin_failed"));
|
|
1373
1379
|
}
|
|
1374
1380
|
}, M = async (n) => {
|
|
1375
1381
|
try {
|
|
1376
|
-
const
|
|
1382
|
+
const V = await I.shareThread(n.id.replace(/^\//, "")), fe = `${window.location.origin}${V.url}`;
|
|
1377
1383
|
navigator.clipboard.writeText(fe), J.success(t("share_success"), {
|
|
1378
1384
|
description: t("share_description")
|
|
1379
1385
|
});
|
|
@@ -1381,20 +1387,20 @@ function Ta({ side: a = "left" }) {
|
|
|
1381
1387
|
J.error(t("share_failed"));
|
|
1382
1388
|
}
|
|
1383
1389
|
}, G = (n) => {
|
|
1384
|
-
|
|
1390
|
+
b(n.id), E(n.firstMessage ?? ""), setTimeout(() => l.current?.focus(), 0);
|
|
1385
1391
|
}, ae = (n) => {
|
|
1386
|
-
n?.preventDefault(), n?.stopPropagation(),
|
|
1392
|
+
n?.preventDefault(), n?.stopPropagation(), b(null), E("");
|
|
1387
1393
|
}, ee = async (n) => {
|
|
1388
1394
|
if (n?.preventDefault(), n && "stopPropagation" in n && n.stopPropagation(), !(!q || !u.trim()))
|
|
1389
1395
|
try {
|
|
1390
|
-
await
|
|
1396
|
+
await I.updateThreadTitle(q, u), C.invalidateQueries({ queryKey: [B, "conversations"] }), b(null), J.success(t("rename_success"));
|
|
1391
1397
|
} catch {
|
|
1392
1398
|
J.error(t("rename_failed"));
|
|
1393
1399
|
}
|
|
1394
1400
|
}, oe = (n) => {
|
|
1395
1401
|
R(n), O(!0);
|
|
1396
1402
|
}, s = () => {
|
|
1397
|
-
|
|
1403
|
+
D && (Pa(D.id, C, K, z), O(!1), R(null), J.success(t("chat_deleted_success")));
|
|
1398
1404
|
}, F = (n) => new Intl.DateTimeFormat(o.language, {
|
|
1399
1405
|
year: "numeric",
|
|
1400
1406
|
month: "short",
|
|
@@ -1440,7 +1446,7 @@ function Ta({ side: a = "left" }) {
|
|
|
1440
1446
|
] }) }),
|
|
1441
1447
|
T && /* @__PURE__ */ r(Ee, { className: "group-data-[collapsible=icon]:hidden", children: [
|
|
1442
1448
|
/* @__PURE__ */ r(Ae, { children: [
|
|
1443
|
-
H.map((n,
|
|
1449
|
+
H.map((n, V) => {
|
|
1444
1450
|
const fe = q === n.id, Se = Te(n.firstMessage ?? ""), Xe = Se === "rtl";
|
|
1445
1451
|
return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: fe ? /* @__PURE__ */ r("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
|
|
1446
1452
|
/* @__PURE__ */ e(
|
|
@@ -1486,7 +1492,7 @@ function Ta({ side: a = "left" }) {
|
|
|
1486
1492
|
"absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
|
|
1487
1493
|
o.language === "fa" ? "left-2" : "right-1.5"
|
|
1488
1494
|
), children: [
|
|
1489
|
-
n.pinned && /* @__PURE__ */ e(
|
|
1495
|
+
n.pinned && /* @__PURE__ */ e(De, { className: "size-3.5 text-primary opacity-70 md:absolute md:inset-0 md:m-auto md:group-hover/sidebar-menu-item:opacity-0 transition-opacity pointer-events-none" }),
|
|
1490
1496
|
/* @__PURE__ */ r(ct, { dir: o.language === "fa" ? "rtl" : "ltr", children: [
|
|
1491
1497
|
/* @__PURE__ */ e(dt, { asChild: !0, children: /* @__PURE__ */ e(
|
|
1492
1498
|
Z,
|
|
@@ -1504,7 +1510,7 @@ function Ta({ side: a = "left" }) {
|
|
|
1504
1510
|
className: "min-w-[120px] p-1",
|
|
1505
1511
|
children: [
|
|
1506
1512
|
x?.showPin !== !1 && /* @__PURE__ */ r(de, { onSelect: () => _(n), className: "cursor-pointer flex items-center gap-2", children: [
|
|
1507
|
-
n.pinned ? /* @__PURE__ */ e(Bt, { className: "size-4" }) : /* @__PURE__ */ e(
|
|
1513
|
+
n.pinned ? /* @__PURE__ */ e(Bt, { className: "size-4" }) : /* @__PURE__ */ e(De, { className: "size-4" }),
|
|
1508
1514
|
/* @__PURE__ */ e("span", { children: n.pinned ? t("unpin_conversation") : t("pin_conversation") })
|
|
1509
1515
|
] }),
|
|
1510
1516
|
x?.showShare !== !1 && /* @__PURE__ */ r(de, { onSelect: () => M(n), className: "cursor-pointer flex items-center gap-2", children: [
|
|
@@ -1531,12 +1537,12 @@ function Ta({ side: a = "left" }) {
|
|
|
1531
1537
|
)
|
|
1532
1538
|
] })
|
|
1533
1539
|
] })
|
|
1534
|
-
] }) },
|
|
1540
|
+
] }) }, V);
|
|
1535
1541
|
}),
|
|
1536
1542
|
!k && P.length === 0 && !A && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
|
|
1537
1543
|
] }),
|
|
1538
|
-
/* @__PURE__ */ e("div", { ref:
|
|
1539
|
-
|
|
1544
|
+
/* @__PURE__ */ e("div", { ref: f, className: "h-4 w-full" }),
|
|
1545
|
+
h && /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
|
|
1540
1546
|
/* @__PURE__ */ e("div", { className: "size-4 border-2 border-primary border-t-transparent rounded-full animate-spin" }),
|
|
1541
1547
|
/* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wider font-medium", children: t("loading_more") })
|
|
1542
1548
|
] })
|
|
@@ -1544,7 +1550,7 @@ function Ta({ side: a = "left" }) {
|
|
|
1544
1550
|
] }) }),
|
|
1545
1551
|
/* @__PURE__ */ e(wa, {}),
|
|
1546
1552
|
/* @__PURE__ */ e(He, { open: W, onOpenChange: O, children: /* @__PURE__ */ r(
|
|
1547
|
-
|
|
1553
|
+
Ve,
|
|
1548
1554
|
{
|
|
1549
1555
|
onKeyDown: (n) => {
|
|
1550
1556
|
n.key === "Enter" && (n.preventDefault(), s());
|
|
@@ -1572,10 +1578,10 @@ function Ta({ side: a = "left" }) {
|
|
|
1572
1578
|
) })
|
|
1573
1579
|
] }) });
|
|
1574
1580
|
}
|
|
1575
|
-
function
|
|
1576
|
-
const { config: p } = je(), { history: g } = re(),
|
|
1581
|
+
function Va({ sidebar: a, header: t, components: o, classNames: m, disclaimer: c, welcome: d }) {
|
|
1582
|
+
const { config: p } = je(), { history: g } = re(), h = p?.language === "fa" ? "right" : "left", k = g?.enabled ?? !0;
|
|
1577
1583
|
return /* @__PURE__ */ r(va, { defaultOpen: k, children: [
|
|
1578
|
-
a !== void 0 ? a : k ? /* @__PURE__ */ e(Ta, { side:
|
|
1584
|
+
a !== void 0 ? a : k ? /* @__PURE__ */ e(Ta, { side: h }) : null,
|
|
1579
1585
|
/* @__PURE__ */ r("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
|
|
1580
1586
|
t !== void 0 ? t : /* @__PURE__ */ e(We, {}),
|
|
1581
1587
|
/* @__PURE__ */ e(
|
|
@@ -1589,7 +1595,7 @@ function Qa({ sidebar: a, header: t, components: o, classNames: h, disclaimer: c
|
|
|
1589
1595
|
na,
|
|
1590
1596
|
{
|
|
1591
1597
|
components: o,
|
|
1592
|
-
classNames:
|
|
1598
|
+
classNames: m,
|
|
1593
1599
|
disclaimer: c,
|
|
1594
1600
|
welcome: d
|
|
1595
1601
|
}
|
|
@@ -1599,69 +1605,69 @@ function Qa({ sidebar: a, header: t, components: o, classNames: h, disclaimer: c
|
|
|
1599
1605
|
] })
|
|
1600
1606
|
] });
|
|
1601
1607
|
}
|
|
1602
|
-
function
|
|
1603
|
-
const [t, o] = S(null),
|
|
1608
|
+
function Qa({ children: a }) {
|
|
1609
|
+
const [t, o] = S(null), m = Qe(), c = _e(), d = pe();
|
|
1604
1610
|
return j(() => {
|
|
1605
1611
|
(async () => {
|
|
1606
|
-
const g = new URLSearchParams(
|
|
1607
|
-
if (
|
|
1612
|
+
const g = new URLSearchParams(m.search), h = g.get("token");
|
|
1613
|
+
if (h)
|
|
1608
1614
|
try {
|
|
1609
|
-
|
|
1610
|
-
const x = g.toString(), N =
|
|
1615
|
+
I.setToken(h), await I.getBalance(), g.delete("token");
|
|
1616
|
+
const x = g.toString(), N = m.pathname + (x ? `?${x}` : "");
|
|
1611
1617
|
c(N, { replace: !0 }), o(!0);
|
|
1612
1618
|
return;
|
|
1613
1619
|
} catch (x) {
|
|
1614
1620
|
console.error("Error validating token from URL:", x), o(!1);
|
|
1615
1621
|
return;
|
|
1616
1622
|
}
|
|
1617
|
-
if (!
|
|
1623
|
+
if (!I.getToken()) {
|
|
1618
1624
|
o(!1);
|
|
1619
1625
|
return;
|
|
1620
1626
|
}
|
|
1621
1627
|
try {
|
|
1622
|
-
await
|
|
1628
|
+
await I.getBalance(), o(!0);
|
|
1623
1629
|
} catch (x) {
|
|
1624
|
-
console.error("Token validation failed:", x), x.status === 401 ? (
|
|
1630
|
+
console.error("Token validation failed:", x), x.status === 401 ? (I.clearToken(), d.clear(), o(!1)) : o(!0);
|
|
1625
1631
|
}
|
|
1626
1632
|
})();
|
|
1627
|
-
}, [
|
|
1633
|
+
}, [m.search, c, m.pathname, d]), t === null ? /* @__PURE__ */ e("div", { className: "flex h-screen w-full items-center justify-center", children: /* @__PURE__ */ e("div", { className: "size-8 rounded-full border-4 border-primary border-t-transparent animate-spin" }) }) : t ? /* @__PURE__ */ e(ke, { children: a }) : /* @__PURE__ */ e(Xt, { to: "/login", replace: !0 });
|
|
1628
1634
|
}
|
|
1629
1635
|
const qe = (a) => a.replace(/[^0-9]/g, "");
|
|
1630
1636
|
function Ga() {
|
|
1631
|
-
const { t: a, i18n: t } = ce(["login", "translation"]), { app: o } = re(),
|
|
1637
|
+
const { t: a, i18n: t } = ce(["login", "translation"]), { app: o } = re(), m = t.dir() === "rtl", c = m ? "text-right" : "text-left", d = _e(), p = pe(), [g, h] = S("login"), k = !!o?.disableSignup, x = !!o?.disableAuthPage, [N, i] = S(""), [T, P] = S(""), [z, K] = S(""), [C, y] = S(""), [f, L] = S(""), [B, W] = S(""), O = $(() => o?.userMetadataFields?.filter((l) => l.showInSignup) || [], [o?.userMetadataFields]), [D, R] = S(() => {
|
|
1632
1638
|
const l = {};
|
|
1633
1639
|
return O.forEach((w) => {
|
|
1634
1640
|
w.defaultValue !== void 0 && (l[w.key] = w.defaultValue);
|
|
1635
1641
|
}), l;
|
|
1636
1642
|
});
|
|
1637
1643
|
j(() => {
|
|
1638
|
-
const l = { ...
|
|
1644
|
+
const l = { ...D };
|
|
1639
1645
|
let w = !1;
|
|
1640
1646
|
O.forEach((H) => {
|
|
1641
|
-
H.condition && !he(H.condition,
|
|
1647
|
+
H.condition && !he(H.condition, D) && l[H.key] !== void 0 && (delete l[H.key], w = !0);
|
|
1642
1648
|
}), w && R(l);
|
|
1643
|
-
}, [
|
|
1644
|
-
const [A, U] = S(""), [q,
|
|
1649
|
+
}, [D, O]);
|
|
1650
|
+
const [A, U] = S(""), [q, b] = S(!1);
|
|
1645
1651
|
j(() => {
|
|
1646
|
-
k && g === "register" &&
|
|
1652
|
+
k && g === "register" && h("login");
|
|
1647
1653
|
}, [k, g]);
|
|
1648
1654
|
const u = async (l) => {
|
|
1649
|
-
l.preventDefault(), U(""),
|
|
1655
|
+
l.preventDefault(), U(""), b(!0);
|
|
1650
1656
|
try {
|
|
1651
|
-
await
|
|
1657
|
+
await I.login(N, T), p.clear(), d("/");
|
|
1652
1658
|
} catch (w) {
|
|
1653
1659
|
U(le(w, a));
|
|
1654
1660
|
} finally {
|
|
1655
|
-
|
|
1661
|
+
b(!1);
|
|
1656
1662
|
}
|
|
1657
1663
|
}, E = async (l) => {
|
|
1658
|
-
l.preventDefault(), U(""),
|
|
1664
|
+
l.preventDefault(), U(""), b(!0);
|
|
1659
1665
|
try {
|
|
1660
|
-
await
|
|
1666
|
+
await I.register(z, C, f, B, D), p.clear(), d("/");
|
|
1661
1667
|
} catch (w) {
|
|
1662
1668
|
U(le(w, a));
|
|
1663
1669
|
} finally {
|
|
1664
|
-
|
|
1670
|
+
b(!1);
|
|
1665
1671
|
}
|
|
1666
1672
|
};
|
|
1667
1673
|
return x ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center p-4", dir: t.dir(), children: /* @__PURE__ */ r("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
|
|
@@ -1676,7 +1682,7 @@ function Ga() {
|
|
|
1676
1682
|
{
|
|
1677
1683
|
type: "button",
|
|
1678
1684
|
onClick: () => {
|
|
1679
|
-
|
|
1685
|
+
h("login"), U("");
|
|
1680
1686
|
},
|
|
1681
1687
|
className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${g === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
1682
1688
|
children: a("login_tab", "Login")
|
|
@@ -1687,7 +1693,7 @@ function Ga() {
|
|
|
1687
1693
|
{
|
|
1688
1694
|
type: "button",
|
|
1689
1695
|
onClick: () => {
|
|
1690
|
-
|
|
1696
|
+
h("register"), U("");
|
|
1691
1697
|
},
|
|
1692
1698
|
className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${g === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
1693
1699
|
children: a("signup_tab", "Sign Up")
|
|
@@ -1696,7 +1702,7 @@ function Ga() {
|
|
|
1696
1702
|
] }),
|
|
1697
1703
|
g === "login" && /* @__PURE__ */ r("form", { onSubmit: u, className: "space-y-4", children: [
|
|
1698
1704
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
1699
|
-
/* @__PURE__ */ e(
|
|
1705
|
+
/* @__PURE__ */ e(Q, { htmlFor: "login-phone", children: a("phone", "Phone") }),
|
|
1700
1706
|
/* @__PURE__ */ e(
|
|
1701
1707
|
X,
|
|
1702
1708
|
{
|
|
@@ -1712,7 +1718,7 @@ function Ga() {
|
|
|
1712
1718
|
)
|
|
1713
1719
|
] }),
|
|
1714
1720
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
1715
|
-
/* @__PURE__ */ e(
|
|
1721
|
+
/* @__PURE__ */ e(Q, { htmlFor: "login-pass", children: a("password", "Password") }),
|
|
1716
1722
|
/* @__PURE__ */ e(
|
|
1717
1723
|
X,
|
|
1718
1724
|
{
|
|
@@ -1740,7 +1746,7 @@ function Ga() {
|
|
|
1740
1746
|
] }),
|
|
1741
1747
|
!k && g === "register" && /* @__PURE__ */ r("form", { onSubmit: E, className: "space-y-4", children: [
|
|
1742
1748
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
1743
|
-
/* @__PURE__ */ e(
|
|
1749
|
+
/* @__PURE__ */ e(Q, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
|
|
1744
1750
|
/* @__PURE__ */ e(
|
|
1745
1751
|
X,
|
|
1746
1752
|
{
|
|
@@ -1756,7 +1762,7 @@ function Ga() {
|
|
|
1756
1762
|
)
|
|
1757
1763
|
] }),
|
|
1758
1764
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
1759
|
-
/* @__PURE__ */ e(
|
|
1765
|
+
/* @__PURE__ */ e(Q, { htmlFor: "reg-pass", children: a("password", "Password") }),
|
|
1760
1766
|
/* @__PURE__ */ e(
|
|
1761
1767
|
X,
|
|
1762
1768
|
{
|
|
@@ -1773,13 +1779,13 @@ function Ga() {
|
|
|
1773
1779
|
] }),
|
|
1774
1780
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
1775
1781
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
1776
|
-
/* @__PURE__ */ e(
|
|
1782
|
+
/* @__PURE__ */ e(Q, { htmlFor: "reg-name", children: a("name", "Name") }),
|
|
1777
1783
|
/* @__PURE__ */ e(
|
|
1778
1784
|
X,
|
|
1779
1785
|
{
|
|
1780
1786
|
id: "reg-name",
|
|
1781
1787
|
type: "text",
|
|
1782
|
-
value:
|
|
1788
|
+
value: f,
|
|
1783
1789
|
onChange: (l) => L(l.target.value),
|
|
1784
1790
|
required: !0,
|
|
1785
1791
|
className: c,
|
|
@@ -1788,7 +1794,7 @@ function Ga() {
|
|
|
1788
1794
|
)
|
|
1789
1795
|
] }),
|
|
1790
1796
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
1791
|
-
/* @__PURE__ */ e(
|
|
1797
|
+
/* @__PURE__ */ e(Q, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
|
|
1792
1798
|
/* @__PURE__ */ e(
|
|
1793
1799
|
X,
|
|
1794
1800
|
{
|
|
@@ -1803,15 +1809,15 @@ function Ga() {
|
|
|
1803
1809
|
)
|
|
1804
1810
|
] })
|
|
1805
1811
|
] }),
|
|
1806
|
-
O.map((l) => he(l.condition,
|
|
1807
|
-
/* @__PURE__ */ e(
|
|
1812
|
+
O.map((l) => he(l.condition, D) ? /* @__PURE__ */ r("div", { className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200", children: [
|
|
1813
|
+
/* @__PURE__ */ e(Q, { htmlFor: `signup-${l.key}`, children: a(l.label) }),
|
|
1808
1814
|
l.type === "select" ? /* @__PURE__ */ r(
|
|
1809
1815
|
ve,
|
|
1810
1816
|
{
|
|
1811
|
-
value: String(
|
|
1812
|
-
onValueChange: (w) => R({ ...
|
|
1817
|
+
value: String(D[l.key] || ""),
|
|
1818
|
+
onValueChange: (w) => R({ ...D, [l.key]: w }),
|
|
1813
1819
|
required: l.required,
|
|
1814
|
-
dir:
|
|
1820
|
+
dir: m ? "rtl" : "ltr",
|
|
1815
1821
|
children: [
|
|
1816
1822
|
/* @__PURE__ */ e(xe, { className: v("bg-background", c), children: /* @__PURE__ */ e(ye, { placeholder: a(l.placeholder || "select_placeholder") }) }),
|
|
1817
1823
|
/* @__PURE__ */ e(we, { className: "rounded-xl", children: l.options?.map((w) => /* @__PURE__ */ e(me, { value: String(w.value), children: a(w.label) }, String(w.value))) })
|
|
@@ -1822,8 +1828,8 @@ function Ga() {
|
|
|
1822
1828
|
ft,
|
|
1823
1829
|
{
|
|
1824
1830
|
id: `signup-${l.key}`,
|
|
1825
|
-
checked: !!
|
|
1826
|
-
onCheckedChange: (w) => R({ ...
|
|
1831
|
+
checked: !!D[l.key],
|
|
1832
|
+
onCheckedChange: (w) => R({ ...D, [l.key]: !!w }),
|
|
1827
1833
|
required: l.required
|
|
1828
1834
|
}
|
|
1829
1835
|
),
|
|
@@ -1833,8 +1839,8 @@ function Ga() {
|
|
|
1833
1839
|
{
|
|
1834
1840
|
id: `signup-${l.key}`,
|
|
1835
1841
|
type: l.type,
|
|
1836
|
-
value:
|
|
1837
|
-
onChange: (w) => R({ ...
|
|
1842
|
+
value: D[l.key] || "",
|
|
1843
|
+
onChange: (w) => R({ ...D, [l.key]: w.target.value }),
|
|
1838
1844
|
required: l.required,
|
|
1839
1845
|
className: c,
|
|
1840
1846
|
placeholder: a(l.placeholder || "")
|
|
@@ -1855,15 +1861,15 @@ function Ga() {
|
|
|
1855
1861
|
] }) });
|
|
1856
1862
|
}
|
|
1857
1863
|
function Ma() {
|
|
1858
|
-
const { shareId: a } = Jt(), [t, o] = S(null), [
|
|
1864
|
+
const { shareId: a } = Jt(), [t, o] = S(null), [m, c] = S(!0), [d, p] = S(null), { MessageList: g } = re(), h = te(/* @__PURE__ */ new Set());
|
|
1859
1865
|
return j(() => () => {
|
|
1860
|
-
|
|
1866
|
+
h.current.forEach((k) => URL.revokeObjectURL(k)), h.current.clear();
|
|
1861
1867
|
}, []), j(() => {
|
|
1862
1868
|
if (!a) return;
|
|
1863
1869
|
(async () => {
|
|
1864
1870
|
try {
|
|
1865
1871
|
c(!0);
|
|
1866
|
-
const x = await
|
|
1872
|
+
const x = await I.getSharedThread(a);
|
|
1867
1873
|
x.items && (x.items = await Promise.all(
|
|
1868
1874
|
x.items.map(async (N) => {
|
|
1869
1875
|
if (!N.parts) return N;
|
|
@@ -1871,8 +1877,8 @@ function Ma() {
|
|
|
1871
1877
|
N.parts.map(async (T) => {
|
|
1872
1878
|
if (T.type === "file" && T.object_name && !T.url)
|
|
1873
1879
|
try {
|
|
1874
|
-
const P = await
|
|
1875
|
-
return
|
|
1880
|
+
const P = await I.getPublicAttachmentBlobUrl(T.object_name);
|
|
1881
|
+
return h.current.add(P), { ...T, url: P };
|
|
1876
1882
|
} catch (P) {
|
|
1877
1883
|
console.error("Failed to resolve shared attachment:", T.object_name, P);
|
|
1878
1884
|
}
|
|
@@ -1888,7 +1894,7 @@ function Ma() {
|
|
|
1888
1894
|
c(!1);
|
|
1889
1895
|
}
|
|
1890
1896
|
})();
|
|
1891
|
-
}, [a]),
|
|
1897
|
+
}, [a]), m ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(bt, {}) }) : d || !t ? /* @__PURE__ */ r("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
|
|
1892
1898
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-destructive mb-2 font-display", children: "Shared Chat Not Found" }),
|
|
1893
1899
|
/* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: d || "This shared conversation might have been deleted or the link is invalid." })
|
|
1894
1900
|
] }) : /* @__PURE__ */ r("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
|
|
@@ -1917,14 +1923,14 @@ function Wa() {
|
|
|
1917
1923
|
export {
|
|
1918
1924
|
Ta as AppSidebar,
|
|
1919
1925
|
na as Chat,
|
|
1920
|
-
|
|
1926
|
+
Va as ChatUI,
|
|
1921
1927
|
rr as FilePart,
|
|
1922
1928
|
Ha as GentiqProvider,
|
|
1923
1929
|
nr as MessageList,
|
|
1924
1930
|
sr as Part,
|
|
1925
1931
|
or as PromptInputArea,
|
|
1926
1932
|
ir as ReasoningPart,
|
|
1927
|
-
|
|
1933
|
+
Qa as RequireAuth,
|
|
1928
1934
|
ve as Select,
|
|
1929
1935
|
we as SelectContent,
|
|
1930
1936
|
lr as SelectGroup,
|
|
@@ -1947,6 +1953,6 @@ export {
|
|
|
1947
1953
|
re as useComponents,
|
|
1948
1954
|
aa as useGentiqChat,
|
|
1949
1955
|
er as useTranslation,
|
|
1950
|
-
|
|
1956
|
+
I as userAPI,
|
|
1951
1957
|
tr as withTranslation
|
|
1952
1958
|
};
|