gentiq 0.7.31 → 0.7.32

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.
@@ -1,35 +1,35 @@
1
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 P, useMemo as j, useEffect as O, useRef as te, useCallback as Y, useLayoutEffect as Je } from "react";
4
- import { QueryClient as Ye, QueryClientProvider as Ze, useQueryClient as pe, useQuery as et, useInfiniteQuery as tt } from "@tanstack/react-query";
5
- import { I18nextProvider as at, useTranslation as ce } from "react-i18next";
6
- import { Trans as Ya, Translation as Za, useTranslation as er, withTranslation as tr } from "react-i18next";
7
- import { g as rt, u as D, d as nt, C as Fe, T as st, a as re, b as je, j as be, G as Pe, c as le, e as f, f as ot, h as Oe, i as $e, k as Be, l as Ue, B as Z, m as Ke, n as he, D as He, o as it, p as Ve, L as V, I as X, S as ve, q as xe, r as ye, s as we, t as me, v as lt, w as Te, x as ct, y as dt, z as ut, A as de, E as mt, F as ht, H as pt, J as gt, K as ft, M as bt } from "./checkbox-CXJMAW8-.js";
8
- import { N as rr, O as nr, P as sr, Q as or, R as ir, U as lr, V as cr, W as dr, X as ur, Y as mr, Z as hr, _ as pr, $ as gr } from "./checkbox-CXJMAW8-.js";
9
- import { Loader2Icon as vt, OctagonXIcon as xt, TriangleAlertIcon as yt, InfoIcon as wt, CircleCheckIcon as Nt, XIcon as kt, PanelLeftIcon as _t, Layers as Me, User as Ct, ShieldCheck as St, Settings as Ne, Smartphone as Pt, Lock as Tt, Save as Mt, Sun as It, Moon as Dt, Monitor as Et, Zap as Ie, Globe as At, Coins as Lt, LogOut as zt, CirclePlus as Rt, Plus as qt, Search as Ft, Check as jt, X as Ot, Pin as De, MoreVertical as $t, PinOff as Bt, Share2 as Ut, Pencil as Kt, Trash as Ht } from "lucide-react";
2
+ import * as ae from "react";
3
+ import { useState as T, useMemo as R, useEffect as F, useRef as Z, useCallback as J, useLayoutEffect as Je } from "react";
4
+ import { QueryClient as Ye, QueryClientProvider as Ze, useQueryClient as ue, useQuery as et, useInfiniteQuery as tt } from "@tanstack/react-query";
5
+ import { I18nextProvider as at, useTranslation as de } from "react-i18next";
6
+ import { Trans as Za, Translation as er, useTranslation as tr, withTranslation as ar } from "react-i18next";
7
+ import { g as rt, u as E, d as nt, C as Fe, T as st, a as te, b as je, j as be, G as Pe, c as ce, e as v, f as ot, h as Oe, i as $e, k as Ue, l as Be, B as Y, m as Ke, n as ge, D as He, o as it, p as Qe, L as Q, I as W, S as ve, q as xe, r as ye, s as we, t as pe, v as lt, w as ct, x as Te, y as dt, z as ut, A as mt, E as me, F as ht, H as pt, J as gt, K as ft, M as bt, N as vt } from "./checkbox-CdPG-d34.js";
8
+ import { O as nr, P as sr, Q as or, R as ir, U as lr, V as cr, W as dr, X as ur, Y as mr, Z as hr, _ as pr, $ as gr, a0 as fr, a1 as br } from "./checkbox-CdPG-d34.js";
9
+ import { Loader2Icon as xt, OctagonXIcon as yt, TriangleAlertIcon as wt, InfoIcon as Nt, CircleCheckIcon as kt, XIcon as _t, PanelLeftIcon as Ct, Layers as Me, User as St, ShieldCheck as Pt, Settings as Ne, Smartphone as Tt, Lock as Mt, Save as Dt, Sun as It, Moon as Et, Monitor as At, Zap as De, Globe as Lt, Coins as zt, LogOut as qt, CirclePlus as Rt, Plus as Ft, Search as jt, Check as Ot, X as $t, Pin as Ie, MoreVertical as Ut, PinOff as Bt, Share2 as Kt, Pencil as Ht, Trash as Qt } from "lucide-react";
10
10
  import { useTheme as Vt } from "next-themes";
11
- import { Toaster as Qt, toast as J } from "sonner";
12
- import { useChat as Gt } from "@ai-sdk/react";
13
- import { DefaultChatTransport as Wt } from "ai";
14
- import { useLocation as Qe, useNavigate as _e, Navigate as Xt, useParams as Jt } from "react-router-dom";
15
- import { nanoid as ue } from "nanoid";
16
- import { Slot as Yt } from "@radix-ui/react-slot";
17
- import { cva as Zt } from "class-variance-authority";
11
+ import { Toaster as Gt, toast as X } from "sonner";
12
+ import { useChat as Wt } from "@ai-sdk/react";
13
+ import { DefaultChatTransport as Xt } from "ai";
14
+ import { useLocation as Ve, useNavigate as _e, Navigate as Jt, useParams as Yt } from "react-router-dom";
15
+ import { nanoid as he } from "nanoid";
16
+ import { Slot as Zt } from "@radix-ui/react-slot";
17
+ import { cva as ea } from "class-variance-authority";
18
18
  import "@radix-ui/react-separator";
