gentiq 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/{checkbox-hWwU3a5K.js → checkbox-DyzncQpE.js} +1680 -1712
  2. package/dist/gentiq-admin.es.js +4089 -3259
  3. package/dist/gentiq-index.es.js +1973 -1380
  4. package/dist/gentiq.css +1 -1
  5. package/dist/src/App.d.ts +1 -1
  6. package/dist/src/ComponentsContext.d.ts +1 -1
  7. package/dist/src/Part.d.ts +2 -1
  8. package/dist/src/admin/components/ErrorBanner.d.ts +7 -0
  9. package/dist/src/admin/components/I18nPreview.d.ts +6 -0
  10. package/dist/src/admin/components/ModalCloseButton.d.ts +7 -0
  11. package/dist/src/admin/components/SectionHeader.d.ts +8 -0
  12. package/dist/src/admin/lib/api.d.ts +109 -16
  13. package/dist/src/admin/pages/settings/ChatSection.d.ts +12 -0
  14. package/dist/src/admin/pages/settings/FieldModeGrid.d.ts +14 -0
  15. package/dist/src/admin/pages/settings/GeneralSection.d.ts +11 -0
  16. package/dist/src/admin/pages/settings/SettingsToggleCard.d.ts +10 -0
  17. package/dist/src/admin/pages/settings/TranslationEditor.d.ts +9 -0
  18. package/dist/src/admin/pages/settings/types.d.ts +12 -0
  19. package/dist/src/admin/pages/users/UserBulkBalanceModal.d.ts +11 -0
  20. package/dist/src/admin/pages/users/UserFormModal.d.ts +13 -0
  21. package/dist/src/admin/pages/users/UserRechargeModal.d.ts +10 -0
  22. package/dist/src/admin/pages/users/UserUsageDialog.d.ts +9 -0
  23. package/dist/src/admin/pages/users/UsersTable.d.ts +21 -0
  24. package/dist/src/components/PromptInputArea.d.ts +1 -1
  25. package/dist/src/components/ai-elements/Conversation.d.ts +10 -0
  26. package/dist/src/hooks/useGentiqAdmin.d.ts +9 -9
  27. package/dist/src/hooks/useGentiqChat.d.ts +3 -2
  28. package/dist/src/index.d.ts +4 -3
  29. package/dist/src/lib/GentiqApiContext.d.ts +12 -0
  30. package/dist/src/lib/api.d.ts +37 -17
  31. package/dist/src/lib/errors.d.ts +6 -5
  32. package/dist/src/lib/messageParts.d.ts +40 -0
  33. package/dist/src/locales/en.json.d.ts +456 -456
  34. package/dist/src/locales/fa.json.d.ts +455 -455
  35. package/dist/src/parts/FilePart.d.ts +1 -1
  36. package/dist/src/parts/ToolPart.d.ts +1 -1
  37. package/dist/src/types.d.ts +188 -14
  38. package/package.json +5 -5
  39. package/dist/src/components/ai-elements/Branch.d.ts +0 -20
  40. package/dist/src/components/ai-elements/Image.d.ts +0 -6
  41. package/dist/src/components/ai-elements/InlineCitation.d.ts +0 -38
  42. package/dist/src/components/ai-elements/Task.d.ts +0 -14
  43. package/dist/src/components/ai-elements/WebPreview.d.ts +0 -34
  44. package/dist/src/components/ui/carousel.d.ts +0 -19
@@ -1,35 +1,35 @@
1
- import { jsx as e, jsxs as r, Fragment as ke } from "react/jsx-runtime";
2
- import * as ne from "react";
3
- import { useState as T, useMemo as O, useEffect as $, useRef as ae, useCallback as J, useLayoutEffect as Ye } from "react";
4
- import { QueryClient as Ze, QueryClientProvider as et, useQueryClient as ue, useQuery as tt, useInfiniteQuery as at } from "@tanstack/react-query";
5
- import { I18nextProvider as rt, useTranslation as de } from "react-i18next";
6
- import { Trans as er, Translation as tr, useTranslation as ar, withTranslation as rr } from "react-i18next";
7
- import { g as nt, u as D, d as st, C as Fe, T as ot, a as re, b as je, j as be, G as Pe, c as ce, e as Oe, f as v, h as it, i as $e, k as Ue, l as Be, m as Ke, B as te, n as Qe, o as ge, D as He, p as lt, q as Ve, L as G, I as X, S as xe, r as ve, s as ye, t as we, v as pe, w as ct, x as dt, y as Te, z as ut, A as mt, E as ht, F as me, H as pt, J as gt, K as ft, M as bt, N as xt, O as vt } from "./checkbox-hWwU3a5K.js";
8
- import { 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, a0 as fr, a1 as br, a2 as xr, a3 as vr, a4 as yr, a5 as wr, a6 as Nr } from "./checkbox-hWwU3a5K.js";
9
- import { Loader2Icon as yt, OctagonXIcon as wt, TriangleAlertIcon as Nt, InfoIcon as kt, CircleCheckIcon as _t, XIcon as Ct, PanelLeftIcon as St, Layers as Me, User as Pt, ShieldCheck as Tt, Settings as Ne, Smartphone as Mt, Lock as It, Save as Dt, Sun as At, Moon as Et, Monitor as Lt, Zap as Ie, Globe as Rt, Coins as zt, LogOut as qt, CirclePlus as Ft, Plus as jt, Search as Ot, Check as $t, X as Ut, Pin as De, MoreVertical as Bt, PinOff as Kt, Share2 as Qt, Pencil as Ht, Trash as Vt } from "lucide-react";
10
- import { useTheme as Gt } from "next-themes";
11
- import { Toaster as Wt, toast as ee } from "sonner";
12
- import { useChat as Xt } from "@ai-sdk/react";
13
- import { DefaultChatTransport as Jt } from "ai";
14
- import { useLocation as Ge, useNavigate as _e, Navigate as Yt, useParams as Zt } from "react-router-dom";
15
- import { nanoid as he } from "nanoid";
16
- import { Slot as ea } from "@radix-ui/react-slot";
17
- import { cva as ta } from "class-variance-authority";
1
+ import { jsx as e, jsxs as s, Fragment as _e } from "react/jsx-runtime";
2
+ import * as se from "react";
3
+ import { useState as _, useMemo as Q, useEffect as B, useRef as re, useCallback as ee, useLayoutEffect as et } from "react";
4
+ import { QueryClient as tt, QueryClientProvider as at, useQueryClient as he, useQuery as rt, useInfiniteQuery as nt } from "@tanstack/react-query";
5
+ import { I18nextProvider as st, useTranslation as ue } from "react-i18next";
6
+ import { Trans as or, Translation as ir, useTranslation as lr, withTranslation as cr } from "react-i18next";
7
+ import { G as be, g as ot, d as it, a as lt, C as je, T as ct, u as ne, b as Oe, c as oe, j as xe, e as ge, f as de, h as He, i as v, k as dt, l as Ue, m as Be, n as Ke, o as Qe, B as ae, p as Ve, q as ye, D as Ge, r as ut, s as We, L as X, I as Y, S as we, t as Ne, v as ke, w as Se, x as fe, y as ht, z as pt, A as Me, E as mt, F as gt, H as ft, J as pe, K as bt, M as yt, N as vt, O as xt, P as wt, Q as Nt } from "./checkbox-DyzncQpE.js";
8
+ import { R as ur, U as hr, V as pr, W as mr, X as gr, Y as fr, Z as br, _ as yr, $ as vr, a0 as xr, a1 as wr, a2 as Nr, a3 as kr, a4 as Sr, a5 as Cr, a6 as _r, a7 as Tr, a8 as Pr } from "./checkbox-DyzncQpE.js";
9
+ import { Loader2Icon as kt, OctagonXIcon as St, TriangleAlertIcon as Ct, InfoIcon as _t, CircleCheckIcon as Tt, XIcon as Pt, PanelLeftIcon as Et, Layers as Ae, User as Mt, ShieldCheck as At, Settings as Ce, Smartphone as It, Lock as Rt, Save as Dt, Sun as $t, Moon as Lt, Monitor as Ft, Zap as Ie, Globe as qt, Coins as zt, LogOut as jt, CirclePlus as Ot, Plus as Ht, Search as Ut, Check as Bt, X as Kt, Pin as Re, MoreVertical as Qt, PinOff as Vt, Share2 as Gt, Pencil as Wt, Trash as Jt } from "lucide-react";
10
+ import { useTheme as Xt } from "next-themes";
11
+ import { Toaster as Yt, toast as te } from "sonner";
12
+ import { useChat as Zt } from "@ai-sdk/react";
13
+ import { DefaultChatTransport as ea } from "ai";
14
+ import { useLocation as Je, useNavigate as Te, Navigate as ta, useParams as aa } from "react-router-dom";
15
+ import { nanoid as me } from "nanoid";
16
+ import { Slot as ra } from "@radix-ui/react-slot";
17
+ import { cva as na } from "class-variance-authority";
18
18
  import "@radix-ui/react-separator";
19
- import * as ie from "@radix-ui/react-dialog";
20
- const aa = ({ ...a }) => {
21
- const { theme: t = "system" } = Gt();
19
+ import * as le from "@radix-ui/react-dialog";
20
+ const sa = ({ ...a }) => {
21
+ const { theme: t = "system" } = Xt();
22
22
  return /* @__PURE__ */ e(
23
- Wt,
23
+ Yt,
24
24
  {
25
25
  theme: t,
26
26
  className: "toaster group",
27
27
  icons: {
28
- success: /* @__PURE__ */ e(_t, { className: "size-4" }),
29
- info: /* @__PURE__ */ e(kt, { className: "size-4" }),
30
- warning: /* @__PURE__ */ e(Nt, { className: "size-4" }),
31
- error: /* @__PURE__ */ e(wt, { className: "size-4" }),
32
- loading: /* @__PURE__ */ e(yt, { className: "size-4 animate-spin" })
28
+ success: /* @__PURE__ */ e(Tt, { className: "size-4" }),
29
+ info: /* @__PURE__ */ e(_t, { className: "size-4" }),
30
+ warning: /* @__PURE__ */ e(Ct, { className: "size-4" }),
31
+ error: /* @__PURE__ */ e(St, { className: "size-4" }),
32
+ loading: /* @__PURE__ */ e(kt, { className: "size-4 animate-spin" })
33
33
  },
34
34
  style: {
35
35
  "--normal-bg": "var(--popover)",
@@ -40,474 +40,821 @@ const aa = ({ ...a }) => {
40
40
  ...a
41
41
  }
42
42
  );
43
+ }, oa = () => ({
44
+ api: {
45
+ basePath: "/api"
46
+ },
47
+ app: {
48
+ basePath: "/",
49
+ cacheNamespace: "gentiq"
50
+ }
51
+ }), ia = {
52
+ getToken: () => localStorage.getItem("token"),
53
+ setToken: (a) => localStorage.setItem("token", a),
54
+ clearToken: () => {
55
+ localStorage.removeItem("token");
56
+ },
57
+ getHeaders: () => {
58
+ const a = localStorage.getItem("token");
59
+ return a ? { Authorization: `Bearer ${a}` } : {};
60
+ }
43
61
  };
44
- function Va({
62
+ function la(a) {
63
+ let t = oa(), d = ia;
64
+ const o = {
65
+ /**
66
+ * Merge new config into this instance. Safe to call repeatedly (e.g. when
67
+ * the provider re-resolves config after fetching dynamic settings).
68
+ */
69
+ configure: (n) => {
70
+ if (t = {
71
+ ...t,
72
+ ...n,
73
+ api: n.api ? { ...t.api, ...n.api } : t.api,
74
+ app: n.app ? { ...t.app, ...n.app } : t.app
75
+ }, n.api?.authAdapter) {
76
+ const i = n.api.authAdapter;
77
+ d = {
78
+ ...i,
79
+ getHeaders: i.getHeaders || (() => {
80
+ const r = i.getToken();
81
+ return r ? { Authorization: `Bearer ${r}` } : {};
82
+ })
83
+ };
84
+ }
85
+ },
86
+ getConfig: () => t,
87
+ getToken: () => d.getToken(),
88
+ setToken: (n) => {
89
+ d.setToken(n);
90
+ },
91
+ clearToken: () => {
92
+ d.clearToken();
93
+ },
94
+ getHeaders: () => d.getHeaders(),
95
+ getEndpoint: (n, i, ...r) => {
96
+ const u = t.api?.endpoints?.[n];
97
+ return u ? typeof u == "function" ? u(...r) : u : typeof i == "function" ? i(...r) : i;
98
+ },
99
+ handleResponse: async (n, i = "Request failed") => {
100
+ if (!n.ok) {
101
+ const r = await n.json().catch(() => ({}));
102
+ if (r.error && (typeof r.error.code == "string" || typeof r.error.message == "string"))
103
+ throw new be(r, n.status);
104
+ let u = i, c = "error", y = null;
105
+ throw typeof r.detail == "string" ? u = r.detail : typeof r.message == "string" ? u = r.message : typeof r.error == "string" ? u = r.error : Array.isArray(r.detail) ? (u = "Validation failed", y = r.detail, c = "validation_error") : r.error && typeof r.error.message == "string" && (u = r.error.message), new be(
106
+ {
107
+ error: {
108
+ code: c,
109
+ message: u,
110
+ details: y
111
+ }
112
+ },
113
+ n.status
114
+ );
115
+ }
116
+ return n.json();
117
+ },
118
+ login: async (n, i) => {
119
+ const r = o.getEndpoint("login", "/public/auth/login"), u = await fetch(`${t.api?.basePath}${r}`, {
120
+ method: "POST",
121
+ headers: { "Content-Type": "application/json" },
122
+ body: JSON.stringify({ phone: n, password: i })
123
+ }), c = await o.handleResponse(u, "Login failed");
124
+ return c.token && o.setToken(c.token), c;
125
+ },
126
+ register: async (n, i, r, u, c) => {
127
+ const y = o.getEndpoint("register", "/public/auth/register"), k = await fetch(`${t.api?.basePath}${y}`, {
128
+ method: "POST",
129
+ headers: { "Content-Type": "application/json" },
130
+ body: JSON.stringify({ phone: n, password: i, name: r, surname: u, metadata: c })
131
+ }), g = await o.handleResponse(k, "Registration failed");
132
+ return g.token && o.setToken(g.token), g;
133
+ },
134
+ getBalance: async () => {
135
+ const n = o.getEndpoint("balance", "/users/balance"), i = await fetch(`${t.api?.basePath}${n}`, {
136
+ headers: {
137
+ ...d.getHeaders()
138
+ }
139
+ });
140
+ return o.handleResponse(i, "Failed to fetch balance");
141
+ },
142
+ getHistory: async (n = 0, i = 50) => {
143
+ const r = o.getEndpoint("threads", "/chat/threads"), u = await fetch(`${t.api?.basePath}${r}?skip=${n}&limit=${i}`, {
144
+ headers: {
145
+ ...d.getHeaders()
146
+ }
147
+ });
148
+ return o.handleResponse(u, "Failed to fetch chat history");
149
+ },
150
+ getThreadMessages: async (n) => {
151
+ if (!o.getToken()) throw new Error("No token found");
152
+ const r = o.getEndpoint(
153
+ "threadMessages",
154
+ (c) => `/chat/threads/${c.replace(/^\//, "")}`,
155
+ n
156
+ ), u = await fetch(`${t.api?.basePath}${r}`, {
157
+ headers: {
158
+ ...d.getHeaders()
159
+ }
160
+ });
161
+ return o.handleResponse(u, "Failed to fetch thread messages");
162
+ },
163
+ deleteThread: async (n) => {
164
+ if (!o.getToken()) throw new Error("No token found");
165
+ const r = o.getEndpoint(
166
+ "deleteThread",
167
+ (c) => `/chat/threads/${c.replace(/^\//, "")}`,
168
+ n
169
+ ), u = await fetch(`${t.api?.basePath}${r}`, {
170
+ method: "DELETE",
171
+ headers: {
172
+ ...d.getHeaders()
173
+ }
174
+ });
175
+ return o.handleResponse(u, "Failed to delete thread");
176
+ },
177
+ updateThreadTitle: async (n, i) => {
178
+ if (!o.getToken()) throw new Error("No token found");
179
+ const u = o.getEndpoint(
180
+ "updateThreadTitle",
181
+ (y) => `/chat/threads/${y.replace(/^\//, "")}`,
182
+ n
183
+ ), c = await fetch(`${t.api?.basePath}${u}`, {
184
+ method: "PATCH",
185
+ headers: {
186
+ "Content-Type": "application/json",
187
+ ...d.getHeaders()
188
+ },
189
+ body: JSON.stringify({ title: i })
190
+ });
191
+ return o.handleResponse(c, "Failed to update thread title");
192
+ },
193
+ /**
194
+ * Fetch an attachment from the Minio-backed proxy endpoint and return
195
+ * a local blob URL usable in <img src>. Caller should revoke via
196
+ * URL.revokeObjectURL when the component unmounts.
197
+ */
198
+ async getAttachmentBlobUrl(n) {
199
+ if (t.api?.attachmentResolver)
200
+ return t.api.attachmentResolver(n);
201
+ const i = o.getEndpoint(
202
+ "attachments",
203
+ (c) => `/chat/attachments/${c}`,
204
+ n
205
+ ), r = await fetch(`${t.api?.basePath}${i}`, {
206
+ headers: { ...d.getHeaders() }
207
+ });
208
+ if (!r.ok) return o.handleResponse(r, "Failed to fetch attachment");
209
+ const u = await r.blob();
210
+ return URL.createObjectURL(u);
211
+ },
212
+ /**
213
+ * Fetch an attachment from the public shared endpoint and return
214
+ * a local blob URL.
215
+ */
216
+ async getPublicAttachmentBlobUrl(n) {
217
+ const i = o.getEndpoint(
218
+ "sharedAttachments",
219
+ (c) => `/public/attachments/${c}`,
220
+ n
221
+ ), r = await fetch(`${t.api?.basePath}${i}`, {
222
+ headers: {
223
+ "Content-Type": "application/json"
224
+ }
225
+ });
226
+ if (!r.ok) return o.handleResponse(r, "Failed to fetch public attachment");
227
+ const u = await r.blob();
228
+ return URL.createObjectURL(u);
229
+ },
230
+ saveFeedback: async (n, i, r) => {
231
+ const u = o.getEndpoint("feedback", "/chat/feedback"), c = await fetch(`${t.api?.basePath}${u}`, {
232
+ method: "POST",
233
+ headers: {
234
+ "Content-Type": "application/json",
235
+ ...d.getHeaders()
236
+ },
237
+ body: JSON.stringify({
238
+ thread_id: n.replace(/^\//, ""),
239
+ message_id: i,
240
+ sentiment: r
241
+ })
242
+ });
243
+ return o.handleResponse(c, "Failed to save feedback");
244
+ },
245
+ getMe: async () => {
246
+ const n = o.getEndpoint("me", "/users/me"), i = await fetch(`${t.api?.basePath}${n}`, {
247
+ headers: {
248
+ ...d.getHeaders()
249
+ }
250
+ });
251
+ return o.handleResponse(i, "Failed to fetch user profile");
252
+ },
253
+ updateMe: async (n) => {
254
+ const i = o.getEndpoint("me", "/users/me"), r = await fetch(`${t.api?.basePath}${i}`, {
255
+ method: "PATCH",
256
+ headers: {
257
+ "Content-Type": "application/json",
258
+ ...d.getHeaders()
259
+ },
260
+ body: JSON.stringify(n)
261
+ });
262
+ return o.handleResponse(r, "Failed to update user profile");
263
+ },
264
+ pinThread: async (n, i) => {
265
+ if (!o.getToken()) throw new Error("No token found");
266
+ const u = o.getEndpoint(
267
+ "updateThreadTitle",
268
+ (y) => `/chat/threads/${y.replace(/^\//, "")}`,
269
+ n
270
+ ), c = await fetch(`${t.api?.basePath}${u}`, {
271
+ method: "PATCH",
272
+ headers: {
273
+ "Content-Type": "application/json",
274
+ ...d.getHeaders()
275
+ },
276
+ body: JSON.stringify({ pinned: i })
277
+ });
278
+ return o.handleResponse(c, "Failed to pin thread");
279
+ },
280
+ shareThread: async (n) => {
281
+ if (!o.getToken()) throw new Error("No token found");
282
+ const r = o.getEndpoint(
283
+ "shareThread",
284
+ (c) => `/chat/threads/${c.replace(/^\//, "")}/share`,
285
+ n
286
+ ), u = await fetch(`${t.api?.basePath}${r}`, {
287
+ method: "POST",
288
+ headers: {
289
+ ...d.getHeaders()
290
+ }
291
+ });
292
+ return o.handleResponse(u, "Failed to share thread");
293
+ },
294
+ getSharedThread: async (n) => {
295
+ const i = o.getEndpoint("sharedThread", (u) => `/public/shared/${u}`, n), r = await fetch(`${t.api?.basePath}${i}`, {
296
+ headers: {
297
+ "Content-Type": "application/json"
298
+ }
299
+ });
300
+ return o.handleResponse(r, "Failed to fetch shared thread");
301
+ },
302
+ getAppConfig: async () => {
303
+ const n = await fetch(`${t.api?.basePath}/config`);
304
+ return o.handleResponse(n, "Failed to fetch app configuration");
305
+ }
306
+ };
307
+ return a && o.configure(a), o;
308
+ }
309
+ function Za({
45
310
  children: a,
46
311
  api: t,
47
- app: i,
48
- i18n: m,
49
- components: c,
50
- history: u,
51
- welcome: g,
52
- threadActions: f,
53
- composer: h,
54
- theme: N,
55
- disclaimer: y,
56
- settings: C
312
+ app: d,
313
+ i18n: o,
314
+ components: n,
315
+ history: i,
316
+ welcome: r,
317
+ threadActions: u,
318
+ composer: c,
319
+ theme: y,
320
+ disclaimer: k,
321
+ settings: g
57
322
  }) {
58
- const [s, M] = T(null), P = O(
59
- () => m?.instance ?? nt,
60
- // eslint-disable-next-line react-hooks/exhaustive-deps
61
- [m?.instance]
62
- ), U = t || {};
63
- $(() => {
64
- D.getAppConfig().then((d) => M(d)).catch((d) => console.debug("Gentiq: No dynamic settings available or fetch failed", d));
65
- }, []), $(() => {
66
- s?.app_name && (document.title = P.t(s.app_name));
67
- }, [s, P]);
68
- const q = O(() => {
69
- const d = {
323
+ const [p, A] = _(null), P = Q(() => o?.instance ?? ot, [o?.instance]), I = t || {}, [E] = _(() => la({ api: I }));
324
+ B(() => {
325
+ E.getAppConfig().then((w) => A(w)).catch((w) => console.debug("Gentiq: No dynamic settings available or fetch failed", w));
326
+ }, [E]), B(() => {
327
+ p?.app_name && (document.title = P.t(p.app_name));
328
+ }, [p, P]);
329
+ const R = Q(() => {
330
+ const w = {
70
331
  basePath: "/",
71
332
  cacheNamespace: "gentiq",
72
- ...i
333
+ ...d
73
334
  };
74
- return s ? {
75
- ...d,
76
- name: (s.app_name ? P.t(s.app_name) : null) || d.name,
77
- adminTitle: (s.admin_title ? P.t(s.admin_title) : null) || d.adminTitle,
78
- version: s.app_version || d.version,
79
- showSettings: s.show_settings ?? d.showSettings,
80
- showVersionInSettings: s.show_version_in_settings ?? d.showVersionInSettings,
81
- showToolDetails: s.show_tool_details ?? d.showToolDetails,
82
- disableSignup: s.disable_signup ?? d.disableSignup,
83
- disableAuthPage: s.disable_auth_page ?? d.disableAuthPage,
84
- settingsGeneralMode: s.settings_general_mode || d.settingsGeneralMode,
85
- settingsProfileMode: s.settings_profile_mode || d.settingsProfileMode,
86
- settingsAccountMode: s.settings_account_mode || d.settingsAccountMode
87
- } : d;
88
- }, [i, s, P]), A = O(() => {
89
- if (!s) return g;
90
- const d = typeof g?.greeting == "function" ? g.greeting : s.welcome_greeting || g?.greeting;
335
+ return p ? {
336
+ ...w,
337
+ name: (p.app_name ? P.t(p.app_name) : null) || w.name,
338
+ adminTitle: (p.admin_title ? P.t(p.admin_title) : null) || w.adminTitle,
339
+ version: p.app_version || w.version,
340
+ showSettings: p.show_settings ?? w.showSettings,
341
+ showVersionInSettings: p.show_version_in_settings ?? w.showVersionInSettings,
342
+ showToolDetails: p.show_tool_details ?? w.showToolDetails,
343
+ disableSignup: p.disable_signup ?? w.disableSignup,
344
+ disableAuthPage: p.disable_auth_page ?? w.disableAuthPage,
345
+ settingsGeneralMode: p.settings_general_mode || w.settingsGeneralMode,
346
+ settingsProfileMode: p.settings_profile_mode || w.settingsProfileMode,
347
+ settingsAccountMode: p.settings_account_mode || w.settingsAccountMode
348
+ } : w;
349
+ }, [d, p, P]), D = Q(() => {
350
+ if (!p) return r;
351
+ const w = typeof r?.greeting == "function" ? r.greeting : p.welcome_greeting || r?.greeting;
91
352
  return {
92
- ...g,
93
- greeting: d,
94
- subtitle: s.welcome_subtitle || g?.subtitle
353
+ ...r,
354
+ greeting: w,
355
+ subtitle: p.welcome_subtitle || r?.subtitle
95
356
  };
96
- }, [g, s]), p = O(() => {
97
- const d = s?.disclaimer || y;
98
- return d && P.t(d);
99
- }, [y, s, P]), Q = O(() => s ? {
357
+ }, [r, p]), T = Q(() => {
358
+ const w = p?.disclaimer || k;
359
+ return typeof w == "string" ? P.t(w) : w;
360
+ }, [k, p, P]), q = Q(() => p ? {
361
+ ...i,
362
+ enabled: p.history_enabled ?? i?.enabled,
363
+ showDelete: p.history_show_delete ?? i?.showDelete,
364
+ showRename: p.history_show_rename ?? i?.showRename,
365
+ showShare: p.history_show_share ?? i?.showShare,
366
+ showPin: p.history_show_pin ?? i?.showPin
367
+ } : i, [i, p]), x = Q(() => p ? {
100
368
  ...u,
101
- enabled: s.history_enabled ?? u?.enabled,
102
- showDelete: s.history_show_delete ?? u?.showDelete,
103
- showRename: s.history_show_rename ?? u?.showRename,
104
- showShare: s.history_show_share ?? u?.showShare,
105
- showPin: s.history_show_pin ?? u?.showPin
106
- } : u, [u, s]), x = O(() => s ? {
107
- ...f,
108
- feedback: s.thread_actions_feedback ?? f?.feedback,
109
- retry: s.thread_actions_retry ?? f?.retry
110
- } : f, [f, s]), B = O(() => s ? {
111
- ...h,
369
+ feedback: p.thread_actions_feedback ?? u?.feedback,
370
+ retry: p.thread_actions_retry ?? u?.retry
371
+ } : u, [u, p]), V = Q(() => p ? {
372
+ ...c,
112
373
  attachments: {
113
- ...h?.attachments,
114
- enabled: s.composer_attachments ?? h?.attachments?.enabled
374
+ ...c?.attachments,
375
+ enabled: p.composer_attachments ?? c?.attachments?.enabled
115
376
  }
116
- } : h, [h, s]), W = O(() => ({
117
- ...N,
118
- defaultTheme: s?.default_theme ?? N?.defaultTheme,
119
- accent: s?.default_accent ?? N?.accent
120
- }), [N, s]), K = O(() => s ? {
121
- ...C,
377
+ } : c, [c, p]), K = Q(
378
+ () => ({
379
+ ...y,
380
+ defaultTheme: p?.default_theme ?? y?.defaultTheme,
381
+ accent: p?.default_accent ?? y?.accent
382
+ }),
383
+ [y, p]
384
+ ), M = Q(() => p ? {
385
+ ...g,
122
386
  sections: {
123
- ...C?.sections,
387
+ ...g?.sections,
124
388
  general: {
125
- ...C?.sections?.general,
126
- mode: s.settings_general_mode || C?.sections?.general?.mode,
127
- enabled: C?.sections?.general?.enabled ?? !0,
389
+ ...g?.sections?.general,
390
+ mode: p.settings_general_mode || g?.sections?.general?.mode,
391
+ enabled: g?.sections?.general?.enabled ?? !0,
128
392
  fields: {
129
- ...C?.sections?.general?.fields,
130
- ...s.settings_general_fields
393
+ ...g?.sections?.general?.fields,
394
+ ...p.settings_general_fields
131
395
  }
132
396
  },
133
397
  profile: {
134
- ...C?.sections?.profile,
135
- mode: s.settings_profile_mode || C?.sections?.profile?.mode,
136
- enabled: C?.sections?.profile?.enabled ?? !0,
398
+ ...g?.sections?.profile,
399
+ mode: p.settings_profile_mode || g?.sections?.profile?.mode,
400
+ enabled: g?.sections?.profile?.enabled ?? !0,
137
401
  fields: {
138
- ...C?.sections?.profile?.fields,
139
- ...s.settings_profile_fields
402
+ ...g?.sections?.profile?.fields,
403
+ ...p.settings_profile_fields
140
404
  }
141
405
  },
142
406
  account: {
143
- ...C?.sections?.account,
144
- mode: s.settings_account_mode || C?.sections?.account?.mode,
145
- enabled: C?.sections?.account?.enabled ?? !0,
407
+ ...g?.sections?.account,
408
+ mode: p.settings_account_mode || g?.sections?.account?.mode,
409
+ enabled: g?.sections?.account?.enabled ?? !0,
146
410
  fields: {
147
- ...C?.sections?.account?.fields,
148
- ...s.settings_account_fields
411
+ ...g?.sections?.account?.fields,
412
+ ...p.settings_account_fields
149
413
  }
150
414
  }
151
415
  }
152
- } : C, [C, s]), E = O(() => new Ze({
153
- defaultOptions: {
154
- queries: {
155
- staleTime: 5e3,
156
- retry: 1
416
+ } : g, [g, p]), $ = Q(
417
+ () => new tt({
418
+ defaultOptions: {
419
+ queries: {
420
+ staleTime: 5e3,
421
+ retry: 1
422
+ }
157
423
  }
158
- }
159
- }), []);
160
- $(() => {
161
- D.init({
162
- api: U,
163
- app: q
424
+ }),
425
+ []
426
+ );
427
+ B(() => {
428
+ E.configure({
429
+ api: I,
430
+ app: R
164
431
  });
165
- }, [q]);
166
- const V = ae(null), R = m?.resources;
167
- R !== V.current && (V.current = R, R && Object.entries(R).forEach(([d, n]) => {
168
- Object.entries(n).forEach(([k, I]) => {
169
- P.addResourceBundle(d, k, I, !0, !0);
432
+ }, [E, R]);
433
+ const G = re(null), F = o?.resources;
434
+ F !== G.current && (G.current = F, F && Object.entries(F).forEach(([w, m]) => {
435
+ Object.entries(m).forEach(([C, f]) => {
436
+ P.addResourceBundle(w, C, f, !0, !0);
170
437
  });
171
438
  }));
172
- const L = ae(null), H = s?.translations;
173
- H && H !== L.current && (L.current = H, Object.entries(H).forEach(([d, n]) => {
174
- Object.entries(n).forEach(([k, I]) => {
175
- P.addResourceBundle(d, k, I, !0, !0);
439
+ const J = re(null), W = p?.translations;
440
+ W && W !== J.current && (J.current = W, Object.entries(W).forEach(([w, m]) => {
441
+ Object.entries(m).forEach(([C, f]) => {
442
+ P.addResourceBundle(w, C, f, !0, !0);
176
443
  });
177
444
  }));
178
- const F = ae(null), b = m?.instance;
179
- return b && b !== F.current && (F.current = b, Object.entries(st).forEach(([d, n]) => {
180
- Object.entries(n).forEach(([k, I]) => {
181
- b.hasResourceBundle(d, k) || b.addResourceBundle(d, k, I, !0, !1);
445
+ const j = re(null), L = o?.instance;
446
+ return L && L !== j.current && (j.current = L, Object.entries(it).forEach(([w, m]) => {
447
+ Object.entries(m).forEach(([C, f]) => {
448
+ L.hasResourceBundle(w, C) || L.addResourceBundle(w, C, f, !0, !1);
182
449
  });
183
- })), /* @__PURE__ */ e(rt, { i18n: P, children: /* @__PURE__ */ r(et, { client: E, children: [
184
- /* @__PURE__ */ r(
185
- Fe,
450
+ })), /* @__PURE__ */ e(st, { i18n: P, children: /* @__PURE__ */ s(at, { client: $, children: [
451
+ /* @__PURE__ */ e(lt, { api: E, children: /* @__PURE__ */ s(
452
+ je,
186
453
  {
187
- components: c,
188
- history: Q,
189
- welcome: A,
454
+ components: n,
455
+ history: q,
456
+ welcome: D,
190
457
  threadActions: x,
191
- composer: B,
192
- theme: W,
193
- disclaimer: p,
194
- app: q,
195
- i18n: m,
196
- settings: K,
458
+ composer: V,
459
+ theme: K,
460
+ disclaimer: T,
461
+ app: R,
462
+ i18n: o,
463
+ settings: M,
197
464
  children: [
198
- /* @__PURE__ */ e(ra, {}),
199
- /* @__PURE__ */ e(ot, { defaultTheme: "system", storageKey: "chatbot-theme", config: W, children: a })
465
+ /* @__PURE__ */ e(ca, {}),
466
+ /* @__PURE__ */ e(ct, { defaultTheme: "system", storageKey: "chatbot-theme", config: K, children: a })
200
467
  ]
201
468
  }
202
- ),
203
- /* @__PURE__ */ e(aa, { richColors: !0 })
469
+ ) }),
470
+ /* @__PURE__ */ e(sa, { richColors: !0 })
204
471
  ] }) });
205
472
  }
206
- function ra() {
207
- const { app: a } = re();
208
- return je(), $(() => {
473
+ function ca() {
474
+ const { app: a } = ne();
475
+ return Oe(), B(() => {
209
476
  a?.name && (document.title = a.name);
210
- }, [a?.name]), $(() => {
477
+ }, [a?.name]), B(() => {
211
478
  if (!a?.favicon) return;
212
479
  let t = document.querySelector("link[rel~='icon']");
213
480
  t || (t = document.createElement("link"), t.rel = "icon", document.head.appendChild(t)), t.href = a.favicon;
214
481
  }, [a?.favicon]), null;
215
482
  }
216
- function Ce() {
217
- const a = Ge(), t = _e(), m = D.getConfig().app?.basePath || "/", c = O(() => {
218
- const g = a.pathname, f = g.endsWith("/") && g !== "/" ? g.slice(0, -1) : g, h = m.endsWith("/") && m !== "/" ? m.slice(0, -1) : m;
219
- if (f === (h || "/")) return "/";
220
- if (g.startsWith(h) && h !== "/") {
221
- let N = g.slice(h.length);
222
- return N.startsWith("/") || (N = "/" + N), N;
483
+ function Pe() {
484
+ const a = Je(), t = Te(), n = oe().getConfig().app?.basePath || "/", i = Q(() => {
485
+ const u = a.pathname, c = u.endsWith("/") && u !== "/" ? u.slice(0, -1) : u, y = n.endsWith("/") && n !== "/" ? n.slice(0, -1) : n;
486
+ if (c === (y || "/")) return "/";
487
+ if (u.startsWith(y) && y !== "/") {
488
+ let k = u.slice(y.length);
489
+ return k.startsWith("/") || (k = "/" + k), k;
223
490
  }
224
- return h === "/" ? g : "/";
225
- }, [a.pathname, m]), u = J((g) => {
226
- t(be(m, g || "/"), { replace: !1 });
227
- }, [t, m]);
228
- return [c, u];
491
+ return y === "/" ? u : "/";
492
+ }, [a.pathname, n]), r = ee(
493
+ (u) => {
494
+ t(xe(n, u || "/"), { replace: !1 });
495
+ },
496
+ [t, n]
497
+ );
498
+ return [i, r];
229
499
  }
230
- function na({ onFinish: a } = {}) {
231
- const { t } = de(["chat", "errors"]), i = ue(), m = D.getConfig(), c = m.app?.cacheNamespace || "gentiq", [u, g] = Ce(), [f, h] = T(() => he()), N = ae(/* @__PURE__ */ new Set());
232
- $(() => {
233
- u === "/" ? h(he()) : f && u !== `/${f}` && h(he());
234
- }, [u]);
235
- const y = O(() => u === "/" ? f : u.replace(/^\//, ""), [u, f]), C = J((b) => (N.current.add(b), b), []), s = J(() => {
236
- N.current.forEach((b) => URL.revokeObjectURL(b)), N.current.clear();
500
+ function da({ onFinish: a } = {}) {
501
+ const { t } = ue(["chat", "errors"]), d = he(), o = oe(), n = o.getConfig(), i = n.app?.cacheNamespace || "gentiq", [r, u] = Pe(), [c, y] = _(() => me()), k = re(/* @__PURE__ */ new Set());
502
+ B(() => {
503
+ y((f) => r === "/" ? me() : f && r !== `/${f}` ? me() : f);
504
+ }, [r]);
505
+ const g = Q(() => r === "/" ? c : r.replace(/^\//, ""), [r, c]), p = ee((f) => (k.current.add(f), f), []), A = ee(() => {
506
+ k.current.forEach((f) => URL.revokeObjectURL(f)), k.current.clear();
237
507
  }, []);
238
- $(() => () => s(), [s]);
508
+ B(() => () => A(), [A]);
239
509
  const {
240
- data: M,
241
- isLoading: P,
242
- isError: U
243
- } = tt({
244
- queryKey: [c, "threadMessages", y],
510
+ data: P,
511
+ isLoading: I,
512
+ isError: E
513
+ } = rt({
514
+ queryKey: [i, "threadMessages", g],
245
515
  queryFn: async () => {
246
- if (u === "/") return [];
247
- if (u === `/${f}`) return [];
248
- const b = await D.getThreadMessages(y);
249
- return !b.items || !Array.isArray(b.items) ? [] : Promise.all(
250
- b.items.map(async (d) => {
251
- const n = typeof d.content == "string" ? d.content : d.content?.text || JSON.stringify(d.content), I = [...Array.isArray(d.parts) && d.parts.length > 0 ? d.parts : [{ type: "text", text: n }]].sort((S, w) => S.type === "file" && w.type !== "file" ? -1 : S.type !== "file" && w.type === "file" ? 1 : 0), j = await Promise.all(
252
- I.map(async (S) => {
253
- if (S.type === "file" && S.object_name && !S.url)
516
+ if (r === "/") return [];
517
+ if (r === `/${c}`) return [];
518
+ const f = await o.getThreadMessages(g);
519
+ return !f.items || !Array.isArray(f.items) ? [] : await Promise.all(
520
+ f.items.map(async (S) => {
521
+ const Z = typeof S.content == "string" ? S.content : S.content?.text || JSON.stringify(S.content), z = [...Array.isArray(S.parts) && S.parts.length > 0 ? S.parts : [{ type: "text", text: Z }]].sort((b, l) => b.type === "file" && l.type !== "file" ? -1 : b.type !== "file" && l.type === "file" ? 1 : 0), U = await Promise.all(
522
+ z.map(async (b) => {
523
+ if (b.type === "file" && b.object_name && !b.url)
254
524
  try {
255
- const w = await D.getAttachmentBlobUrl(S.object_name);
256
- return { ...S, url: C(w), mediaType: S.mediaType || S.media_type };
257
- } catch (w) {
258
- return console.warn("Load attachment failed:", S.object_name, w), { ...S, mediaType: S.mediaType || S.media_type };
525
+ const l = await o.getAttachmentBlobUrl(b.object_name);
526
+ return {
527
+ ...b,
528
+ url: p(l),
529
+ mediaType: b.mediaType || b.media_type
530
+ };
531
+ } catch (l) {
532
+ return console.warn("Load attachment failed:", b.object_name, l), { ...b, mediaType: b.mediaType || b.media_type };
259
533
  }
260
- return S;
534
+ return b;
261
535
  })
262
536
  );
263
537
  return {
264
- id: d.id || he(),
265
- role: d.role,
266
- parts: j,
267
- metadata: { feedback: d.feedback }
538
+ id: S.id || me(),
539
+ role: S.role,
540
+ parts: U,
541
+ metadata: { feedback: S.feedback }
268
542
  };
269
543
  })
270
544
  );
271
545
  },
272
- enabled: u !== "/",
546
+ enabled: r !== "/",
273
547
  staleTime: 5e3
274
548
  // Keep history fresh for 5 seconds
275
- }), q = O(() => new Jt({
276
- api: D.getEndpoint("chat", "/chat"),
277
- fetch: async (b, d) => {
278
- const n = new Headers(d?.headers), k = D.getHeaders();
279
- Object.entries(k).forEach(([w, z]) => {
280
- n.set(w, z);
281
- }), n.set("X-Thread-Id", y);
282
- const I = m.api?.basePath || "/api", j = typeof b == "string" && !b.startsWith("http") ? `${I}${b.startsWith("/") ? b : "/" + b}` : b, S = await fetch(j, { ...d, headers: n });
283
- if (!S.ok) {
284
- const w = await S.json().catch(() => ({}));
285
- if (w.error && (typeof w.error.code == "string" || typeof w.error.message == "string"))
286
- throw new Pe(w, S.status);
287
- let z = S.statusText || `HTTP ${S.status}`, Y = "error", Z = null;
288
- throw typeof w.detail == "string" ? z = w.detail : typeof w.message == "string" ? z = w.message : typeof w.error == "string" ? z = w.error : Array.isArray(w.detail) ? (z = "Validation failed", Z = w.detail, Y = "validation_error") : w.error && typeof w.error.message == "string" && (z = w.error.message), new Pe({
289
- error: {
290
- code: Y,
291
- message: z,
292
- details: Z
293
- }
294
- }, S.status);
549
+ }), R = Q(
550
+ () => new ea({
551
+ api: o.getEndpoint("chat", "/chat"),
552
+ fetch: async (f, O) => {
553
+ const S = new Headers(O?.headers), Z = o.getHeaders();
554
+ Object.entries(Z).forEach(([b, l]) => {
555
+ S.set(b, l);
556
+ }), S.set("X-Thread-Id", g);
557
+ const H = n.api?.basePath || "/api", z = typeof f == "string" && !f.startsWith("http") ? `${H}${f.startsWith("/") ? f : "/" + f}` : f, U = await fetch(z, { ...O, headers: S });
558
+ if (!U.ok) {
559
+ const b = await U.json().catch(() => ({}));
560
+ if (b.error && (typeof b.error.code == "string" || typeof b.error.message == "string"))
561
+ throw new be(b, U.status);
562
+ let l = U.statusText || `HTTP ${U.status}`, h = "error", N = null;
563
+ throw typeof b.detail == "string" ? l = b.detail : typeof b.message == "string" ? l = b.message : typeof b.error == "string" ? l = b.error : Array.isArray(b.detail) ? (l = "Validation failed", N = b.detail, h = "validation_error") : b.error && typeof b.error.message == "string" && (l = b.error.message), new be(
564
+ {
565
+ error: {
566
+ code: h,
567
+ message: l,
568
+ details: N
569
+ }
570
+ },
571
+ U.status
572
+ );
573
+ }
574
+ return U;
295
575
  }
296
- return S;
297
- }
298
- }), [y, m.api?.basePath]), A = J(() => {
299
- x("ready"), i.invalidateQueries({ queryKey: [c, "conversations"] }), a?.();
300
- }, [i, a, c]), p = Xt({
301
- id: y,
302
- onFinish: A,
303
- transport: q
304
- }), [Q, x] = T("idle"), [B, W] = T(null), K = J(() => {
305
- W(null);
576
+ }),
577
+ [g, n.api?.basePath, o]
578
+ ), D = ee(() => {
579
+ M("ready"), d.invalidateQueries({ queryKey: [i, "conversations"] }), a?.();
580
+ }, [d, a, i]), T = Zt({
581
+ id: g,
582
+ onFinish: D,
583
+ transport: R
584
+ }), { setMessages: q, sendMessage: x, stop: V } = T, [K, M] = _("idle"), [$, G] = _(null), F = ee(() => {
585
+ G(null);
306
586
  }, []);
307
- $(() => {
308
- M && (u === `/${f}` || (p.setMessages(M), x("ready")));
309
- }, [M, p.setMessages, u, f]), $(() => {
310
- u === "/" && (p.setMessages([]), x("idle"));
311
- }, [u, p.setMessages]), $(() => {
312
- if (u === "/") {
313
- x("idle");
587
+ B(() => {
588
+ P && (r === `/${c}` || (q(P), M("ready")));
589
+ }, [P, q, r, c]), B(() => {
590
+ r === "/" && (q([]), M("idle"));
591
+ }, [r, q]), B(() => {
592
+ if (r === "/") {
593
+ M("idle");
314
594
  return;
315
595
  }
316
- const b = u === `/${f}`;
317
- P && !b ? x("loading-history") : U || B || p.error ? x("error") : p.status === "streaming" || p.status === "submitted" ? x(p.status) : x("ready");
318
- }, [P, U, p.status, B, p.error, u, f]), $(() => () => {
319
- p.stop();
320
- }, [y, p.stop]);
321
- const E = ae(/* @__PURE__ */ new Set()), V = O(() => p.messages.filter((b) => b.role === "assistant"), [p.messages]);
322
- $(() => {
323
- let b = !1;
324
- for (const d of V) {
325
- if (E.current.has(d.id)) continue;
326
- const n = d.parts.find((k) => k.type === "data-title");
327
- n && n.data?.[0]?.title && (E.current.add(d.id), b = !0);
596
+ const f = r === `/${c}`;
597
+ I && !f ? M("loading-history") : E || $ || T.error ? M("error") : T.status === "streaming" || T.status === "submitted" ? M(T.status) : M("ready");
598
+ }, [
599
+ I,
600
+ E,
601
+ T.status,
602
+ $,
603
+ T.error,
604
+ r,
605
+ c
606
+ ]), B(() => () => {
607
+ V();
608
+ }, [g, V]);
609
+ const J = re(/* @__PURE__ */ new Set()), W = Q(
610
+ () => T.messages.filter((f) => f.role === "assistant"),
611
+ [T.messages]
612
+ );
613
+ B(() => {
614
+ let f = !1;
615
+ for (const O of W) {
616
+ if (J.current.has(O.id)) continue;
617
+ const S = O.parts.find((H) => H.type === "data-title");
618
+ (S ? ge(S) : void 0)?.data?.[0]?.title && (J.current.add(O.id), f = !0);
328
619
  }
329
- b && i.invalidateQueries({ queryKey: [c, "conversations"] });
330
- }, [V, i, c]);
331
- const R = J((b) => {
332
- if (b.length === 0) return;
333
- const d = b.map((n) => ({
334
- type: "data-reference",
335
- data: n
336
- }));
337
- p.setMessages((n) => {
338
- const k = new Set(b.map((w) => w.id));
339
- if (n.some(
340
- (w) => w.parts.some((z) => z.type === "data-reference" && k.has(z.data?.id))
341
- )) return n;
342
- const j = [...n].reverse().findIndex((w) => w.role === "user" && !w.parts.some((z) => z.type === "data-reference"));
343
- if (j === -1) return n;
344
- const S = n.length - 1 - j;
345
- return n.map((w, z) => z !== S ? w : {
346
- ...w,
347
- metadata: {
348
- ...w.metadata || {},
349
- references: b
350
- },
351
- parts: [
352
- ...d,
353
- ...w.parts
354
- ]
355
- });
356
- });
357
- }, [p.setMessages]), L = J(async (b, d, n = []) => {
358
- const k = u === "/", I = b.trim();
359
- if (!(!I && (!d || d.length === 0) && n.length === 0) && !(Q === "loading-history" || Q === "streaming" || Q === "submitted")) {
360
- if (p.stop(), k) {
361
- g(`/${y}`);
362
- const j = I || (n[0]?.excerpt ? `↳ ${n[0].excerpt}` : t("attach_file")), S = j.length > 30 ? j.slice(0, 30) + "..." : j;
363
- i.setQueryData([c, "conversations"], (w) => {
364
- const z = { id: `/${y}`, firstMessage: S, timestamp: Date.now() };
365
- return w && Array.isArray(w.pages) ? {
366
- ...w,
367
- pages: w.pages.map((Y, Z) => Z === 0 ? {
368
- ...Y,
369
- threads: [z, ...Y.threads || []]
370
- } : Y)
371
- } : [z, ...Array.isArray(w) ? w : []];
620
+ f && d.invalidateQueries({ queryKey: [i, "conversations"] });
621
+ }, [W, d, i]);
622
+ const j = re(null), L = ee(
623
+ (f) => {
624
+ if (f.length === 0) return;
625
+ const O = f.map((S) => ({
626
+ type: "data-reference",
627
+ data: S
628
+ }));
629
+ q((S) => {
630
+ const Z = new Set(f.map((b) => b.id));
631
+ if (S.some(
632
+ (b) => b.parts.some(
633
+ (l) => l.type === "data-reference" && Z.has(ge(l).data?.id)
634
+ )
635
+ )) return S;
636
+ const z = [...S].reverse().findIndex(
637
+ (b) => b.role === "user" && !b.parts.some((l) => l.type === "data-reference")
638
+ );
639
+ if (z === -1) return S;
640
+ const U = S.length - 1 - z;
641
+ return S.map((b, l) => l !== U ? b : {
642
+ ...b,
643
+ metadata: {
644
+ ...b.metadata || {},
645
+ references: f
646
+ },
647
+ parts: [...O, ...b.parts]
372
648
  });
373
- }
374
- x("submitted"), W(null);
375
- try {
376
- if (n.length > 0) {
377
- const j = p.sendMessage({ text: I, files: d }, { body: { references: n } });
378
- window.setTimeout(() => R(n), 0), window.setTimeout(() => R(n), 80), await j;
379
- } else
380
- await p.sendMessage({ text: I, files: d });
381
- } catch (j) {
382
- console.error("Failed to send message:", j);
383
- const S = ce(j, t);
384
- W(new Error(S)), x("error");
385
- }
649
+ });
650
+ },
651
+ [q]
652
+ );
653
+ B(() => {
654
+ const f = j.current;
655
+ if (!f) return;
656
+ const O = new Set(f.map((H) => H.id));
657
+ if (T.messages.some(
658
+ (H) => H.parts.some(
659
+ (z) => z.type === "data-reference" && O.has(ge(z).data?.id)
660
+ )
661
+ )) {
662
+ j.current = null;
663
+ return;
386
664
  }
387
- }, [p, g, u, y, t, i, Q, c, R]), H = J(() => {
388
- p.stop(), x("ready"), i.invalidateQueries({ queryKey: [c, "conversations"] });
389
- }, [p.stop, i, c]), F = O(() => {
390
- if (B) return B;
391
- if (p.error) {
392
- const b = ce(p.error, t);
393
- return new Error(b);
665
+ T.messages.some(
666
+ (H) => H.role === "user" && !H.parts.some((z) => z.type === "data-reference")
667
+ ) && (L(f), j.current = null);
668
+ }, [T.messages, L]);
669
+ const w = ee(
670
+ async (f, O, S = []) => {
671
+ const Z = r === "/", H = f.trim();
672
+ if (!(!H && (!O || O.length === 0) && S.length === 0) && !(K === "loading-history" || K === "streaming" || K === "submitted")) {
673
+ if (V(), Z) {
674
+ u(`/${g}`);
675
+ const z = H || (S[0]?.excerpt ? `↳ ${S[0].excerpt}` : t("attach_file")), U = z.length > 30 ? z.slice(0, 30) + "..." : z;
676
+ d.setQueryData([i, "conversations"], (b) => {
677
+ const l = {
678
+ id: `/${g}`,
679
+ firstMessage: U,
680
+ timestamp: Date.now()
681
+ };
682
+ return !b || !Array.isArray(b.pages) ? {
683
+ pages: [{ threads: [l], nextSkip: 0, hasMore: !1 }],
684
+ pageParams: [0]
685
+ } : {
686
+ ...b,
687
+ pages: b.pages.map(
688
+ (h, N) => N === 0 ? { ...h, threads: [l, ...h.threads || []] } : h
689
+ )
690
+ };
691
+ });
692
+ }
693
+ M("submitted"), G(null), j.current = S.length > 0 ? S : null;
694
+ try {
695
+ S.length > 0 ? await x({ text: H, files: O }, { body: { references: S } }) : await x({ text: H, files: O });
696
+ } catch (z) {
697
+ console.error("Failed to send message:", z);
698
+ const U = de(z, t);
699
+ G(new Error(U)), M("error");
700
+ }
701
+ }
702
+ },
703
+ [
704
+ V,
705
+ x,
706
+ u,
707
+ r,
708
+ g,
709
+ t,
710
+ d,
711
+ K,
712
+ i
713
+ ]
714
+ ), m = ee(() => {
715
+ V(), M("ready"), d.invalidateQueries({ queryKey: [i, "conversations"] });
716
+ }, [V, d, i]), C = Q(() => {
717
+ if ($) return $;
718
+ if (T.error) {
719
+ const f = de(T.error, t);
720
+ return new Error(f);
394
721
  }
395
722
  return null;
396
- }, [B, p.error, t]);
397
- return O(() => ({
398
- ...p,
399
- sendMessage: L,
400
- stop: H,
401
- clearError: K,
402
- error: F,
403
- status: Q,
404
- // Cast to any to satisfy Chat.tsx expectations of AI SDK statuses
405
- isLoadingHistory: Q === "loading-history",
406
- isErrorHistory: Q === "error" || !!F || U,
407
- conversationId: u
408
- }), [p, L, H, K, F, Q, U, u]);
723
+ }, [$, T.error, t]);
724
+ return Q(
725
+ () => ({
726
+ ...T,
727
+ sendMessage: w,
728
+ stop: m,
729
+ clearError: F,
730
+ error: C,
731
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ChatStatus is a superset of the AI SDK status union expected downstream
732
+ status: K,
733
+ isLoadingHistory: K === "loading-history",
734
+ isErrorHistory: K === "error" || !!C || E,
735
+ conversationId: r
736
+ }),
737
+ [T, w, m, F, C, K, E, r]
738
+ );
409
739
  }
410
- function sa({ classNames: a = {}, disclaimer: t }) {
411
- const { t: i, i18n: m } = de(["chat", "translation"]), c = na(), { messages: u, status: g, regenerate: f, error: h, clearError: N, stop: y, isLoadingHistory: C, conversationId: s, sendMessage: M } = c, { MessageList: P, PromptInput: U, composer: q, disclaimer: A } = re(), p = t ?? A, Q = m.exists("chat:disclaimer") ? i("chat:disclaimer") : null, x = typeof p == "string" ? i(p) : p ?? Q, [B, W] = T(null), K = ae(g);
412
- Ye(() => {
413
- h && N();
414
- }, [s, N, h]);
415
- const E = u[u.length - 1], V = E?.role === "assistant" && (g === "ready" || E.parts.some((L) => L.type === "data-chat-finished"));
416
- $(() => {
417
- g === "error" && K.current !== "error" && B !== s ? W(s) : g === "submitted" && B !== null && W(null), K.current = g;
418
- }, [g, s]);
419
- const R = g === "error" && (s === "/" || B === s);
740
+ function ua({ classNames: a = {}, disclaimer: t }) {
741
+ const { t: d, i18n: o } = ue(["chat", "translation"]), n = da(), {
742
+ messages: i,
743
+ status: r,
744
+ regenerate: u,
745
+ error: c,
746
+ clearError: y,
747
+ stop: k,
748
+ isLoadingHistory: g,
749
+ conversationId: p,
750
+ sendMessage: A
751
+ } = n, { MessageList: P, PromptInput: I, composer: E, disclaimer: R } = ne(), D = t ?? R, T = o.exists("chat:disclaimer") ? d("chat:disclaimer") : null, q = typeof D == "string" ? d(D) : D ?? T, [x, V] = _(null), K = re(r);
752
+ et(() => {
753
+ c && y();
754
+ }, [p, y, c]);
755
+ const M = i[i.length - 1], $ = M?.role === "assistant" && (r === "ready" || M.parts.some((F) => F.type === "data-chat-finished"));
756
+ B(() => {
757
+ r === "error" && K.current !== "error" && x !== p ? V(p) : r === "submitted" && x !== null && V(null), K.current = r;
758
+ }, [r, p]);
759
+ const G = r === "error" && (p === "/" || x === p);
420
760
  return /* @__PURE__ */ e(
421
- Oe,
761
+ He,
422
762
  {
423
- enabled: q?.references?.enabled ?? !0,
424
- maxItems: q?.references?.maxItems,
425
- maxExcerptLength: q?.references?.maxExcerptLength,
426
- children: /* @__PURE__ */ r("div", { className: v("relative flex flex-col h-full overflow-hidden", a.container), children: [
763
+ enabled: E?.references?.enabled ?? !0,
764
+ maxItems: E?.references?.maxItems,
765
+ maxExcerptLength: E?.references?.maxExcerptLength,
766
+ children: /* @__PURE__ */ s("div", { className: v("relative flex flex-col h-full overflow-hidden", a.container), children: [
427
767
  /* @__PURE__ */ e(
428
768
  P,
429
769
  {
430
- messages: u,
431
- status: g,
432
- isLoadingHistory: C,
433
- error: R ? h : null,
434
- conversationId: s,
435
- regen: (L) => f({ messageId: L }),
436
- onSuggestionClick: (L) => M(L),
437
- chat: c,
770
+ messages: i,
771
+ status: r,
772
+ isLoadingHistory: g,
773
+ error: G ? c : null,
774
+ conversationId: p,
775
+ regen: (F) => u({ messageId: F }),
776
+ onSuggestionClick: (F) => A(F),
777
+ chat: n,
438
778
  className: v("flex-1", a.messageList)
439
779
  }
440
780
  ),
441
- /* @__PURE__ */ r("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
781
+ /* @__PURE__ */ s("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
442
782
  /* @__PURE__ */ e(
443
- U,
783
+ I,
444
784
  {
445
- onSend: M,
446
- status: g,
447
- isLastMessageFinished: V,
448
- stop: y,
449
- isErrorVisible: R,
450
- conversationId: s,
451
- className: v("pointer-events-auto", a.inputArea, x && "pb-0 md:pb-0")
785
+ onSend: A,
786
+ status: r,
787
+ isLastMessageFinished: $,
788
+ stop: k,
789
+ isErrorVisible: G,
790
+ conversationId: p,
791
+ className: v(
792
+ "pointer-events-auto",
793
+ a.inputArea,
794
+ q && "pb-0 md:pb-0"
795
+ )
452
796
  }
453
797
  ),
454
- x && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
798
+ q && /* @__PURE__ */ s("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
455
799
  /* @__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" }),
456
- /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: x })
800
+ /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: q })
457
801
  ] })
458
802
  ] })
459
803
  ] })
460
804
  }
461
805
  );
462
806
  }
463
- const oa = ({
807
+ const ha = ({
464
808
  components: a,
465
809
  history: t,
466
- welcome: i,
467
- threadActions: m,
468
- composer: c,
469
- theme: u,
470
- disclaimer: g,
471
- ...f
810
+ welcome: d,
811
+ threadActions: o,
812
+ composer: n,
813
+ theme: i,
814
+ disclaimer: r,
815
+ ...u
472
816
  }) => {
473
- const h = re(), N = O(() => ({
474
- ...h,
475
- ...a,
476
- toolComponents: {
477
- ...h.toolComponents,
478
- ...a?.toolComponents
479
- },
480
- referenceAdapters: {
481
- ...h.referenceAdapters,
482
- ...a?.referenceAdapters
483
- }
484
- }), [h, a]);
817
+ const c = ne(), y = Q(
818
+ () => ({
819
+ ...c,
820
+ ...a,
821
+ toolComponents: {
822
+ ...c.toolComponents,
823
+ ...a?.toolComponents
824
+ },
825
+ referenceAdapters: {
826
+ ...c.referenceAdapters,
827
+ ...a?.referenceAdapters
828
+ }
829
+ }),
830
+ [c, a]
831
+ );
485
832
  return /* @__PURE__ */ e(
486
- Fe,
833
+ je,
487
834
  {
488
- components: N,
489
- history: t ?? h.history,
490
- welcome: i ?? h.welcome,
491
- threadActions: m ?? h.threadActions,
492
- composer: c ?? h.composer,
493
- theme: u ?? h.theme,
494
- disclaimer: g ?? h.disclaimer,
495
- app: h.app,
496
- i18n: h.i18n,
497
- settings: h.settings,
498
- children: /* @__PURE__ */ e(sa, { ...f })
835
+ components: y,
836
+ history: t ?? c.history,
837
+ welcome: d ?? c.welcome,
838
+ threadActions: o ?? c.threadActions,
839
+ composer: n ?? c.composer,
840
+ theme: i ?? c.theme,
841
+ disclaimer: r ?? c.disclaimer,
842
+ app: c.app,
843
+ i18n: c.i18n,
844
+ settings: c.settings,
845
+ children: /* @__PURE__ */ e(ua, { ...u })
499
846
  }
500
847
  );
501
848
  };
502
- function ia({ ...a }) {
503
- return /* @__PURE__ */ e(ie.Root, { "data-slot": "sheet", ...a });
849
+ function pa({ ...a }) {
850
+ return /* @__PURE__ */ e(le.Root, { "data-slot": "sheet", ...a });
504
851
  }
505
- function la({ ...a }) {
506
- return /* @__PURE__ */ e(ie.Portal, { "data-slot": "sheet-portal", ...a });
852
+ function ma({ ...a }) {
853
+ return /* @__PURE__ */ e(le.Portal, { "data-slot": "sheet-portal", ...a });
507
854
  }
508
- function ca({ className: a, ...t }) {
855
+ function ga({ className: a, ...t }) {
509
856
  return /* @__PURE__ */ e(
510
- ie.Overlay,
857
+ le.Overlay,
511
858
  {
512
859
  "data-slot": "sheet-overlay",
513
860
  className: v(
@@ -518,31 +865,31 @@ function ca({ className: a, ...t }) {
518
865
  }
519
866
  );
520
867
  }
521
- function da({
868
+ function fa({
522
869
  className: a,
523
870
  children: t,
524
- side: i = "right",
525
- ...m
871
+ side: d = "right",
872
+ ...o
526
873
  }) {
527
- return /* @__PURE__ */ r(la, { children: [
528
- /* @__PURE__ */ e(ca, {}),
529
- /* @__PURE__ */ r(
530
- ie.Content,
874
+ return /* @__PURE__ */ s(ma, { children: [
875
+ /* @__PURE__ */ e(ga, {}),
876
+ /* @__PURE__ */ s(
877
+ le.Content,
531
878
  {
532
879
  "data-slot": "sheet-content",
533
880
  className: v(
534
881
  "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
535
- i === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
536
- i === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
537
- i === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
538
- i === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
882
+ d === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
883
+ d === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
884
+ d === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
885
+ d === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
539
886
  a
540
887
  ),
541
- ...m,
888
+ ...o,
542
889
  children: [
543
890
  t,
544
- /* @__PURE__ */ r(ie.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: [
545
- /* @__PURE__ */ e(Ct, { className: "size-4" }),
891
+ /* @__PURE__ */ s(le.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: [
892
+ /* @__PURE__ */ e(Pt, { className: "size-4" }),
546
893
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Close" })
547
894
  ] })
548
895
  ]
@@ -550,12 +897,12 @@ function da({
550
897
  )
551
898
  ] });
552
899
  }
553
- function ua({ className: a, ...t }) {
900
+ function ba({ className: a, ...t }) {
554
901
  return /* @__PURE__ */ e("div", { "data-slot": "sheet-header", className: v("flex flex-col gap-1.5 p-4", a), ...t });
555
902
  }
556
- function ma({ className: a, ...t }) {
903
+ function ya({ className: a, ...t }) {
557
904
  return /* @__PURE__ */ e(
558
- ie.Title,
905
+ le.Title,
559
906
  {
560
907
  "data-slot": "sheet-title",
561
908
  className: v("text-foreground font-semibold", a),
@@ -563,9 +910,9 @@ function ma({ className: a, ...t }) {
563
910
  }
564
911
  );
565
912
  }
566
- function ha({ className: a, ...t }) {
913
+ function va({ className: a, ...t }) {
567
914
  return /* @__PURE__ */ e(
568
- ie.Description,
915
+ le.Description,
569
916
  {
570
917
  "data-slot": "sheet-description",
571
918
  className: v("text-muted-foreground text-sm", a),
@@ -573,109 +920,109 @@ function ha({ className: a, ...t }) {
573
920
  }
574
921
  );
575
922
  }
576
- const pa = "sidebar_state", ga = 3600 * 24 * 7, fa = "19rem", ba = "18rem", xa = "3rem", va = "b", We = ne.createContext(null);
577
- function fe() {
578
- const a = ne.useContext(We);
923
+ const xa = "sidebar_state", wa = 3600 * 24 * 7, Na = "19rem", ka = "18rem", Sa = "3rem", Ca = "b", Xe = se.createContext(null);
924
+ function ve() {
925
+ const a = se.useContext(Xe);
579
926
  if (!a)
580
927
  throw new Error("useSidebar must be used within a SidebarProvider.");
581
928
  return a;
582
929
  }
583
- function ya({
930
+ function _a({
584
931
  defaultOpen: a = !0,
585
932
  open: t,
586
- onOpenChange: i,
587
- className: m,
588
- style: c,
589
- children: u,
590
- ...g
933
+ onOpenChange: d,
934
+ className: o,
935
+ style: n,
936
+ children: i,
937
+ ...r
591
938
  }) {
592
- const f = it(), [h, N] = ne.useState(!1), [y, C] = ne.useState(a), s = t ?? y, M = ne.useCallback(
593
- (A) => {
594
- const p = typeof A == "function" ? A(s) : A;
595
- i ? i(p) : C(p), document.cookie = `${pa}=${p}; path=/; max-age=${ga}`;
939
+ const u = dt(), [c, y] = se.useState(!1), [k, g] = se.useState(a), p = t ?? k, A = se.useCallback(
940
+ (R) => {
941
+ const D = typeof R == "function" ? R(p) : R;
942
+ d ? d(D) : g(D), document.cookie = `${xa}=${D}; path=/; max-age=${wa}`;
596
943
  },
597
- [i, s]
598
- ), P = ne.useCallback(() => {
599
- f ? N((A) => !A) : M((A) => !A);
600
- }, [f, M, N]);
601
- ne.useEffect(() => {
602
- const A = (p) => {
603
- p.key === va && (p.metaKey || p.ctrlKey) && (p.preventDefault(), P());
944
+ [d, p]
945
+ ), P = se.useCallback(() => {
946
+ u ? y((R) => !R) : A((R) => !R);
947
+ }, [u, A, y]);
948
+ se.useEffect(() => {
949
+ const R = (D) => {
950
+ D.key === Ca && (D.metaKey || D.ctrlKey) && (D.preventDefault(), P());
604
951
  };
605
- return window.addEventListener("keydown", A), () => {
606
- window.removeEventListener("keydown", A);
952
+ return window.addEventListener("keydown", R), () => {
953
+ window.removeEventListener("keydown", R);
607
954
  };
608
955
  }, [P]);
609
- const U = s ? "expanded" : "collapsed", q = ne.useMemo(
956
+ const I = p ? "expanded" : "collapsed", E = se.useMemo(
610
957
  () => ({
611
- state: U,
612
- open: s,
613
- setOpen: M,
614
- isMobile: f,
615
- openMobile: h,
616
- setOpenMobile: N,
958
+ state: I,
959
+ open: p,
960
+ setOpen: A,
961
+ isMobile: u,
962
+ openMobile: c,
963
+ setOpenMobile: y,
617
964
  toggleSidebar: P
618
965
  }),
619
- [U, s, M, f, h, N, P]
966
+ [I, p, A, u, c, y, P]
620
967
  );
621
- return /* @__PURE__ */ e(We.Provider, { value: q, children: /* @__PURE__ */ e($e, { delayDuration: 0, children: /* @__PURE__ */ e(
968
+ return /* @__PURE__ */ e(Xe.Provider, { value: E, children: /* @__PURE__ */ e(Ue, { delayDuration: 0, children: /* @__PURE__ */ e(
622
969
  "div",
623
970
  {
624
971
  "data-slot": "sidebar-wrapper",
625
972
  style: {
626
- "--sidebar-width": fa,
627
- "--sidebar-width-icon": xa,
628
- ...c
973
+ "--sidebar-width": Na,
974
+ "--sidebar-width-icon": Sa,
975
+ ...n
629
976
  },
630
- className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", m),
631
- ...g,
632
- children: u
977
+ className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", o),
978
+ ...r,
979
+ children: i
633
980
  }
634
981
  ) }) });
635
982
  }
636
- function wa({
983
+ function Ta({
637
984
  side: a = "left",
638
985
  variant: t = "sidebar",
639
- collapsible: i = "offcanvas",
640
- className: m,
641
- children: c,
642
- ...u
986
+ collapsible: d = "offcanvas",
987
+ className: o,
988
+ children: n,
989
+ ...i
643
990
  }) {
644
- const { isMobile: g, state: f, openMobile: h, setOpenMobile: N } = fe();
645
- return i === "none" ? /* @__PURE__ */ e(
991
+ const { isMobile: r, state: u, openMobile: c, setOpenMobile: y } = ve();
992
+ return d === "none" ? /* @__PURE__ */ e(
646
993
  "div",
647
994
  {
648
995
  "data-slot": "sidebar",
649
- className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", m),
650
- ...u,
651
- children: c
996
+ className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", o),
997
+ ...i,
998
+ children: n
652
999
  }
653
- ) : g ? /* @__PURE__ */ e(ia, { open: h, onOpenChange: N, ...u, children: /* @__PURE__ */ r(
654
- da,
1000
+ ) : r ? /* @__PURE__ */ e(pa, { open: c, onOpenChange: y, ...i, children: /* @__PURE__ */ s(
1001
+ fa,
655
1002
  {
656
- onOpenAutoFocus: (y) => y.preventDefault(),
1003
+ onOpenAutoFocus: (k) => k.preventDefault(),
657
1004
  "data-sidebar": "sidebar",
658
1005
  "data-slot": "sidebar",
659
1006
  "data-mobile": "true",
660
1007
  className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
661
1008
  style: {
662
- "--sidebar-width": ba
1009
+ "--sidebar-width": ka
663
1010
  },
664
1011
  side: a,
665
1012
  children: [
666
- /* @__PURE__ */ r(ua, { className: "sr-only", children: [
667
- /* @__PURE__ */ e(ma, { children: "Sidebar" }),
668
- /* @__PURE__ */ e(ha, { children: "Displays the mobile sidebar." })
1013
+ /* @__PURE__ */ s(ba, { className: "sr-only", children: [
1014
+ /* @__PURE__ */ e(ya, { children: "Sidebar" }),
1015
+ /* @__PURE__ */ e(va, { children: "Displays the mobile sidebar." })
669
1016
  ] }),
670
- /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: c })
1017
+ /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: n })
671
1018
  ]
672
1019
  }
673
- ) }) : /* @__PURE__ */ r(
1020
+ ) }) : /* @__PURE__ */ s(
674
1021
  "div",
675
1022
  {
676
1023
  className: "group peer text-sidebar-foreground hidden md:block",
677
- "data-state": f,
678
- "data-collapsible": f === "collapsed" ? i : "",
1024
+ "data-state": u,
1025
+ "data-collapsible": u === "collapsed" ? d : "",
679
1026
  "data-variant": t,
680
1027
  "data-side": a,
681
1028
  "data-slot": "sidebar",
@@ -701,16 +1048,16 @@ function wa({
701
1048
  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)]",
702
1049
  // Adjust the padding for floating and inset variants.
703
1050
  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",
704
- m
1051
+ o
705
1052
  ),
706
- ...u,
1053
+ ...i,
707
1054
  children: /* @__PURE__ */ e(
708
1055
  "div",
709
1056
  {
710
1057
  "data-sidebar": "sidebar",
711
1058
  "data-slot": "sidebar-inner",
712
1059
  className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",
713
- children: c
1060
+ children: n
714
1061
  }
715
1062
  )
716
1063
  }
@@ -719,28 +1066,28 @@ function wa({
719
1066
  }
720
1067
  );
721
1068
  }
722
- function Na({ className: a, onClick: t, ...i }) {
723
- const { toggleSidebar: m } = fe();
724
- return /* @__PURE__ */ r(
725
- te,
1069
+ function Pa({ className: a, onClick: t, ...d }) {
1070
+ const { toggleSidebar: o } = ve();
1071
+ return /* @__PURE__ */ s(
1072
+ ae,
726
1073
  {
727
1074
  "data-sidebar": "trigger",
728
1075
  "data-slot": "sidebar-trigger",
729
1076
  variant: "ghost",
730
1077
  size: "icon",
731
1078
  className: v("size-7", a),
732
- onClick: (c) => {
733
- t?.(c), m();
1079
+ onClick: (n) => {
1080
+ t?.(n), o();
734
1081
  },
735
- ...i,
1082
+ ...d,
736
1083
  children: [
737
- /* @__PURE__ */ e(St, {}),
1084
+ /* @__PURE__ */ e(Et, {}),
738
1085
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle Sidebar" })
739
1086
  ]
740
1087
  }
741
1088
  );
742
1089
  }
743
- function ka({ className: a, ...t }) {
1090
+ function Ea({ className: a, ...t }) {
744
1091
  return /* @__PURE__ */ e(
745
1092
  "div",
746
1093
  {
@@ -751,7 +1098,7 @@ function ka({ className: a, ...t }) {
751
1098
  }
752
1099
  );
753
1100
  }
754
- function _a({ className: a, ...t }) {
1101
+ function Ma({ className: a, ...t }) {
755
1102
  return /* @__PURE__ */ e(
756
1103
  "div",
757
1104
  {
@@ -765,7 +1112,7 @@ function _a({ className: a, ...t }) {
765
1112
  }
766
1113
  );
767
1114
  }
768
- function Ca({ className: a, ...t }) {
1115
+ function Aa({ className: a, ...t }) {
769
1116
  return /* @__PURE__ */ e(
770
1117
  "div",
771
1118
  {
@@ -776,7 +1123,7 @@ function Ca({ className: a, ...t }) {
776
1123
  }
777
1124
  );
778
1125
  }
779
- function Ae({ className: a, ...t }) {
1126
+ function De({ className: a, ...t }) {
780
1127
  return /* @__PURE__ */ e(
781
1128
  "div",
782
1129
  {
@@ -787,7 +1134,7 @@ function Ae({ className: a, ...t }) {
787
1134
  }
788
1135
  );
789
1136
  }
790
- function Ee({ className: a, ...t }) {
1137
+ function $e({ className: a, ...t }) {
791
1138
  return /* @__PURE__ */ e(
792
1139
  "ul",
793
1140
  {
@@ -809,7 +1156,7 @@ function Le({ className: a, ...t }) {
809
1156
  }
810
1157
  );
811
1158
  }
812
- const Sa = ta(
1159
+ const Ia = na(
813
1160
  "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
814
1161
  {
815
1162
  variants: {
@@ -829,476 +1176,636 @@ const Sa = ta(
829
1176
  }
830
1177
  }
831
1178
  );
832
- function Re({
1179
+ function Fe({
833
1180
  asChild: a = !1,
834
1181
  isActive: t = !1,
835
- variant: i = "default",
836
- size: m = "default",
837
- tooltip: c,
838
- className: u,
839
- ...g
1182
+ variant: d = "default",
1183
+ size: o = "default",
1184
+ tooltip: n,
1185
+ className: i,
1186
+ ...r
840
1187
  }) {
841
- const f = a ? ea : "button", { isMobile: h, state: N } = fe(), y = /* @__PURE__ */ e(
842
- f,
1188
+ const u = a ? ra : "button", { isMobile: c, state: y } = ve(), k = /* @__PURE__ */ e(
1189
+ u,
843
1190
  {
844
1191
  "data-slot": "sidebar-menu-button",
845
1192
  "data-sidebar": "menu-button",
846
- "data-size": m,
1193
+ "data-size": o,
847
1194
  "data-active": t,
848
- className: v(Sa({ variant: i, size: m }), u),
849
- ...g
1195
+ className: v(Ia({ variant: d, size: o }), i),
1196
+ ...r
850
1197
  }
851
1198
  );
852
- return c ? (typeof c == "string" && (c = {
853
- children: c
854
- }), /* @__PURE__ */ r(Ue, { children: [
855
- /* @__PURE__ */ e(Be, { asChild: !0, children: y }),
856
- /* @__PURE__ */ e(Ke, { side: "right", align: "center", hidden: N !== "collapsed" || h, ...c })
857
- ] })) : y;
1199
+ return n ? (typeof n == "string" && (n = {
1200
+ children: n
1201
+ }), /* @__PURE__ */ s(Be, { children: [
1202
+ /* @__PURE__ */ e(Ke, { asChild: !0, children: k }),
1203
+ /* @__PURE__ */ e(Qe, { side: "right", align: "center", hidden: y !== "collapsed" || c, ...n })
1204
+ ] })) : k;
858
1205
  }
859
- function Pa({ trigger: a }) {
860
- const { t, i18n: i } = de(["settings", "translation"]), { app: m, settings: c } = re(), u = ue(), { theme: g, setTheme: f, accent: h, setAccent: N, radius: y, setRadius: C } = Qe(), [s, M] = T(null), [P, U] = T(!1), q = ae(null), A = O(() => [
861
- { id: "general", label: t("sections.general", "General"), icon: Me },
862
- { id: "profile", label: t("sections.profile", "Profile"), icon: Pt },
863
- { id: "account", label: t("sections.account", "Account"), icon: Tt }
864
- ].filter((o) => {
865
- const _ = c?.sections?.[o.id];
866
- return (_?.mode ?? (_?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
867
- }), [t, c]), [p, Q] = T(A[0]?.id || "general"), x = J((l, o, _ = "editable") => {
868
- const oe = c?.sections?.[l]?.fields;
869
- return oe && oe[o] || _;
870
- }, [c]), [B, W] = T(""), [K, E] = T(""), [V, R] = T(""), [L, H] = T(""), F = O(() => m?.userMetadataFields?.filter((l) => l.showInProfile) || [], [m?.userMetadataFields]), [b, d] = T({}), [n, k] = T(!1), I = i.language === "fa", j = I ? "text-right" : "text-left", S = J(async () => {
1206
+ function Ra({ trigger: a }) {
1207
+ const { t, i18n: d } = ue(["settings", "translation"]), { app: o, settings: n } = ne(), i = oe(), r = he(), { theme: u, setTheme: c, accent: y, setAccent: k, radius: g, setRadius: p } = Ve(), [A, P] = _(null), [I, E] = _(!1), R = re(null), D = Q(() => [
1208
+ { id: "general", label: t("sections.general", "General"), icon: Ae },
1209
+ { id: "profile", label: t("sections.profile", "Profile"), icon: Mt },
1210
+ { id: "account", label: t("sections.account", "Account"), icon: At }
1211
+ ].filter((h) => {
1212
+ const N = n?.sections?.[h.id];
1213
+ return (N?.mode ?? (N?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
1214
+ }), [t, n]), [T, q] = _(D[0]?.id || "general"), x = ee(
1215
+ (l, h, N = "editable") => {
1216
+ const ie = n?.sections?.[l]?.fields;
1217
+ return ie && ie[h] || N;
1218
+ },
1219
+ [n]
1220
+ ), [V, K] = _(""), [M, $] = _(""), [G, F] = _(""), [J, W] = _(""), j = Q(
1221
+ () => o?.userMetadataFields?.filter((l) => l.showInProfile) || [],
1222
+ [o?.userMetadataFields]
1223
+ ), [L, w] = _({}), [m, C] = _(!1), f = d.language === "fa", O = f ? "text-right" : "text-left", S = ee(async () => {
871
1224
  try {
872
- const l = await D.getMe();
873
- M(l), W(l.name || ""), E(l.surname || ""), R(l.phone || "");
874
- const o = {};
875
- F.forEach((_) => {
876
- o[_.key] = l.metadata?.[_.key] ?? _.defaultValue ?? "";
877
- }), d(o);
1225
+ const l = await i.getMe();
1226
+ P(l), K(l.name || ""), $(l.surname || ""), F(l.phone || "");
1227
+ const h = {};
1228
+ j.forEach((N) => {
1229
+ h[N.key] = l.metadata?.[N.key] ?? N.defaultValue ?? "";
1230
+ }), w(h);
878
1231
  } catch (l) {
879
- console.error("Failed to fetch user:", l), ee.error(ce(l, t));
1232
+ console.error("Failed to fetch user:", l), te.error(de(l, t));
880
1233
  }
881
- }, [t, F]);
882
- $(() => {
883
- if (!P) {
884
- q.current = null;
1234
+ }, [t, j, i]);
1235
+ B(() => {
1236
+ if (!I) {
1237
+ R.current = null;
885
1238
  return;
886
1239
  }
887
- (q.current === null || p === "account") && S(), q.current = p;
888
- }, [P, p, S]), $(() => {
889
- const l = { ...b };
890
- let o = !1;
891
- F.forEach((_) => {
892
- _.condition && !ge(_.condition, b) && l[_.key] !== void 0 && (delete l[_.key], o = !0);
893
- }), o && d(l);
894
- }, [b, F]);
895
- const w = async () => {
896
- k(!0);
1240
+ (R.current === null || T === "account") && S(), R.current = T;
1241
+ }, [I, T, S]), B(() => {
1242
+ const l = { ...L };
1243
+ let h = !1;
1244
+ j.forEach((N) => {
1245
+ N.condition && !ye(N.condition, L) && l[N.key] !== void 0 && (delete l[N.key], h = !0);
1246
+ }), h && w(l);
1247
+ }, [L, j]);
1248
+ const Z = async () => {
1249
+ C(!0);
897
1250
  try {
898
- const l = { name: B, surname: K, phone: V, metadata: b };
899
- L && (l.password = L);
900
- const o = await D.updateMe(l);
901
- u.setQueryData(
902
- ct(m?.cacheNamespace || "gentiq"),
903
- o
904
- ), ee.success(t("profile.success", "Profile updated successfully")), H(""), S();
1251
+ const l = { name: V, surname: M, phone: G, metadata: L };
1252
+ J && (l.password = J);
1253
+ const h = await i.updateMe(l);
1254
+ r.setQueryData(ht(o?.cacheNamespace || "gentiq"), h), te.success(t("profile.success", "Profile updated successfully")), W(""), S();
905
1255
  } catch (l) {
906
- ee.error(ce(l, t));
1256
+ te.error(de(l, t));
907
1257
  } finally {
908
- k(!1);
1258
+ C(!1);
909
1259
  }
910
- }, z = () => {
911
- window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (D.clearToken(), window.location.reload());
912
- }, Y = (l) => {
913
- i.changeLanguage(l);
914
- }, Z = s?.balance ? Math.max(0, Math.min(100, s.balance.tokens / (s.balance.token_limit || 1) * 100)) : 0, se = s?.balance ? Math.max(0, Math.min(100, s.balance.requests / (s.balance.request_limit || 1) * 100)) : 0;
915
- return /* @__PURE__ */ r(He, { open: P, onOpenChange: U, children: [
916
- /* @__PURE__ */ e(lt, { asChild: !0, children: a || /* @__PURE__ */ e(te, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5" }) }) }),
1260
+ }, H = () => {
1261
+ window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (i.clearToken(), window.location.reload());
1262
+ }, z = (l) => {
1263
+ d.changeLanguage(l);
1264
+ }, U = A?.balance ? Math.max(0, Math.min(100, A.balance.tokens / (A.balance.token_limit || 1) * 100)) : 0, b = A?.balance ? Math.max(0, Math.min(100, A.balance.requests / (A.balance.request_limit || 1) * 100)) : 0;
1265
+ return /* @__PURE__ */ s(Ge, { open: I, onOpenChange: E, children: [
1266
+ /* @__PURE__ */ e(ut, { asChild: !0, children: a || /* @__PURE__ */ e(ae, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ce, { className: "h-5 w-5" }) }) }),
917
1267
  /* @__PURE__ */ e(
918
- Ve,
1268
+ We,
919
1269
  {
920
- dir: I ? "rtl" : "ltr",
1270
+ dir: f ? "rtl" : "ltr",
921
1271
  className: v(
922
1272
  "w-full sm:w-[95vw] sm:max-w-[700px] p-0 gap-0 overflow-hidden rounded-t-2xl sm:rounded-3xl border-none shadow-2xl bg-background/95 backdrop-blur-md h-[90vh] sm:h-[750px]",
923
- I && "rtl"
1273
+ f && "rtl"
924
1274
  ),
925
- children: /* @__PURE__ */ r("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
926
- /* @__PURE__ */ r("div", { className: "w-full bg-muted/20 sm:bg-muted/30 border-b border-border/40 pt-12 sm:pt-6 flex flex-col shrink-0", children: [
927
- /* @__PURE__ */ e("div", { className: "flex items-center justify-between px-4 sm:px-6 mb-2 sm:mb-4", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
928
- /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5 text-primary" }) }),
1275
+ children: /* @__PURE__ */ s("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
1276
+ /* @__PURE__ */ s("div", { className: "w-full bg-muted/20 sm:bg-muted/30 border-b border-border/40 pt-12 sm:pt-6 flex flex-col shrink-0", children: [
1277
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-between px-4 sm:px-6 mb-2 sm:mb-4", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
1278
+ /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Ce, { className: "h-5 w-5 text-primary" }) }),
929
1279
  /* @__PURE__ */ e("span", { className: "font-bold text-lg", children: t("title", "Settings") })
930
1280
  ] }) }),
931
- /* @__PURE__ */ e("div", { className: "w-full overflow-x-auto no-scrollbar pt-2 px-2 sm:px-4", children: /* @__PURE__ */ e("nav", { className: "flex items-center gap-2 sm:gap-6 w-max", children: A.map((l) => /* @__PURE__ */ r(
1281
+ /* @__PURE__ */ e("div", { className: "w-full overflow-x-auto no-scrollbar pt-2 px-2 sm:px-4", children: /* @__PURE__ */ e("nav", { className: "flex items-center gap-2 sm:gap-6 w-max", children: D.map((l) => /* @__PURE__ */ s(
932
1282
  "button",
933
1283
  {
934
- onClick: () => Q(l.id),
1284
+ onClick: () => q(l.id),
935
1285
  className: v(
936
1286
  "flex items-center gap-1.5 sm:gap-2 pb-2 sm:pb-3 pt-1 px-2 sm:px-1 text-sm sm:text-base font-medium transition-all border-b-2 whitespace-nowrap shrink-0",
937
- p === l.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
938
- c?.sections?.[l.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
1287
+ T === l.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
1288
+ n?.sections?.[l.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
939
1289
  ),
940
1290
  children: [
941
- /* @__PURE__ */ e(l.icon, { className: v(
942
- "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
943
- p === l.id && "scale-110"
944
- ) }),
1291
+ /* @__PURE__ */ e(
1292
+ l.icon,
1293
+ {
1294
+ className: v(
1295
+ "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
1296
+ T === l.id && "scale-110"
1297
+ )
1298
+ }
1299
+ ),
945
1300
  l.label
946
1301
  ]
947
1302
  },
948
1303
  l.id
949
1304
  )) }) })
950
1305
  ] }),
951
- /* @__PURE__ */ e("div", { className: "flex-1 relative min-h-0 h-full bg-background", children: /* @__PURE__ */ r("div", { className: "absolute inset-0 overflow-y-auto p-5 sm:p-8 pt-12 sm:pt-12 custom-scrollbar", children: [
952
- p === "profile" && /* @__PURE__ */ r("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
953
- /* @__PURE__ */ r("div", { children: [
1306
+ /* @__PURE__ */ e("div", { className: "flex-1 relative min-h-0 h-full bg-background", children: /* @__PURE__ */ s("div", { className: "absolute inset-0 overflow-y-auto p-5 sm:p-8 pt-12 sm:pt-12 custom-scrollbar", children: [
1307
+ T === "profile" && /* @__PURE__ */ s("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1308
+ /* @__PURE__ */ s("div", { children: [
954
1309
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("profile.title", "Profile Information") }),
955
1310
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("profile.subtitle", "Update your personal details below.") })
956
1311
  ] }),
957
- /* @__PURE__ */ r("div", { className: "grid gap-6", children: [
958
- /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
959
- x("profile", "name") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
960
- /* @__PURE__ */ e(G, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
961
- /* @__PURE__ */ e(
962
- X,
963
- {
964
- id: "name",
965
- value: B,
966
- onChange: (l) => W(l.target.value),
967
- disabled: x("profile", "name") === "faded",
968
- className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", j)
969
- }
970
- )
971
- ] }),
972
- x("profile", "surname") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
973
- /* @__PURE__ */ e(G, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
974
- /* @__PURE__ */ e(
975
- X,
976
- {
977
- id: "surname",
978
- value: K,
979
- onChange: (l) => E(l.target.value),
980
- disabled: x("profile", "surname") === "faded",
981
- className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", j)
982
- }
983
- )
984
- ] })
985
- ] }),
986
- x("profile", "phone") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
987
- /* @__PURE__ */ e(G, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
988
- /* @__PURE__ */ r("div", { className: "relative", children: [
989
- /* @__PURE__ */ e(Mt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
990
- /* @__PURE__ */ e(
991
- X,
992
- {
993
- id: "phone",
994
- value: V,
995
- onChange: (l) => R(l.target.value),
996
- disabled: x("profile", "phone") === "faded",
997
- className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
998
- dir: "ltr"
999
- }
1000
- )
1001
- ] })
1002
- ] }),
1003
- x("profile", "password") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1004
- /* @__PURE__ */ e(G, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
1005
- /* @__PURE__ */ r("div", { className: "relative", children: [
1006
- /* @__PURE__ */ e(It, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1007
- /* @__PURE__ */ e(
1008
- X,
1009
- {
1010
- id: "pass",
1011
- type: "password",
1012
- value: L,
1013
- onChange: (l) => H(l.target.value),
1014
- disabled: x("profile", "password") === "faded",
1015
- placeholder: t("profile.password_placeholder", "Leave empty to keep current"),
1016
- className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
1017
- dir: "ltr"
1018
- }
1019
- )
1020
- ] })
1312
+ /* @__PURE__ */ s("div", { className: "grid gap-6", children: [
1313
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
1314
+ x("profile", "name") !== "hidden" && /* @__PURE__ */ s(
1315
+ "div",
1316
+ {
1317
+ className: v(
1318
+ "flex flex-col gap-3",
1319
+ x("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"
1320
+ ),
1321
+ children: [
1322
+ /* @__PURE__ */ e(X, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
1323
+ /* @__PURE__ */ e(
1324
+ Y,
1325
+ {
1326
+ id: "name",
1327
+ value: V,
1328
+ onChange: (l) => K(l.target.value),
1329
+ disabled: x("profile", "name") === "faded",
1330
+ className: v(
1331
+ "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1332
+ O
1333
+ )
1334
+ }
1335
+ )
1336
+ ]
1337
+ }
1338
+ ),
1339
+ x("profile", "surname") !== "hidden" && /* @__PURE__ */ s(
1340
+ "div",
1341
+ {
1342
+ className: v(
1343
+ "flex flex-col gap-3",
1344
+ x("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"
1345
+ ),
1346
+ children: [
1347
+ /* @__PURE__ */ e(X, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
1348
+ /* @__PURE__ */ e(
1349
+ Y,
1350
+ {
1351
+ id: "surname",
1352
+ value: M,
1353
+ onChange: (l) => $(l.target.value),
1354
+ disabled: x("profile", "surname") === "faded",
1355
+ className: v(
1356
+ "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1357
+ O
1358
+ )
1359
+ }
1360
+ )
1361
+ ]
1362
+ }
1363
+ )
1021
1364
  ] }),
1022
- F.map((l) => {
1023
- const o = x("profile", l.key, l.mode || "editable");
1024
- return o === "hidden" || !ge(l.condition, b) ? null : /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200", o === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1025
- /* @__PURE__ */ e(G, { htmlFor: `profile-${l.key}`, className: "px-1", children: t(l.label) }),
1026
- l.type === "select" ? /* @__PURE__ */ r(
1027
- xe,
1028
- {
1029
- value: String(b[l.key] || ""),
1030
- onValueChange: (_) => d({ ...b, [l.key]: _ }),
1031
- disabled: o === "faded",
1032
- dir: I ? "rtl" : "ltr",
1033
- children: [
1034
- /* @__PURE__ */ e(ve, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(ye, { placeholder: t(l.placeholder || "profile.select_placeholder") }) }),
1035
- /* @__PURE__ */ e(we, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: l.options?.map((_) => /* @__PURE__ */ e(pe, { value: String(_.value), className: "rounded-lg focus:bg-primary/10", children: t(_.label) }, String(_.value))) })
1036
- ]
1037
- }
1038
- ) : l.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 px-1 py-1", children: [
1039
- /* @__PURE__ */ e(
1040
- "input",
1041
- {
1042
- id: `profile-${l.key}`,
1043
- type: "checkbox",
1044
- checked: !!b[l.key],
1045
- disabled: o === "faded",
1046
- onChange: (_) => d({ ...b, [l.key]: _.target.checked }),
1047
- className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
1048
- }
1365
+ x("profile", "phone") !== "hidden" && /* @__PURE__ */ s(
1366
+ "div",
1367
+ {
1368
+ className: v(
1369
+ "flex flex-col gap-3",
1370
+ x("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"
1371
+ ),
1372
+ children: [
1373
+ /* @__PURE__ */ e(X, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
1374
+ /* @__PURE__ */ s("div", { className: "relative", children: [
1375
+ /* @__PURE__ */ e(It, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1376
+ /* @__PURE__ */ e(
1377
+ Y,
1378
+ {
1379
+ id: "phone",
1380
+ value: G,
1381
+ onChange: (l) => F(l.target.value),
1382
+ disabled: x("profile", "phone") === "faded",
1383
+ className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
1384
+ dir: "ltr"
1385
+ }
1386
+ )
1387
+ ] })
1388
+ ]
1389
+ }
1390
+ ),
1391
+ x("profile", "password") !== "hidden" && /* @__PURE__ */ s(
1392
+ "div",
1393
+ {
1394
+ className: v(
1395
+ "flex flex-col gap-3",
1396
+ x("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"
1397
+ ),
1398
+ children: [
1399
+ /* @__PURE__ */ e(X, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
1400
+ /* @__PURE__ */ s("div", { className: "relative", children: [
1401
+ /* @__PURE__ */ e(Rt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1402
+ /* @__PURE__ */ e(
1403
+ Y,
1404
+ {
1405
+ id: "pass",
1406
+ type: "password",
1407
+ value: J,
1408
+ onChange: (l) => W(l.target.value),
1409
+ disabled: x("profile", "password") === "faded",
1410
+ placeholder: t(
1411
+ "profile.password_placeholder",
1412
+ "Leave empty to keep current"
1413
+ ),
1414
+ className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
1415
+ dir: "ltr"
1416
+ }
1417
+ )
1418
+ ] })
1419
+ ]
1420
+ }
1421
+ ),
1422
+ j.map((l) => {
1423
+ const h = x("profile", l.key, l.mode || "editable");
1424
+ return h === "hidden" || !ye(l.condition, L) ? null : /* @__PURE__ */ s(
1425
+ "div",
1426
+ {
1427
+ className: v(
1428
+ "flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200",
1429
+ h === "faded" && "opacity-50 pointer-events-none select-none"
1049
1430
  ),
1050
- /* @__PURE__ */ e(G, { htmlFor: `profile-${l.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(l.placeholder || l.label) })
1051
- ] }) : /* @__PURE__ */ e(
1052
- X,
1053
- {
1054
- id: `profile-${l.key}`,
1055
- type: l.type,
1056
- value: b[l.key] || "",
1057
- disabled: o === "faded",
1058
- onChange: (_) => d({ ...b, [l.key]: _.target.value }),
1059
- placeholder: t(l.placeholder || ""),
1060
- className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", j)
1061
- }
1062
- )
1063
- ] }, l.key);
1431
+ children: [
1432
+ /* @__PURE__ */ e(X, { htmlFor: `profile-${l.key}`, className: "px-1", children: t(l.label) }),
1433
+ l.type === "select" ? /* @__PURE__ */ s(
1434
+ we,
1435
+ {
1436
+ value: String(L[l.key] || ""),
1437
+ onValueChange: (N) => w({ ...L, [l.key]: N }),
1438
+ disabled: h === "faded",
1439
+ dir: f ? "rtl" : "ltr",
1440
+ children: [
1441
+ /* @__PURE__ */ e(Ne, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(
1442
+ ke,
1443
+ {
1444
+ placeholder: t(l.placeholder || "profile.select_placeholder")
1445
+ }
1446
+ ) }),
1447
+ /* @__PURE__ */ e(Se, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: l.options?.map((N) => /* @__PURE__ */ e(
1448
+ fe,
1449
+ {
1450
+ value: String(N.value),
1451
+ className: "rounded-lg focus:bg-primary/10",
1452
+ children: t(N.label)
1453
+ },
1454
+ String(N.value)
1455
+ )) })
1456
+ ]
1457
+ }
1458
+ ) : l.type === "checkbox" ? /* @__PURE__ */ s("div", { className: "flex items-center gap-3 px-1 py-1", children: [
1459
+ /* @__PURE__ */ e(
1460
+ "input",
1461
+ {
1462
+ id: `profile-${l.key}`,
1463
+ type: "checkbox",
1464
+ checked: !!L[l.key],
1465
+ disabled: h === "faded",
1466
+ onChange: (N) => w({ ...L, [l.key]: N.target.checked }),
1467
+ className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
1468
+ }
1469
+ ),
1470
+ /* @__PURE__ */ e(
1471
+ X,
1472
+ {
1473
+ htmlFor: `profile-${l.key}`,
1474
+ className: "text-sm font-medium text-muted-foreground cursor-pointer",
1475
+ children: t(l.placeholder || l.label)
1476
+ }
1477
+ )
1478
+ ] }) : /* @__PURE__ */ e(
1479
+ Y,
1480
+ {
1481
+ id: `profile-${l.key}`,
1482
+ type: l.type,
1483
+ value: L[l.key] || "",
1484
+ disabled: h === "faded",
1485
+ onChange: (N) => w({ ...L, [l.key]: N.target.value }),
1486
+ placeholder: t(l.placeholder || ""),
1487
+ className: v(
1488
+ "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1489
+ O
1490
+ )
1491
+ }
1492
+ )
1493
+ ]
1494
+ },
1495
+ l.key
1496
+ );
1064
1497
  }),
1065
- /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ r(
1066
- te,
1498
+ /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ s(
1499
+ ae,
1067
1500
  {
1068
- onClick: w,
1069
- disabled: n,
1501
+ onClick: Z,
1502
+ disabled: m,
1070
1503
  className: "w-full sm:w-auto px-8 rounded-xl gap-2 font-semibold shadow-lg shadow-primary/20 h-11 transition-all active:scale-[0.98]",
1071
1504
  children: [
1072
1505
  /* @__PURE__ */ e(Dt, { className: "h-4 w-4" }),
1073
- n ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1506
+ m ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1074
1507
  ]
1075
1508
  }
1076
1509
  ) })
1077
1510
  ] })
1078
1511
  ] }),
1079
- p === "general" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1080
- /* @__PURE__ */ r("div", { children: [
1512
+ T === "general" && /* @__PURE__ */ s("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1513
+ /* @__PURE__ */ s("div", { children: [
1081
1514
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("general.title", "General Settings") }),
1082
1515
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("general.subtitle", "Configure look and feel and language.") })
1083
1516
  ] }),
1084
- /* @__PURE__ */ r("div", { className: "space-y-8", children: [
1085
- x("general", "theme") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", x("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1086
- /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1087
- /* @__PURE__ */ e(Me, { className: "h-4 w-4 text-primary" }),
1088
- t("general.theme", "Theme")
1089
- ] }),
1090
- /* @__PURE__ */ r("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1091
- /* @__PURE__ */ r(
1092
- "button",
1093
- {
1094
- onClick: () => f("light"),
1095
- disabled: x("general", "theme") === "faded",
1096
- className: v(
1097
- "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1098
- g === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1099
- ),
1100
- children: [
1101
- /* @__PURE__ */ e(At, { className: "h-4 w-4" }),
1102
- /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.light", "Light") })
1103
- ]
1104
- }
1105
- ),
1106
- /* @__PURE__ */ r(
1107
- "button",
1108
- {
1109
- onClick: () => f("dark"),
1110
- disabled: x("general", "theme") === "faded",
1111
- className: v(
1112
- "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1113
- g === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1114
- ),
1115
- children: [
1116
- /* @__PURE__ */ e(Et, { className: "h-4 w-4" }),
1117
- /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.dark", "Dark") })
1118
- ]
1119
- }
1517
+ /* @__PURE__ */ s("div", { className: "space-y-8", children: [
1518
+ x("general", "theme") !== "hidden" && /* @__PURE__ */ s(
1519
+ "div",
1520
+ {
1521
+ className: v(
1522
+ "space-y-3",
1523
+ x("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"
1120
1524
  ),
1121
- /* @__PURE__ */ r(
1122
- "button",
1123
- {
1124
- onClick: () => f("system"),
1125
- disabled: x("general", "theme") === "faded",
1126
- className: v(
1127
- "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1128
- g === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1129
- ),
1130
- children: [
1131
- /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
1132
- /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.system", "System") })
1133
- ]
1134
- }
1135
- )
1136
- ] })
1137
- ] }),
1138
- x("general", "accent") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", x("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1139
- /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1140
- /* @__PURE__ */ e(Ie, { className: "h-4 w-4 text-primary" }),
1141
- t("general.accent", "Accent Color")
1142
- ] }),
1143
- /* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
1144
- "oklch(0.623 0.214 259.815)",
1145
- // Blue
1146
- "oklch(0.585 0.233 277.117)",
1147
- // Indigo
1148
- "oklch(0.627 0.265 303.9)",
1149
- // Purple
1150
- "oklch(0.645 0.246 16.439)",
1151
- // Rose
1152
- "oklch(0.712 0.194 46.666)",
1153
- // Orange
1154
- "oklch(0.627 0.194 149.214)",
1155
- // Green
1156
- "oklch(0.633 0.145 182.903)",
1157
- // Teal
1158
- "oklch(0.552 0.016 285.938)"
1159
- // Slate
1160
- ].map((l) => {
1161
- const o = (h || "oklch(0.623 0.214 259.815)") === l;
1162
- return /* @__PURE__ */ e(
1163
- "button",
1164
- {
1165
- onClick: () => N(l),
1166
- disabled: x("general", "accent") === "faded",
1167
- className: v(
1168
- "h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
1169
- o ? "border-foreground" : "border-transparent"
1525
+ children: [
1526
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1527
+ /* @__PURE__ */ e(Ae, { className: "h-4 w-4 text-primary" }),
1528
+ t("general.theme", "Theme")
1529
+ ] }),
1530
+ /* @__PURE__ */ s("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1531
+ /* @__PURE__ */ s(
1532
+ "button",
1533
+ {
1534
+ onClick: () => c("light"),
1535
+ disabled: x("general", "theme") === "faded",
1536
+ className: v(
1537
+ "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1538
+ u === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1539
+ ),
1540
+ children: [
1541
+ /* @__PURE__ */ e($t, { className: "h-4 w-4" }),
1542
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.light", "Light") })
1543
+ ]
1544
+ }
1170
1545
  ),
1171
- style: { backgroundColor: l }
1172
- },
1173
- l
1174
- );
1175
- }) })
1176
- ] }),
1177
- x("general", "radius") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", x("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1178
- /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1179
- /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
1180
- t("general.radius", "Rounded Corners")
1181
- ] }),
1182
- /* @__PURE__ */ e("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1183
- { id: "sharp", value: "0.3rem" },
1184
- { id: "round", value: "1.25rem" }
1185
- ].map((l) => {
1186
- const o = (y || "1.25rem") === l.value;
1187
- return /* @__PURE__ */ e(
1188
- "button",
1189
- {
1190
- onClick: () => C(l.value),
1191
- disabled: x("general", "radius") === "faded",
1192
- className: v(
1193
- "flex-1 py-2 rounded-xl transition-all text-sm font-medium",
1194
- o ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1546
+ /* @__PURE__ */ s(
1547
+ "button",
1548
+ {
1549
+ onClick: () => c("dark"),
1550
+ disabled: x("general", "theme") === "faded",
1551
+ className: v(
1552
+ "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1553
+ u === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1554
+ ),
1555
+ children: [
1556
+ /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
1557
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.dark", "Dark") })
1558
+ ]
1559
+ }
1195
1560
  ),
1196
- children: t(`general.radius_levels.${l.id}`)
1197
- },
1198
- l.id
1199
- );
1200
- }) })
1201
- ] }),
1202
- x("general", "language") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", x("general", "language") === "faded" && "opacity-50"), children: [
1203
- /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1204
- /* @__PURE__ */ e(Rt, { className: "h-4 w-4 text-primary" }),
1205
- t("general.language", "Language")
1206
- ] }),
1207
- /* @__PURE__ */ r(
1208
- xe,
1209
- {
1210
- value: i.language,
1211
- onValueChange: Y,
1212
- disabled: x("general", "language") === "faded",
1213
- dir: I ? "rtl" : "ltr",
1214
- children: [
1215
- /* @__PURE__ */ e(ve, { 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") }) }),
1216
- /* @__PURE__ */ r(we, { className: "rounded-2xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: [
1217
- /* @__PURE__ */ e(pe, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1218
- /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "EN" }),
1219
- t("general.languages.en", "English")
1220
- ] }) }),
1221
- /* @__PURE__ */ e(pe, { value: "fa", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1222
- /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "FA" }),
1223
- t("general.languages.fa", "Persian")
1224
- ] }) })
1225
- ] })
1226
- ]
1227
- }
1228
- )
1229
- ] })
1561
+ /* @__PURE__ */ s(
1562
+ "button",
1563
+ {
1564
+ onClick: () => c("system"),
1565
+ disabled: x("general", "theme") === "faded",
1566
+ className: v(
1567
+ "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1568
+ u === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1569
+ ),
1570
+ children: [
1571
+ /* @__PURE__ */ e(Ft, { className: "h-4 w-4" }),
1572
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.system", "System") })
1573
+ ]
1574
+ }
1575
+ )
1576
+ ] })
1577
+ ]
1578
+ }
1579
+ ),
1580
+ x("general", "accent") !== "hidden" && /* @__PURE__ */ s(
1581
+ "div",
1582
+ {
1583
+ className: v(
1584
+ "space-y-4",
1585
+ x("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"
1586
+ ),
1587
+ children: [
1588
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1589
+ /* @__PURE__ */ e(Ie, { className: "h-4 w-4 text-primary" }),
1590
+ t("general.accent", "Accent Color")
1591
+ ] }),
1592
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
1593
+ "oklch(0.623 0.214 259.815)",
1594
+ // Blue
1595
+ "oklch(0.585 0.233 277.117)",
1596
+ // Indigo
1597
+ "oklch(0.627 0.265 303.9)",
1598
+ // Purple
1599
+ "oklch(0.645 0.246 16.439)",
1600
+ // Rose
1601
+ "oklch(0.712 0.194 46.666)",
1602
+ // Orange
1603
+ "oklch(0.627 0.194 149.214)",
1604
+ // Green
1605
+ "oklch(0.633 0.145 182.903)",
1606
+ // Teal
1607
+ "oklch(0.552 0.016 285.938)"
1608
+ // Slate
1609
+ ].map((l) => {
1610
+ const h = (y || "oklch(0.623 0.214 259.815)") === l;
1611
+ return /* @__PURE__ */ e(
1612
+ "button",
1613
+ {
1614
+ onClick: () => k(l),
1615
+ disabled: x("general", "accent") === "faded",
1616
+ className: v(
1617
+ "h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
1618
+ h ? "border-foreground" : "border-transparent"
1619
+ ),
1620
+ style: { backgroundColor: l }
1621
+ },
1622
+ l
1623
+ );
1624
+ }) })
1625
+ ]
1626
+ }
1627
+ ),
1628
+ x("general", "radius") !== "hidden" && /* @__PURE__ */ s(
1629
+ "div",
1630
+ {
1631
+ className: v(
1632
+ "space-y-4",
1633
+ x("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"
1634
+ ),
1635
+ children: [
1636
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1637
+ /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
1638
+ t("general.radius", "Rounded Corners")
1639
+ ] }),
1640
+ /* @__PURE__ */ e("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1641
+ { id: "sharp", value: "0.3rem" },
1642
+ { id: "round", value: "1.25rem" }
1643
+ ].map((l) => {
1644
+ const h = (g || "1.25rem") === l.value;
1645
+ return /* @__PURE__ */ e(
1646
+ "button",
1647
+ {
1648
+ onClick: () => p(l.value),
1649
+ disabled: x("general", "radius") === "faded",
1650
+ className: v(
1651
+ "flex-1 py-2 rounded-xl transition-all text-sm font-medium",
1652
+ h ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1653
+ ),
1654
+ children: t(`general.radius_levels.${l.id}`)
1655
+ },
1656
+ l.id
1657
+ );
1658
+ }) })
1659
+ ]
1660
+ }
1661
+ ),
1662
+ x("general", "language") !== "hidden" && /* @__PURE__ */ s(
1663
+ "div",
1664
+ {
1665
+ className: v(
1666
+ "space-y-3",
1667
+ x("general", "language") === "faded" && "opacity-50"
1668
+ ),
1669
+ children: [
1670
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1671
+ /* @__PURE__ */ e(qt, { className: "h-4 w-4 text-primary" }),
1672
+ t("general.language", "Language")
1673
+ ] }),
1674
+ /* @__PURE__ */ s(
1675
+ we,
1676
+ {
1677
+ value: d.language,
1678
+ onValueChange: z,
1679
+ disabled: x("general", "language") === "faded",
1680
+ dir: f ? "rtl" : "ltr",
1681
+ children: [
1682
+ /* @__PURE__ */ e(Ne, { className: "w-full bg-muted/50 rounded-2xl border-border/40 h-11 focus:ring-primary/20", children: /* @__PURE__ */ e(
1683
+ ke,
1684
+ {
1685
+ placeholder: t("general.language_placeholder", "Select language")
1686
+ }
1687
+ ) }),
1688
+ /* @__PURE__ */ s(Se, { className: "rounded-2xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: [
1689
+ /* @__PURE__ */ e(fe, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
1690
+ /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "EN" }),
1691
+ t("general.languages.en", "English")
1692
+ ] }) }),
1693
+ /* @__PURE__ */ e(fe, { value: "fa", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
1694
+ /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "FA" }),
1695
+ t("general.languages.fa", "Persian")
1696
+ ] }) })
1697
+ ] })
1698
+ ]
1699
+ }
1700
+ )
1701
+ ]
1702
+ }
1703
+ )
1230
1704
  ] })
1231
1705
  ] }),
1232
- p === "account" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1233
- /* @__PURE__ */ r("div", { children: [
1706
+ T === "account" && /* @__PURE__ */ s("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1707
+ /* @__PURE__ */ s("div", { children: [
1234
1708
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("account.title", "Account & Usage") }),
1235
1709
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("account.subtitle", "Monitor your quotas and manage your session.") })
1236
1710
  ] }),
1237
- /* @__PURE__ */ r("div", { className: "space-y-6", children: [
1238
- x("account", "balance") !== "hidden" && /* @__PURE__ */ r("div", { className: v("p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6", x("account", "balance") === "faded" && "opacity-50"), children: [
1239
- /* @__PURE__ */ r(G, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1240
- /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1241
- t("account.balance", "Current Balance")
1242
- ] }),
1243
- /* @__PURE__ */ r("div", { className: "space-y-5", children: [
1244
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
1245
- /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1246
- /* @__PURE__ */ e("span", { className: "font-medium text-muted-foreground", children: t("account.tokens", "Tokens") }),
1247
- /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1248
- Z.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1249
- "%"
1250
- ] })
1711
+ /* @__PURE__ */ s("div", { className: "space-y-6", children: [
1712
+ x("account", "balance") !== "hidden" && /* @__PURE__ */ s(
1713
+ "div",
1714
+ {
1715
+ className: v(
1716
+ "p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6",
1717
+ x("account", "balance") === "faded" && "opacity-50"
1718
+ ),
1719
+ children: [
1720
+ /* @__PURE__ */ s(X, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1721
+ /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1722
+ t("account.balance", "Current Balance")
1251
1723
  ] }),
1252
- /* @__PURE__ */ e("div", { className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5", dir: "ltr", children: /* @__PURE__ */ e(
1253
- "div",
1254
- {
1255
- className: v(
1256
- "h-full rounded-full transition-all duration-1000 shadow-sm",
1257
- Z > 60 ? "bg-emerald-500 shadow-emerald-500/20" : Z > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1258
- ),
1259
- style: { width: `${Z}%` }
1260
- }
1261
- ) })
1262
- ] }),
1263
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
1264
- /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1265
- /* @__PURE__ */ r("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
1266
- /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
1267
- t("account.requests", "Requests")
1724
+ /* @__PURE__ */ s("div", { className: "space-y-5", children: [
1725
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
1726
+ /* @__PURE__ */ s("div", { className: "flex justify-between text-sm mb-1", children: [
1727
+ /* @__PURE__ */ e("span", { className: "font-medium text-muted-foreground", children: t("account.tokens", "Tokens") }),
1728
+ /* @__PURE__ */ s("span", { className: "font-bold text-primary", children: [
1729
+ U.toLocaleString(d.language, {
1730
+ maximumFractionDigits: 0
1731
+ }),
1732
+ "%"
1733
+ ] })
1734
+ ] }),
1735
+ /* @__PURE__ */ e(
1736
+ "div",
1737
+ {
1738
+ className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5",
1739
+ dir: "ltr",
1740
+ children: /* @__PURE__ */ e(
1741
+ "div",
1742
+ {
1743
+ className: v(
1744
+ "h-full rounded-full transition-all duration-1000 shadow-sm",
1745
+ U > 60 ? "bg-emerald-500 shadow-emerald-500/20" : U > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1746
+ ),
1747
+ style: { width: `${U}%` }
1748
+ }
1749
+ )
1750
+ }
1751
+ )
1268
1752
  ] }),
1269
- /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1270
- se.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1271
- "%"
1753
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
1754
+ /* @__PURE__ */ s("div", { className: "flex justify-between text-sm mb-1", children: [
1755
+ /* @__PURE__ */ s("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
1756
+ /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
1757
+ t("account.requests", "Requests")
1758
+ ] }),
1759
+ /* @__PURE__ */ s("span", { className: "font-bold text-primary", children: [
1760
+ b.toLocaleString(d.language, {
1761
+ maximumFractionDigits: 0
1762
+ }),
1763
+ "%"
1764
+ ] })
1765
+ ] }),
1766
+ /* @__PURE__ */ e(
1767
+ "div",
1768
+ {
1769
+ className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5",
1770
+ dir: "ltr",
1771
+ children: /* @__PURE__ */ e(
1772
+ "div",
1773
+ {
1774
+ className: v(
1775
+ "h-full rounded-full transition-all duration-1000 shadow-sm",
1776
+ b > 60 ? "bg-emerald-500 shadow-emerald-500/20" : b > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1777
+ ),
1778
+ style: { width: `${b}%` }
1779
+ }
1780
+ )
1781
+ }
1782
+ )
1272
1783
  ] })
1273
- ] }),
1274
- /* @__PURE__ */ e("div", { className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5", dir: "ltr", children: /* @__PURE__ */ e(
1275
- "div",
1276
- {
1277
- className: v(
1278
- "h-full rounded-full transition-all duration-1000 shadow-sm",
1279
- se > 60 ? "bg-emerald-500 shadow-emerald-500/20" : se > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1280
- ),
1281
- style: { width: `${se}%` }
1282
- }
1283
- ) })
1284
- ] })
1285
- ] })
1286
- ] }),
1287
- /* @__PURE__ */ r("div", { className: "pt-2 flex flex-col gap-3", children: [
1288
- s?.balance?.updated_at && x("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
1784
+ ] })
1785
+ ]
1786
+ }
1787
+ ),
1788
+ /* @__PURE__ */ s("div", { className: "pt-2 flex flex-col gap-3", children: [
1789
+ A?.balance?.updated_at && x("account", "balance") !== "hidden" && /* @__PURE__ */ s("p", { className: "text-xs text-muted-foreground px-1", children: [
1289
1790
  t("account.last_recharge", "Last balance update on"),
1290
- ": ",
1291
- new Date(s.balance?.updated_at || "").toLocaleDateString(i.language)
1791
+ ":",
1792
+ " ",
1793
+ new Date(A.balance?.updated_at || "").toLocaleDateString(
1794
+ d.language
1795
+ )
1292
1796
  ] }),
1293
- x("account", "logout") !== "hidden" && /* @__PURE__ */ r(
1294
- te,
1797
+ x("account", "logout") !== "hidden" && /* @__PURE__ */ s(
1798
+ ae,
1295
1799
  {
1296
1800
  variant: "destructive",
1297
- onClick: z,
1801
+ onClick: H,
1298
1802
  disabled: x("account", "logout") === "faded",
1299
- className: v("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]", x("account", "logout") === "faded" && "opacity-50 pointer-events-none"),
1803
+ className: v(
1804
+ "rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]",
1805
+ x("account", "logout") === "faded" && "opacity-50 pointer-events-none"
1806
+ ),
1300
1807
  children: [
1301
- /* @__PURE__ */ e(qt, { className: "h-4 w-4" }),
1808
+ /* @__PURE__ */ e(jt, { className: "h-4 w-4" }),
1302
1809
  t("account.logout", "Logout from Account")
1303
1810
  ]
1304
1811
  }
@@ -1307,62 +1814,64 @@ function Pa({ trigger: a }) {
1307
1814
  ] })
1308
1815
  ] })
1309
1816
  ] }) }),
1310
- m?.showVersionInSettings !== !1 && m?.version && x("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", x("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: [
1311
- "v",
1312
- m.version
1313
- ] }) }) })
1817
+ o?.showVersionInSettings !== !1 && o?.version && x("general", "version") !== "hidden" && /* @__PURE__ */ e(
1818
+ "div",
1819
+ {
1820
+ className: v(
1821
+ "shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80",
1822
+ x("general", "version", "faded") === "faded" && "opacity-70"
1823
+ ),
1824
+ children: /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground text-center", dir: "ltr", children: /* @__PURE__ */ s("span", { className: "font-mono text-foreground/75", children: [
1825
+ "v",
1826
+ o.version
1827
+ ] }) })
1828
+ }
1829
+ )
1314
1830
  ] })
1315
1831
  }
1316
1832
  )
1317
1833
  ] });
1318
1834
  }
1319
- function Xe({ hideActions: a = !1 }) {
1320
- const [, t] = Ce(), { t: i } = de(["sidebar", "chat"]), { history: m, app: c } = re(), { theme: u } = Qe(), g = !a && (m?.enabled ?? !0), [f, h] = T("light");
1321
- $(() => {
1322
- if (u === "system") {
1323
- const C = window.matchMedia("(prefers-color-scheme: dark)").matches;
1324
- h(C ? "dark" : "light");
1835
+ function Ye({ hideActions: a = !1 }) {
1836
+ const [, t] = Pe(), { t: d } = ue(["sidebar", "chat"]), { history: o, app: n } = ne(), { theme: i } = Ve(), r = !a && (o?.enabled ?? !0), [u, c] = _("light");
1837
+ B(() => {
1838
+ if (i === "system") {
1839
+ const g = window.matchMedia("(prefers-color-scheme: dark)").matches;
1840
+ c(g ? "dark" : "light");
1325
1841
  } else
1326
- h(u);
1327
- }, [u]);
1328
- const N = O(() => c?.logo ? typeof c.logo == "string" ? c.logo : f === "dark" ? c.logo.dark : c.logo.light : dt, [c?.logo, f]), y = c?.name || "Gentiq";
1329
- 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: [
1330
- /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: g && /* @__PURE__ */ e(Na, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1331
- /* @__PURE__ */ e("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2.5 select-none animate-in fade-in zoom-in-95 duration-500", children: /* @__PURE__ */ e(
1332
- "img",
1333
- {
1334
- src: N,
1335
- alt: y,
1336
- className: "size-8 object-contain"
1337
- }
1338
- ) }) }),
1339
- /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-w-[36px] md:min-w-[80px] justify-end", children: !a && /* @__PURE__ */ r(ke, { children: [
1340
- /* @__PURE__ */ r(Ue, { children: [
1341
- /* @__PURE__ */ e(Be, { asChild: !0, children: /* @__PURE__ */ e(
1842
+ c(i);
1843
+ }, [i]);
1844
+ const y = Q(() => n?.logo ? typeof n.logo == "string" ? n.logo : u === "dark" ? n.logo.dark : n.logo.light : pt, [n?.logo, u]), k = n?.name || "Gentiq";
1845
+ return /* @__PURE__ */ s("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: [
1846
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: r && /* @__PURE__ */ e(Pa, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1847
+ /* @__PURE__ */ e("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2.5 select-none animate-in fade-in zoom-in-95 duration-500", children: /* @__PURE__ */ e("img", { src: y, alt: k, className: "size-8 object-contain" }) }) }),
1848
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-w-[36px] md:min-w-[80px] justify-end", children: !a && /* @__PURE__ */ s(_e, { children: [
1849
+ /* @__PURE__ */ s(Be, { children: [
1850
+ /* @__PURE__ */ e(Ke, { asChild: !0, children: /* @__PURE__ */ e(
1342
1851
  "button",
1343
1852
  {
1344
1853
  type: "button",
1345
1854
  className: v(
1346
1855
  "flex items-center justify-center size-9 rounded-lg hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 text-muted-foreground hover:text-primary",
1347
- g && "md:hidden"
1856
+ r && "md:hidden"
1348
1857
  ),
1349
1858
  onClick: () => {
1350
1859
  t("/");
1351
1860
  },
1352
- children: /* @__PURE__ */ e(Ft, { className: "size-5" })
1861
+ children: /* @__PURE__ */ e(Ot, { className: "size-5" })
1353
1862
  }
1354
1863
  ) }),
1355
- /* @__PURE__ */ e(Ke, { side: "bottom", className: "text-xs", children: i("new_chat") })
1864
+ /* @__PURE__ */ e(Qe, { side: "bottom", className: "text-xs", children: d("new_chat") })
1356
1865
  ] }),
1357
- c?.showSettings !== !1 && /* @__PURE__ */ e(
1358
- Pa,
1866
+ n?.showSettings !== !1 && /* @__PURE__ */ e(
1867
+ Ra,
1359
1868
  {
1360
1869
  trigger: /* @__PURE__ */ e(
1361
1870
  "button",
1362
1871
  {
1363
1872
  type: "button",
1364
1873
  className: "flex items-center justify-center size-9 rounded-lg hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 text-muted-foreground hover:text-primary",
1365
- children: /* @__PURE__ */ e(Ne, { className: "size-5" })
1874
+ children: /* @__PURE__ */ e(Ce, { className: "size-5" })
1366
1875
  }
1367
1876
  )
1368
1877
  }
@@ -1370,275 +1879,342 @@ function Xe({ hideActions: a = !1 }) {
1370
1879
  ] }) })
1371
1880
  ] });
1372
1881
  }
1373
- const ze = 20;
1374
- function Ta() {
1375
- const t = D.getConfig().app?.cacheNamespace || "gentiq";
1376
- return at({
1377
- queryKey: [t, "conversations"],
1378
- queryFn: async ({ pageParam: i = 0 }) => {
1379
- const m = await D.getHistory(i, ze);
1882
+ const qe = 20;
1883
+ function Da() {
1884
+ const a = oe(), d = a.getConfig().app?.cacheNamespace || "gentiq";
1885
+ return nt({
1886
+ queryKey: [d, "conversations"],
1887
+ queryFn: async ({ pageParam: o = 0 }) => {
1888
+ const n = await a.getHistory(o, qe);
1380
1889
  return {
1381
- threads: m.threads.map((c) => ({
1382
- id: `/${c.id}`,
1383
- firstMessage: c.title || c.firstMessage || "Chat",
1384
- timestamp: new Date(c.created_at).getTime(),
1385
- pinned: !!c.pinned
1890
+ threads: n.threads.map((i) => ({
1891
+ id: `/${i.id}`,
1892
+ firstMessage: i.title || i.firstMessage || "Chat",
1893
+ timestamp: new Date(i.created_at).getTime(),
1894
+ pinned: !!i.pinned
1386
1895
  })),
1387
- nextSkip: i + ze,
1388
- hasMore: i + m.threads.length < (m.total_count ?? 0)
1896
+ nextSkip: o + qe,
1897
+ hasMore: o + n.threads.length < (n.total_count ?? 0)
1389
1898
  };
1390
1899
  },
1391
1900
  initialPageParam: 0,
1392
- getNextPageParam: (i) => i.hasMore ? i.nextSkip : void 0,
1901
+ getNextPageParam: (o) => o.hasMore ? o.nextSkip : void 0,
1393
1902
  staleTime: 1e3 * 60 * 5
1394
1903
  // 5 minutes
1395
1904
  });
1396
1905
  }
1397
- async function Ma(a, t, i, m) {
1398
- const u = D.getConfig().app?.cacheNamespace || "gentiq";
1906
+ async function $a(a, t, d, o, n) {
1907
+ const r = a.getConfig().app?.cacheNamespace || "gentiq";
1399
1908
  try {
1400
- await D.deleteThread(a), t.invalidateQueries({ queryKey: [u, "conversations"] }), m === a && i("/");
1401
- } catch (g) {
1402
- console.error("Failed to delete conversation:", g), ee.error("Failed to delete conversation");
1909
+ await a.deleteThread(t), d.invalidateQueries({ queryKey: [r, "conversations"] }), n === t && o("/");
1910
+ } catch (u) {
1911
+ console.error("Failed to delete conversation:", u), te.error("Failed to delete conversation");
1403
1912
  }
1404
1913
  }
1405
- function Ia({ side: a = "left" }) {
1406
- const { t, i18n: i } = de(["sidebar", "translation"]), { setOpenMobile: m, isMobile: c } = fe(), {
1407
- data: u,
1408
- fetchNextPage: g,
1409
- hasNextPage: f,
1410
- isFetchingNextPage: h,
1411
- isLoading: N
1412
- } = Ta(), { history: y, app: C } = re(), s = C?.basePath || "/", M = y?.enabled ?? !1, P = u?.pages.flatMap((o) => o.threads) ?? [], [U, q] = Ce(), A = ue(), p = ae(null), Q = J(
1413
- (o) => {
1414
- p.current && (p.current.disconnect(), p.current = null), o && f && !h && (p.current = new IntersectionObserver(
1415
- (_) => {
1416
- _[0].isIntersecting && g();
1914
+ function La({ side: a = "left" }) {
1915
+ const { t, i18n: d } = ue(["sidebar", "translation"]), { setOpenMobile: o, isMobile: n } = ve(), { data: i, fetchNextPage: r, hasNextPage: u, isFetchingNextPage: c, isLoading: y } = Da(), { history: k, app: g } = ne(), p = g?.basePath || "/", A = k?.enabled ?? !1, P = i?.pages.flatMap((h) => h.threads) ?? [], [I, E] = Pe(), R = he(), D = re(null), T = ee(
1916
+ (h) => {
1917
+ D.current && (D.current.disconnect(), D.current = null), h && u && !c && (D.current = new IntersectionObserver(
1918
+ (N) => {
1919
+ N[0].isIntersecting && r();
1417
1920
  },
1418
1921
  {
1419
1922
  threshold: 0,
1420
1923
  rootMargin: "100px"
1421
1924
  }
1422
- ), p.current.observe(o));
1925
+ ), D.current.observe(h));
1423
1926
  },
1424
- [f, g, h]
1425
- ), B = D.getConfig().app?.cacheNamespace || "gentiq", [W, K] = T(!1), [E, V] = T(null), [R, L] = T(""), [H, F] = T(null), [b, d] = T(""), n = ae(null), k = J((o, _) => {
1426
- o.button !== 0 || o.metaKey || o.ctrlKey || (o.preventDefault(), q(_), c && m(!1));
1427
- }, [q, c, m]), I = P.filter(
1428
- (o) => o.firstMessage?.toLowerCase().includes(R.toLowerCase())
1429
- ).sort((o, _) => o.pinned && !_.pinned ? -1 : !o.pinned && _.pinned ? 1 : _.timestamp - o.timestamp), j = async (o) => {
1927
+ [u, r, c]
1928
+ ), q = oe(), V = q.getConfig().app?.cacheNamespace || "gentiq", [K, M] = _(!1), [$, G] = _(null), [F, J] = _(""), [W, j] = _(null), [L, w] = _(""), m = re(null), C = ee(
1929
+ (h, N) => {
1930
+ h.button !== 0 || h.metaKey || h.ctrlKey || (h.preventDefault(), E(N), n && o(!1));
1931
+ },
1932
+ [E, n, o]
1933
+ ), f = P.filter((h) => h.firstMessage?.toLowerCase().includes(F.toLowerCase())).sort((h, N) => h.pinned && !N.pinned ? -1 : !h.pinned && N.pinned ? 1 : N.timestamp - h.timestamp), O = async (h) => {
1430
1934
  try {
1431
- await D.pinThread(o.id.replace(/^\//, ""), !o.pinned), A.invalidateQueries({ queryKey: [B, "conversations"] }), ee.success(o.pinned ? t("unpinned_success") : t("pinned_success"));
1935
+ await q.pinThread(h.id.replace(/^\//, ""), !h.pinned), R.invalidateQueries({ queryKey: [V, "conversations"] }), te.success(h.pinned ? t("unpinned_success") : t("pinned_success"));
1432
1936
  } catch {
1433
- ee.error(t("pin_failed"));
1937
+ te.error(t("pin_failed"));
1434
1938
  }
1435
- }, S = async (o) => {
1939
+ }, S = async (h) => {
1436
1940
  try {
1437
- const _ = await D.shareThread(o.id.replace(/^\//, "")), oe = `${window.location.origin}${_.url}`;
1438
- navigator.clipboard.writeText(oe), ee.success(t("share_success"), {
1941
+ const N = await q.shareThread(h.id.replace(/^\//, "")), ie = `${window.location.origin}${N.url}`;
1942
+ navigator.clipboard.writeText(ie), te.success(t("share_success"), {
1439
1943
  description: t("share_description")
1440
1944
  });
1441
1945
  } catch {
1442
- ee.error(t("share_failed"));
1946
+ te.error(t("share_failed"));
1443
1947
  }
1444
- }, w = (o) => {
1445
- F(o.id), d(o.firstMessage ?? ""), setTimeout(() => n.current?.focus(), 0);
1446
- }, z = (o) => {
1447
- o?.preventDefault(), o?.stopPropagation(), F(null), d("");
1448
- }, Y = async (o) => {
1449
- if (o?.preventDefault(), o && "stopPropagation" in o && o.stopPropagation(), !(!H || !b.trim()))
1948
+ }, Z = (h) => {
1949
+ j(h.id), w(h.firstMessage ?? ""), setTimeout(() => m.current?.focus(), 0);
1950
+ }, H = (h) => {
1951
+ h?.preventDefault(), h?.stopPropagation(), j(null), w("");
1952
+ }, z = async (h) => {
1953
+ if (h?.preventDefault(), h && "stopPropagation" in h && h.stopPropagation(), !(!W || !L.trim()))
1450
1954
  try {
1451
- await D.updateThreadTitle(H, b), A.invalidateQueries({ queryKey: [B, "conversations"] }), F(null), ee.success(t("rename_success"));
1955
+ await q.updateThreadTitle(W, L), R.invalidateQueries({ queryKey: [V, "conversations"] }), j(null), te.success(t("rename_success"));
1452
1956
  } catch {
1453
- ee.error(t("rename_failed"));
1957
+ te.error(t("rename_failed"));
1454
1958
  }
1455
- }, Z = (o) => {
1456
- V(o), K(!0);
1457
- }, se = () => {
1458
- E && (Ma(E.id, A, q, U), K(!1), V(null), ee.success(t("chat_deleted_success")));
1459
- }, l = (o) => new Intl.DateTimeFormat(i.language, {
1959
+ }, U = (h) => {
1960
+ G(h), M(!0);
1961
+ }, b = () => {
1962
+ $ && ($a(
1963
+ q,
1964
+ $.id,
1965
+ R,
1966
+ E,
1967
+ I
1968
+ ), M(!1), G(null), te.success(t("chat_deleted_success")));
1969
+ }, l = (h) => new Intl.DateTimeFormat(d.language, {
1460
1970
  year: "numeric",
1461
1971
  month: "short",
1462
1972
  day: "numeric",
1463
1973
  hour: "2-digit",
1464
1974
  minute: "2-digit",
1465
- calendar: i.language === "fa" ? "persian" : "gregory"
1466
- }).format(new Date(o));
1467
- return /* @__PURE__ */ e($e, { children: /* @__PURE__ */ r(wa, { collapsible: "icon", side: a, children: [
1468
- /* @__PURE__ */ e(_a, { className: "custom-scrollbar", children: /* @__PURE__ */ r(Ca, { children: [
1469
- /* @__PURE__ */ e(Ee, { className: "mt-2 mb-6 px-2 group-data-[collapsible=icon]:px-0", children: /* @__PURE__ */ e(Le, { className: "group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:justify-center", children: /* @__PURE__ */ e(
1470
- Re,
1975
+ calendar: d.language === "fa" ? "persian" : "gregory"
1976
+ }).format(new Date(h));
1977
+ return /* @__PURE__ */ e(Ue, { children: /* @__PURE__ */ s(Ta, { collapsible: "icon", side: a, children: [
1978
+ /* @__PURE__ */ e(Ma, { className: "custom-scrollbar", children: /* @__PURE__ */ s(Aa, { children: [
1979
+ /* @__PURE__ */ e($e, { className: "mt-2 mb-6 px-2 group-data-[collapsible=icon]:px-0", children: /* @__PURE__ */ e(Le, { className: "group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:justify-center", children: /* @__PURE__ */ e(
1980
+ Fe,
1471
1981
  {
1472
1982
  asChild: !0,
1473
1983
  tooltip: t("tooltip_new_conversation"),
1474
1984
  className: "h-[52px] rounded-2xl bg-white/40 dark:bg-white/5 border border-border/40 hover:border-primary/50 hover:bg-white/90 dark:hover:bg-white/10 text-foreground shadow-[0_4px_12px_-4px_rgba(0,0,0,0.1)] hover:shadow-[0_12px_30px_-10px_var(--glow)] transition-all duration-500 group-data-[collapsible=icon]:size-10 group-data-[collapsible=icon]:p-0! mb-2 group/new-chat overflow-hidden backdrop-blur-md group-data-[collapsible=icon]:mx-auto",
1475
- children: /* @__PURE__ */ r(
1985
+ children: /* @__PURE__ */ s(
1476
1986
  "a",
1477
1987
  {
1478
- href: be(s, "/"),
1479
- onClick: (o) => k(o, "/"),
1988
+ href: xe(p, "/"),
1989
+ onClick: (h) => C(h, "/"),
1480
1990
  className: "px-5 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:justify-center flex items-center gap-3 active:scale-[0.96] w-full h-full relative",
1481
1991
  children: [
1482
1992
  /* @__PURE__ */ e("div", { className: "absolute inset-0 bg-linear-to-tr from-primary/10 via-transparent to-primary/5 opacity-0 group-hover/new-chat:opacity-100 transition-opacity duration-700" }),
1483
- /* @__PURE__ */ e("div", { className: "relative size-8 rounded-xl bg-linear-to-br from-primary/20 to-primary/5 flex items-center justify-center shrink-0 group-hover/new-chat:from-primary/30 group-hover/new-chat:to-primary/10 transition-all duration-500 shadow-inner", children: /* @__PURE__ */ e(jt, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1993
+ /* @__PURE__ */ e("div", { className: "relative size-8 rounded-xl bg-linear-to-br from-primary/20 to-primary/5 flex items-center justify-center shrink-0 group-hover/new-chat:from-primary/30 group-hover/new-chat:to-primary/10 transition-all duration-500 shadow-inner", children: /* @__PURE__ */ e(Ht, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1484
1994
  /* @__PURE__ */ e("span", { className: "font-bold text-[0.95rem] group-data-[collapsible=icon]:hidden tracking-tight bg-clip-text text-foreground/90 group-hover/new-chat:text-foreground transition-colors", children: t("new_conversation") })
1485
1995
  ]
1486
1996
  }
1487
1997
  )
1488
1998
  }
1489
1999
  ) }) }),
1490
- M && /* @__PURE__ */ e(Ae, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ r("div", { className: "relative group/search", children: [
1491
- /* @__PURE__ */ e(Ot, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
2000
+ A && /* @__PURE__ */ e(De, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ s("div", { className: "relative group/search", children: [
2001
+ /* @__PURE__ */ e(Ut, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
1492
2002
  /* @__PURE__ */ e(
1493
- X,
2003
+ Y,
1494
2004
  {
1495
2005
  placeholder: t("search_conversations"),
1496
- value: R,
1497
- onChange: (o) => L(o.target.value),
2006
+ value: F,
2007
+ onChange: (h) => J(h.target.value),
1498
2008
  className: "pl-9 h-10 bg-accent/15 border border-border/40 focus-visible:ring-primary/20 rounded-xl transition-all"
1499
2009
  }
1500
2010
  )
1501
2011
  ] }) }),
1502
- M && /* @__PURE__ */ r(Ae, { className: "group-data-[collapsible=icon]:hidden", children: [
1503
- /* @__PURE__ */ r(Ee, { children: [
1504
- I.map((o, _) => {
1505
- const oe = H === o.id, Se = Te(o.firstMessage ?? ""), Je = Se === "rtl";
1506
- return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: oe ? /* @__PURE__ */ r("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
2012
+ A && /* @__PURE__ */ s(De, { className: "group-data-[collapsible=icon]:hidden", children: [
2013
+ /* @__PURE__ */ s($e, { children: [
2014
+ f.map((h, N) => {
2015
+ const ie = W === h.id, Ee = Me(h.firstMessage ?? ""), Ze = Ee === "rtl";
2016
+ return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: ie ? /* @__PURE__ */ s("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
1507
2017
  /* @__PURE__ */ e(
1508
- X,
2018
+ Y,
1509
2019
  {
1510
- ref: n,
1511
- value: b,
1512
- onChange: (le) => d(le.target.value),
1513
- onKeyDown: (le) => {
1514
- le.key === "Enter" && Y(), le.key === "Escape" && z();
2020
+ ref: m,
2021
+ value: L,
2022
+ onChange: (ce) => w(ce.target.value),
2023
+ onKeyDown: (ce) => {
2024
+ ce.key === "Enter" && z(), ce.key === "Escape" && H();
1515
2025
  },
1516
2026
  className: "h-8 py-0 px-2 text-sm",
1517
- dir: Te(b)
2027
+ dir: Me(L)
2028
+ }
2029
+ ),
2030
+ /* @__PURE__ */ e(
2031
+ ae,
2032
+ {
2033
+ size: "icon",
2034
+ variant: "ghost",
2035
+ className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50",
2036
+ onClick: z,
2037
+ children: /* @__PURE__ */ e(Bt, { className: "size-4" })
1518
2038
  }
1519
2039
  ),
1520
- /* @__PURE__ */ e(te, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50", onClick: Y, children: /* @__PURE__ */ e($t, { className: "size-4" }) }),
1521
- /* @__PURE__ */ e(te, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-destructive hover:bg-destructive/10", onClick: z, children: /* @__PURE__ */ e(Ut, { className: "size-4" }) })
1522
- ] }) : /* @__PURE__ */ r(ke, { children: [
1523
2040
  /* @__PURE__ */ e(
1524
- Re,
2041
+ ae,
2042
+ {
2043
+ size: "icon",
2044
+ variant: "ghost",
2045
+ className: "size-8 shrink-0 text-destructive hover:bg-destructive/10",
2046
+ onClick: H,
2047
+ children: /* @__PURE__ */ e(Kt, { className: "size-4" })
2048
+ }
2049
+ )
2050
+ ] }) : /* @__PURE__ */ s(_e, { children: [
2051
+ /* @__PURE__ */ e(
2052
+ Fe,
1525
2053
  {
1526
2054
  asChild: !0,
1527
2055
  className: v("h-auto py-2.5 px-3", {
1528
- "bg-accent opacity-100 pointer-events-none": o.id === U,
1529
- "opacity-70 hover:opacity-100": o.id !== U
2056
+ "bg-accent opacity-100 pointer-events-none": h.id === I,
2057
+ "opacity-70 hover:opacity-100": h.id !== I
1530
2058
  }),
1531
- children: /* @__PURE__ */ r(
2059
+ children: /* @__PURE__ */ s(
1532
2060
  "a",
1533
2061
  {
1534
- href: be(s, o.id),
1535
- onClick: (le) => k(le, o.id),
1536
- dir: Se,
1537
- className: v("flex flex-col gap-0.5 w-full overflow-hidden", Je ? "items-end" : "items-start"),
2062
+ href: xe(p, h.id),
2063
+ onClick: (ce) => C(ce, h.id),
2064
+ dir: Ee,
2065
+ className: v(
2066
+ "flex flex-col gap-0.5 w-full overflow-hidden",
2067
+ Ze ? "items-end" : "items-start"
2068
+ ),
1538
2069
  children: [
1539
- /* @__PURE__ */ e("span", { className: v("truncate w-full font-medium text-[0.9375rem]", i.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: o.firstMessage }),
1540
- /* @__PURE__ */ e("div", { className: v("text-[10px] opacity-40 w-full", i.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: l(o.timestamp) })
2070
+ /* @__PURE__ */ e(
2071
+ "span",
2072
+ {
2073
+ className: v(
2074
+ "truncate w-full font-medium text-[0.9375rem]",
2075
+ d.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"
2076
+ ),
2077
+ children: h.firstMessage
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ e(
2081
+ "div",
2082
+ {
2083
+ className: v(
2084
+ "text-[10px] opacity-40 w-full",
2085
+ d.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"
2086
+ ),
2087
+ children: l(h.timestamp)
2088
+ }
2089
+ )
1541
2090
  ]
1542
2091
  }
1543
2092
  )
1544
2093
  }
1545
2094
  ),
1546
- /* @__PURE__ */ r("div", { className: v(
1547
- "absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
1548
- i.language === "fa" ? "left-2" : "right-1.5"
1549
- ), children: [
1550
- o.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" }),
1551
- /* @__PURE__ */ r(ut, { dir: i.language === "fa" ? "rtl" : "ltr", children: [
1552
- /* @__PURE__ */ e(mt, { asChild: !0, children: /* @__PURE__ */ e(
1553
- te,
1554
- {
1555
- variant: "ghost",
1556
- size: "icon",
1557
- className: "size-7 rounded-full opacity-100 md:opacity-0 md:group-hover/sidebar-menu-item:opacity-100 hover:bg-accent hover:text-accent-foreground data-[state=open]:opacity-100 transition-all",
1558
- children: /* @__PURE__ */ e(Bt, { className: "size-3.5" })
1559
- }
1560
- ) }),
1561
- /* @__PURE__ */ r(
1562
- ht,
1563
- {
1564
- align: "end",
1565
- className: "min-w-[120px] p-1",
1566
- children: [
1567
- y?.showPin !== !1 && /* @__PURE__ */ r(me, { onSelect: () => j(o), className: "cursor-pointer flex items-center gap-2", children: [
1568
- o.pinned ? /* @__PURE__ */ e(Kt, { className: "size-4" }) : /* @__PURE__ */ e(De, { className: "size-4" }),
1569
- /* @__PURE__ */ e("span", { children: o.pinned ? t("unpin_conversation") : t("pin_conversation") })
1570
- ] }),
1571
- y?.showShare !== !1 && /* @__PURE__ */ r(me, { onSelect: () => S(o), className: "cursor-pointer flex items-center gap-2", children: [
1572
- /* @__PURE__ */ e(Qt, { className: "size-4" }),
1573
- /* @__PURE__ */ e("span", { children: t("share_conversation") })
1574
- ] }),
1575
- (y?.showRename ?? !1) && /* @__PURE__ */ r(me, { onSelect: () => w(o), className: "cursor-pointer flex items-center gap-2", children: [
1576
- /* @__PURE__ */ e(Ht, { className: "size-4" }),
1577
- /* @__PURE__ */ e("span", { children: t("rename_conversation") })
1578
- ] }),
1579
- (y?.showDelete ?? !1) && /* @__PURE__ */ r(
1580
- me,
2095
+ /* @__PURE__ */ s(
2096
+ "div",
2097
+ {
2098
+ className: v(
2099
+ "absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
2100
+ d.language === "fa" ? "left-2" : "right-1.5"
2101
+ ),
2102
+ children: [
2103
+ h.pinned && /* @__PURE__ */ e(Re, { 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" }),
2104
+ /* @__PURE__ */ s(mt, { dir: d.language === "fa" ? "rtl" : "ltr", children: [
2105
+ /* @__PURE__ */ e(gt, { asChild: !0, children: /* @__PURE__ */ e(
2106
+ ae,
2107
+ {
2108
+ variant: "ghost",
2109
+ size: "icon",
2110
+ className: "size-7 rounded-full opacity-100 md:opacity-0 md:group-hover/sidebar-menu-item:opacity-100 hover:bg-accent hover:text-accent-foreground data-[state=open]:opacity-100 transition-all",
2111
+ children: /* @__PURE__ */ e(Qt, { className: "size-3.5" })
2112
+ }
2113
+ ) }),
2114
+ /* @__PURE__ */ s(ft, { align: "end", className: "min-w-[120px] p-1", children: [
2115
+ k?.showPin !== !1 && /* @__PURE__ */ s(
2116
+ pe,
2117
+ {
2118
+ onSelect: () => O(h),
2119
+ className: "cursor-pointer flex items-center gap-2",
2120
+ children: [
2121
+ h.pinned ? /* @__PURE__ */ e(Vt, { className: "size-4" }) : /* @__PURE__ */ e(Re, { className: "size-4" }),
2122
+ /* @__PURE__ */ e("span", { children: h.pinned ? t("unpin_conversation") : t("pin_conversation") })
2123
+ ]
2124
+ }
2125
+ ),
2126
+ k?.showShare !== !1 && /* @__PURE__ */ s(
2127
+ pe,
2128
+ {
2129
+ onSelect: () => S(h),
2130
+ className: "cursor-pointer flex items-center gap-2",
2131
+ children: [
2132
+ /* @__PURE__ */ e(Gt, { className: "size-4" }),
2133
+ /* @__PURE__ */ e("span", { children: t("share_conversation") })
2134
+ ]
2135
+ }
2136
+ ),
2137
+ (k?.showRename ?? !1) && /* @__PURE__ */ s(
2138
+ pe,
2139
+ {
2140
+ onSelect: () => Z(h),
2141
+ className: "cursor-pointer flex items-center gap-2",
2142
+ children: [
2143
+ /* @__PURE__ */ e(Wt, { className: "size-4" }),
2144
+ /* @__PURE__ */ e("span", { children: t("rename_conversation") })
2145
+ ]
2146
+ }
2147
+ ),
2148
+ (k?.showDelete ?? !1) && /* @__PURE__ */ s(
2149
+ pe,
1581
2150
  {
1582
2151
  className: "text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer flex items-center gap-2",
1583
- onSelect: () => Z(o),
2152
+ onSelect: () => U(h),
1584
2153
  children: [
1585
- /* @__PURE__ */ e(Vt, { className: "size-4" }),
2154
+ /* @__PURE__ */ e(Jt, { className: "size-4" }),
1586
2155
  /* @__PURE__ */ e("span", { children: t("delete_conversation") })
1587
2156
  ]
1588
2157
  }
1589
2158
  )
1590
- ]
1591
- }
1592
- )
1593
- ] })
1594
- ] })
1595
- ] }) }, _);
2159
+ ] })
2160
+ ] })
2161
+ ]
2162
+ }
2163
+ )
2164
+ ] }) }, N);
1596
2165
  }),
1597
- !N && P.length === 0 && !R && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
2166
+ !y && P.length === 0 && !F && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
1598
2167
  ] }),
1599
- /* @__PURE__ */ e("div", { ref: Q, className: "h-4 w-full" }),
1600
- h && /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
2168
+ /* @__PURE__ */ e("div", { ref: T, className: "h-4 w-full" }),
2169
+ c && /* @__PURE__ */ s("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
1601
2170
  /* @__PURE__ */ e("div", { className: "size-4 border-2 border-primary border-t-transparent rounded-full animate-spin" }),
1602
2171
  /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wider font-medium", children: t("loading_more") })
1603
2172
  ] })
1604
2173
  ] })
1605
2174
  ] }) }),
1606
- /* @__PURE__ */ e(ka, {}),
1607
- /* @__PURE__ */ e(He, { open: W, onOpenChange: K, children: /* @__PURE__ */ r(
1608
- Ve,
2175
+ /* @__PURE__ */ e(Ea, {}),
2176
+ /* @__PURE__ */ e(Ge, { open: K, onOpenChange: M, children: /* @__PURE__ */ s(
2177
+ We,
1609
2178
  {
1610
- onKeyDown: (o) => {
1611
- o.key === "Enter" && (o.preventDefault(), se());
2179
+ onKeyDown: (h) => {
2180
+ h.key === "Enter" && (h.preventDefault(), b());
1612
2181
  },
1613
2182
  children: [
1614
- /* @__PURE__ */ r(pt, { children: [
1615
- /* @__PURE__ */ e(gt, { children: t("delete_confirm_title") }),
1616
- /* @__PURE__ */ e(ft, { children: t("delete_confirm_description") })
2183
+ /* @__PURE__ */ s(bt, { children: [
2184
+ /* @__PURE__ */ e(yt, { children: t("delete_confirm_title") }),
2185
+ /* @__PURE__ */ e(vt, { children: t("delete_confirm_description") })
1617
2186
  ] }),
1618
- /* @__PURE__ */ r(bt, { children: [
2187
+ /* @__PURE__ */ s(xt, { children: [
1619
2188
  /* @__PURE__ */ e(
1620
- te,
2189
+ ae,
1621
2190
  {
1622
2191
  variant: "outline",
1623
2192
  onClick: () => {
1624
- K(!1);
2193
+ M(!1);
1625
2194
  },
1626
2195
  children: t("cancel")
1627
2196
  }
1628
2197
  ),
1629
- /* @__PURE__ */ e(te, { variant: "destructive", onClick: se, autoFocus: !0, children: t("delete") })
2198
+ /* @__PURE__ */ e(ae, { variant: "destructive", onClick: b, autoFocus: !0, children: t("delete") })
1630
2199
  ] })
1631
2200
  ]
1632
2201
  }
1633
2202
  ) })
1634
2203
  ] }) });
1635
2204
  }
1636
- function Ga({ sidebar: a, header: t, components: i, classNames: m, disclaimer: c, welcome: u }) {
1637
- const { config: g } = je(), { history: f } = re(), h = g?.language === "fa" ? "right" : "left", N = f?.enabled ?? !0;
1638
- return /* @__PURE__ */ r(ya, { defaultOpen: N, children: [
1639
- a !== void 0 ? a : N ? /* @__PURE__ */ e(Ia, { side: h }) : null,
1640
- /* @__PURE__ */ r("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
1641
- t !== void 0 ? t : /* @__PURE__ */ e(Xe, {}),
2205
+ function er({
2206
+ sidebar: a,
2207
+ header: t,
2208
+ components: d,
2209
+ classNames: o,
2210
+ disclaimer: n,
2211
+ welcome: i
2212
+ }) {
2213
+ const { config: r } = Oe(), { history: u } = ne(), c = r?.language === "fa" ? "right" : "left", y = u?.enabled ?? !0;
2214
+ return /* @__PURE__ */ s(_a, { defaultOpen: y, children: [
2215
+ a !== void 0 ? a : y ? /* @__PURE__ */ e(La, { side: c }) : null,
2216
+ /* @__PURE__ */ s("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
2217
+ t !== void 0 ? t : /* @__PURE__ */ e(Ye, {}),
1642
2218
  /* @__PURE__ */ e(
1643
2219
  "div",
1644
2220
  {
@@ -1647,12 +2223,12 @@ function Ga({ sidebar: a, header: t, components: i, classNames: m, disclaimer: c
1647
2223
  "has-[.stick-to-bottom:empty]:overflow-visible has-[.stick-to-bottom:empty]:flex-initial transition-[flex] duration-200"
1648
2224
  ),
1649
2225
  children: /* @__PURE__ */ e(
1650
- oa,
2226
+ ha,
1651
2227
  {
1652
- components: i,
1653
- classNames: m,
1654
- disclaimer: c,
1655
- welcome: u
2228
+ components: d,
2229
+ classNames: o,
2230
+ disclaimer: n,
2231
+ welcome: i
1656
2232
  }
1657
2233
  )
1658
2234
  }
@@ -1660,302 +2236,318 @@ function Ga({ sidebar: a, header: t, components: i, classNames: m, disclaimer: c
1660
2236
  ] })
1661
2237
  ] });
1662
2238
  }
1663
- function Wa({ children: a }) {
1664
- const [t, i] = T(null), m = Ge(), c = _e(), u = ue();
1665
- return $(() => {
2239
+ function tr({ children: a }) {
2240
+ const [t, d] = _(null), o = Je(), n = Te(), i = he(), r = oe();
2241
+ return B(() => {
1666
2242
  (async () => {
1667
- const f = new URLSearchParams(m.search), h = f.get("token");
1668
- if (h)
2243
+ const c = new URLSearchParams(o.search), y = c.get("token");
2244
+ if (y)
1669
2245
  try {
1670
- D.setToken(h), await D.getBalance(), f.delete("token");
1671
- const y = f.toString(), C = m.pathname + (y ? `?${y}` : "");
1672
- c(C, { replace: !0 }), i(!0);
2246
+ r.setToken(y), await r.getBalance(), c.delete("token");
2247
+ const g = c.toString(), p = o.pathname + (g ? `?${g}` : "");
2248
+ n(p, { replace: !0 }), d(!0);
1673
2249
  return;
1674
- } catch (y) {
1675
- console.error("Error validating token from URL:", y), i(!1);
2250
+ } catch (g) {
2251
+ console.error("Error validating token from URL:", g), d(!1);
1676
2252
  return;
1677
2253
  }
1678
- if (!D.getToken()) {
1679
- i(!1);
2254
+ if (!r.getToken()) {
2255
+ d(!1);
1680
2256
  return;
1681
2257
  }
1682
2258
  try {
1683
- await D.getBalance(), i(!0);
1684
- } catch (y) {
1685
- console.error("Token validation failed:", y), y.status === 401 ? (D.clearToken(), u.clear(), i(!1)) : i(!0);
2259
+ await r.getBalance(), d(!0);
2260
+ } catch (g) {
2261
+ console.error("Token validation failed:", g), g?.status === 401 ? (r.clearToken(), i.clear(), d(!1)) : d(!0);
1686
2262
  }
1687
2263
  })();
1688
- }, [m.search, c, m.pathname, u]), 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(Yt, { to: "/login", replace: !0 });
2264
+ }, [o.search, n, o.pathname, i, r]), 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(_e, { children: a }) : /* @__PURE__ */ e(ta, { to: "/login", replace: !0 });
1689
2265
  }
1690
- const qe = (a) => a.replace(/[^0-9]/g, "");
1691
- function Xa() {
1692
- const { t: a, i18n: t } = de(["login", "translation"]), { app: i } = re(), m = t.dir() === "rtl", c = m ? "text-right" : "text-left", u = _e(), g = ue(), [f, h] = T("login"), N = !!i?.disableSignup, y = !!i?.disableAuthPage, [C, s] = T(""), [M, P] = T(""), [U, q] = T(""), [A, p] = T(""), [Q, x] = T(""), [B, W] = T(""), K = O(() => i?.userMetadataFields?.filter((n) => n.showInSignup) || [], [i?.userMetadataFields]), [E, V] = T(() => {
1693
- const n = {};
1694
- return K.forEach((k) => {
1695
- k.defaultValue !== void 0 && (n[k.key] = k.defaultValue);
1696
- }), n;
2266
+ const ze = (a) => a.replace(/[^0-9]/g, "");
2267
+ function ar() {
2268
+ const { t: a, i18n: t } = ue(["login", "translation"]), { app: d } = ne(), o = oe(), n = t.dir() === "rtl", i = n ? "text-right" : "text-left", r = Te(), u = he(), [c, y] = _("login"), k = !!d?.disableSignup, g = !!d?.disableAuthPage, [p, A] = _(""), [P, I] = _(""), [E, R] = _(""), [D, T] = _(""), [q, x] = _(""), [V, K] = _(""), M = Q(
2269
+ () => d?.userMetadataFields?.filter((m) => m.showInSignup) || [],
2270
+ [d?.userMetadataFields]
2271
+ ), [$, G] = _(() => {
2272
+ const m = {};
2273
+ return M.forEach((C) => {
2274
+ C.defaultValue !== void 0 && (m[C.key] = C.defaultValue);
2275
+ }), m;
1697
2276
  });
1698
- $(() => {
1699
- const n = { ...E };
1700
- let k = !1;
1701
- K.forEach((I) => {
1702
- I.condition && !ge(I.condition, E) && n[I.key] !== void 0 && (delete n[I.key], k = !0);
1703
- }), k && V(n);
1704
- }, [E, K]);
1705
- const [R, L] = T(""), [H, F] = T(!1);
1706
- $(() => {
1707
- N && f === "register" && h("login");
1708
- }, [N, f]);
1709
- const b = async (n) => {
1710
- n.preventDefault(), L(""), F(!0);
2277
+ B(() => {
2278
+ const m = { ...$ };
2279
+ let C = !1;
2280
+ M.forEach((f) => {
2281
+ f.condition && !ye(f.condition, $) && m[f.key] !== void 0 && (delete m[f.key], C = !0);
2282
+ }), C && G(m);
2283
+ }, [$, M]);
2284
+ const [F, J] = _(""), [W, j] = _(!1);
2285
+ B(() => {
2286
+ k && c === "register" && y("login");
2287
+ }, [k, c]);
2288
+ const L = async (m) => {
2289
+ m.preventDefault(), J(""), j(!0);
1711
2290
  try {
1712
- await D.login(C, M), g.clear(), u("/");
1713
- } catch (k) {
1714
- L(ce(k, a));
2291
+ await o.login(p, P), u.clear(), r("/");
2292
+ } catch (C) {
2293
+ J(de(C, a));
1715
2294
  } finally {
1716
- F(!1);
2295
+ j(!1);
1717
2296
  }
1718
- }, d = async (n) => {
1719
- n.preventDefault(), L(""), F(!0);
2297
+ }, w = async (m) => {
2298
+ m.preventDefault(), J(""), j(!0);
1720
2299
  try {
1721
- await D.register(U, A, Q, B, E), g.clear(), u("/");
1722
- } catch (k) {
1723
- L(ce(k, a));
2300
+ await o.register(E, D, q, V, $), u.clear(), r("/");
2301
+ } catch (C) {
2302
+ J(de(C, a));
1724
2303
  } finally {
1725
- F(!1);
2304
+ j(!1);
1726
2305
  }
1727
2306
  };
1728
- return y ? /* @__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: [
1729
- /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: i?.name }),
1730
- /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
1731
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: a("auth_page_disabled_description", "Please contact the administrator for access.") })
1732
- ] }) }) : /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex flex-col items-center justify-center p-4", dir: t.dir(), children: /* @__PURE__ */ r("div", { className: "w-full max-w-md bg-card border border-border rounded-xl shadow-lg p-6", children: [
1733
- /* @__PURE__ */ e("div", { className: "text-center mb-6", children: /* @__PURE__ */ e("h1", { className: "text-2xl font-bold bg-gradient-to-r from-primary to-primary/60 bg-clip-text text-transparent", children: i?.name }) }),
1734
- /* @__PURE__ */ r("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
1735
- /* @__PURE__ */ e(
1736
- "button",
1737
- {
1738
- type: "button",
1739
- onClick: () => {
1740
- h("login"), L("");
1741
- },
1742
- className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${f === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1743
- children: a("login_tab", "Login")
1744
- }
1745
- ),
1746
- !N && /* @__PURE__ */ e(
1747
- "button",
1748
- {
1749
- type: "button",
1750
- onClick: () => {
1751
- h("register"), L("");
1752
- },
1753
- className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${f === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1754
- children: a("signup_tab", "Sign Up")
1755
- }
1756
- )
1757
- ] }),
1758
- f === "login" && /* @__PURE__ */ r("form", { onSubmit: b, className: "space-y-4", children: [
1759
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1760
- /* @__PURE__ */ e(G, { htmlFor: "login-phone", children: a("phone", "Phone") }),
1761
- /* @__PURE__ */ e(
1762
- X,
1763
- {
1764
- id: "login-phone",
1765
- type: "tel",
1766
- value: C,
1767
- onChange: (n) => s(qe(n.target.value)),
1768
- required: !0,
1769
- className: "text-left",
1770
- placeholder: a("phone_placeholder", "Phone number"),
1771
- dir: "ltr"
1772
- }
1773
- )
1774
- ] }),
1775
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1776
- /* @__PURE__ */ e(G, { htmlFor: "login-pass", children: a("password", "Password") }),
1777
- /* @__PURE__ */ e(
1778
- X,
1779
- {
1780
- id: "login-pass",
1781
- type: "password",
1782
- value: M,
1783
- onChange: (n) => P(n.target.value),
1784
- required: !0,
1785
- className: "text-left",
1786
- placeholder: "••••••••",
1787
- dir: "ltr"
1788
- }
1789
- )
1790
- ] }),
1791
- R && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: R }),
1792
- /* @__PURE__ */ e(
1793
- te,
1794
- {
1795
- type: "submit",
1796
- disabled: H,
1797
- className: "w-full font-semibold",
1798
- children: H ? a("logging_in", "Logging in...") : a("login_button", "Login")
1799
- }
1800
- )
1801
- ] }),
1802
- !N && f === "register" && /* @__PURE__ */ r("form", { onSubmit: d, className: "space-y-4", children: [
1803
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1804
- /* @__PURE__ */ e(G, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
1805
- /* @__PURE__ */ e(
1806
- X,
1807
- {
1808
- id: "reg-phone",
1809
- type: "tel",
1810
- value: U,
1811
- onChange: (n) => q(qe(n.target.value)),
1812
- required: !0,
1813
- className: "text-left",
1814
- placeholder: a("phone_placeholder", "Phone number"),
1815
- dir: "ltr"
1816
- }
1817
- )
1818
- ] }),
1819
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1820
- /* @__PURE__ */ e(G, { htmlFor: "reg-pass", children: a("password", "Password") }),
1821
- /* @__PURE__ */ e(
1822
- X,
1823
- {
1824
- id: "reg-pass",
1825
- type: "password",
1826
- value: A,
1827
- onChange: (n) => p(n.target.value),
1828
- required: !0,
1829
- className: "text-left",
1830
- placeholder: "••••••••",
1831
- dir: "ltr"
1832
- }
1833
- )
1834
- ] }),
1835
- /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1836
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1837
- /* @__PURE__ */ e(G, { htmlFor: "reg-name", children: a("name", "Name") }),
2307
+ return g ? /* @__PURE__ */ e(
2308
+ "div",
2309
+ {
2310
+ className: "min-h-screen bg-background flex items-center justify-center p-4",
2311
+ dir: t.dir(),
2312
+ children: /* @__PURE__ */ s("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
2313
+ /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: d?.name }),
2314
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
2315
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: a("auth_page_disabled_description", "Please contact the administrator for access.") })
2316
+ ] })
2317
+ }
2318
+ ) : /* @__PURE__ */ e(
2319
+ "div",
2320
+ {
2321
+ className: "min-h-screen bg-background flex flex-col items-center justify-center p-4",
2322
+ dir: t.dir(),
2323
+ children: /* @__PURE__ */ s("div", { className: "w-full max-w-md bg-card border border-border rounded-xl shadow-lg p-6", children: [
2324
+ /* @__PURE__ */ e("div", { className: "text-center mb-6", children: /* @__PURE__ */ e("h1", { className: "text-2xl font-bold bg-gradient-to-r from-primary to-primary/60 bg-clip-text text-transparent", children: d?.name }) }),
2325
+ /* @__PURE__ */ s("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
1838
2326
  /* @__PURE__ */ e(
1839
- X,
2327
+ "button",
1840
2328
  {
1841
- id: "reg-name",
1842
- type: "text",
1843
- value: Q,
1844
- onChange: (n) => x(n.target.value),
1845
- required: !0,
1846
- className: c,
1847
- placeholder: a("name_placeholder", "First Name")
2329
+ type: "button",
2330
+ onClick: () => {
2331
+ y("login"), J("");
2332
+ },
2333
+ className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${c === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
2334
+ children: a("login_tab", "Login")
1848
2335
  }
1849
- )
1850
- ] }),
1851
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1852
- /* @__PURE__ */ e(G, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
1853
- /* @__PURE__ */ e(
1854
- X,
2336
+ ),
2337
+ !k && /* @__PURE__ */ e(
2338
+ "button",
1855
2339
  {
1856
- id: "reg-surname",
1857
- type: "text",
1858
- value: B,
1859
- onChange: (n) => W(n.target.value),
1860
- required: !0,
1861
- className: c,
1862
- placeholder: a("surname_placeholder", "Last Name")
2340
+ type: "button",
2341
+ onClick: () => {
2342
+ y("register"), J("");
2343
+ },
2344
+ className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${c === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
2345
+ children: a("signup_tab", "Sign Up")
1863
2346
  }
1864
2347
  )
1865
- ] })
1866
- ] }),
1867
- K.map((n) => ge(n.condition, E) ? /* @__PURE__ */ r("div", { className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200", children: [
1868
- /* @__PURE__ */ e(G, { htmlFor: `signup-${n.key}`, children: a(n.label) }),
1869
- n.type === "select" ? /* @__PURE__ */ r(
1870
- xe,
1871
- {
1872
- value: String(E[n.key] || ""),
1873
- onValueChange: (k) => V({ ...E, [n.key]: k }),
1874
- required: n.required,
1875
- dir: m ? "rtl" : "ltr",
1876
- children: [
1877
- /* @__PURE__ */ e(ve, { className: v("bg-background", c), children: /* @__PURE__ */ e(ye, { placeholder: a(n.placeholder || "select_placeholder") }) }),
1878
- /* @__PURE__ */ e(we, { className: "rounded-xl", children: n.options?.map((k) => /* @__PURE__ */ e(pe, { value: String(k.value), children: a(k.label) }, String(k.value))) })
1879
- ]
1880
- }
1881
- ) : n.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-2", children: [
1882
- /* @__PURE__ */ e(
1883
- xt,
2348
+ ] }),
2349
+ c === "login" && /* @__PURE__ */ s("form", { onSubmit: L, className: "space-y-4", children: [
2350
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2351
+ /* @__PURE__ */ e(X, { htmlFor: "login-phone", children: a("phone", "Phone") }),
2352
+ /* @__PURE__ */ e(
2353
+ Y,
2354
+ {
2355
+ id: "login-phone",
2356
+ type: "tel",
2357
+ value: p,
2358
+ onChange: (m) => A(ze(m.target.value)),
2359
+ required: !0,
2360
+ className: "text-left",
2361
+ placeholder: a("phone_placeholder", "Phone number"),
2362
+ dir: "ltr"
2363
+ }
2364
+ )
2365
+ ] }),
2366
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2367
+ /* @__PURE__ */ e(X, { htmlFor: "login-pass", children: a("password", "Password") }),
2368
+ /* @__PURE__ */ e(
2369
+ Y,
2370
+ {
2371
+ id: "login-pass",
2372
+ type: "password",
2373
+ value: P,
2374
+ onChange: (m) => I(m.target.value),
2375
+ required: !0,
2376
+ className: "text-left",
2377
+ placeholder: "••••••••",
2378
+ dir: "ltr"
2379
+ }
2380
+ )
2381
+ ] }),
2382
+ F && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: F }),
2383
+ /* @__PURE__ */ e(ae, { type: "submit", disabled: W, className: "w-full font-semibold", children: W ? a("logging_in", "Logging in...") : a("login_button", "Login") })
2384
+ ] }),
2385
+ !k && c === "register" && /* @__PURE__ */ s("form", { onSubmit: w, className: "space-y-4", children: [
2386
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2387
+ /* @__PURE__ */ e(X, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
2388
+ /* @__PURE__ */ e(
2389
+ Y,
2390
+ {
2391
+ id: "reg-phone",
2392
+ type: "tel",
2393
+ value: E,
2394
+ onChange: (m) => R(ze(m.target.value)),
2395
+ required: !0,
2396
+ className: "text-left",
2397
+ placeholder: a("phone_placeholder", "Phone number"),
2398
+ dir: "ltr"
2399
+ }
2400
+ )
2401
+ ] }),
2402
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2403
+ /* @__PURE__ */ e(X, { htmlFor: "reg-pass", children: a("password", "Password") }),
2404
+ /* @__PURE__ */ e(
2405
+ Y,
2406
+ {
2407
+ id: "reg-pass",
2408
+ type: "password",
2409
+ value: D,
2410
+ onChange: (m) => T(m.target.value),
2411
+ required: !0,
2412
+ className: "text-left",
2413
+ placeholder: "••••••••",
2414
+ dir: "ltr"
2415
+ }
2416
+ )
2417
+ ] }),
2418
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
2419
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2420
+ /* @__PURE__ */ e(X, { htmlFor: "reg-name", children: a("name", "Name") }),
2421
+ /* @__PURE__ */ e(
2422
+ Y,
2423
+ {
2424
+ id: "reg-name",
2425
+ type: "text",
2426
+ value: q,
2427
+ onChange: (m) => x(m.target.value),
2428
+ required: !0,
2429
+ className: i,
2430
+ placeholder: a("name_placeholder", "First Name")
2431
+ }
2432
+ )
2433
+ ] }),
2434
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2435
+ /* @__PURE__ */ e(X, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
2436
+ /* @__PURE__ */ e(
2437
+ Y,
2438
+ {
2439
+ id: "reg-surname",
2440
+ type: "text",
2441
+ value: V,
2442
+ onChange: (m) => K(m.target.value),
2443
+ required: !0,
2444
+ className: i,
2445
+ placeholder: a("surname_placeholder", "Last Name")
2446
+ }
2447
+ )
2448
+ ] })
2449
+ ] }),
2450
+ M.map((m) => ye(m.condition, $) ? /* @__PURE__ */ s(
2451
+ "div",
1884
2452
  {
1885
- id: `signup-${n.key}`,
1886
- checked: !!E[n.key],
1887
- onCheckedChange: (k) => V({ ...E, [n.key]: !!k }),
1888
- required: n.required
1889
- }
1890
- ),
1891
- /* @__PURE__ */ e("label", { htmlFor: `signup-${n.key}`, className: "text-sm text-muted-foreground cursor-pointer select-none", children: a(n.placeholder || n.label) })
1892
- ] }) : /* @__PURE__ */ e(
1893
- X,
1894
- {
1895
- id: `signup-${n.key}`,
1896
- type: n.type,
1897
- value: E[n.key] || "",
1898
- onChange: (k) => V({ ...E, [n.key]: k.target.value }),
1899
- required: n.required,
1900
- className: c,
1901
- placeholder: a(n.placeholder || "")
1902
- }
1903
- )
1904
- ] }, n.key) : null),
1905
- R && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: R }),
1906
- /* @__PURE__ */ e(
1907
- te,
1908
- {
1909
- type: "submit",
1910
- disabled: H,
1911
- className: "w-full font-semibold",
1912
- children: H ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up")
1913
- }
1914
- )
1915
- ] })
1916
- ] }) });
2453
+ className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200",
2454
+ children: [
2455
+ /* @__PURE__ */ e(X, { htmlFor: `signup-${m.key}`, children: a(m.label) }),
2456
+ m.type === "select" ? /* @__PURE__ */ s(
2457
+ we,
2458
+ {
2459
+ value: String($[m.key] || ""),
2460
+ onValueChange: (C) => G({ ...$, [m.key]: C }),
2461
+ required: m.required,
2462
+ dir: n ? "rtl" : "ltr",
2463
+ children: [
2464
+ /* @__PURE__ */ e(Ne, { className: v("bg-background", i), children: /* @__PURE__ */ e(ke, { placeholder: a(m.placeholder || "select_placeholder") }) }),
2465
+ /* @__PURE__ */ e(Se, { className: "rounded-xl", children: m.options?.map((C) => /* @__PURE__ */ e(fe, { value: String(C.value), children: a(C.label) }, String(C.value))) })
2466
+ ]
2467
+ }
2468
+ ) : m.type === "checkbox" ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2 py-2", children: [
2469
+ /* @__PURE__ */ e(
2470
+ wt,
2471
+ {
2472
+ id: `signup-${m.key}`,
2473
+ checked: !!$[m.key],
2474
+ onCheckedChange: (C) => G({ ...$, [m.key]: !!C }),
2475
+ required: m.required
2476
+ }
2477
+ ),
2478
+ /* @__PURE__ */ e(
2479
+ "label",
2480
+ {
2481
+ htmlFor: `signup-${m.key}`,
2482
+ className: "text-sm text-muted-foreground cursor-pointer select-none",
2483
+ children: a(m.placeholder || m.label)
2484
+ }
2485
+ )
2486
+ ] }) : /* @__PURE__ */ e(
2487
+ Y,
2488
+ {
2489
+ id: `signup-${m.key}`,
2490
+ type: m.type,
2491
+ value: $[m.key] || "",
2492
+ onChange: (C) => G({ ...$, [m.key]: C.target.value }),
2493
+ required: m.required,
2494
+ className: i,
2495
+ placeholder: a(m.placeholder || "")
2496
+ }
2497
+ )
2498
+ ]
2499
+ },
2500
+ m.key
2501
+ ) : null),
2502
+ F && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: F }),
2503
+ /* @__PURE__ */ e(ae, { type: "submit", disabled: W, className: "w-full font-semibold", children: W ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up") })
2504
+ ] })
2505
+ ] })
2506
+ }
2507
+ );
1917
2508
  }
1918
- function Da() {
1919
- const { shareId: a } = Zt(), [t, i] = T(null), [m, c] = T(!0), [u, g] = T(null), { MessageList: f } = re(), h = ae(/* @__PURE__ */ new Set());
1920
- return $(() => () => {
1921
- h.current.forEach((N) => URL.revokeObjectURL(N)), h.current.clear();
1922
- }, []), $(() => {
2509
+ function Fa() {
2510
+ const { shareId: a } = aa(), [t, d] = _(null), [o, n] = _(!0), [i, r] = _(null), { MessageList: u } = ne(), c = oe(), y = re(/* @__PURE__ */ new Set());
2511
+ return B(() => () => {
2512
+ y.current.forEach((k) => URL.revokeObjectURL(k)), y.current.clear();
2513
+ }, []), B(() => {
1923
2514
  if (!a) return;
1924
2515
  (async () => {
1925
2516
  try {
1926
- c(!0);
1927
- const y = await D.getSharedThread(a);
1928
- y.items && (y.items = await Promise.all(
1929
- y.items.map(async (C) => {
1930
- if (!C.parts) return C;
1931
- const s = await Promise.all(
1932
- C.parts.map(async (M) => {
1933
- if (M.type === "file" && M.object_name && !M.url)
2517
+ n(!0);
2518
+ const g = await c.getSharedThread(a);
2519
+ g.items && (g.items = await Promise.all(
2520
+ g.items.map(async (p) => {
2521
+ if (!p.parts) return p;
2522
+ const A = await Promise.all(
2523
+ p.parts.map(async (P) => {
2524
+ const I = ge(P);
2525
+ if (I.type === "file" && I.object_name && !I.url)
1934
2526
  try {
1935
- const P = await D.getPublicAttachmentBlobUrl(M.object_name);
1936
- return h.current.add(P), { ...M, url: P };
1937
- } catch (P) {
1938
- console.error("Failed to resolve shared attachment:", M.object_name, P);
2527
+ const E = await c.getPublicAttachmentBlobUrl(I.object_name);
2528
+ return y.current.add(E), { ...I, url: E };
2529
+ } catch (E) {
2530
+ console.error("Failed to resolve shared attachment:", I.object_name, E);
1939
2531
  }
1940
- return M;
2532
+ return I;
1941
2533
  })
1942
2534
  );
1943
- return { ...C, parts: s };
2535
+ return { ...p, parts: A };
1944
2536
  })
1945
- )), i(y);
1946
- } catch (y) {
1947
- console.error("Failed to fetch shared chat:", y), g(y.message || "Failed to load shared chat");
2537
+ )), d(g);
2538
+ } catch (g) {
2539
+ console.error("Failed to fetch shared chat:", g), r(g instanceof Error ? g.message : "Failed to load shared chat");
1948
2540
  } finally {
1949
- c(!1);
2541
+ n(!1);
1950
2542
  }
1951
2543
  })();
1952
- }, [a]), m ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(vt, {}) }) : u || !t ? /* @__PURE__ */ r("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
2544
+ }, [a, c]), o ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(Nt, {}) }) : i || !t ? /* @__PURE__ */ s("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
1953
2545
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-destructive mb-2 font-display", children: "Shared Chat Not Found" }),
1954
- /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: u || "This shared conversation might have been deleted or the link is invalid." })
1955
- ] }) : /* @__PURE__ */ r("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
1956
- /* @__PURE__ */ e(Xe, { hideActions: !0 }),
1957
- /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 overflow-hidden relative flex flex-col", children: /* @__PURE__ */ e(Oe, { readonly: !0, children: /* @__PURE__ */ e(
1958
- f,
2546
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: i || "This shared conversation might have been deleted or the link is invalid." })
2547
+ ] }) : /* @__PURE__ */ s("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
2548
+ /* @__PURE__ */ e(Ye, { hideActions: !0 }),
2549
+ /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 overflow-hidden relative flex flex-col", children: /* @__PURE__ */ e(He, { readonly: !0, children: /* @__PURE__ */ e(
2550
+ u,
1959
2551
  {
1960
2552
  messages: t.items || [],
1961
2553
  status: "ready",
@@ -1972,47 +2564,48 @@ function Da() {
1972
2564
  ) }) })
1973
2565
  ] });
1974
2566
  }
1975
- function Ja() {
1976
- return /* @__PURE__ */ e(Da, {});
2567
+ function rr() {
2568
+ return /* @__PURE__ */ e(Fa, {});
1977
2569
  }
1978
2570
  export {
1979
- Ia as AppSidebar,
1980
- oa as Chat,
1981
- Ga as ChatUI,
1982
- sr as ChoiceQuestionPart,
1983
- or as FilePart,
1984
- Va as GentiqProvider,
1985
- ir as MessageList,
1986
- lr as Part,
1987
- cr as PromptInputArea,
1988
- dr as ReasoningPart,
1989
- ur as ReferencePart,
1990
- mr as Referenceable,
1991
- Wa as RequireAuth,
1992
- xe as Select,
1993
- we as SelectContent,
1994
- hr as SelectGroup,
1995
- pe as SelectItem,
1996
- pr as SelectLabel,
1997
- gr as SelectScrollDownButton,
1998
- fr as SelectScrollUpButton,
1999
- br as SelectSeparator,
2000
- ve as SelectTrigger,
2001
- ye as SelectValue,
2002
- Pa as SettingsDialog,
2003
- Ja as SharedChatView,
2004
- ya as SidebarProvider,
2005
- xr as TextPart,
2006
- vr as ToolPart,
2007
- er as Trans,
2008
- tr as Translation,
2009
- Xa as UserLoginPage,
2010
- yr as WelcomeScreen,
2011
- wr as useChatReferences,
2012
- re as useComponents,
2013
- na as useGentiqChat,
2014
- Nr as useGentiqUser,
2015
- ar as useTranslation,
2016
- D as userAPI,
2017
- rr as withTranslation
2571
+ La as AppSidebar,
2572
+ ha as Chat,
2573
+ er as ChatUI,
2574
+ ur as ChoiceQuestionPart,
2575
+ hr as FilePart,
2576
+ Za as GentiqProvider,
2577
+ pr as MessageList,
2578
+ mr as Part,
2579
+ gr as PromptInputArea,
2580
+ fr as ReasoningPart,
2581
+ br as ReferencePart,
2582
+ yr as Referenceable,
2583
+ tr as RequireAuth,
2584
+ we as Select,
2585
+ Se as SelectContent,
2586
+ vr as SelectGroup,
2587
+ fe as SelectItem,
2588
+ xr as SelectLabel,
2589
+ wr as SelectScrollDownButton,
2590
+ Nr as SelectScrollUpButton,
2591
+ kr as SelectSeparator,
2592
+ Ne as SelectTrigger,
2593
+ ke as SelectValue,
2594
+ Ra as SettingsDialog,
2595
+ rr as SharedChatView,
2596
+ _a as SidebarProvider,
2597
+ Sr as TextPart,
2598
+ Cr as ToolPart,
2599
+ or as Trans,
2600
+ ir as Translation,
2601
+ ar as UserLoginPage,
2602
+ _r as WelcomeScreen,
2603
+ la as createGentiqApi,
2604
+ Tr as useChatReferences,
2605
+ ne as useComponents,
2606
+ oe as useGentiqApi,
2607
+ da as useGentiqChat,
2608
+ Pr as useGentiqUser,
2609
+ lr as useTranslation,
2610
+ cr as withTranslation
2018
2611
  };