19
- import * as se from "@radix-ui/react-dialog";
20
- const ea = ({ ...a }) => {
19
+ import * as oe from "@radix-ui/react-dialog";
20
+ const ta = ({ ...a }) => {
21
21
  const { theme: t = "system" } = Vt();
22
22
  return /* @__PURE__ */ e(
23
- Qt,
23
+ Gt,
24
24
  {
25
25
  theme: t,
26
26
  className: "toaster group",
27
27
  icons: {
28
- success: /* @__PURE__ */ e(Nt, { className: "size-4" }),
29
- info: /* @__PURE__ */ e(wt, { className: "size-4" }),
30
- warning: /* @__PURE__ */ e(yt, { className: "size-4" }),
31
- error: /* @__PURE__ */ e(xt, { className: "size-4" }),
32
- loading: /* @__PURE__ */ e(vt, { className: "size-4 animate-spin" })
28
+ success: /* @__PURE__ */ e(kt, { className: "size-4" }),
29
+ info: /* @__PURE__ */ e(Nt, { className: "size-4" }),
30
+ warning: /* @__PURE__ */ e(wt, { className: "size-4" }),
31
+ error: /* @__PURE__ */ e(yt, { className: "size-4" }),
32
+ loading: /* @__PURE__ */ e(xt, { className: "size-4 animate-spin" })
33
33
  },
34
34
  style: {
35
35
  "--normal-bg": "var(--popover)",
@@ -41,111 +41,115 @@ const ea = ({ ...a }) => {
41
41
  }
42
42
  );
43
43
  };
44
- function Ha({
44
+ function Qa({
45
45
  children: a,
46
46
  api: t,
47
- app: i,
47
+ app: o,
48
48
  i18n: u,
49
49
  components: l,
50
50
  history: d,
51
51
  welcome: h,
52
52
  threadActions: p,
53
53
  composer: m,
54
- theme: N,
55
- disclaimer: v,
56
- settings: k
54
+ theme: w,
55
+ disclaimer: x,
56
+ settings: C
57
57
  }) {
58
- const [s, M] = P(null), T = j(
58
+ const [n, D] = T(null), P = R(
59
59
  () => u?.instance ?? rt,
60
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
61
61
  [u?.instance]
62
- ), q = t || {};
63
- O(() => {
64
- D.getAppConfig().then((x) => M(x)).catch((x) => console.debug("Gentiq: No dynamic settings available or fetch failed", x));
65
- }, []), O(() => {
66
- s?.app_name && (document.title = T.t(s.app_name));
67
- }, [s, T]);
68
- const K = j(() => {
69
- const x = {
62
+ ), j = t || {};
63
+ F(() => {
64
+ E.getAppConfig().then((b) => D(b)).catch((b) => console.debug("Gentiq: No dynamic settings available or fetch failed", b));
65
+ }, []), F(() => {
66
+ n?.app_name && (document.title = P.t(n.app_name));
67
+ }, [n, P]);
68
+ const U = R(() => {
69
+ const b = {
70
70
  basePath: "/",
71
71
  cacheNamespace: "gentiq",
72
- ...i
72
+ ...o
73
73
  };
74
- return s ? {
75
- ...x,
76
- name: (s.app_name ? T.t(s.app_name) : null) || x.name,
77
- adminTitle: (s.admin_title ? T.t(s.admin_title) : null) || x.adminTitle,
78
- version: s.app_version || x.version,
79
- showSettings: s.show_settings ?? x.showSettings,
80
- showVersionInSettings: s.show_version_in_settings ?? x.showVersionInSettings,
81
- showToolDetails: s.show_tool_details ?? x.showToolDetails,
82
- disableSignup: s.disable_signup ?? x.disableSignup,
83
- disableAuthPage: s.disable_auth_page ?? x.disableAuthPage,
84
- settingsGeneralMode: s.settings_general_mode || x.settingsGeneralMode,
85
- settingsProfileMode: s.settings_profile_mode || x.settingsProfileMode,
86
- settingsAccountMode: s.settings_account_mode || x.settingsAccountMode
87
- } : x;
88
- }, [i, s, T]), S = j(() => s ? {
89
- ...h,
90
- greeting: s.welcome_greeting || h?.greeting,
91
- subtitle: s.welcome_subtitle || h?.subtitle
92
- } : h, [h, s]), y = j(() => {
93
- const x = s?.disclaimer || v;
94
- return x && T.t(x);
95
- }, [v, s, T]), g = j(() => s ? {
74
+ return n ? {
75
+ ...b,
76
+ name: (n.app_name ? P.t(n.app_name) : null) || b.name,
77
+ adminTitle: (n.admin_title ? P.t(n.admin_title) : null) || b.adminTitle,
78
+ version: n.app_version || b.version,
79
+ showSettings: n.show_settings ?? b.showSettings,
80
+ showVersionInSettings: n.show_version_in_settings ?? b.showVersionInSettings,
81
+ showToolDetails: n.show_tool_details ?? b.showToolDetails,
82
+ disableSignup: n.disable_signup ?? b.disableSignup,
83
+ disableAuthPage: n.disable_auth_page ?? b.disableAuthPage,
84
+ settingsGeneralMode: n.settings_general_mode || b.settingsGeneralMode,
85
+ settingsProfileMode: n.settings_profile_mode || b.settingsProfileMode,
86
+ settingsAccountMode: n.settings_account_mode || b.settingsAccountMode
87
+ } : b;
88
+ }, [o, n, P]), I = R(() => {
89
+ if (!n) return h;
90
+ const b = typeof h?.greeting == "function" ? h.greeting : n.welcome_greeting || h?.greeting;
91
+ return {
92
+ ...h,
93
+ greeting: b,
94
+ subtitle: n.welcome_subtitle || h?.subtitle
95
+ };
96
+ }, [h, n]), f = R(() => {
97
+ const b = n?.disclaimer || x;
98
+ return b && P.t(b);
99
+ }, [x, n, P]), q = R(() => n ? {
96
100
  ...d,
97
- enabled: s.history_enabled ?? d?.enabled,
98
- showDelete: s.history_show_delete ?? d?.showDelete,
99
- showRename: s.history_show_rename ?? d?.showRename,
100
- showShare: s.history_show_share ?? d?.showShare,
101
- showPin: s.history_show_pin ?? d?.showPin
102
- } : d, [d, s]), z = j(() => s ? {
101
+ enabled: n.history_enabled ?? d?.enabled,
102
+ showDelete: n.history_show_delete ?? d?.showDelete,
103
+ showRename: n.history_show_rename ?? d?.showRename,
104
+ showShare: n.history_show_share ?? d?.showShare,
105
+ showPin: n.history_show_pin ?? d?.showPin
106
+ } : d, [d, n]), g = R(() => n ? {
103
107
  ...p,
104
- feedback: s.thread_actions_feedback ?? p?.feedback,
105
- retry: s.thread_actions_retry ?? p?.retry
106
- } : p, [p, s]), B = j(() => s ? {
108
+ feedback: n.thread_actions_feedback ?? p?.feedback,
109
+ retry: n.thread_actions_retry ?? p?.retry
110
+ } : p, [p, n]), B = R(() => n ? {
107
111
  ...m,
108
112
  attachments: {
109
113
  ...m?.attachments,
110
- enabled: s.composer_attachments ?? m?.attachments?.enabled
114
+ enabled: n.composer_attachments ?? m?.attachments?.enabled
111
115
  }
112
- } : m, [m, s]), G = j(() => ({
113
- ...N,
114
- defaultTheme: s?.default_theme ?? N?.defaultTheme,
115
- accent: s?.default_accent ?? N?.accent
116
- }), [N, s]), $ = j(() => s ? {
117
- ...k,
116
+ } : m, [m, n]), V = R(() => ({
117
+ ...w,
118
+ defaultTheme: n?.default_theme ?? w?.defaultTheme,
119
+ accent: n?.default_accent ?? w?.accent
120
+ }), [w, n]), O = R(() => n ? {
121
+ ...C,
118
122
  sections: {
119
- ...k?.sections,
123
+ ...C?.sections,
120
124
  general: {
121
- ...k?.sections?.general,
122
- mode: s.settings_general_mode || k?.sections?.general?.mode,
123
- enabled: k?.sections?.general?.enabled ?? !0,
125
+ ...C?.sections?.general,
126
+ mode: n.settings_general_mode || C?.sections?.general?.mode,
127
+ enabled: C?.sections?.general?.enabled ?? !0,
124
128
  fields: {
125
- ...k?.sections?.general?.fields,
126
- ...s.settings_general_fields
129
+ ...C?.sections?.general?.fields,
130
+ ...n.settings_general_fields
127
131
  }
128
132
  },
129
133
  profile: {
130
- ...k?.sections?.profile,
131
- mode: s.settings_profile_mode || k?.sections?.profile?.mode,
132
- enabled: k?.sections?.profile?.enabled ?? !0,
134
+ ...C?.sections?.profile,
135
+ mode: n.settings_profile_mode || C?.sections?.profile?.mode,
136
+ enabled: C?.sections?.profile?.enabled ?? !0,
133
137
  fields: {
134
- ...k?.sections?.profile?.fields,
135
- ...s.settings_profile_fields
138
+ ...C?.sections?.profile?.fields,
139
+ ...n.settings_profile_fields
136
140
  }
137
141
  },
138
142
  account: {
139
- ...k?.sections?.account,
140
- mode: s.settings_account_mode || k?.sections?.account?.mode,
141
- enabled: k?.sections?.account?.enabled ?? !0,
143
+ ...C?.sections?.account,
144
+ mode: n.settings_account_mode || C?.sections?.account?.mode,
145
+ enabled: C?.sections?.account?.enabled ?? !0,
142
146
  fields: {
143
- ...k?.sections?.account?.fields,
144
- ...s.settings_account_fields
147
+ ...C?.sections?.account?.fields,
148
+ ...n.settings_account_fields
145
149
  }
146
150
  }
147
151
  }
148
- } : k, [k, s]), A = j(() => new Ye({
152
+ } : C, [C, n]), z = R(() => new Ye({
149
153
  defaultOptions: {
150
154
  queries: {
151
155
  staleTime: 5e3,
@@ -153,114 +157,114 @@ function Ha({
153
157
  }
154
158
  }
155
159
  }), []);
156
- O(() => {
157
- D.init({
158
- api: q,
159
- app: K
160
+ F(() => {
161
+ E.init({
162
+ api: j,
163
+ app: U
160
164
  });
161
- }, [K]);
162
- const U = te(null), E = u?.resources;
163
- E !== U.current && (U.current = E, E && Object.entries(E).forEach(([x, c]) => {
164
- Object.entries(c).forEach(([w, L]) => {
165
- T.addResourceBundle(x, w, L, !0, !0);
165
+ }, [U]);
166
+ const K = Z(null), L = u?.resources;
167
+ L !== K.current && (K.current = L, L && Object.entries(L).forEach(([b, c]) => {
168
+ Object.entries(c).forEach(([k, A]) => {
169
+ P.addResourceBundle(b, k, A, !0, !0);
166
170
  });
167
171
  }));
168
- const Q = te(null), R = s?.translations;
169
- R && R !== Q.current && (Q.current = R, Object.entries(R).forEach(([x, c]) => {
170
- Object.entries(c).forEach(([w, L]) => {
171
- T.addResourceBundle(x, w, L, !0, !0);
172
+ const H = Z(null), $ = n?.translations;
173
+ $ && $ !== H.current && (H.current = $, Object.entries($).forEach(([b, c]) => {
174
+ Object.entries(c).forEach(([k, A]) => {
175
+ P.addResourceBundle(b, k, A, !0, !0);
172
176
  });
173
177
  }));
174
- const b = te(null), _ = u?.instance;
175
- return _ && _ !== b.current && (b.current = _, Object.entries(nt).forEach(([x, c]) => {
176
- Object.entries(c).forEach(([w, L]) => {
177
- _.hasResourceBundle(x, w) || _.addResourceBundle(x, w, L, !0, !1);
178
+ const N = Z(null), y = u?.instance;
179
+ return y && y !== N.current && (N.current = y, Object.entries(nt).forEach(([b, c]) => {
180
+ Object.entries(c).forEach(([k, A]) => {
181
+ y.hasResourceBundle(b, k) || y.addResourceBundle(b, k, A, !0, !1);
178
182
  });
179
- })), /* @__PURE__ */ e(at, { i18n: T, children: /* @__PURE__ */ r(Ze, { client: A, children: [
183
+ })), /* @__PURE__ */ e(at, { i18n: P, children: /* @__PURE__ */ r(Ze, { client: z, children: [
180
184
  /* @__PURE__ */ r(
181
185
  Fe,
182
186
  {
183
187
  components: l,
184
- history: g,
185
- welcome: S,
186
- threadActions: z,
188
+ history: q,
189
+ welcome: I,
190
+ threadActions: g,
187
191
  composer: B,
188
- theme: G,
189
- disclaimer: y,
190
- app: K,
192
+ theme: V,
193
+ disclaimer: f,
194
+ app: U,
191
195
  i18n: u,
192
- settings: $,
196
+ settings: O,
193
197
  children: [
194
- /* @__PURE__ */ e(ta, {}),
195
- /* @__PURE__ */ e(st, { defaultTheme: "system", storageKey: "chatbot-theme", config: G, children: a })
198
+ /* @__PURE__ */ e(aa, {}),
199
+ /* @__PURE__ */ e(st, { defaultTheme: "system", storageKey: "chatbot-theme", config: V, children: a })
196
200
  ]
197
201
  }
198
202
  ),
199
- /* @__PURE__ */ e(ea, { richColors: !0 })
203
+ /* @__PURE__ */ e(ta, { richColors: !0 })
200
204
  ] }) });
201
205
  }
202
- function ta() {
203
- const { app: a } = re();
204
- return je(), O(() => {
206
+ function aa() {
207
+ const { app: a } = te();
208
+ return je(), F(() => {
205
209
  a?.name && (document.title = a.name);
206
- }, [a?.name]), O(() => {
210
+ }, [a?.name]), F(() => {
207
211
  if (!a?.favicon) return;
208
212
  let t = document.querySelector("link[rel~='icon']");
209
213
  t || (t = document.createElement("link"), t.rel = "icon", document.head.appendChild(t)), t.href = a.favicon;
210
214
  }, [a?.favicon]), null;
211
215
  }
212
216
  function Ce() {
213
- const a = Qe(), t = _e(), u = D.getConfig().app?.basePath || "/", l = j(() => {
217
+ const a = Ve(), t = _e(), u = E.getConfig().app?.basePath || "/", l = R(() => {
214
218
  const h = a.pathname, p = h.endsWith("/") && h !== "/" ? h.slice(0, -1) : h, m = u.endsWith("/") && u !== "/" ? u.slice(0, -1) : u;
215
219
  if (p === (m || "/")) return "/";
216
220
  if (h.startsWith(m) && m !== "/") {
217
- let N = h.slice(m.length);
218
- return N.startsWith("/") || (N = "/" + N), N;
221
+ let w = h.slice(m.length);
222
+ return w.startsWith("/") || (w = "/" + w), w;
219
223
  }
220
224
  return m === "/" ? h : "/";
221
- }, [a.pathname, u]), d = Y((h) => {
225
+ }, [a.pathname, u]), d = J((h) => {
222
226
  t(be(u, h || "/"), { replace: !1 });
223
227
  }, [t, u]);
224
228
  return [l, d];
225
229
  }
226
- function aa({ onFinish: a } = {}) {
227
- const { t } = ce(["chat", "errors"]), i = pe(), u = D.getConfig(), l = u.app?.cacheNamespace || "gentiq", [d, h] = Ce(), [p, m] = P(() => ue()), N = te(/* @__PURE__ */ new Set());
228
- O(() => {
229
- d === "/" ? m(ue()) : p && d !== `/${p}` && m(ue());
230
+ function ra({ onFinish: a } = {}) {
231
+ const { t } = de(["chat", "errors"]), o = ue(), u = E.getConfig(), l = u.app?.cacheNamespace || "gentiq", [d, h] = Ce(), [p, m] = T(() => he()), w = Z(/* @__PURE__ */ new Set());
232
+ F(() => {
233
+ d === "/" ? m(he()) : p && d !== `/${p}` && m(he());
230
234
  }, [d]);
231
- const v = j(() => d === "/" ? p : d.replace(/^\//, ""), [d, p]), k = Y((b) => (N.current.add(b), b), []), s = Y(() => {
232
- N.current.forEach((b) => URL.revokeObjectURL(b)), N.current.clear();
235
+ const x = R(() => d === "/" ? p : d.replace(/^\//, ""), [d, p]), C = J((N) => (w.current.add(N), N), []), n = J(() => {
236
+ w.current.forEach((N) => URL.revokeObjectURL(N)), w.current.clear();
233
237
  }, []);
234
- O(() => () => s(), [s]);
238
+ F(() => () => n(), [n]);
235
239
  const {
236
- data: M,
237
- isLoading: T,
238
- isError: q
240
+ data: D,
241
+ isLoading: P,
242
+ isError: j
239
243
  } = et({
240
- queryKey: [l, "threadMessages", v],
244
+ queryKey: [l, "threadMessages", x],
241
245
  queryFn: async () => {
242
246
  if (d === "/") return [];
243
247
  if (d === `/${p}`) return [];
244
- const b = await D.getThreadMessages(v);
245
- return !b.items || !Array.isArray(b.items) ? [] : Promise.all(
246
- b.items.map(async (_) => {
247
- const x = typeof _.content == "string" ? _.content : _.content?.text || JSON.stringify(_.content), w = [...Array.isArray(_.parts) && _.parts.length > 0 ? _.parts : [{ type: "text", text: x }]].sort((C, I) => C.type === "file" && I.type !== "file" ? -1 : C.type !== "file" && I.type === "file" ? 1 : 0), L = await Promise.all(
248
- w.map(async (C) => {
249
- if (C.type === "file" && C.object_name && !C.url)
248
+ const N = await E.getThreadMessages(x);
249
+ return !N.items || !Array.isArray(N.items) ? [] : Promise.all(
250
+ N.items.map(async (y) => {
251
+ const b = typeof y.content == "string" ? y.content : y.content?.text || JSON.stringify(y.content), k = [...Array.isArray(y.parts) && y.parts.length > 0 ? y.parts : [{ type: "text", text: b }]].sort((S, M) => S.type === "file" && M.type !== "file" ? -1 : S.type !== "file" && M.type === "file" ? 1 : 0), A = await Promise.all(
252
+ k.map(async (S) => {
253
+ if (S.type === "file" && S.object_name && !S.url)
250
254
  try {
251
- const I = await D.getAttachmentBlobUrl(C.object_name);
252
- return { ...C, url: k(I), mediaType: C.mediaType || C.media_type };
253
- } catch (I) {
254
- return console.warn("Load attachment failed:", C.object_name, I), { ...C, mediaType: C.mediaType || C.media_type };
255
+ const M = await E.getAttachmentBlobUrl(S.object_name);
256
+ return { ...S, url: C(M), mediaType: S.mediaType || S.media_type };
257
+ } catch (M) {
258
+ return console.warn("Load attachment failed:", S.object_name, M), { ...S, mediaType: S.mediaType || S.media_type };
255
259
  }
256
- return C;
260
+ return S;
257
261
  })
258
262
  );
259
263
  return {
260
- id: _.id || ue(),
261
- role: _.role,
262
- parts: L,
263
- metadata: { feedback: _.feedback }
264
+ id: y.id || he(),
265
+ role: y.role,
266
+ parts: A,
267
+ metadata: { feedback: y.feedback }
264
268
  };
265
269
  })
266
270
  );
@@ -268,167 +272,167 @@ function aa({ onFinish: a } = {}) {
268
272
  enabled: d !== "/",
269
273
  staleTime: 5e3
270
274
  // Keep history fresh for 5 seconds
271
- }), K = j(() => new Wt({
272
- api: D.getEndpoint("chat", "/chat"),
273
- fetch: async (b, _) => {
274
- const x = new Headers(_?.headers), c = D.getHeaders();
275
- Object.entries(c).forEach(([I, W]) => {
276
- x.set(I, W);
277
- }), x.set("X-Thread-Id", v);
278
- const w = u.api?.basePath || "/api", L = typeof b == "string" && !b.startsWith("http") ? `${w}${b.startsWith("/") ? b : "/" + b}` : b, C = await fetch(L, { ..._, headers: x });
279
- if (!C.ok) {
280
- const I = await C.json().catch(() => ({}));
281
- if (I.error && (typeof I.error.code == "string" || typeof I.error.message == "string"))
282
- throw new Pe(I, C.status);
283
- let W = C.statusText || `HTTP ${C.status}`, ae = "error", ee = null;
284
- throw typeof I.detail == "string" ? W = I.detail : typeof I.message == "string" ? W = I.message : typeof I.error == "string" ? W = I.error : Array.isArray(I.detail) ? (W = "Validation failed", ee = I.detail, ae = "validation_error") : I.error && typeof I.error.message == "string" && (W = I.error.message), new Pe({
275
+ }), U = R(() => new Xt({
276
+ api: E.getEndpoint("chat", "/chat"),
277
+ fetch: async (N, y) => {
278
+ const b = new Headers(y?.headers), c = E.getHeaders();
279
+ Object.entries(c).forEach(([M, G]) => {
280
+ b.set(M, G);
281
+ }), b.set("X-Thread-Id", x);
282
+ const k = u.api?.basePath || "/api", A = typeof N == "string" && !N.startsWith("http") ? `${k}${N.startsWith("/") ? N : "/" + N}` : N, S = await fetch(A, { ...y, headers: b });
283
+ if (!S.ok) {
284
+ const M = await S.json().catch(() => ({}));
285
+ if (M.error && (typeof M.error.code == "string" || typeof M.error.message == "string"))
286
+ throw new Pe(M, S.status);
287
+ let G = S.statusText || `HTTP ${S.status}`, ee = "error", re = null;
288
+ throw typeof M.detail == "string" ? G = M.detail : typeof M.message == "string" ? G = M.message : typeof M.error == "string" ? G = M.error : Array.isArray(M.detail) ? (G = "Validation failed", re = M.detail, ee = "validation_error") : M.error && typeof M.error.message == "string" && (G = M.error.message), new Pe({
285
289
  error: {
286
- code: ae,
287
- message: W,
288
- details: ee
290
+ code: ee,
291
+ message: G,
292
+ details: re
289
293
  }
290
- }, C.status);
294
+ }, S.status);
291
295
  }
292
- return C;
296
+ return S;
293
297
  }
294
- }), [v, u.api?.basePath]), S = Y(() => {
295
- z("ready"), i.invalidateQueries({ queryKey: [l, "conversations"] }), a?.();
296
- }, [i, a, l]), y = Gt({
297
- id: v,
298
- onFinish: S,
299
- transport: K
300
- }), [g, z] = P("idle"), [B, G] = P(null), $ = Y(() => {
301
- G(null);
298
+ }), [x, u.api?.basePath]), I = J(() => {
299
+ g("ready"), o.invalidateQueries({ queryKey: [l, "conversations"] }), a?.();
300
+ }, [o, a, l]), f = Wt({
301
+ id: x,
302
+ onFinish: I,
303
+ transport: U
304
+ }), [q, g] = T("idle"), [B, V] = T(null), O = J(() => {
305
+ V(null);
302
306
  }, []);
303
- O(() => {
304
- M && (d === `/${p}` || (y.setMessages(M), z("ready")));
305
- }, [M, y.setMessages, d, p]), O(() => {
306
- d === "/" && (y.setMessages([]), z("idle"));
307
- }, [d, y.setMessages]), O(() => {
307
+ F(() => {
308
+ D && (d === `/${p}` || (f.setMessages(D), g("ready")));
309
+ }, [D, f.setMessages, d, p]), F(() => {
310
+ d === "/" && (f.setMessages([]), g("idle"));
311
+ }, [d, f.setMessages]), F(() => {
308
312
  if (d === "/") {
309
- z("idle");
313
+ g("idle");
310
314
  return;
311
315
  }
312
- const b = d === `/${p}`;
313
- T && !b ? z("loading-history") : q || B || y.error ? z("error") : y.status === "streaming" || y.status === "submitted" ? z(y.status) : z("ready");
314
- }, [T, q, y.status, B, y.error, d, p]), O(() => () => {
315
- y.stop();
316
- }, [v, y.stop]);
317
- const A = te(/* @__PURE__ */ new Set()), U = j(() => y.messages.filter((b) => b.role === "assistant"), [y.messages]);
318
- O(() => {
319
- let b = !1;
320
- for (const _ of U) {
321
- if (A.current.has(_.id)) continue;
322
- const x = _.parts.find((c) => c.type === "data-title");
323
- x && x.data?.[0]?.title && (A.current.add(_.id), b = !0);
316
+ const N = d === `/${p}`;
317
+ P && !N ? g("loading-history") : j || B || f.error ? g("error") : f.status === "streaming" || f.status === "submitted" ? g(f.status) : g("ready");
318
+ }, [P, j, f.status, B, f.error, d, p]), F(() => () => {
319
+ f.stop();
320
+ }, [x, f.stop]);
321
+ const z = Z(/* @__PURE__ */ new Set()), K = R(() => f.messages.filter((N) => N.role === "assistant"), [f.messages]);
322
+ F(() => {
323
+ let N = !1;
324
+ for (const y of K) {
325
+ if (z.current.has(y.id)) continue;
326
+ const b = y.parts.find((c) => c.type === "data-title");
327
+ b && b.data?.[0]?.title && (z.current.add(y.id), N = !0);
324
328
  }
325
- b && i.invalidateQueries({ queryKey: [l, "conversations"] });
326
- }, [U, i, l]);
327
- const E = Y(async (b, _) => {
328
- const x = d === "/", c = b.trim();
329
- if (!(!c && (!_ || _.length === 0)) && !(g === "loading-history" || g === "streaming" || g === "submitted")) {
330
- if (y.stop(), x) {
331
- h(`/${v}`);
332
- const w = c || t("attach_file"), L = w.length > 30 ? w.slice(0, 30) + "..." : w;
333
- i.setQueryData([l, "conversations"], (C) => {
334
- const I = { id: `/${v}`, firstMessage: L, timestamp: Date.now() };
335
- return C && Array.isArray(C.pages) ? {
336
- ...C,
337
- pages: C.pages.map((W, ae) => ae === 0 ? {
338
- ...W,
339
- threads: [I, ...W.threads || []]
340
- } : W)
341
- } : [I, ...Array.isArray(C) ? C : []];
329
+ N && o.invalidateQueries({ queryKey: [l, "conversations"] });
330
+ }, [K, o, l]);
331
+ const L = J(async (N, y) => {
332
+ const b = d === "/", c = N.trim();
333
+ if (!(!c && (!y || y.length === 0)) && !(q === "loading-history" || q === "streaming" || q === "submitted")) {
334
+ if (f.stop(), b) {
335
+ h(`/${x}`);
336
+ const k = c || t("attach_file"), A = k.length > 30 ? k.slice(0, 30) + "..." : k;
337
+ o.setQueryData([l, "conversations"], (S) => {
338
+ const M = { id: `/${x}`, firstMessage: A, timestamp: Date.now() };
339
+ return S && Array.isArray(S.pages) ? {
340
+ ...S,
341
+ pages: S.pages.map((G, ee) => ee === 0 ? {
342
+ ...G,
343
+ threads: [M, ...G.threads || []]
344
+ } : G)
345
+ } : [M, ...Array.isArray(S) ? S : []];
342
346
  });
343
347
  }
344
- z("submitted"), G(null);
348
+ g("submitted"), V(null);
345
349
  try {
346
- await y.sendMessage({ text: c, files: _ });
347
- } catch (w) {
348
- console.error("Failed to send message:", w);
349
- const L = le(w, t);
350
- G(new Error(L)), z("error");
350
+ await f.sendMessage({ text: c, files: y });
351
+ } catch (k) {
352
+ console.error("Failed to send message:", k);
353
+ const A = ce(k, t);
354
+ V(new Error(A)), g("error");
351
355
  }
352
356
  }
353
- }, [y, h, d, v, t, i, g, l]), Q = Y(() => {
354
- y.stop(), z("ready"), i.invalidateQueries({ queryKey: [l, "conversations"] });
355
- }, [y.stop, i, l]), R = j(() => {
357
+ }, [f, h, d, x, t, o, q, l]), H = J(() => {
358
+ f.stop(), g("ready"), o.invalidateQueries({ queryKey: [l, "conversations"] });
359
+ }, [f.stop, o, l]), $ = R(() => {
356
360
  if (B) return B;
357
- if (y.error) {
358
- const b = le(y.error, t);
359
- return new Error(b);
361
+ if (f.error) {
362
+ const N = ce(f.error, t);
363
+ return new Error(N);
360
364
  }
361
365
  return null;
362
- }, [B, y.error, t]);
363
- return j(() => ({
364
- ...y,
365
- sendMessage: E,
366
- stop: Q,
367
- clearError: $,
368
- error: R,
369
- status: g,
366
+ }, [B, f.error, t]);
367
+ return R(() => ({
368
+ ...f,
369
+ sendMessage: L,
370
+ stop: H,
371
+ clearError: O,
372
+ error: $,
373
+ status: q,
370
374
  // Cast to any to satisfy Chat.tsx expectations of AI SDK statuses
371
- isLoadingHistory: g === "loading-history",
372
- isErrorHistory: g === "error" || !!R || q,
375
+ isLoadingHistory: q === "loading-history",
376
+ isErrorHistory: q === "error" || !!$ || j,
373
377
  conversationId: d
374
- }), [y, E, Q, $, R, g, q, d]);
378
+ }), [f, L, H, O, $, q, j, d]);
375
379
  }
376
- function ra({ classNames: a = {}, disclaimer: t }) {
377
- const { t: i, i18n: u } = ce(["chat", "translation"]), l = aa(), { messages: d, status: h, regenerate: p, error: m, clearError: N, stop: v, isLoadingHistory: k, conversationId: s, sendMessage: M } = l, { MessageList: T, PromptInput: q, disclaimer: K } = re(), S = t ?? K, y = u.exists("chat:disclaimer") ? i("chat:disclaimer") : null, g = typeof S == "string" ? i(S) : S ?? y, [z, B] = P(null), G = te(h);
380
+ function na({ classNames: a = {}, disclaimer: t }) {
381
+ const { t: o, i18n: u } = de(["chat", "translation"]), l = ra(), { messages: d, status: h, regenerate: p, error: m, clearError: w, stop: x, isLoadingHistory: C, conversationId: n, sendMessage: D } = l, { MessageList: P, PromptInput: j, disclaimer: U } = te(), I = t ?? U, f = u.exists("chat:disclaimer") ? o("chat:disclaimer") : null, q = typeof I == "string" ? o(I) : I ?? f, [g, B] = T(null), V = Z(h);
378
382
  Je(() => {
379
- m && N();
380
- }, [s, N, m]);
381
- const $ = d[d.length - 1], A = $?.role === "assistant" && (h === "ready" || $.parts.some((E) => E.type === "data-chat-finished"));
382
- O(() => {
383
- h === "error" && G.current !== "error" && z !== s ? B(s) : h === "submitted" && z !== null && B(null), G.current = h;
384
- }, [h, s]);
385
- const U = h === "error" && (s === "/" || z === s);
386
- return /* @__PURE__ */ r("div", { className: f("relative flex flex-col h-full overflow-hidden", a.container), children: [
383
+ m && w();
384
+ }, [n, w, m]);
385
+ const O = d[d.length - 1], z = O?.role === "assistant" && (h === "ready" || O.parts.some((L) => L.type === "data-chat-finished"));
386
+ F(() => {
387
+ h === "error" && V.current !== "error" && g !== n ? B(n) : h === "submitted" && g !== null && B(null), V.current = h;
388
+ }, [h, n]);
389
+ const K = h === "error" && (n === "/" || g === n);
390
+ return /* @__PURE__ */ r("div", { className: v("relative flex flex-col h-full overflow-hidden", a.container), children: [
387
391
  /* @__PURE__ */ e(
388
- T,
392
+ P,
389
393
  {
390
394
  messages: d,
391
395
  status: h,
392
- isLoadingHistory: k,
393
- error: U ? m : null,
394
- conversationId: s,
395
- regen: (E) => p({ messageId: E }),
396
- onSuggestionClick: (E) => M(E),
396
+ isLoadingHistory: C,
397
+ error: K ? m : null,
398
+ conversationId: n,
399
+ regen: (L) => p({ messageId: L }),
400
+ onSuggestionClick: (L) => D(L),
397
401
  chat: l,
398
- className: f("flex-1", a.messageList)
402
+ className: v("flex-1", a.messageList)
399
403
  }
400
404
  ),
401
405
  /* @__PURE__ */ r("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
402
406
  /* @__PURE__ */ e(
403
- q,
407
+ j,
404
408
  {
405
- onSend: M,
409
+ onSend: D,
406
410
  status: h,
407
- isLastMessageFinished: A,
408
- stop: v,
409
- isErrorVisible: U,
410
- conversationId: s,
411
- className: f("pointer-events-auto", a.inputArea, g && "pb-0 md:pb-0")
411
+ isLastMessageFinished: z,
412
+ stop: x,
413
+ isErrorVisible: K,
414
+ conversationId: n,
415
+ className: v("pointer-events-auto", a.inputArea, q && "pb-0 md:pb-0")
412
416
  }
413
417
  ),
414
- g && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
418
+ q && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
415
419
  /* @__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" }),
416
- /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: g })
420
+ /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: q })
417
421
  ] })
418
422
  ] })
419
423
  ] });
420
424
  }
421
- const na = ({
425
+ const sa = ({
422
426
  components: a,
423
427
  history: t,
424
- welcome: i,
428
+ welcome: o,
425
429
  threadActions: u,
426
430
  composer: l,
427
431
  theme: d,
428
432
  disclaimer: h,
429
433
  ...p
430
434
  }) => {
431
- const m = re(), N = j(() => ({
435
+ const m = te(), w = R(() => ({
432
436
  ...m,
433
437
  ...a,
434
438
  toolComponents: {
@@ -439,9 +443,9 @@ const na = ({
439
443
  return /* @__PURE__ */ e(
440
444
  Fe,
441
445
  {
442
- components: N,
446
+ components: w,
443
447
  history: t ?? m.history,
444
- welcome: i ?? m.welcome,
448
+ welcome: o ?? m.welcome,
445
449
  threadActions: u ?? m.threadActions,
446
450
  composer: l ?? m.composer,
447
451
  theme: d ?? m.theme,
@@ -449,22 +453,22 @@ const na = ({
449
453
  app: m.app,
450
454
  i18n: m.i18n,
451
455
  settings: m.settings,
452
- children: /* @__PURE__ */ e(ra, { ...p })
456
+ children: /* @__PURE__ */ e(na, { ...p })
453
457
  }
454
458
  );
455
459
  };
456
- function sa({ ...a }) {
457
- return /* @__PURE__ */ e(se.Root, { "data-slot": "sheet", ...a });
458
- }
459
460
  function oa({ ...a }) {
460
- return /* @__PURE__ */ e(se.Portal, { "data-slot": "sheet-portal", ...a });
461
+ return /* @__PURE__ */ e(oe.Root, { "data-slot": "sheet", ...a });
461
462
  }
462
- function ia({ className: a, ...t }) {
463
+ function ia({ ...a }) {
464
+ return /* @__PURE__ */ e(oe.Portal, { "data-slot": "sheet-portal", ...a });
465
+ }
466
+ function la({ className: a, ...t }) {
463
467
  return /* @__PURE__ */ e(
464
- se.Overlay,
468
+ oe.Overlay,
465
469
  {
466
470
  "data-slot": "sheet-overlay",
467
- className: f(
471
+ className: v(
468
472
  "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
469
473
  a
470
474
  ),
@@ -472,31 +476,31 @@ function ia({ className: a, ...t }) {
472
476
  }
473
477
  );
474
478
  }
475
- function la({
479
+ function ca({
476
480
  className: a,
477
481
  children: t,
478
- side: i = "right",
482
+ side: o = "right",
479
483
  ...u
480
484
  }) {
481
- return /* @__PURE__ */ r(oa, { children: [
482
- /* @__PURE__ */ e(ia, {}),
485
+ return /* @__PURE__ */ r(ia, { children: [
486
+ /* @__PURE__ */ e(la, {}),
483
487
  /* @__PURE__ */ r(
484
- se.Content,
488
+ oe.Content,
485
489
  {
486
490
  "data-slot": "sheet-content",
487
- className: f(
491
+ className: v(
488
492
  "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",
489
- 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",
490
- 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",
491
- 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",
492
- 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",
493
+ o === "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",
494
+ o === "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",
495
+ o === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
496
+ o === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
493
497
  a
494
498
  ),
495
499
  ...u,
496
500
  children: [
497
501
  t,
498
- /* @__PURE__ */ r(se.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
499
- /* @__PURE__ */ e(kt, { className: "size-4" }),
502
+ /* @__PURE__ */ r(oe.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: [
503
+ /* @__PURE__ */ e(_t, { className: "size-4" }),
500
504
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Close" })
501
505
  ] })
502
506
  ]
@@ -504,122 +508,122 @@ function la({
504
508
  )
505
509
  ] });
506
510
  }
507
- function ca({ className: a, ...t }) {
508
- return /* @__PURE__ */ e("div", { "data-slot": "sheet-header", className: f("flex flex-col gap-1.5 p-4", a), ...t });
509
- }
510
511
  function da({ className: a, ...t }) {
512
+ return /* @__PURE__ */ e("div", { "data-slot": "sheet-header", className: v("flex flex-col gap-1.5 p-4", a), ...t });
513
+ }
514
+ function ua({ className: a, ...t }) {
511
515
  return /* @__PURE__ */ e(
512
- se.Title,
516
+ oe.Title,
513
517
  {
514
518
  "data-slot": "sheet-title",
515
- className: f("text-foreground font-semibold", a),
519
+ className: v("text-foreground font-semibold", a),
516
520
  ...t
517
521
  }
518
522
  );
519
523
  }
520
- function ua({ className: a, ...t }) {
524
+ function ma({ className: a, ...t }) {
521
525
  return /* @__PURE__ */ e(
522
- se.Description,
526
+ oe.Description,
523
527
  {
524
528
  "data-slot": "sheet-description",
525
- className: f("text-muted-foreground text-sm", a),
529
+ className: v("text-muted-foreground text-sm", a),
526
530
  ...t
527
531
  }
528
532
  );
529
533
  }
530
- const ma = "sidebar_state", ha = 3600 * 24 * 7, pa = "19rem", ga = "18rem", fa = "3rem", ba = "b", Ge = ne.createContext(null);
531
- function ge() {
532
- const a = ne.useContext(Ge);
534
+ const ha = "sidebar_state", pa = 3600 * 24 * 7, ga = "19rem", fa = "18rem", ba = "3rem", va = "b", Ge = ae.createContext(null);
535
+ function fe() {
536
+ const a = ae.useContext(Ge);
533
537
  if (!a)
534
538
  throw new Error("useSidebar must be used within a SidebarProvider.");
535
539
  return a;
536
540
  }
537
- function va({
541
+ function xa({
538
542
  defaultOpen: a = !0,
539
543
  open: t,
540
- onOpenChange: i,
544
+ onOpenChange: o,
541
545
  className: u,
542
546
  style: l,
543
547
  children: d,
544
548
  ...h
545
549
  }) {
546
- const p = ot(), [m, N] = ne.useState(!1), [v, k] = ne.useState(a), s = t ?? v, M = ne.useCallback(
547
- (S) => {
548
- const y = typeof S == "function" ? S(s) : S;
549
- i ? i(y) : k(y), document.cookie = `${ma}=${y}; path=/; max-age=${ha}`;
550
+ const p = ot(), [m, w] = ae.useState(!1), [x, C] = ae.useState(a), n = t ?? x, D = ae.useCallback(
551
+ (I) => {
552
+ const f = typeof I == "function" ? I(n) : I;
553
+ o ? o(f) : C(f), document.cookie = `${ha}=${f}; path=/; max-age=${pa}`;
550
554
  },
551
- [i, s]
552
- ), T = ne.useCallback(() => {
553
- p ? N((S) => !S) : M((S) => !S);
554
- }, [p, M, N]);
555
- ne.useEffect(() => {
556
- const S = (y) => {
557
- y.key === ba && (y.metaKey || y.ctrlKey) && (y.preventDefault(), T());
555
+ [o, n]
556
+ ), P = ae.useCallback(() => {
557
+ p ? w((I) => !I) : D((I) => !I);
558
+ }, [p, D, w]);
559
+ ae.useEffect(() => {
560
+ const I = (f) => {
561
+ f.key === va && (f.metaKey || f.ctrlKey) && (f.preventDefault(), P());
558
562
  };
559
- return window.addEventListener("keydown", S), () => {
560
- window.removeEventListener("keydown", S);
563
+ return window.addEventListener("keydown", I), () => {
564
+ window.removeEventListener("keydown", I);
561
565
  };
562
- }, [T]);
563
- const q = s ? "expanded" : "collapsed", K = ne.useMemo(
566
+ }, [P]);
567
+ const j = n ? "expanded" : "collapsed", U = ae.useMemo(
564
568
  () => ({
565
- state: q,
566
- open: s,
567
- setOpen: M,
569
+ state: j,
570
+ open: n,
571
+ setOpen: D,
568
572
  isMobile: p,
569
573
  openMobile: m,
570
- setOpenMobile: N,
571
- toggleSidebar: T
574
+ setOpenMobile: w,
575
+ toggleSidebar: P
572
576
  }),
573
- [q, s, M, p, m, N, T]
577
+ [j, n, D, p, m, w, P]
574
578
  );
575
- return /* @__PURE__ */ e(Ge.Provider, { value: K, children: /* @__PURE__ */ e(Oe, { delayDuration: 0, children: /* @__PURE__ */ e(
579
+ return /* @__PURE__ */ e(Ge.Provider, { value: U, children: /* @__PURE__ */ e(Oe, { delayDuration: 0, children: /* @__PURE__ */ e(
576
580
  "div",
577
581
  {
578
582
  "data-slot": "sidebar-wrapper",
579
583
  style: {
580
- "--sidebar-width": pa,
581
- "--sidebar-width-icon": fa,
584
+ "--sidebar-width": ga,
585
+ "--sidebar-width-icon": ba,
582
586
  ...l
583
587
  },
584
- className: f("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", u),
588
+ className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", u),
585
589
  ...h,
586
590
  children: d
587
591
  }
588
592
  ) }) });
589
593
  }
590
- function xa({
594
+ function ya({
591
595
  side: a = "left",
592
596
  variant: t = "sidebar",
593
- collapsible: i = "offcanvas",
597
+ collapsible: o = "offcanvas",
594
598
  className: u,
595
599
  children: l,
596
600
  ...d
597
601
  }) {
598
- const { isMobile: h, state: p, openMobile: m, setOpenMobile: N } = ge();
599
- return i === "none" ? /* @__PURE__ */ e(
602
+ const { isMobile: h, state: p, openMobile: m, setOpenMobile: w } = fe();
603
+ return o === "none" ? /* @__PURE__ */ e(
600
604
  "div",
601
605
  {
602
606
  "data-slot": "sidebar",
603
- className: f("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", u),
607
+ className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", u),
604
608
  ...d,
605
609
  children: l
606
610
  }
607
- ) : h ? /* @__PURE__ */ e(sa, { open: m, onOpenChange: N, ...d, children: /* @__PURE__ */ r(
608
- la,
611
+ ) : h ? /* @__PURE__ */ e(oa, { open: m, onOpenChange: w, ...d, children: /* @__PURE__ */ r(
612
+ ca,
609
613
  {
610
- onOpenAutoFocus: (v) => v.preventDefault(),
614
+ onOpenAutoFocus: (x) => x.preventDefault(),
611
615
  "data-sidebar": "sidebar",
612
616
  "data-slot": "sidebar",
613
617
  "data-mobile": "true",
614
618
  className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
615
619
  style: {
616
- "--sidebar-width": ga
620
+ "--sidebar-width": fa
617
621
  },
618
622
  side: a,
619
623
  children: [
620
- /* @__PURE__ */ r(ca, { className: "sr-only", children: [
621
- /* @__PURE__ */ e(da, { children: "Sidebar" }),
622
- /* @__PURE__ */ e(ua, { children: "Displays the mobile sidebar." })
624
+ /* @__PURE__ */ r(da, { className: "sr-only", children: [
625
+ /* @__PURE__ */ e(ua, { children: "Sidebar" }),
626
+ /* @__PURE__ */ e(ma, { children: "Displays the mobile sidebar." })
623
627
  ] }),
624
628
  /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: l })
625
629
  ]
@@ -629,7 +633,7 @@ function xa({
629
633
  {
630
634
  className: "group peer text-sidebar-foreground hidden md:block",
631
635
  "data-state": p,
632
- "data-collapsible": p === "collapsed" ? i : "",
636
+ "data-collapsible": p === "collapsed" ? o : "",
633
637
  "data-variant": t,
634
638
  "data-side": a,
635
639
  "data-slot": "sidebar",
@@ -638,7 +642,7 @@ function xa({
638
642
  "div",
639
643
  {
640
644
  "data-slot": "sidebar-gap",
641
- className: f(
645
+ className: v(
642
646
  "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
643
647
  "group-data-[collapsible=offcanvas]:w-0",
644
648
  "group-data-[side=right]:rotate-180",
@@ -650,7 +654,7 @@ function xa({
650
654
  "div",
651
655
  {
652
656
  "data-slot": "sidebar-container",
653
- className: f(
657
+ className: v(
654
658
  "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
655
659
  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)]",
656
660
  // Adjust the padding for floating and inset variants.
@@ -673,45 +677,45 @@ function xa({
673
677
  }
674
678
  );
675
679
  }
676
- function ya({ className: a, onClick: t, ...i }) {
677
- const { toggleSidebar: u } = ge();
680
+ function wa({ className: a, onClick: t, ...o }) {
681
+ const { toggleSidebar: u } = fe();
678
682
  return /* @__PURE__ */ r(
679
- Z,
683
+ Y,
680
684
  {
681
685
  "data-sidebar": "trigger",
682
686
  "data-slot": "sidebar-trigger",
683
687
  variant: "ghost",
684
688
  size: "icon",
685
- className: f("size-7", a),
689
+ className: v("size-7", a),
686
690
  onClick: (l) => {
687
691
  t?.(l), u();
688
692
  },
689
- ...i,
693
+ ...o,
690
694
  children: [
691
- /* @__PURE__ */ e(_t, {}),
695
+ /* @__PURE__ */ e(Ct, {}),
692
696
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle Sidebar" })
693
697
  ]
694
698
  }
695
699
  );
696
700
  }
697
- function wa({ className: a, ...t }) {
701
+ function Na({ className: a, ...t }) {
698
702
  return /* @__PURE__ */ e(
699
703
  "div",
700
704
  {
701
705
  "data-slot": "sidebar-footer",
702
706
  "data-sidebar": "footer",
703
- className: f("flex flex-col gap-2 p-2", a),
707
+ className: v("flex flex-col gap-2 p-2", a),
704
708
  ...t
705
709
  }
706
710
  );
707
711
  }
708
- function Na({ className: a, ...t }) {
712
+ function ka({ className: a, ...t }) {
709
713
  return /* @__PURE__ */ e(
710
714
  "div",
711
715
  {
712
716
  "data-slot": "sidebar-content",
713
717
  "data-sidebar": "content",
714
- className: f(
718
+ className: v(
715
719
  "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
716
720
  a
717
721
  ),
@@ -719,13 +723,13 @@ function Na({ className: a, ...t }) {
719
723
  }
720
724
  );
721
725
  }
722
- function ka({ className: a, ...t }) {
726
+ function _a({ className: a, ...t }) {
723
727
  return /* @__PURE__ */ e(
724
728
  "div",
725
729
  {
726
730
  "data-slot": "sidebar-group",
727
731
  "data-sidebar": "group",
728
- className: f("relative flex w-full min-w-0 flex-col p-2", a),
732
+ className: v("relative flex w-full min-w-0 flex-col p-2", a),
729
733
  ...t
730
734
  }
731
735
  );
@@ -736,7 +740,7 @@ function Ee({ className: a, ...t }) {
736
740
  {
737
741
  "data-slot": "sidebar-group-content",
738
742
  "data-sidebar": "group-content",
739
- className: f("w-full text-sm", a),
743
+ className: v("w-full text-sm", a),
740
744
  ...t
741
745
  }
742
746
  );
@@ -747,7 +751,7 @@ function Ae({ className: a, ...t }) {
747
751
  {
748
752
  "data-slot": "sidebar-menu",
749
753
  "data-sidebar": "menu",
750
- className: f("flex w-full min-w-0 flex-col gap-1", a),
754
+ className: v("flex w-full min-w-0 flex-col gap-1", a),
751
755
  ...t
752
756
  }
753
757
  );
@@ -758,12 +762,12 @@ function Le({ className: a, ...t }) {
758
762
  {
759
763
  "data-slot": "sidebar-menu-item",
760
764
  "data-sidebar": "menu-item",
761
- className: f("group/menu-item relative", a),
765
+ className: v("group/menu-item relative", a),
762
766
  ...t
763
767
  }
764
768
  );
765
769
  }
766
- const _a = Zt(
770
+ const Ca = ea(
767
771
  "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",
768
772
  {
769
773
  variants: {
@@ -786,90 +790,95 @@ const _a = Zt(
786
790
  function ze({
787
791
  asChild: a = !1,
788
792
  isActive: t = !1,
789
- variant: i = "default",
793
+ variant: o = "default",
790
794
  size: u = "default",
791
795
  tooltip: l,
792
796
  className: d,
793
797
  ...h
794
798
  }) {
795
- const p = a ? Yt : "button", { isMobile: m, state: N } = ge(), v = /* @__PURE__ */ e(
799
+ const p = a ? Zt : "button", { isMobile: m, state: w } = fe(), x = /* @__PURE__ */ e(
796
800
  p,
797
801
  {
798
802
  "data-slot": "sidebar-menu-button",
799
803
  "data-sidebar": "menu-button",
800
804
  "data-size": u,
801
805
  "data-active": t,
802
- className: f(_a({ variant: i, size: u }), d),
806
+ className: v(Ca({ variant: o, size: u }), d),
803
807
  ...h
804
808
  }
805
809
  );
806
810
  return l ? (typeof l == "string" && (l = {
807
811
  children: l
808
812
  }), /* @__PURE__ */ r($e, { children: [
809
- /* @__PURE__ */ e(Be, { asChild: !0, children: v }),
810
- /* @__PURE__ */ e(Ue, { side: "right", align: "center", hidden: N !== "collapsed" || m, ...l })
811
- ] })) : v;
813
+ /* @__PURE__ */ e(Ue, { asChild: !0, children: x }),
814
+ /* @__PURE__ */ e(Be, { side: "right", align: "center", hidden: w !== "collapsed" || m, ...l })
815
+ ] })) : x;
812
816
  }
813
- function Ca({ trigger: a }) {
814
- const { t, i18n: i } = ce(["settings", "translation"]), { app: u, settings: l } = re(), { theme: d, setTheme: h, accent: p, setAccent: m, radius: N, setRadius: v } = Ke(), [k, s] = P(null), [M, T] = P(!1), q = te(null), K = j(() => [
817
+ function Sa({ trigger: a }) {
818
+ const { t, i18n: o } = de(["settings", "translation"]), { app: u, settings: l } = te(), d = ue(), { theme: h, setTheme: p, accent: m, setAccent: w, radius: x, setRadius: C } = Ke(), [n, D] = T(null), [P, j] = T(!1), U = Z(null), I = R(() => [
815
819
  { id: "general", label: t("sections.general", "General"), icon: Me },
816
- { id: "profile", label: t("sections.profile", "Profile"), icon: Ct },
817
- { id: "account", label: t("sections.account", "Account"), icon: St }
818
- ].filter((F) => {
819
- const n = l?.sections?.[F.id];
820
- return (n?.mode ?? (n?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
821
- }), [t, l]), [S, y] = P(K[0]?.id || "general"), g = Y((o, F, n = "editable") => {
822
- const H = l?.sections?.[o]?.fields;
823
- return H && H[F] || n;
824
- }, [l]), [z, B] = P(""), [G, $] = P(""), [A, U] = P(""), [E, Q] = P(""), R = j(() => u?.userMetadataFields?.filter((o) => o.showInProfile) || [], [u?.userMetadataFields]), [b, _] = P({}), [x, c] = P(!1), w = i.language === "fa", L = w ? "text-right" : "text-left", C = Y(async () => {
820
+ { id: "profile", label: t("sections.profile", "Profile"), icon: St },
821
+ { id: "account", label: t("sections.account", "Account"), icon: Pt }
822
+ ].filter((s) => {
823
+ const _ = l?.sections?.[s.id];
824
+ return (_?.mode ?? (_?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
825
+ }), [t, l]), [f, q] = T(I[0]?.id || "general"), g = J((i, s, _ = "editable") => {
826
+ const se = l?.sections?.[i]?.fields;
827
+ return se && se[s] || _;
828
+ }, [l]), [B, V] = T(""), [O, z] = T(""), [K, L] = T(""), [H, $] = T(""), N = R(() => u?.userMetadataFields?.filter((i) => i.showInProfile) || [], [u?.userMetadataFields]), [y, b] = T({}), [c, k] = T(!1), A = o.language === "fa", S = A ? "text-right" : "text-left", M = J(async () => {
825
829
  try {
826
- const o = await D.getMe();
827
- s(o), B(o.name || ""), $(o.surname || ""), U(o.phone || "");
828
- const F = {};
829
- R.forEach((n) => {
830
- F[n.key] = o.metadata?.[n.key] ?? n.defaultValue ?? "";
831
- }), _(F);
832
- } catch (o) {
833
- console.error("Failed to fetch user:", o), J.error(le(o, t));
830
+ const i = await E.getMe();
831
+ D(i), V(i.name || ""), z(i.surname || ""), L(i.phone || "");
832
+ const s = {};
833
+ N.forEach((_) => {
834
+ s[_.key] = i.metadata?.[_.key] ?? _.defaultValue ?? "";
835
+ }), b(s);
836
+ } catch (i) {
837
+ console.error("Failed to fetch user:", i), X.error(ce(i, t));
834
838
  }
835
- }, [t, R]);
836
- O(() => {
837
- if (!M) {
838
- q.current = null;
839
+ }, [t, N]);
840
+ F(() => {
841
+ if (!P) {
842
+ U.current = null;
839
843
  return;
840
844
  }
841
- (q.current === null || S === "account") && C(), q.current = S;
842
- }, [M, S, C]), O(() => {
843
- const o = { ...b };
844
- let F = !1;
845
- R.forEach((n) => {
846
- n.condition && !he(n.condition, b) && o[n.key] !== void 0 && (delete o[n.key], F = !0);
847
- }), F && _(o);
848
- }, [b, R]);
849
- const I = async () => {
850
- c(!0);
845
+ (U.current === null || f === "account") && M(), U.current = f;
846
+ }, [P, f, M]), F(() => {
847
+ const i = { ...y };
848
+ let s = !1;
849
+ N.forEach((_) => {
850
+ _.condition && !ge(_.condition, y) && i[_.key] !== void 0 && (delete i[_.key], s = !0);
851
+ }), s && b(i);
852
+ }, [y, N]);
853
+ const G = async () => {
854
+ k(!0);
851
855
  try {
852
- const o = { name: z, surname: G, phone: A, metadata: b };
853
- E && (o.password = E), await D.updateMe(o), J.success(t("profile.success", "Profile updated successfully")), Q(""), C();
854
- } catch (o) {
855
- J.error(le(o, t));
856
+ const i = { name: B, surname: O, phone: K, metadata: y };
857
+ H && (i.password = H);
858
+ const s = await E.updateMe(i);
859
+ d.setQueryData(
860
+ lt(u?.cacheNamespace || "gentiq"),
861
+ s
862
+ ), X.success(t("profile.success", "Profile updated successfully")), $(""), M();
863
+ } catch (i) {
864
+ X.error(ce(i, t));
856
865
  } finally {
857
- c(!1);
866
+ k(!1);
858
867
  }
859
- }, W = () => {
860
- window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (D.clearToken(), window.location.reload());
861
- }, ae = (o) => {
862
- i.changeLanguage(o);
863
- }, ee = k ? Math.max(0, Math.min(100, k.balance.tokens / (k.balance.token_limit || 1) * 100)) : 0, oe = k ? Math.max(0, Math.min(100, k.balance.requests / (k.balance.request_limit || 1) * 100)) : 0;
864
- return /* @__PURE__ */ r(He, { open: M, onOpenChange: T, children: [
865
- /* @__PURE__ */ e(it, { asChild: !0, children: a || /* @__PURE__ */ e(Z, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5" }) }) }),
868
+ }, ee = () => {
869
+ window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (E.clearToken(), window.location.reload());
870
+ }, re = (i) => {
871
+ o.changeLanguage(i);
872
+ }, ie = n?.balance ? Math.max(0, Math.min(100, n.balance.tokens / (n.balance.token_limit || 1) * 100)) : 0, ne = n?.balance ? Math.max(0, Math.min(100, n.balance.requests / (n.balance.request_limit || 1) * 100)) : 0;
873
+ return /* @__PURE__ */ r(He, { open: P, onOpenChange: j, children: [
874
+ /* @__PURE__ */ e(it, { asChild: !0, children: a || /* @__PURE__ */ e(Y, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5" }) }) }),
866
875
  /* @__PURE__ */ e(
867
- Ve,
876
+ Qe,
868
877
  {
869
- dir: w ? "rtl" : "ltr",
870
- className: f(
878
+ dir: A ? "rtl" : "ltr",
879
+ className: v(
871
880
  "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]",
872
- w && "rtl"
881
+ A && "rtl"
873
882
  ),
874
883
  children: /* @__PURE__ */ r("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
875
884
  /* @__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: [
@@ -877,71 +886,71 @@ function Ca({ trigger: a }) {
877
886
  /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5 text-primary" }) }),
878
887
  /* @__PURE__ */ e("span", { className: "font-bold text-lg", children: t("title", "Settings") })
879
888
  ] }) }),
880
- /* @__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: K.map((o) => /* @__PURE__ */ r(
889
+ /* @__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: I.map((i) => /* @__PURE__ */ r(
881
890
  "button",
882
891
  {
883
- onClick: () => y(o.id),
884
- className: f(
892
+ onClick: () => q(i.id),
893
+ className: v(
885
894
  "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",
886
- S === o.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
887
- l?.sections?.[o.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
895
+ f === i.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
896
+ l?.sections?.[i.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
888
897
  ),
889
898
  children: [
890
- /* @__PURE__ */ e(o.icon, { className: f(
899
+ /* @__PURE__ */ e(i.icon, { className: v(
891
900
  "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
892
- S === o.id && "scale-110"
901
+ f === i.id && "scale-110"
893
902
  ) }),
894
- o.label
903
+ i.label
895
904
  ]
896
905
  },
897
- o.id
906
+ i.id
898
907
  )) }) })
899
908
  ] }),
900
909
  /* @__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: [
901
- S === "profile" && /* @__PURE__ */ r("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
910
+ f === "profile" && /* @__PURE__ */ r("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
902
911
  /* @__PURE__ */ r("div", { children: [
903
912
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("profile.title", "Profile Information") }),
904
913
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("profile.subtitle", "Update your personal details below.") })
905
914
  ] }),
906
915
  /* @__PURE__ */ r("div", { className: "grid gap-6", children: [
907
916
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
908
- g("profile", "name") !== "hidden" && /* @__PURE__ */ r("div", { className: f("flex flex-col gap-3", g("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
909
- /* @__PURE__ */ e(V, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
917
+ g("profile", "name") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
918
+ /* @__PURE__ */ e(Q, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
910
919
  /* @__PURE__ */ e(
911
- X,
920
+ W,
912
921
  {
913
922
  id: "name",
914
- value: z,
915
- onChange: (o) => B(o.target.value),
923
+ value: B,
924
+ onChange: (i) => V(i.target.value),
916
925
  disabled: g("profile", "name") === "faded",
917
- className: f("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", L)
926
+ className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", S)
918
927
  }
919
928
  )
920
929
  ] }),
921
- g("profile", "surname") !== "hidden" && /* @__PURE__ */ r("div", { className: f("flex flex-col gap-3", g("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
922
- /* @__PURE__ */ e(V, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
930
+ g("profile", "surname") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
931
+ /* @__PURE__ */ e(Q, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
923
932
  /* @__PURE__ */ e(
924
- X,
933
+ W,
925
934
  {
926
935
  id: "surname",
927
- value: G,
928
- onChange: (o) => $(o.target.value),
936
+ value: O,
937
+ onChange: (i) => z(i.target.value),
929
938
  disabled: g("profile", "surname") === "faded",
930
- className: f("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", L)
939
+ className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", S)
931
940
  }
932
941
  )
933
942
  ] })
934
943
  ] }),
935
- g("profile", "phone") !== "hidden" && /* @__PURE__ */ r("div", { className: f("flex flex-col gap-3", g("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
936
- /* @__PURE__ */ e(V, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
944
+ g("profile", "phone") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
945
+ /* @__PURE__ */ e(Q, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
937
946
  /* @__PURE__ */ r("div", { className: "relative", children: [
938
- /* @__PURE__ */ e(Pt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
947
+ /* @__PURE__ */ e(Tt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
939
948
  /* @__PURE__ */ e(
940
- X,
949
+ W,
941
950
  {
942
951
  id: "phone",
943
- value: A,
944
- onChange: (o) => U(o.target.value),
952
+ value: K,
953
+ onChange: (i) => L(i.target.value),
945
954
  disabled: g("profile", "phone") === "faded",
946
955
  className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
947
956
  dir: "ltr"
@@ -949,17 +958,17 @@ function Ca({ trigger: a }) {
949
958
  )
950
959
  ] })
951
960
  ] }),
952
- g("profile", "password") !== "hidden" && /* @__PURE__ */ r("div", { className: f("flex flex-col gap-3", g("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
953
- /* @__PURE__ */ e(V, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
961
+ g("profile", "password") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
962
+ /* @__PURE__ */ e(Q, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
954
963
  /* @__PURE__ */ r("div", { className: "relative", children: [
955
- /* @__PURE__ */ e(Tt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
964
+ /* @__PURE__ */ e(Mt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
956
965
  /* @__PURE__ */ e(
957
- X,
966
+ W,
958
967
  {
959
968
  id: "pass",
960
969
  type: "password",
961
- value: E,
962
- onChange: (o) => Q(o.target.value),
970
+ value: H,
971
+ onChange: (i) => $(i.target.value),
963
972
  disabled: g("profile", "password") === "faded",
964
973
  placeholder: t("profile.password_placeholder", "Leave empty to keep current"),
965
974
  className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
@@ -968,71 +977,71 @@ function Ca({ trigger: a }) {
968
977
  )
969
978
  ] })
970
979
  ] }),
971
- R.map((o) => {
972
- const F = g("profile", o.key, o.mode || "editable");
973
- return F === "hidden" || !he(o.condition, b) ? null : /* @__PURE__ */ r("div", { className: f("flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200", F === "faded" && "opacity-50 pointer-events-none select-none"), children: [
974
- /* @__PURE__ */ e(V, { htmlFor: `profile-${o.key}`, className: "px-1", children: t(o.label) }),
975
- o.type === "select" ? /* @__PURE__ */ r(
980
+ N.map((i) => {
981
+ const s = g("profile", i.key, i.mode || "editable");
982
+ return s === "hidden" || !ge(i.condition, y) ? null : /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200", s === "faded" && "opacity-50 pointer-events-none select-none"), children: [
983
+ /* @__PURE__ */ e(Q, { htmlFor: `profile-${i.key}`, className: "px-1", children: t(i.label) }),
984
+ i.type === "select" ? /* @__PURE__ */ r(
976
985
  ve,
977
986
  {
978
- value: String(b[o.key] || ""),
979
- onValueChange: (n) => _({ ...b, [o.key]: n }),
980
- disabled: F === "faded",
981
- dir: w ? "rtl" : "ltr",
987
+ value: String(y[i.key] || ""),
988
+ onValueChange: (_) => b({ ...y, [i.key]: _ }),
989
+ disabled: s === "faded",
990
+ dir: A ? "rtl" : "ltr",
982
991
  children: [
983
- /* @__PURE__ */ e(xe, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(ye, { placeholder: t(o.placeholder || "profile.select_placeholder") }) }),
984
- /* @__PURE__ */ e(we, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: o.options?.map((n) => /* @__PURE__ */ e(me, { value: String(n.value), className: "rounded-lg focus:bg-primary/10", children: t(n.label) }, String(n.value))) })
992
+ /* @__PURE__ */ e(xe, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(ye, { placeholder: t(i.placeholder || "profile.select_placeholder") }) }),
993
+ /* @__PURE__ */ e(we, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: i.options?.map((_) => /* @__PURE__ */ e(pe, { value: String(_.value), className: "rounded-lg focus:bg-primary/10", children: t(_.label) }, String(_.value))) })
985
994
  ]
986
995
  }
987
- ) : o.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 px-1 py-1", children: [
996
+ ) : i.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 px-1 py-1", children: [
988
997
  /* @__PURE__ */ e(
989
998
  "input",
990
999
  {
991
- id: `profile-${o.key}`,
1000
+ id: `profile-${i.key}`,
992
1001
  type: "checkbox",
993
- checked: !!b[o.key],
994
- disabled: F === "faded",
995
- onChange: (n) => _({ ...b, [o.key]: n.target.checked }),
1002
+ checked: !!y[i.key],
1003
+ disabled: s === "faded",
1004
+ onChange: (_) => b({ ...y, [i.key]: _.target.checked }),
996
1005
  className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
997
1006
  }
998
1007
  ),
999
- /* @__PURE__ */ e(V, { htmlFor: `profile-${o.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(o.placeholder || o.label) })
1008
+ /* @__PURE__ */ e(Q, { htmlFor: `profile-${i.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(i.placeholder || i.label) })
1000
1009
  ] }) : /* @__PURE__ */ e(
1001
- X,
1010
+ W,
1002
1011
  {
1003
- id: `profile-${o.key}`,
1004
- type: o.type,
1005
- value: b[o.key] || "",
1006
- disabled: F === "faded",
1007
- onChange: (n) => _({ ...b, [o.key]: n.target.value }),
1008
- placeholder: t(o.placeholder || ""),
1009
- className: f("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", L)
1012
+ id: `profile-${i.key}`,
1013
+ type: i.type,
1014
+ value: y[i.key] || "",
1015
+ disabled: s === "faded",
1016
+ onChange: (_) => b({ ...y, [i.key]: _.target.value }),
1017
+ placeholder: t(i.placeholder || ""),
1018
+ className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", S)
1010
1019
  }
1011
1020
  )
1012
- ] }, o.key);
1021
+ ] }, i.key);
1013
1022
  }),
1014
1023
  /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ r(
1015
- Z,
1024
+ Y,
1016
1025
  {
1017
- onClick: I,
1018
- disabled: x,
1026
+ onClick: G,
1027
+ disabled: c,
1019
1028
  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]",
1020
1029
  children: [
1021
- /* @__PURE__ */ e(Mt, { className: "h-4 w-4" }),
1022
- x ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1030
+ /* @__PURE__ */ e(Dt, { className: "h-4 w-4" }),
1031
+ c ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1023
1032
  ]
1024
1033
  }
1025
1034
  ) })
1026
1035
  ] })
1027
1036
  ] }),
1028
- S === "general" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1037
+ f === "general" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1029
1038
  /* @__PURE__ */ r("div", { children: [
1030
1039
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("general.title", "General Settings") }),
1031
1040
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("general.subtitle", "Configure look and feel and language.") })
1032
1041
  ] }),
1033
1042
  /* @__PURE__ */ r("div", { className: "space-y-8", children: [
1034
- g("general", "theme") !== "hidden" && /* @__PURE__ */ r("div", { className: f("space-y-3", g("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1035
- /* @__PURE__ */ r(V, { className: "text-sm font-semibold flex items-center gap-2", children: [
1043
+ g("general", "theme") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", g("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1044
+ /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1036
1045
  /* @__PURE__ */ e(Me, { className: "h-4 w-4 text-primary" }),
1037
1046
  t("general.theme", "Theme")
1038
1047
  ] }),
@@ -1040,11 +1049,11 @@ function Ca({ trigger: a }) {
1040
1049
  /* @__PURE__ */ r(
1041
1050
  "button",
1042
1051
  {
1043
- onClick: () => h("light"),
1052
+ onClick: () => p("light"),
1044
1053
  disabled: g("general", "theme") === "faded",
1045
- className: f(
1054
+ className: v(
1046
1055
  "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1047
- d === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1056
+ h === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1048
1057
  ),
1049
1058
  children: [
1050
1059
  /* @__PURE__ */ e(It, { className: "h-4 w-4" }),
@@ -1055,14 +1064,14 @@ function Ca({ trigger: a }) {
1055
1064
  /* @__PURE__ */ r(
1056
1065
  "button",
1057
1066
  {
1058
- onClick: () => h("dark"),
1067
+ onClick: () => p("dark"),
1059
1068
  disabled: g("general", "theme") === "faded",
1060
- className: f(
1069
+ className: v(
1061
1070
  "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1062
- d === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1071
+ h === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1063
1072
  ),
1064
1073
  children: [
1065
- /* @__PURE__ */ e(Dt, { className: "h-4 w-4" }),
1074
+ /* @__PURE__ */ e(Et, { className: "h-4 w-4" }),
1066
1075
  /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.dark", "Dark") })
1067
1076
  ]
1068
1077
  }
@@ -1070,23 +1079,23 @@ function Ca({ trigger: a }) {
1070
1079
  /* @__PURE__ */ r(
1071
1080
  "button",
1072
1081
  {
1073
- onClick: () => h("system"),
1082
+ onClick: () => p("system"),
1074
1083
  disabled: g("general", "theme") === "faded",
1075
- className: f(
1084
+ className: v(
1076
1085
  "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1077
- d === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1086
+ h === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1078
1087
  ),
1079
1088
  children: [
1080
- /* @__PURE__ */ e(Et, { className: "h-4 w-4" }),
1089
+ /* @__PURE__ */ e(At, { className: "h-4 w-4" }),
1081
1090
  /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.system", "System") })
1082
1091
  ]
1083
1092
  }
1084
1093
  )
1085
1094
  ] })
1086
1095
  ] }),
1087
- g("general", "accent") !== "hidden" && /* @__PURE__ */ r("div", { className: f("space-y-4", g("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1088
- /* @__PURE__ */ r(V, { className: "text-sm font-semibold flex items-center gap-2", children: [
1089
- /* @__PURE__ */ e(Ie, { className: "h-4 w-4 text-primary" }),
1096
+ g("general", "accent") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", g("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1097
+ /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1098
+ /* @__PURE__ */ e(De, { className: "h-4 w-4 text-primary" }),
1090
1099
  t("general.accent", "Accent Color")
1091
1100
  ] }),
1092
1101
  /* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
@@ -1106,68 +1115,68 @@ function Ca({ trigger: a }) {
1106
1115
  // Teal
1107
1116
  "oklch(0.552 0.016 285.938)"
1108
1117
  // Slate
1109
- ].map((o) => {
1110
- const F = (p || "oklch(0.623 0.214 259.815)") === o;
1118
+ ].map((i) => {
1119
+ const s = (m || "oklch(0.623 0.214 259.815)") === i;
1111
1120
  return /* @__PURE__ */ e(
1112
1121
  "button",
1113
1122
  {
1114
- onClick: () => m(o),
1123
+ onClick: () => w(i),
1115
1124
  disabled: g("general", "accent") === "faded",
1116
- className: f(
1125
+ className: v(
1117
1126
  "h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
1118
- F ? "border-foreground" : "border-transparent"
1127
+ s ? "border-foreground" : "border-transparent"
1119
1128
  ),
1120
- style: { backgroundColor: o }
1129
+ style: { backgroundColor: i }
1121
1130
  },
1122
- o
1131
+ i
1123
1132
  );
1124
1133
  }) })
1125
1134
  ] }),
1126
- g("general", "radius") !== "hidden" && /* @__PURE__ */ r("div", { className: f("space-y-4", g("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1127
- /* @__PURE__ */ r(V, { className: "text-sm font-semibold flex items-center gap-2", children: [
1135
+ g("general", "radius") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", g("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1136
+ /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1128
1137
  /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
1129
1138
  t("general.radius", "Rounded Corners")
1130
1139
  ] }),
1131
1140
  /* @__PURE__ */ e("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1132
1141
  { id: "sharp", value: "0.3rem" },
1133
1142
  { id: "round", value: "1.25rem" }
1134
- ].map((o) => {
1135
- const F = (N || "1.25rem") === o.value;
1143
+ ].map((i) => {
1144
+ const s = (x || "1.25rem") === i.value;
1136
1145
  return /* @__PURE__ */ e(
1137
1146
  "button",
1138
1147
  {
1139
- onClick: () => v(o.value),
1148
+ onClick: () => C(i.value),
1140
1149
  disabled: g("general", "radius") === "faded",
1141
- className: f(
1150
+ className: v(
1142
1151
  "flex-1 py-2 rounded-xl transition-all text-sm font-medium",
1143
- F ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1152
+ s ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1144
1153
  ),
1145
- children: t(`general.radius_levels.${o.id}`)
1154
+ children: t(`general.radius_levels.${i.id}`)
1146
1155
  },
1147
- o.id
1156
+ i.id
1148
1157
  );
1149
1158
  }) })
1150
1159
  ] }),
1151
- g("general", "language") !== "hidden" && /* @__PURE__ */ r("div", { className: f("space-y-3", g("general", "language") === "faded" && "opacity-50"), children: [
1152
- /* @__PURE__ */ r(V, { className: "text-sm font-semibold flex items-center gap-2", children: [
1153
- /* @__PURE__ */ e(At, { className: "h-4 w-4 text-primary" }),
1160
+ g("general", "language") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", g("general", "language") === "faded" && "opacity-50"), children: [
1161
+ /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1162
+ /* @__PURE__ */ e(Lt, { className: "h-4 w-4 text-primary" }),
1154
1163
  t("general.language", "Language")
1155
1164
  ] }),
1156
1165
  /* @__PURE__ */ r(
1157
1166
  ve,
1158
1167
  {
1159
- value: i.language,
1160
- onValueChange: ae,
1168
+ value: o.language,
1169
+ onValueChange: re,
1161
1170
  disabled: g("general", "language") === "faded",
1162
- dir: w ? "rtl" : "ltr",
1171
+ dir: A ? "rtl" : "ltr",
1163
1172
  children: [
1164
1173
  /* @__PURE__ */ e(xe, { className: "w-full bg-muted/50 rounded-2xl border-border/40 h-11 focus:ring-primary/20", children: /* @__PURE__ */ e(ye, { placeholder: t("general.language_placeholder", "Select language") }) }),
1165
1174
  /* @__PURE__ */ r(we, { className: "rounded-2xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: [
1166
- /* @__PURE__ */ e(me, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1175
+ /* @__PURE__ */ e(pe, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1167
1176
  /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "EN" }),
1168
1177
  t("general.languages.en", "English")
1169
1178
  ] }) }),
1170
- /* @__PURE__ */ e(me, { value: "fa", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1179
+ /* @__PURE__ */ e(pe, { value: "fa", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1171
1180
  /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "FA" }),
1172
1181
  t("general.languages.fa", "Persian")
1173
1182
  ] }) })
@@ -1178,15 +1187,15 @@ function Ca({ trigger: a }) {
1178
1187
  ] })
1179
1188
  ] })
1180
1189
  ] }),
1181
- S === "account" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1190
+ f === "account" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1182
1191
  /* @__PURE__ */ r("div", { children: [
1183
1192
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("account.title", "Account & Usage") }),
1184
1193
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("account.subtitle", "Monitor your quotas and manage your session.") })
1185
1194
  ] }),
1186
1195
  /* @__PURE__ */ r("div", { className: "space-y-6", children: [
1187
- g("account", "balance") !== "hidden" && /* @__PURE__ */ r("div", { className: f("p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6", g("account", "balance") === "faded" && "opacity-50"), children: [
1188
- /* @__PURE__ */ r(V, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1189
- /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
1196
+ g("account", "balance") !== "hidden" && /* @__PURE__ */ r("div", { className: v("p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6", g("account", "balance") === "faded" && "opacity-50"), children: [
1197
+ /* @__PURE__ */ r(Q, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1198
+ /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1190
1199
  t("account.balance", "Current Balance")
1191
1200
  ] }),
1192
1201
  /* @__PURE__ */ r("div", { className: "space-y-5", children: [
@@ -1194,60 +1203,60 @@ function Ca({ trigger: a }) {
1194
1203
  /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1195
1204
  /* @__PURE__ */ e("span", { className: "font-medium text-muted-foreground", children: t("account.tokens", "Tokens") }),
1196
1205
  /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1197
- ee.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1206
+ ie.toLocaleString(o.language, { maximumFractionDigits: 0 }),
1198
1207
  "%"
1199
1208
  ] })
1200
1209
  ] }),
1201
1210
  /* @__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(
1202
1211
  "div",
1203
1212
  {
1204
- className: f(
1213
+ className: v(
1205
1214
  "h-full rounded-full transition-all duration-1000 shadow-sm",
1206
- ee > 60 ? "bg-emerald-500 shadow-emerald-500/20" : ee > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1215
+ ie > 60 ? "bg-emerald-500 shadow-emerald-500/20" : ie > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1207
1216
  ),
1208
- style: { width: `${ee}%` }
1217
+ style: { width: `${ie}%` }
1209
1218
  }
1210
1219
  ) })
1211
1220
  ] }),
1212
1221
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
1213
1222
  /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1214
1223
  /* @__PURE__ */ r("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
1215
- /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
1224
+ /* @__PURE__ */ e(De, { className: "h-3.5 w-3.5 text-blue-500" }),
1216
1225
  t("account.requests", "Requests")
1217
1226
  ] }),
1218
1227
  /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1219
- oe.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1228
+ ne.toLocaleString(o.language, { maximumFractionDigits: 0 }),
1220
1229
  "%"
1221
1230
  ] })
1222
1231
  ] }),
1223
1232
  /* @__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(
1224
1233
  "div",
1225
1234
  {
1226
- className: f(
1235
+ className: v(
1227
1236
  "h-full rounded-full transition-all duration-1000 shadow-sm",
1228
- oe > 60 ? "bg-emerald-500 shadow-emerald-500/20" : oe > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1237
+ ne > 60 ? "bg-emerald-500 shadow-emerald-500/20" : ne > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1229
1238
  ),
1230
- style: { width: `${oe}%` }
1239
+ style: { width: `${ne}%` }
1231
1240
  }
1232
1241
  ) })
1233
1242
  ] })
1234
1243
  ] })
1235
1244
  ] }),
1236
1245
  /* @__PURE__ */ r("div", { className: "pt-2 flex flex-col gap-3", children: [
1237
- k?.balance.updated_at && g("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
1246
+ n?.balance?.updated_at && g("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
1238
1247
  t("account.last_recharge", "Last balance update on"),
1239
1248
  ": ",
1240
- new Date(k.balance.updated_at).toLocaleDateString(i.language)
1249
+ new Date(n.balance?.updated_at || "").toLocaleDateString(o.language)
1241
1250
  ] }),
1242
1251
  g("account", "logout") !== "hidden" && /* @__PURE__ */ r(
1243
- Z,
1252
+ Y,
1244
1253
  {
1245
1254
  variant: "destructive",
1246
- onClick: W,
1255
+ onClick: ee,
1247
1256
  disabled: g("account", "logout") === "faded",
1248
- className: f("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]", g("account", "logout") === "faded" && "opacity-50 pointer-events-none"),
1257
+ className: v("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]", g("account", "logout") === "faded" && "opacity-50 pointer-events-none"),
1249
1258
  children: [
1250
- /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1259
+ /* @__PURE__ */ e(qt, { className: "h-4 w-4" }),
1251
1260
  t("account.logout", "Logout from Account")
1252
1261
  ]
1253
1262
  }
@@ -1256,7 +1265,7 @@ function Ca({ trigger: a }) {
1256
1265
  ] })
1257
1266
  ] })
1258
1267
  ] }) }),
1259
- u?.showVersionInSettings !== !1 && u?.version && g("general", "version") !== "hidden" && /* @__PURE__ */ e("div", { className: f("shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80", g("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: [
1268
+ u?.showVersionInSettings !== !1 && u?.version && g("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", g("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: [
1260
1269
  "v",
1261
1270
  u.version
1262
1271
  ] }) }) })
@@ -1266,32 +1275,32 @@ function Ca({ trigger: a }) {
1266
1275
  ] });
1267
1276
  }
1268
1277
  function We({ hideActions: a = !1 }) {
1269
- const [, t] = Ce(), { t: i } = ce(["sidebar", "chat"]), { history: u, app: l } = re(), { theme: d } = Ke(), h = !a && (u?.enabled ?? !0), [p, m] = P("light");
1270
- O(() => {
1278
+ const [, t] = Ce(), { t: o } = de(["sidebar", "chat"]), { history: u, app: l } = te(), { theme: d } = Ke(), h = !a && (u?.enabled ?? !0), [p, m] = T("light");
1279
+ F(() => {
1271
1280
  if (d === "system") {
1272
- const k = window.matchMedia("(prefers-color-scheme: dark)").matches;
1273
- m(k ? "dark" : "light");
1281
+ const C = window.matchMedia("(prefers-color-scheme: dark)").matches;
1282
+ m(C ? "dark" : "light");
1274
1283
  } else
1275
1284
  m(d);
1276
1285
  }, [d]);
1277
- const N = j(() => l?.logo ? typeof l.logo == "string" ? l.logo : p === "dark" ? l.logo.dark : l.logo.light : lt, [l?.logo, p]), v = l?.name || "Gentiq";
1286
+ const w = R(() => l?.logo ? typeof l.logo == "string" ? l.logo : p === "dark" ? l.logo.dark : l.logo.light : ct, [l?.logo, p]), x = l?.name || "Gentiq";
1278
1287
  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: [
1279
- /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: h && /* @__PURE__ */ e(ya, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1288
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: h && /* @__PURE__ */ e(wa, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1280
1289
  /* @__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(
1281
1290
  "img",
1282
1291
  {
1283
- src: N,
1284
- alt: v,
1292
+ src: w,
1293
+ alt: x,
1285
1294
  className: "size-8 object-contain"
1286
1295
  }
1287
1296
  ) }) }),
1288
1297
  /* @__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: [
1289
1298
  /* @__PURE__ */ r($e, { children: [
1290
- /* @__PURE__ */ e(Be, { asChild: !0, children: /* @__PURE__ */ e(
1299
+ /* @__PURE__ */ e(Ue, { asChild: !0, children: /* @__PURE__ */ e(
1291
1300
  "button",
1292
1301
  {
1293
1302
  type: "button",
1294
- className: f(
1303
+ className: v(
1295
1304
  "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",
1296
1305
  h && "md:hidden"
1297
1306
  ),
@@ -1301,10 +1310,10 @@ function We({ hideActions: a = !1 }) {
1301
1310
  children: /* @__PURE__ */ e(Rt, { className: "size-5" })
1302
1311
  }
1303
1312
  ) }),
1304
- /* @__PURE__ */ e(Ue, { side: "bottom", className: "text-xs", children: i("new_chat") })
1313
+ /* @__PURE__ */ e(Be, { side: "bottom", className: "text-xs", children: o("new_chat") })
1305
1314
  ] }),
1306
1315
  l?.showSettings !== !1 && /* @__PURE__ */ e(
1307
- Ca,
1316
+ Sa,
1308
1317
  {
1309
1318
  trigger: /* @__PURE__ */ e(
1310
1319
  "button",
@@ -1319,13 +1328,13 @@ function We({ hideActions: a = !1 }) {
1319
1328
  ] }) })
1320
1329
  ] });
1321
1330
  }
1322
- const Re = 20;
1323
- function Sa() {
1324
- const t = D.getConfig().app?.cacheNamespace || "gentiq";
1331
+ const qe = 20;
1332
+ function Pa() {
1333
+ const t = E.getConfig().app?.cacheNamespace || "gentiq";
1325
1334
  return tt({
1326
1335
  queryKey: [t, "conversations"],
1327
- queryFn: async ({ pageParam: i = 0 }) => {
1328
- const u = await D.getHistory(i, Re);
1336
+ queryFn: async ({ pageParam: o = 0 }) => {
1337
+ const u = await E.getHistory(o, qe);
1329
1338
  return {
1330
1339
  threads: u.threads.map((l) => ({
1331
1340
  id: `/${l.id}`,
@@ -1333,88 +1342,88 @@ function Sa() {
1333
1342
  timestamp: new Date(l.created_at).getTime(),
1334
1343
  pinned: !!l.pinned
1335
1344
  })),
1336
- nextSkip: i + Re,
1337
- hasMore: i + u.threads.length < (u.total_count ?? 0)
1345
+ nextSkip: o + qe,
1346
+ hasMore: o + u.threads.length < (u.total_count ?? 0)
1338
1347
  };
1339
1348
  },
1340
1349
  initialPageParam: 0,
1341
- getNextPageParam: (i) => i.hasMore ? i.nextSkip : void 0,
1350
+ getNextPageParam: (o) => o.hasMore ? o.nextSkip : void 0,
1342
1351
  staleTime: 1e3 * 60 * 5
1343
1352
  // 5 minutes
1344
1353
  });
1345
1354
  }
1346
- async function Pa(a, t, i, u) {
1347
- const d = D.getConfig().app?.cacheNamespace || "gentiq";
1355
+ async function Ta(a, t, o, u) {
1356
+ const d = E.getConfig().app?.cacheNamespace || "gentiq";
1348
1357
  try {
1349
- await D.deleteThread(a), t.invalidateQueries({ queryKey: [d, "conversations"] }), u === a && i("/");
1358
+ await E.deleteThread(a), t.invalidateQueries({ queryKey: [d, "conversations"] }), u === a && o("/");
1350
1359
  } catch (h) {
1351
- console.error("Failed to delete conversation:", h), J.error("Failed to delete conversation");
1360
+ console.error("Failed to delete conversation:", h), X.error("Failed to delete conversation");
1352
1361
  }
1353
1362
  }
1354
- function Ta({ side: a = "left" }) {
1355
- const { t, i18n: i } = ce(["sidebar", "translation"]), { setOpenMobile: u, isMobile: l } = ge(), {
1363
+ function Ma({ side: a = "left" }) {
1364
+ const { t, i18n: o } = de(["sidebar", "translation"]), { setOpenMobile: u, isMobile: l } = fe(), {
1356
1365
  data: d,
1357
1366
  fetchNextPage: h,
1358
1367
  hasNextPage: p,
1359
1368
  isFetchingNextPage: m,
1360
- isLoading: N
1361
- } = Sa(), { history: v, app: k } = re(), s = k?.basePath || "/", M = v?.enabled ?? !1, T = d?.pages.flatMap((n) => n.threads) ?? [], [q, K] = Ce(), S = pe(), y = te(null), g = Y(
1362
- (n) => {
1363
- y.current && (y.current.disconnect(), y.current = null), n && p && !m && (y.current = new IntersectionObserver(
1364
- (H) => {
1365
- H[0].isIntersecting && h();
1369
+ isLoading: w
1370
+ } = Pa(), { history: x, app: C } = te(), n = C?.basePath || "/", D = x?.enabled ?? !1, P = d?.pages.flatMap((s) => s.threads) ?? [], [j, U] = Ce(), I = ue(), f = Z(null), q = J(
1371
+ (s) => {
1372
+ f.current && (f.current.disconnect(), f.current = null), s && p && !m && (f.current = new IntersectionObserver(
1373
+ (_) => {
1374
+ _[0].isIntersecting && h();
1366
1375
  },
1367
1376
  {
1368
1377
  threshold: 0,
1369
1378
  rootMargin: "100px"
1370
1379
  }
1371
- ), y.current.observe(n));
1380
+ ), f.current.observe(s));
1372
1381
  },
1373
1382
  [p, h, m]
1374
- ), B = D.getConfig().app?.cacheNamespace || "gentiq", [G, $] = P(!1), [A, U] = P(null), [E, Q] = P(""), [R, b] = P(null), [_, x] = P(""), c = te(null), w = Y((n, H) => {
1375
- n.button !== 0 || n.metaKey || n.ctrlKey || (n.preventDefault(), K(H), l && u(!1));
1376
- }, [K, l, u]), L = T.filter(
1377
- (n) => n.firstMessage?.toLowerCase().includes(E.toLowerCase())
1378
- ).sort((n, H) => n.pinned && !H.pinned ? -1 : !n.pinned && H.pinned ? 1 : H.timestamp - n.timestamp), C = async (n) => {
1383
+ ), B = E.getConfig().app?.cacheNamespace || "gentiq", [V, O] = T(!1), [z, K] = T(null), [L, H] = T(""), [$, N] = T(null), [y, b] = T(""), c = Z(null), k = J((s, _) => {
1384
+ s.button !== 0 || s.metaKey || s.ctrlKey || (s.preventDefault(), U(_), l && u(!1));
1385
+ }, [U, l, u]), A = P.filter(
1386
+ (s) => s.firstMessage?.toLowerCase().includes(L.toLowerCase())
1387
+ ).sort((s, _) => s.pinned && !_.pinned ? -1 : !s.pinned && _.pinned ? 1 : _.timestamp - s.timestamp), S = async (s) => {
1379
1388
  try {
1380
- await D.pinThread(n.id.replace(/^\//, ""), !n.pinned), S.invalidateQueries({ queryKey: [B, "conversations"] }), J.success(n.pinned ? t("unpinned_success") : t("pinned_success"));
1389
+ await E.pinThread(s.id.replace(/^\//, ""), !s.pinned), I.invalidateQueries({ queryKey: [B, "conversations"] }), X.success(s.pinned ? t("unpinned_success") : t("pinned_success"));
1381
1390
  } catch {
1382
- J.error(t("pin_failed"));
1391
+ X.error(t("pin_failed"));
1383
1392
  }
1384
- }, I = async (n) => {
1393
+ }, M = async (s) => {
1385
1394
  try {
1386
- const H = await D.shareThread(n.id.replace(/^\//, "")), fe = `${window.location.origin}${H.url}`;
1387
- navigator.clipboard.writeText(fe), J.success(t("share_success"), {
1395
+ const _ = await E.shareThread(s.id.replace(/^\//, "")), se = `${window.location.origin}${_.url}`;
1396
+ navigator.clipboard.writeText(se), X.success(t("share_success"), {
1388
1397
  description: t("share_description")
1389
1398
  });
1390
1399
  } catch {
1391
- J.error(t("share_failed"));
1400
+ X.error(t("share_failed"));
1392
1401
  }
1393
- }, W = (n) => {
1394
- b(n.id), x(n.firstMessage ?? ""), setTimeout(() => c.current?.focus(), 0);
1395
- }, ae = (n) => {
1396
- n?.preventDefault(), n?.stopPropagation(), b(null), x("");
1397
- }, ee = async (n) => {
1398
- if (n?.preventDefault(), n && "stopPropagation" in n && n.stopPropagation(), !(!R || !_.trim()))
1402
+ }, G = (s) => {
1403
+ N(s.id), b(s.firstMessage ?? ""), setTimeout(() => c.current?.focus(), 0);
1404
+ }, ee = (s) => {
1405
+ s?.preventDefault(), s?.stopPropagation(), N(null), b("");
1406
+ }, re = async (s) => {
1407
+ if (s?.preventDefault(), s && "stopPropagation" in s && s.stopPropagation(), !(!$ || !y.trim()))
1399
1408
  try {
1400
- await D.updateThreadTitle(R, _), S.invalidateQueries({ queryKey: [B, "conversations"] }), b(null), J.success(t("rename_success"));
1409
+ await E.updateThreadTitle($, y), I.invalidateQueries({ queryKey: [B, "conversations"] }), N(null), X.success(t("rename_success"));
1401
1410
  } catch {
1402
- J.error(t("rename_failed"));
1411
+ X.error(t("rename_failed"));
1403
1412
  }
1404
- }, oe = (n) => {
1405
- U(n), $(!0);
1406
- }, o = () => {
1407
- A && (Pa(A.id, S, K, q), $(!1), U(null), J.success(t("chat_deleted_success")));
1408
- }, F = (n) => new Intl.DateTimeFormat(i.language, {
1413
+ }, ie = (s) => {
1414
+ K(s), O(!0);
1415
+ }, ne = () => {
1416
+ z && (Ta(z.id, I, U, j), O(!1), K(null), X.success(t("chat_deleted_success")));
1417
+ }, i = (s) => new Intl.DateTimeFormat(o.language, {
1409
1418
  year: "numeric",
1410
1419
  month: "short",
1411
1420
  day: "numeric",
1412
1421
  hour: "2-digit",
1413
1422
  minute: "2-digit",
1414
- calendar: i.language === "fa" ? "persian" : "gregory"
1415
- }).format(new Date(n));
1416
- return /* @__PURE__ */ e(Oe, { children: /* @__PURE__ */ r(xa, { collapsible: "icon", side: a, children: [
1417
- /* @__PURE__ */ e(Na, { className: "custom-scrollbar", children: /* @__PURE__ */ r(ka, { children: [
1423
+ calendar: o.language === "fa" ? "persian" : "gregory"
1424
+ }).format(new Date(s));
1425
+ return /* @__PURE__ */ e(Oe, { children: /* @__PURE__ */ r(ya, { collapsible: "icon", side: a, children: [
1426
+ /* @__PURE__ */ e(ka, { className: "custom-scrollbar", children: /* @__PURE__ */ r(_a, { children: [
1418
1427
  /* @__PURE__ */ e(Ae, { 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(
1419
1428
  ze,
1420
1429
  {
@@ -1424,114 +1433,114 @@ function Ta({ side: a = "left" }) {
1424
1433
  children: /* @__PURE__ */ r(
1425
1434
  "a",
1426
1435
  {
1427
- href: be(s, "/"),
1428
- onClick: (n) => w(n, "/"),
1436
+ href: be(n, "/"),
1437
+ onClick: (s) => k(s, "/"),
1429
1438
  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",
1430
1439
  children: [
1431
1440
  /* @__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" }),
1432
- /* @__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(qt, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1441
+ /* @__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(Ft, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1433
1442
  /* @__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") })
1434
1443
  ]
1435
1444
  }
1436
1445
  )
1437
1446
  }
1438
1447
  ) }) }),
1439
- M && /* @__PURE__ */ e(Ee, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ r("div", { className: "relative group/search", children: [
1440
- /* @__PURE__ */ e(Ft, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
1448
+ D && /* @__PURE__ */ e(Ee, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ r("div", { className: "relative group/search", children: [
1449
+ /* @__PURE__ */ e(jt, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
1441
1450
  /* @__PURE__ */ e(
1442
- X,
1451
+ W,
1443
1452
  {
1444
1453
  placeholder: t("search_conversations"),
1445
- value: E,
1446
- onChange: (n) => Q(n.target.value),
1454
+ value: L,
1455
+ onChange: (s) => H(s.target.value),
1447
1456
  className: "pl-9 h-10 bg-accent/15 border border-border/40 focus-visible:ring-primary/20 rounded-xl transition-all"
1448
1457
  }
1449
1458
  )
1450
1459
  ] }) }),
1451
- M && /* @__PURE__ */ r(Ee, { className: "group-data-[collapsible=icon]:hidden", children: [
1460
+ D && /* @__PURE__ */ r(Ee, { className: "group-data-[collapsible=icon]:hidden", children: [
1452
1461
  /* @__PURE__ */ r(Ae, { children: [
1453
- L.map((n, H) => {
1454
- const fe = R === n.id, Se = Te(n.firstMessage ?? ""), Xe = Se === "rtl";
1455
- return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: fe ? /* @__PURE__ */ r("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
1462
+ A.map((s, _) => {
1463
+ const se = $ === s.id, Se = Te(s.firstMessage ?? ""), Xe = Se === "rtl";
1464
+ return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: se ? /* @__PURE__ */ r("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
1456
1465
  /* @__PURE__ */ e(
1457
- X,
1466
+ W,
1458
1467
  {
1459
1468
  ref: c,
1460
- value: _,
1461
- onChange: (ie) => x(ie.target.value),
1462
- onKeyDown: (ie) => {
1463
- ie.key === "Enter" && ee(), ie.key === "Escape" && ae();
1469
+ value: y,
1470
+ onChange: (le) => b(le.target.value),
1471
+ onKeyDown: (le) => {
1472
+ le.key === "Enter" && re(), le.key === "Escape" && ee();
1464
1473
  },
1465
1474
  className: "h-8 py-0 px-2 text-sm",
1466
- dir: Te(_)
1475
+ dir: Te(y)
1467
1476
  }
1468
1477
  ),
1469
- /* @__PURE__ */ e(Z, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50", onClick: ee, children: /* @__PURE__ */ e(jt, { className: "size-4" }) }),
1470
- /* @__PURE__ */ e(Z, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-destructive hover:bg-destructive/10", onClick: ae, children: /* @__PURE__ */ e(Ot, { className: "size-4" }) })
1478
+ /* @__PURE__ */ e(Y, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50", onClick: re, children: /* @__PURE__ */ e(Ot, { className: "size-4" }) }),
1479
+ /* @__PURE__ */ e(Y, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-destructive hover:bg-destructive/10", onClick: ee, children: /* @__PURE__ */ e($t, { className: "size-4" }) })
1471
1480
  ] }) : /* @__PURE__ */ r(ke, { children: [
1472
1481
  /* @__PURE__ */ e(
1473
1482
  ze,
1474
1483
  {
1475
1484
  asChild: !0,
1476
- className: f("h-auto py-2.5 px-3", {
1477
- "bg-accent opacity-100 pointer-events-none": n.id === q,
1478
- "opacity-70 hover:opacity-100": n.id !== q
1485
+ className: v("h-auto py-2.5 px-3", {
1486
+ "bg-accent opacity-100 pointer-events-none": s.id === j,
1487
+ "opacity-70 hover:opacity-100": s.id !== j
1479
1488
  }),
1480
1489
  children: /* @__PURE__ */ r(
1481
1490
  "a",
1482
1491
  {
1483
- href: be(s, n.id),
1484
- onClick: (ie) => w(ie, n.id),
1492
+ href: be(n, s.id),
1493
+ onClick: (le) => k(le, s.id),
1485
1494
  dir: Se,
1486
- className: f("flex flex-col gap-0.5 w-full overflow-hidden", Xe ? "items-end" : "items-start"),
1495
+ className: v("flex flex-col gap-0.5 w-full overflow-hidden", Xe ? "items-end" : "items-start"),
1487
1496
  children: [
1488
- /* @__PURE__ */ e("span", { className: f("truncate w-full font-medium text-[0.9375rem]", i.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: n.firstMessage }),
1489
- /* @__PURE__ */ e("div", { className: f("text-[10px] opacity-40 w-full", i.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: F(n.timestamp) })
1497
+ /* @__PURE__ */ e("span", { className: v("truncate w-full font-medium text-[0.9375rem]", o.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: s.firstMessage }),
1498
+ /* @__PURE__ */ e("div", { className: v("text-[10px] opacity-40 w-full", o.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: i(s.timestamp) })
1490
1499
  ]
1491
1500
  }
1492
1501
  )
1493
1502
  }
1494
1503
  ),
1495
- /* @__PURE__ */ r("div", { className: f(
1504
+ /* @__PURE__ */ r("div", { className: v(
1496
1505
  "absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
1497
- i.language === "fa" ? "left-2" : "right-1.5"
1506
+ o.language === "fa" ? "left-2" : "right-1.5"
1498
1507
  ), children: [
1499
- n.pinned && /* @__PURE__ */ e(De, { className: "size-3.5 text-primary opacity-70 md:absolute md:inset-0 md:m-auto md:group-hover/sidebar-menu-item:opacity-0 transition-opacity pointer-events-none" }),
1500
- /* @__PURE__ */ r(ct, { dir: i.language === "fa" ? "rtl" : "ltr", children: [
1501
- /* @__PURE__ */ e(dt, { asChild: !0, children: /* @__PURE__ */ e(
1502
- Z,
1508
+ s.pinned && /* @__PURE__ */ e(Ie, { 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" }),
1509
+ /* @__PURE__ */ r(dt, { dir: o.language === "fa" ? "rtl" : "ltr", children: [
1510
+ /* @__PURE__ */ e(ut, { asChild: !0, children: /* @__PURE__ */ e(
1511
+ Y,
1503
1512
  {
1504
1513
  variant: "ghost",
1505
1514
  size: "icon",
1506
1515
  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",
1507
- children: /* @__PURE__ */ e($t, { className: "size-3.5" })
1516
+ children: /* @__PURE__ */ e(Ut, { className: "size-3.5" })
1508
1517
  }
1509
1518
  ) }),
1510
1519
  /* @__PURE__ */ r(
1511
- ut,
1520
+ mt,
1512
1521
  {
1513
1522
  align: "end",
1514
1523
  className: "min-w-[120px] p-1",
1515
1524
  children: [
1516
- v?.showPin !== !1 && /* @__PURE__ */ r(de, { onSelect: () => C(n), className: "cursor-pointer flex items-center gap-2", children: [
1517
- n.pinned ? /* @__PURE__ */ e(Bt, { className: "size-4" }) : /* @__PURE__ */ e(De, { className: "size-4" }),
1518
- /* @__PURE__ */ e("span", { children: n.pinned ? t("unpin_conversation") : t("pin_conversation") })
1525
+ x?.showPin !== !1 && /* @__PURE__ */ r(me, { onSelect: () => S(s), className: "cursor-pointer flex items-center gap-2", children: [
1526
+ s.pinned ? /* @__PURE__ */ e(Bt, { className: "size-4" }) : /* @__PURE__ */ e(Ie, { className: "size-4" }),
1527
+ /* @__PURE__ */ e("span", { children: s.pinned ? t("unpin_conversation") : t("pin_conversation") })
1519
1528
  ] }),
1520
- v?.showShare !== !1 && /* @__PURE__ */ r(de, { onSelect: () => I(n), className: "cursor-pointer flex items-center gap-2", children: [
1521
- /* @__PURE__ */ e(Ut, { className: "size-4" }),
1529
+ x?.showShare !== !1 && /* @__PURE__ */ r(me, { onSelect: () => M(s), className: "cursor-pointer flex items-center gap-2", children: [
1530
+ /* @__PURE__ */ e(Kt, { className: "size-4" }),
1522
1531
  /* @__PURE__ */ e("span", { children: t("share_conversation") })
1523
1532
  ] }),
1524
- (v?.showRename ?? !1) && /* @__PURE__ */ r(de, { onSelect: () => W(n), className: "cursor-pointer flex items-center gap-2", children: [
1525
- /* @__PURE__ */ e(Kt, { className: "size-4" }),
1533
+ (x?.showRename ?? !1) && /* @__PURE__ */ r(me, { onSelect: () => G(s), className: "cursor-pointer flex items-center gap-2", children: [
1534
+ /* @__PURE__ */ e(Ht, { className: "size-4" }),
1526
1535
  /* @__PURE__ */ e("span", { children: t("rename_conversation") })
1527
1536
  ] }),
1528
- (v?.showDelete ?? !1) && /* @__PURE__ */ r(
1529
- de,
1537
+ (x?.showDelete ?? !1) && /* @__PURE__ */ r(
1538
+ me,
1530
1539
  {
1531
1540
  className: "text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer flex items-center gap-2",
1532
- onSelect: () => oe(n),
1541
+ onSelect: () => ie(s),
1533
1542
  children: [
1534
- /* @__PURE__ */ e(Ht, { className: "size-4" }),
1543
+ /* @__PURE__ */ e(Qt, { className: "size-4" }),
1535
1544
  /* @__PURE__ */ e("span", { children: t("delete_conversation") })
1536
1545
  ]
1537
1546
  }
@@ -1541,64 +1550,64 @@ function Ta({ side: a = "left" }) {
1541
1550
  )
1542
1551
  ] })
1543
1552
  ] })
1544
- ] }) }, H);
1553
+ ] }) }, _);
1545
1554
  }),
1546
- !N && T.length === 0 && !E && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
1555
+ !w && P.length === 0 && !L && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
1547
1556
  ] }),
1548
- /* @__PURE__ */ e("div", { ref: g, className: "h-4 w-full" }),
1557
+ /* @__PURE__ */ e("div", { ref: q, className: "h-4 w-full" }),
1549
1558
  m && /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
1550
1559
  /* @__PURE__ */ e("div", { className: "size-4 border-2 border-primary border-t-transparent rounded-full animate-spin" }),
1551
1560
  /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wider font-medium", children: t("loading_more") })
1552
1561
  ] })
1553
1562
  ] })
1554
1563
  ] }) }),
1555
- /* @__PURE__ */ e(wa, {}),
1556
- /* @__PURE__ */ e(He, { open: G, onOpenChange: $, children: /* @__PURE__ */ r(
1557
- Ve,
1564
+ /* @__PURE__ */ e(Na, {}),
1565
+ /* @__PURE__ */ e(He, { open: V, onOpenChange: O, children: /* @__PURE__ */ r(
1566
+ Qe,
1558
1567
  {
1559
- onKeyDown: (n) => {
1560
- n.key === "Enter" && (n.preventDefault(), o());
1568
+ onKeyDown: (s) => {
1569
+ s.key === "Enter" && (s.preventDefault(), ne());
1561
1570
  },
1562
1571
  children: [
1563
- /* @__PURE__ */ r(mt, { children: [
1564
- /* @__PURE__ */ e(ht, { children: t("delete_confirm_title") }),
1565
- /* @__PURE__ */ e(pt, { children: t("delete_confirm_description") })
1572
+ /* @__PURE__ */ r(ht, { children: [
1573
+ /* @__PURE__ */ e(pt, { children: t("delete_confirm_title") }),
1574
+ /* @__PURE__ */ e(gt, { children: t("delete_confirm_description") })
1566
1575
  ] }),
1567
- /* @__PURE__ */ r(gt, { children: [
1576
+ /* @__PURE__ */ r(ft, { children: [
1568
1577
  /* @__PURE__ */ e(
1569
- Z,
1578
+ Y,
1570
1579
  {
1571
1580
  variant: "outline",
1572
1581
  onClick: () => {
1573
- $(!1);
1582
+ O(!1);
1574
1583
  },
1575
1584
  children: t("cancel")
1576
1585
  }
1577
1586
  ),
1578
- /* @__PURE__ */ e(Z, { variant: "destructive", onClick: o, autoFocus: !0, children: t("delete") })
1587
+ /* @__PURE__ */ e(Y, { variant: "destructive", onClick: ne, autoFocus: !0, children: t("delete") })
1579
1588
  ] })
1580
1589
  ]
1581
1590
  }
1582
1591
  ) })
1583
1592
  ] }) });
1584
1593
  }
1585
- function Va({ sidebar: a, header: t, components: i, classNames: u, disclaimer: l, welcome: d }) {
1586
- const { config: h } = je(), { history: p } = re(), m = h?.language === "fa" ? "right" : "left", N = p?.enabled ?? !0;
1587
- return /* @__PURE__ */ r(va, { defaultOpen: N, children: [
1588
- a !== void 0 ? a : N ? /* @__PURE__ */ e(Ta, { side: m }) : null,
1594
+ function Va({ sidebar: a, header: t, components: o, classNames: u, disclaimer: l, welcome: d }) {
1595
+ const { config: h } = je(), { history: p } = te(), m = h?.language === "fa" ? "right" : "left", w = p?.enabled ?? !0;
1596
+ return /* @__PURE__ */ r(xa, { defaultOpen: w, children: [
1597
+ a !== void 0 ? a : w ? /* @__PURE__ */ e(Ma, { side: m }) : null,
1589
1598
  /* @__PURE__ */ r("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
1590
1599
  t !== void 0 ? t : /* @__PURE__ */ e(We, {}),
1591
1600
  /* @__PURE__ */ e(
1592
1601
  "div",
1593
1602
  {
1594
- className: f(
1603
+ className: v(
1595
1604
  "flex flex-col relative w-full flex-1 min-h-0 overflow-hidden",
1596
1605
  "has-[.stick-to-bottom:empty]:overflow-visible has-[.stick-to-bottom:empty]:flex-initial transition-[flex] duration-200"
1597
1606
  ),
1598
1607
  children: /* @__PURE__ */ e(
1599
- na,
1608
+ sa,
1600
1609
  {
1601
- components: i,
1610
+ components: o,
1602
1611
  classNames: u,
1603
1612
  disclaimer: l,
1604
1613
  welcome: d
@@ -1609,111 +1618,111 @@ function Va({ sidebar: a, header: t, components: i, classNames: u, disclaimer: l
1609
1618
  ] })
1610
1619
  ] });
1611
1620
  }
1612
- function Qa({ children: a }) {
1613
- const [t, i] = P(null), u = Qe(), l = _e(), d = pe();
1614
- return O(() => {
1621
+ function Ga({ children: a }) {
1622
+ const [t, o] = T(null), u = Ve(), l = _e(), d = ue();
1623
+ return F(() => {
1615
1624
  (async () => {
1616
1625
  const p = new URLSearchParams(u.search), m = p.get("token");
1617
1626
  if (m)
1618
1627
  try {
1619
- D.setToken(m), await D.getBalance(), p.delete("token");
1620
- const v = p.toString(), k = u.pathname + (v ? `?${v}` : "");
1621
- l(k, { replace: !0 }), i(!0);
1628
+ E.setToken(m), await E.getBalance(), p.delete("token");
1629
+ const x = p.toString(), C = u.pathname + (x ? `?${x}` : "");
1630
+ l(C, { replace: !0 }), o(!0);
1622
1631
  return;
1623
- } catch (v) {
1624
- console.error("Error validating token from URL:", v), i(!1);
1632
+ } catch (x) {
1633
+ console.error("Error validating token from URL:", x), o(!1);
1625
1634
  return;
1626
1635
  }
1627
- if (!D.getToken()) {
1628
- i(!1);
1636
+ if (!E.getToken()) {
1637
+ o(!1);
1629
1638
  return;
1630
1639
  }
1631
1640
  try {
1632
- await D.getBalance(), i(!0);
1633
- } catch (v) {
1634
- console.error("Token validation failed:", v), v.status === 401 ? (D.clearToken(), d.clear(), i(!1)) : i(!0);
1641
+ await E.getBalance(), o(!0);
1642
+ } catch (x) {
1643
+ console.error("Token validation failed:", x), x.status === 401 ? (E.clearToken(), d.clear(), o(!1)) : o(!0);
1635
1644
  }
1636
1645
  })();
1637
- }, [u.search, l, u.pathname, d]), t === null ? /* @__PURE__ */ e("div", { className: "flex h-screen w-full items-center justify-center", children: /* @__PURE__ */ e("div", { className: "size-8 rounded-full border-4 border-primary border-t-transparent animate-spin" }) }) : t ? /* @__PURE__ */ e(ke, { children: a }) : /* @__PURE__ */ e(Xt, { to: "/login", replace: !0 });
1646
+ }, [u.search, l, u.pathname, d]), t === null ? /* @__PURE__ */ e("div", { className: "flex h-screen w-full items-center justify-center", children: /* @__PURE__ */ e("div", { className: "size-8 rounded-full border-4 border-primary border-t-transparent animate-spin" }) }) : t ? /* @__PURE__ */ e(ke, { children: a }) : /* @__PURE__ */ e(Jt, { to: "/login", replace: !0 });
1638
1647
  }
1639
- const qe = (a) => a.replace(/[^0-9]/g, "");
1640
- function Ga() {
1641
- const { t: a, i18n: t } = ce(["login", "translation"]), { app: i } = re(), u = t.dir() === "rtl", l = u ? "text-right" : "text-left", d = _e(), h = pe(), [p, m] = P("login"), N = !!i?.disableSignup, v = !!i?.disableAuthPage, [k, s] = P(""), [M, T] = P(""), [q, K] = P(""), [S, y] = P(""), [g, z] = P(""), [B, G] = P(""), $ = j(() => i?.userMetadataFields?.filter((c) => c.showInSignup) || [], [i?.userMetadataFields]), [A, U] = P(() => {
1648
+ const Re = (a) => a.replace(/[^0-9]/g, "");
1649
+ function Wa() {
1650
+ const { t: a, i18n: t } = de(["login", "translation"]), { app: o } = te(), u = t.dir() === "rtl", l = u ? "text-right" : "text-left", d = _e(), h = ue(), [p, m] = T("login"), w = !!o?.disableSignup, x = !!o?.disableAuthPage, [C, n] = T(""), [D, P] = T(""), [j, U] = T(""), [I, f] = T(""), [q, g] = T(""), [B, V] = T(""), O = R(() => o?.userMetadataFields?.filter((c) => c.showInSignup) || [], [o?.userMetadataFields]), [z, K] = T(() => {
1642
1651
  const c = {};
1643
- return $.forEach((w) => {
1644
- w.defaultValue !== void 0 && (c[w.key] = w.defaultValue);
1652
+ return O.forEach((k) => {
1653
+ k.defaultValue !== void 0 && (c[k.key] = k.defaultValue);
1645
1654
  }), c;
1646
1655
  });
1647
- O(() => {
1648
- const c = { ...A };
1649
- let w = !1;
1650
- $.forEach((L) => {
1651
- L.condition && !he(L.condition, A) && c[L.key] !== void 0 && (delete c[L.key], w = !0);
1652
- }), w && U(c);
1653
- }, [A, $]);
1654
- const [E, Q] = P(""), [R, b] = P(!1);
1655
- O(() => {
1656
- N && p === "register" && m("login");
1657
- }, [N, p]);
1658
- const _ = async (c) => {
1659
- c.preventDefault(), Q(""), b(!0);
1656
+ F(() => {
1657
+ const c = { ...z };
1658
+ let k = !1;
1659
+ O.forEach((A) => {
1660
+ A.condition && !ge(A.condition, z) && c[A.key] !== void 0 && (delete c[A.key], k = !0);
1661
+ }), k && K(c);
1662
+ }, [z, O]);
1663
+ const [L, H] = T(""), [$, N] = T(!1);
1664
+ F(() => {
1665
+ w && p === "register" && m("login");
1666
+ }, [w, p]);
1667
+ const y = async (c) => {
1668
+ c.preventDefault(), H(""), N(!0);
1660
1669
  try {
1661
- await D.login(k, M), h.clear(), d("/");
1662
- } catch (w) {
1663
- Q(le(w, a));
1670
+ await E.login(C, D), h.clear(), d("/");
1671
+ } catch (k) {
1672
+ H(ce(k, a));
1664
1673
  } finally {
1665
- b(!1);
1674
+ N(!1);
1666
1675
  }
1667
- }, x = async (c) => {
1668
- c.preventDefault(), Q(""), b(!0);
1676
+ }, b = async (c) => {
1677
+ c.preventDefault(), H(""), N(!0);
1669
1678
  try {
1670
- await D.register(q, S, g, B, A), h.clear(), d("/");
1671
- } catch (w) {
1672
- Q(le(w, a));
1679
+ await E.register(j, I, q, B, z), h.clear(), d("/");
1680
+ } catch (k) {
1681
+ H(ce(k, a));
1673
1682
  } finally {
1674
- b(!1);
1683
+ N(!1);
1675
1684
  }
1676
1685
  };
1677
- return v ? /* @__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: [
1678
- /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: i?.name }),
1686
+ return x ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center p-4", dir: t.dir(), children: /* @__PURE__ */ r("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
1687
+ /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: o?.name }),
1679
1688
  /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
1680
1689
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: a("auth_page_disabled_description", "Please contact the administrator for access.") })
1681
1690
  ] }) }) : /* @__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: [
1682
- /* @__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 }) }),
1691
+ /* @__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: o?.name }) }),
1683
1692
  /* @__PURE__ */ r("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
1684
1693
  /* @__PURE__ */ e(
1685
1694
  "button",
1686
1695
  {
1687
1696
  type: "button",
1688
1697
  onClick: () => {
1689
- m("login"), Q("");
1698
+ m("login"), H("");
1690
1699
  },
1691
1700
  className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${p === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1692
1701
  children: a("login_tab", "Login")
1693
1702
  }
1694
1703
  ),
1695
- !N && /* @__PURE__ */ e(
1704
+ !w && /* @__PURE__ */ e(
1696
1705
  "button",
1697
1706
  {
1698
1707
  type: "button",
1699
1708
  onClick: () => {
1700
- m("register"), Q("");
1709
+ m("register"), H("");
1701
1710
  },
1702
1711
  className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${p === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1703
1712
  children: a("signup_tab", "Sign Up")
1704
1713
  }
1705
1714
  )
1706
1715
  ] }),
1707
- p === "login" && /* @__PURE__ */ r("form", { onSubmit: _, className: "space-y-4", children: [
1716
+ p === "login" && /* @__PURE__ */ r("form", { onSubmit: y, className: "space-y-4", children: [
1708
1717
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1709
- /* @__PURE__ */ e(V, { htmlFor: "login-phone", children: a("phone", "Phone") }),
1718
+ /* @__PURE__ */ e(Q, { htmlFor: "login-phone", children: a("phone", "Phone") }),
1710
1719
  /* @__PURE__ */ e(
1711
- X,
1720
+ W,
1712
1721
  {
1713
1722
  id: "login-phone",
1714
1723
  type: "tel",
1715
- value: k,
1716
- onChange: (c) => s(qe(c.target.value)),
1724
+ value: C,
1725
+ onChange: (c) => n(Re(c.target.value)),
1717
1726
  required: !0,
1718
1727
  className: "text-left",
1719
1728
  placeholder: a("phone_placeholder", "Phone number"),
@@ -1722,14 +1731,14 @@ function Ga() {
1722
1731
  )
1723
1732
  ] }),
1724
1733
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1725
- /* @__PURE__ */ e(V, { htmlFor: "login-pass", children: a("password", "Password") }),
1734
+ /* @__PURE__ */ e(Q, { htmlFor: "login-pass", children: a("password", "Password") }),
1726
1735
  /* @__PURE__ */ e(
1727
- X,
1736
+ W,
1728
1737
  {
1729
1738
  id: "login-pass",
1730
1739
  type: "password",
1731
- value: M,
1732
- onChange: (c) => T(c.target.value),
1740
+ value: D,
1741
+ onChange: (c) => P(c.target.value),
1733
1742
  required: !0,
1734
1743
  className: "text-left",
1735
1744
  placeholder: "••••••••",
@@ -1737,27 +1746,27 @@ function Ga() {
1737
1746
  }
1738
1747
  )
1739
1748
  ] }),
1740
- E && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: E }),
1749
+ L && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: L }),
1741
1750
  /* @__PURE__ */ e(
1742
- Z,
1751
+ Y,
1743
1752
  {
1744
1753
  type: "submit",
1745
- disabled: R,
1754
+ disabled: $,
1746
1755
  className: "w-full font-semibold",
1747
- children: R ? a("logging_in", "Logging in...") : a("login_button", "Login")
1756
+ children: $ ? a("logging_in", "Logging in...") : a("login_button", "Login")
1748
1757
  }
1749
1758
  )
1750
1759
  ] }),
1751
- !N && p === "register" && /* @__PURE__ */ r("form", { onSubmit: x, className: "space-y-4", children: [
1760
+ !w && p === "register" && /* @__PURE__ */ r("form", { onSubmit: b, className: "space-y-4", children: [
1752
1761
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1753
- /* @__PURE__ */ e(V, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
1762
+ /* @__PURE__ */ e(Q, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
1754
1763
  /* @__PURE__ */ e(
1755
- X,
1764
+ W,
1756
1765
  {
1757
1766
  id: "reg-phone",
1758
1767
  type: "tel",
1759
- value: q,
1760
- onChange: (c) => K(qe(c.target.value)),
1768
+ value: j,
1769
+ onChange: (c) => U(Re(c.target.value)),
1761
1770
  required: !0,
1762
1771
  className: "text-left",
1763
1772
  placeholder: a("phone_placeholder", "Phone number"),
@@ -1766,14 +1775,14 @@ function Ga() {
1766
1775
  )
1767
1776
  ] }),
1768
1777
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1769
- /* @__PURE__ */ e(V, { htmlFor: "reg-pass", children: a("password", "Password") }),
1778
+ /* @__PURE__ */ e(Q, { htmlFor: "reg-pass", children: a("password", "Password") }),
1770
1779
  /* @__PURE__ */ e(
1771
- X,
1780
+ W,
1772
1781
  {
1773
1782
  id: "reg-pass",
1774
1783
  type: "password",
1775
- value: S,
1776
- onChange: (c) => y(c.target.value),
1784
+ value: I,
1785
+ onChange: (c) => f(c.target.value),
1777
1786
  required: !0,
1778
1787
  className: "text-left",
1779
1788
  placeholder: "••••••••",
@@ -1783,14 +1792,14 @@ function Ga() {
1783
1792
  ] }),
1784
1793
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1785
1794
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1786
- /* @__PURE__ */ e(V, { htmlFor: "reg-name", children: a("name", "Name") }),
1795
+ /* @__PURE__ */ e(Q, { htmlFor: "reg-name", children: a("name", "Name") }),
1787
1796
  /* @__PURE__ */ e(
1788
- X,
1797
+ W,
1789
1798
  {
1790
1799
  id: "reg-name",
1791
1800
  type: "text",
1792
- value: g,
1793
- onChange: (c) => z(c.target.value),
1801
+ value: q,
1802
+ onChange: (c) => g(c.target.value),
1794
1803
  required: !0,
1795
1804
  className: l,
1796
1805
  placeholder: a("name_placeholder", "First Name")
@@ -1798,14 +1807,14 @@ function Ga() {
1798
1807
  )
1799
1808
  ] }),
1800
1809
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1801
- /* @__PURE__ */ e(V, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
1810
+ /* @__PURE__ */ e(Q, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
1802
1811
  /* @__PURE__ */ e(
1803
- X,
1812
+ W,
1804
1813
  {
1805
1814
  id: "reg-surname",
1806
1815
  type: "text",
1807
1816
  value: B,
1808
- onChange: (c) => G(c.target.value),
1817
+ onChange: (c) => V(c.target.value),
1809
1818
  required: !0,
1810
1819
  className: l,
1811
1820
  placeholder: a("surname_placeholder", "Last Name")
@@ -1813,92 +1822,92 @@ function Ga() {
1813
1822
  )
1814
1823
  ] })
1815
1824
  ] }),
1816
- $.map((c) => he(c.condition, A) ? /* @__PURE__ */ r("div", { className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200", children: [
1817
- /* @__PURE__ */ e(V, { htmlFor: `signup-${c.key}`, children: a(c.label) }),
1825
+ O.map((c) => ge(c.condition, z) ? /* @__PURE__ */ r("div", { className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200", children: [
1826
+ /* @__PURE__ */ e(Q, { htmlFor: `signup-${c.key}`, children: a(c.label) }),
1818
1827
  c.type === "select" ? /* @__PURE__ */ r(
1819
1828
  ve,
1820
1829
  {
1821
- value: String(A[c.key] || ""),
1822
- onValueChange: (w) => U({ ...A, [c.key]: w }),
1830
+ value: String(z[c.key] || ""),
1831
+ onValueChange: (k) => K({ ...z, [c.key]: k }),
1823
1832
  required: c.required,
1824
1833
  dir: u ? "rtl" : "ltr",
1825
1834
  children: [
1826
- /* @__PURE__ */ e(xe, { className: f("bg-background", l), children: /* @__PURE__ */ e(ye, { placeholder: a(c.placeholder || "select_placeholder") }) }),
1827
- /* @__PURE__ */ e(we, { className: "rounded-xl", children: c.options?.map((w) => /* @__PURE__ */ e(me, { value: String(w.value), children: a(w.label) }, String(w.value))) })
1835
+ /* @__PURE__ */ e(xe, { className: v("bg-background", l), children: /* @__PURE__ */ e(ye, { placeholder: a(c.placeholder || "select_placeholder") }) }),
1836
+ /* @__PURE__ */ e(we, { className: "rounded-xl", children: c.options?.map((k) => /* @__PURE__ */ e(pe, { value: String(k.value), children: a(k.label) }, String(k.value))) })
1828
1837
  ]
1829
1838
  }
1830
1839
  ) : c.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-2", children: [
1831
1840
  /* @__PURE__ */ e(
1832
- ft,
1841
+ bt,
1833
1842
  {
1834
1843
  id: `signup-${c.key}`,
1835
- checked: !!A[c.key],
1836
- onCheckedChange: (w) => U({ ...A, [c.key]: !!w }),
1844
+ checked: !!z[c.key],
1845
+ onCheckedChange: (k) => K({ ...z, [c.key]: !!k }),
1837
1846
  required: c.required
1838
1847
  }
1839
1848
  ),
1840
1849
  /* @__PURE__ */ e("label", { htmlFor: `signup-${c.key}`, className: "text-sm text-muted-foreground cursor-pointer select-none", children: a(c.placeholder || c.label) })
1841
1850
  ] }) : /* @__PURE__ */ e(
1842
- X,
1851
+ W,
1843
1852
  {
1844
1853
  id: `signup-${c.key}`,
1845
1854
  type: c.type,
1846
- value: A[c.key] || "",
1847
- onChange: (w) => U({ ...A, [c.key]: w.target.value }),
1855
+ value: z[c.key] || "",
1856
+ onChange: (k) => K({ ...z, [c.key]: k.target.value }),
1848
1857
  required: c.required,
1849
1858
  className: l,
1850
1859
  placeholder: a(c.placeholder || "")
1851
1860
  }
1852
1861
  )
1853
1862
  ] }, c.key) : null),
1854
- E && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: E }),
1863
+ L && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: L }),
1855
1864
  /* @__PURE__ */ e(
1856
- Z,
1865
+ Y,
1857
1866
  {
1858
1867
  type: "submit",
1859
- disabled: R,
1868
+ disabled: $,
1860
1869
  className: "w-full font-semibold",
1861
- children: R ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up")
1870
+ children: $ ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up")
1862
1871
  }
1863
1872
  )
1864
1873
  ] })
1865
1874
  ] }) });
1866
1875
  }
1867
- function Ma() {
1868
- const { shareId: a } = Jt(), [t, i] = P(null), [u, l] = P(!0), [d, h] = P(null), { MessageList: p } = re(), m = te(/* @__PURE__ */ new Set());
1869
- return O(() => () => {
1870
- m.current.forEach((N) => URL.revokeObjectURL(N)), m.current.clear();
1871
- }, []), O(() => {
1876
+ function Da() {
1877
+ const { shareId: a } = Yt(), [t, o] = T(null), [u, l] = T(!0), [d, h] = T(null), { MessageList: p } = te(), m = Z(/* @__PURE__ */ new Set());
1878
+ return F(() => () => {
1879
+ m.current.forEach((w) => URL.revokeObjectURL(w)), m.current.clear();
1880
+ }, []), F(() => {
1872
1881
  if (!a) return;
1873
1882
  (async () => {
1874
1883
  try {
1875
1884
  l(!0);
1876
- const v = await D.getSharedThread(a);
1877
- v.items && (v.items = await Promise.all(
1878
- v.items.map(async (k) => {
1879
- if (!k.parts) return k;
1880
- const s = await Promise.all(
1881
- k.parts.map(async (M) => {
1882
- if (M.type === "file" && M.object_name && !M.url)
1885
+ const x = await E.getSharedThread(a);
1886
+ x.items && (x.items = await Promise.all(
1887
+ x.items.map(async (C) => {
1888
+ if (!C.parts) return C;
1889
+ const n = await Promise.all(
1890
+ C.parts.map(async (D) => {
1891
+ if (D.type === "file" && D.object_name && !D.url)
1883
1892
  try {
1884
- const T = await D.getPublicAttachmentBlobUrl(M.object_name);
1885
- return m.current.add(T), { ...M, url: T };
1886
- } catch (T) {
1887
- console.error("Failed to resolve shared attachment:", M.object_name, T);
1893
+ const P = await E.getPublicAttachmentBlobUrl(D.object_name);
1894
+ return m.current.add(P), { ...D, url: P };
1895
+ } catch (P) {
1896
+ console.error("Failed to resolve shared attachment:", D.object_name, P);
1888
1897
  }
1889
- return M;
1898
+ return D;
1890
1899
  })
1891
1900
  );
1892
- return { ...k, parts: s };
1901
+ return { ...C, parts: n };
1893
1902
  })
1894
- )), i(v);
1895
- } catch (v) {
1896
- console.error("Failed to fetch shared chat:", v), h(v.message || "Failed to load shared chat");
1903
+ )), o(x);
1904
+ } catch (x) {
1905
+ console.error("Failed to fetch shared chat:", x), h(x.message || "Failed to load shared chat");
1897
1906
  } finally {
1898
1907
  l(!1);
1899
1908
  }
1900
1909
  })();
1901
- }, [a]), u ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(bt, {}) }) : d || !t ? /* @__PURE__ */ r("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
1910
+ }, [a]), u ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(vt, {}) }) : d || !t ? /* @__PURE__ */ r("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
1902
1911
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-destructive mb-2 font-display", children: "Shared Chat Not Found" }),
1903
1912
  /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: d || "This shared conversation might have been deleted or the link is invalid." })
1904
1913
  ] }) : /* @__PURE__ */ r("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
@@ -1921,42 +1930,43 @@ function Ma() {
1921
1930
  ) })
1922
1931
  ] });
1923
1932
  }
1924
- function Wa() {
1925
- return /* @__PURE__ */ e(Ma, {});
1933
+ function Xa() {
1934
+ return /* @__PURE__ */ e(Da, {});
1926
1935
  }
1927
1936
  export {
1928
- Ta as AppSidebar,
1929
- na as Chat,
1937
+ Ma as AppSidebar,
1938
+ sa as Chat,
1930
1939
  Va as ChatUI,
1931
- rr as FilePart,
1932
- Ha as GentiqProvider,
1933
- nr as MessageList,
1934
- sr as Part,
1935
- or as PromptInputArea,
1936
- ir as ReasoningPart,
1937
- Qa as RequireAuth,
1940
+ nr as FilePart,
1941
+ Qa as GentiqProvider,
1942
+ sr as MessageList,
1943
+ or as Part,
1944
+ ir as PromptInputArea,
1945
+ lr as ReasoningPart,
1946
+ Ga as RequireAuth,
1938
1947
  ve as Select,
1939
1948
  we as SelectContent,
1940
- lr as SelectGroup,
1941
- me as SelectItem,
1942
- cr as SelectLabel,
1943
- dr as SelectScrollDownButton,
1944
- ur as SelectScrollUpButton,
1945
- mr as SelectSeparator,
1949
+ cr as SelectGroup,
1950
+ pe as SelectItem,
1951
+ dr as SelectLabel,
1952
+ ur as SelectScrollDownButton,
1953
+ mr as SelectScrollUpButton,
1954
+ hr as SelectSeparator,
1946
1955
  xe as SelectTrigger,
1947
1956
  ye as SelectValue,
1948
- Ca as SettingsDialog,
1949
- Wa as SharedChatView,
1950
- va as SidebarProvider,
1951
- hr as TextPart,
1952
- pr as ToolPart,
1953
- Ya as Trans,
1954
- Za as Translation,
1955
- Ga as UserLoginPage,
1956
- gr as WelcomeScreen,
1957
- re as useComponents,
1958
- aa as useGentiqChat,
1959
- er as useTranslation,
1960
- D as userAPI,
1961
- tr as withTranslation
1957
+ Sa as SettingsDialog,
1958
+ Xa as SharedChatView,
1959
+ xa as SidebarProvider,
1960
+ pr as TextPart,
1961
+ gr as ToolPart,
1962
+ Za as Trans,
1963
+ er as Translation,
1964
+ Wa as UserLoginPage,
1965
+ fr as WelcomeScreen,
1966
+ te as useComponents,
1967
+ ra as useGentiqChat,
1968
+ br as useGentiqUser,
1969
+ tr as useTranslation,
1970
+ E as userAPI,
1971
+ ar as withTranslation
1962
1972
  };