gentiq 0.7.24 → 0.7.26

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,13 +1,13 @@
1
- import { jsx as e, jsxs as r, Fragment as De } from "react/jsx-runtime";
2
- import { useState as x, useEffect as G, useMemo as ue, useRef as Me } from "react";
3
- import $e from "i18next";
4
- import { useTranslation as Y, initReactI18next as Oe, I18nextProvider as Ee } from "react-i18next";
5
- import { a as he, l as we, t as Ie, m as ke, S as ae, p as ne, q as oe, e as be, r as ie, s as W, J as Re, D as Ue, n as Fe, o as ze, A as Je, E as Pe, F as He, H as Be, $ as Ve, B as me, L as Z, I as pe, a0 as Se, h as ve, i as ye, k as Ne, w as We, x as Ke, y as Ge, z as Ze, a1 as Qe, d as Xe, T as Ye } from "./checkbox-iAFtpOFJ.js";
1
+ import { jsx as e, jsxs as r, Fragment as Ie } from "react/jsx-runtime";
2
+ import { useState as x, useEffect as G, useMemo as pe, useRef as Me } from "react";
3
+ import De from "i18next";
4
+ import { useTranslation as ee, initReactI18next as Ee, I18nextProvider as Oe } from "react-i18next";
5
+ import { a as me, l as we, t as $e, m as ke, S as ae, p as ne, q as oe, e as be, r as ie, s as W, J as Re, D as Fe, n as Ue, o as ze, A as Je, E as Pe, F as He, H as Be, $ as Ve, B as he, L as Q, I as ge, a0 as Se, h as ve, i as ye, k as Ne, w as We, x as Ke, y as Ge, z as Ze, a1 as Qe, d as Xe, T as Ye } from "./checkbox-D3JJhc0K.js";
6
6
  import { useNavigate as et, useLocation as tt, Routes as rt, Route as se, Navigate as Ce } from "react-router-dom";
7
7
  import { Share2 as st, RefreshCcw as Le, Globe as xe, Keyboard as at, Languages as nt, Plus as ot, Hash as it, ShieldAlert as lt, Monitor as Te, Moon as dt, Sun as ct, LogOut as mt } from "lucide-react";
8
- import { toast as qe } from "sonner";
9
- import * as je from "@radix-ui/react-switch";
10
- import { useQuery as de, useQueryClient as _e, useMutation as ee } from "@tanstack/react-query";
8
+ import { toast as je } from "sonner";
9
+ import * as qe from "@radix-ui/react-switch";
10
+ import { useQuery as ue, useQueryClient as _e, useMutation as te } from "@tanstack/react-query";
11
11
  const Ae = "/api";
12
12
  class ut {
13
13
  token = null;
@@ -23,49 +23,49 @@ class ut {
23
23
  getToken() {
24
24
  return this.token;
25
25
  }
26
- async request(a, o = {}) {
27
- const u = new Headers(o.headers);
28
- u.has("Content-Type") || u.set("Content-Type", "application/json"), this.token && u.set("Authorization", `Bearer ${this.token}`);
29
- const g = await fetch(`${Ae}${a}`, {
30
- ...o,
31
- headers: u
26
+ async request(a, i = {}) {
27
+ const m = new Headers(i.headers);
28
+ m.has("Content-Type") || m.set("Content-Type", "application/json"), this.token && m.set("Authorization", `Bearer ${this.token}`);
29
+ const f = await fetch(`${Ae}${a}`, {
30
+ ...i,
31
+ headers: m
32
32
  });
33
- if (!g.ok) {
34
- const p = await g.json().catch(() => ({ error: "Request failed" }));
35
- throw new Error(p.error || `HTTP ${g.status}`);
33
+ if (!f.ok) {
34
+ const p = await f.json().catch(() => ({ error: "Request failed" }));
35
+ throw new Error(p.error || `HTTP ${f.status}`);
36
36
  }
37
- return g.json();
37
+ return f.json();
38
38
  }
39
- async login(a, o) {
40
- const u = await this.request("/admin/login", {
39
+ async login(a, i) {
40
+ const m = await this.request("/admin/login", {
41
41
  method: "POST",
42
- body: JSON.stringify({ username: a, password: o })
42
+ body: JSON.stringify({ username: a, password: i })
43
43
  });
44
- this.setToken(u.token);
45
- const g = {
46
- admin_id: u.admin_id,
47
- username: u.username,
48
- name: u.name,
49
- permissions: u.permissions
44
+ this.setToken(m.token);
45
+ const f = {
46
+ admin_id: m.admin_id,
47
+ username: m.username,
48
+ name: m.name,
49
+ permissions: m.permissions
50
50
  };
51
- return localStorage.setItem("admin_info", JSON.stringify(g)), u;
51
+ return localStorage.setItem("admin_info", JSON.stringify(f)), m;
52
52
  }
53
53
  async checkSetupStatus() {
54
54
  return this.request("/admin/setup-status");
55
55
  }
56
- async register(a, o, u, g) {
56
+ async register(a, i, m, f) {
57
57
  return this.request("/admin/admins", {
58
58
  method: "POST",
59
- body: JSON.stringify({ username: a, password: o, name: u, permissions: g })
59
+ body: JSON.stringify({ username: a, password: i, name: m, permissions: f })
60
60
  });
61
61
  }
62
62
  async listAdmins() {
63
63
  return this.request("/admin/admins");
64
64
  }
65
- async updateAdmin(a, o) {
65
+ async updateAdmin(a, i) {
66
66
  return this.request(`/admin/admins/${a}`, {
67
67
  method: "PATCH",
68
- body: JSON.stringify(o)
68
+ body: JSON.stringify(i)
69
69
  });
70
70
  }
71
71
  async deleteAdmin(a) {
@@ -76,9 +76,9 @@ class ut {
76
76
  async listPermissions() {
77
77
  return this.request("/admin/permissions");
78
78
  }
79
- async listThreads(a = 0, o = 50, u, g) {
80
- const p = new URLSearchParams({ skip: a.toString(), limit: o.toString() });
81
- return u && p.append("query", u), g && p.append("feedback", g), this.request(`/admin/chat-history/threads?${p}`);
79
+ async listThreads(a = 0, i = 50, m, f) {
80
+ const p = new URLSearchParams({ skip: a.toString(), limit: i.toString() });
81
+ return m && p.append("query", m), f && p.append("feedback", f), this.request(`/admin/chat-history/threads?${p}`);
82
82
  }
83
83
  async getThreadItems(a) {
84
84
  return this.request(`/admin/chat-history/threads/${a}/items`);
@@ -88,26 +88,26 @@ class ut {
88
88
  method: "POST"
89
89
  });
90
90
  }
91
- async listUsers(a = 0, o = 100, u = "") {
92
- const g = new URLSearchParams({ skip: a.toString(), limit: o.toString() });
93
- return u && g.append("query", u), this.request(`/admin/users?${g.toString()}`);
91
+ async listUsers(a = 0, i = 100, m = "") {
92
+ const f = new URLSearchParams({ skip: a.toString(), limit: i.toString() });
93
+ return m && f.append("query", m), this.request(`/admin/users?${f.toString()}`);
94
94
  }
95
- async createUser(a, o, u, g, p, _, N, v) {
96
- const $ = g !== void 0 || p !== void 0 || _ !== void 0 || N !== void 0 ? {
97
- tokens: g || 0,
95
+ async createUser(a, i, m, f, p, y, _, N) {
96
+ const J = f !== void 0 || p !== void 0 || y !== void 0 || _ !== void 0 ? {
97
+ tokens: f || 0,
98
98
  requests: p || 0,
99
- token_limit: _ || g || 0,
100
- request_limit: N || p || 0
99
+ token_limit: y || f || 0,
100
+ request_limit: _ || p || 0
101
101
  } : void 0;
102
102
  return this.request("/admin/users", {
103
103
  method: "POST",
104
- body: JSON.stringify({ phone: a, name: o, surname: u, balance: $, metadata: v })
104
+ body: JSON.stringify({ phone: a, name: i, surname: m, balance: J, metadata: N })
105
105
  });
106
106
  }
107
- async updateUser(a, o) {
107
+ async updateUser(a, i) {
108
108
  return this.request(`/admin/users/${a}`, {
109
109
  method: "PATCH",
110
- body: JSON.stringify(o)
110
+ body: JSON.stringify(i)
111
111
  });
112
112
  }
113
113
  async deleteUser(a) {
@@ -115,10 +115,10 @@ class ut {
115
115
  method: "DELETE"
116
116
  });
117
117
  }
118
- async updateUserBalance(a, o, u, g, p) {
118
+ async updateUserBalance(a, i, m, f, p) {
119
119
  return this.request(`/admin/users/${a}/balance`, {
120
120
  method: "POST",
121
- body: JSON.stringify({ tokens: o, requests: u, token_limit: g, request_limit: p })
121
+ body: JSON.stringify({ tokens: i, requests: m, token_limit: f, request_limit: p })
122
122
  });
123
123
  }
124
124
  async refreshUserToken(a) {
@@ -129,9 +129,9 @@ class ut {
129
129
  async getAnalytics(a = 30) {
130
130
  return this.request(`/admin/analytics?days=${a}`);
131
131
  }
132
- async listJobs(a = 20, o) {
133
- const u = new URLSearchParams({ limit: a.toString() });
134
- return o && u.append("type", o), this.request(`/admin/jobs?${u}`);
132
+ async listJobs(a = 20, i) {
133
+ const m = new URLSearchParams({ limit: a.toString() });
134
+ return i && m.append("type", i), this.request(`/admin/jobs?${m}`);
135
135
  }
136
136
  async cancelJob(a) {
137
137
  return this.request(`/admin/jobs/${a}/cancel`, {
@@ -153,80 +153,80 @@ class ut {
153
153
  });
154
154
  }
155
155
  async getAttachmentBlob(a) {
156
- const o = {};
157
- this.token && (o.Authorization = `Bearer ${this.token}`);
158
- const u = await fetch(`${Ae}/admin/chat-history/attachments/${a}`, {
156
+ const i = {};
157
+ this.token && (i.Authorization = `Bearer ${this.token}`);
158
+ const m = await fetch(`${Ae}/admin/chat-history/attachments/${a}`, {
159
159
  method: "GET",
160
- headers: o
160
+ headers: i
161
161
  });
162
- if (!u.ok) {
163
- const g = await u.json().catch(() => ({ error: "Request failed" }));
164
- throw new Error(g.error || `HTTP ${u.status}`);
162
+ if (!m.ok) {
163
+ const f = await m.json().catch(() => ({ error: "Request failed" }));
164
+ throw new Error(f.error || `HTTP ${m.status}`);
165
165
  }
166
- return u.blob();
166
+ return m.blob();
167
167
  }
168
168
  }
169
- const w = new ut();
169
+ const k = new ut();
170
170
  function ht({ onLoginSuccess: t }) {
171
- const { t: a, i18n: o } = Y(["admin", "translation"]), { app: u } = he(), { theme: g } = we(), [p, _] = x(""), [N, v] = x(""), [$, T] = x(""), [I, A] = x(""), [q, k] = x(!1), [U, O] = x(null), [y, D] = x("light");
171
+ const { t: a, i18n: i } = ee(["admin", "translation"]), { app: m } = me(), { theme: f } = we(), [p, y] = x(""), [_, N] = x(""), [J, T] = x(""), [j, A] = x(""), [D, S] = x(!1), [O, R] = x(null), [w, I] = x("light");
172
172
  G(() => {
173
- if (g === "system") {
173
+ if (f === "system") {
174
174
  const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
175
- D(h ? "dark" : "light");
175
+ I(h ? "dark" : "light");
176
176
  } else
177
- D(g);
178
- }, [g]);
179
- const E = ue(() => u?.logo ? typeof u.logo == "string" ? u.logo : y === "dark" ? u.logo.dark : u.logo.light : Ie, [u?.logo, y]), J = u?.adminTitle || u?.name, K = o.language === "fa";
177
+ I(f);
178
+ }, [f]);
179
+ const P = pe(() => m?.logo ? typeof m.logo == "string" ? m.logo : w === "dark" ? m.logo.dark : m.logo.light : $e, [m?.logo, w]), H = m?.adminTitle || m?.name, V = i.language === "fa";
180
180
  G(() => {
181
- w.checkSetupStatus().then((h) => O(h.needs_setup)).catch(() => O(!1));
181
+ k.checkSetupStatus().then((h) => R(h.needs_setup)).catch(() => R(!1));
182
182
  }, []);
183
- const B = async (h) => {
184
- h.preventDefault(), A(""), k(!0);
183
+ const K = async (h) => {
184
+ h.preventDefault(), A(""), S(!0);
185
185
  try {
186
- await w.login(p, N), t();
187
- } catch (F) {
188
- A(F instanceof Error ? F.message : a("login.error"));
186
+ await k.login(p, _), t();
187
+ } catch (z) {
188
+ A(z instanceof Error ? z.message : a("login.error"));
189
189
  } finally {
190
- k(!1);
190
+ S(!1);
191
191
  }
192
- }, P = async (h) => {
193
- if (h.preventDefault(), A(""), N !== $) {
192
+ }, B = async (h) => {
193
+ if (h.preventDefault(), A(""), _ !== J) {
194
194
  A(a("login.passwords_mismatch"));
195
195
  return;
196
196
  }
197
- if (N.length < 4) {
197
+ if (_.length < 4) {
198
198
  A(a("login.password_too_short"));
199
199
  return;
200
200
  }
201
- k(!0);
201
+ S(!0);
202
202
  try {
203
- await w.register(
203
+ await k.register(
204
204
  "admin",
205
- N,
205
+ _,
206
206
  "Admin",
207
207
  ["chat_history", "admin_management", "user_management", "analytics"]
208
- ), await w.login("admin", N), t();
209
- } catch (F) {
210
- A(F instanceof Error ? F.message : a("login.error"));
208
+ ), await k.login("admin", _), t();
209
+ } catch (z) {
210
+ A(z instanceof Error ? z.message : a("login.error"));
211
211
  } finally {
212
- k(!1);
212
+ S(!1);
213
213
  }
214
214
  };
215
- return U === null ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-6 h-6 border-2 border-border border-t-primary rounded-full animate-spin" }) }) : /* @__PURE__ */ r("div", { className: "min-h-screen bg-background flex items-center justify-center p-4 relative overflow-hidden", dir: K ? "rtl" : "ltr", children: [
215
+ return O === null ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-6 h-6 border-2 border-border border-t-primary rounded-full animate-spin" }) }) : /* @__PURE__ */ r("div", { className: "min-h-screen bg-background flex items-center justify-center p-4 relative overflow-hidden", dir: V ? "rtl" : "ltr", children: [
216
216
  /* @__PURE__ */ e("div", { className: "absolute top-[-10%] right-[-10%] w-[50%] h-[50%] bg-primary/10 rounded-full blur-3xl animate-pulse" }),
217
217
  /* @__PURE__ */ e("div", { className: "absolute bottom-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/5 dark:bg-primary/10 rounded-full blur-3xl" }),
218
218
  /* @__PURE__ */ r("div", { className: "w-full max-w-md z-10", children: [
219
219
  /* @__PURE__ */ r("div", { className: "glass rounded-3xl p-10 shadow-2xl", children: [
220
220
  /* @__PURE__ */ r("div", { className: "text-center mb-10", children: [
221
221
  /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-4 mb-6", children: [
222
- /* @__PURE__ */ e("img", { src: E, alt: J, className: "size-16 object-contain" }),
223
- /* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: U ? a("login.setup_title") : J })
222
+ /* @__PURE__ */ e("img", { src: P, alt: H, className: "size-16 object-contain" }),
223
+ /* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: O ? a("login.setup_title") : H })
224
224
  ] }),
225
- U && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-3", children: a("login.setup_description") })
225
+ O && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-3", children: a("login.setup_description") })
226
226
  ] }),
227
- U ? (
227
+ O ? (
228
228
  /* ---- SETUP FORM ---- */
229
- /* @__PURE__ */ r("form", { onSubmit: P, className: "space-y-7", children: [
229
+ /* @__PURE__ */ r("form", { onSubmit: B, className: "space-y-7", children: [
230
230
  /* @__PURE__ */ r("div", { children: [
231
231
  /* @__PURE__ */ e("label", { className: "block text-xs font-bold text-muted-foreground uppercase tracking-widest mb-3.5 mx-1", children: a("login.username") }),
232
232
  /* @__PURE__ */ e(
@@ -246,8 +246,8 @@ function ht({ onLoginSuccess: t }) {
246
246
  {
247
247
  id: "setup-password",
248
248
  type: "password",
249
- value: N,
250
- onChange: (h) => v(h.target.value),
249
+ value: _,
250
+ onChange: (h) => N(h.target.value),
251
251
  required: !0,
252
252
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
253
253
  placeholder: a("login.set_password_placeholder"),
@@ -262,7 +262,7 @@ function ht({ onLoginSuccess: t }) {
262
262
  {
263
263
  id: "setup-confirm",
264
264
  type: "password",
265
- value: $,
265
+ value: J,
266
266
  onChange: (h) => T(h.target.value),
267
267
  required: !0,
268
268
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
@@ -271,14 +271,14 @@ function ht({ onLoginSuccess: t }) {
271
271
  }
272
272
  )
273
273
  ] }),
274
- I && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3.5 rounded-2xl text-xs backdrop-blur-sm", children: I }),
274
+ j && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3.5 rounded-2xl text-xs backdrop-blur-sm", children: j }),
275
275
  /* @__PURE__ */ e(
276
276
  "button",
277
277
  {
278
278
  type: "submit",
279
- disabled: q,
279
+ disabled: D,
280
280
  className: "w-full bg-primary text-primary-foreground font-bold py-4 px-6 rounded-2xl hover:opacity-90 transition-all text-sm shadow-lg hover:shadow-xl disabled:opacity-50 active:scale-[0.98]",
281
- children: q ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
281
+ children: D ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
282
282
  /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
283
283
  /* @__PURE__ */ e("span", { children: a("login.setting_up") })
284
284
  ] }) : a("login.create_admin")
@@ -287,7 +287,7 @@ function ht({ onLoginSuccess: t }) {
287
287
  ] })
288
288
  ) : (
289
289
  /* ---- LOGIN FORM ---- */
290
- /* @__PURE__ */ r("form", { onSubmit: B, className: "space-y-7", children: [
290
+ /* @__PURE__ */ r("form", { onSubmit: K, className: "space-y-7", children: [
291
291
  /* @__PURE__ */ r("div", { children: [
292
292
  /* @__PURE__ */ e("label", { htmlFor: "username", className: "block text-xs font-bold text-muted-foreground uppercase tracking-widest mb-3.5 mx-1", children: a("login.username") }),
293
293
  /* @__PURE__ */ e(
@@ -296,7 +296,7 @@ function ht({ onLoginSuccess: t }) {
296
296
  id: "username",
297
297
  type: "text",
298
298
  value: p,
299
- onChange: (h) => _(h.target.value),
299
+ onChange: (h) => y(h.target.value),
300
300
  required: !0,
301
301
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
302
302
  placeholder: a("login.username_placeholder"),
@@ -311,8 +311,8 @@ function ht({ onLoginSuccess: t }) {
311
311
  {
312
312
  id: "password",
313
313
  type: "password",
314
- value: N,
315
- onChange: (h) => v(h.target.value),
314
+ value: _,
315
+ onChange: (h) => N(h.target.value),
316
316
  required: !0,
317
317
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
318
318
  placeholder: a("login.password_placeholder"),
@@ -320,14 +320,14 @@ function ht({ onLoginSuccess: t }) {
320
320
  }
321
321
  )
322
322
  ] }),
323
- I && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3.5 rounded-2xl text-xs backdrop-blur-sm", children: I }),
323
+ j && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3.5 rounded-2xl text-xs backdrop-blur-sm", children: j }),
324
324
  /* @__PURE__ */ e(
325
325
  "button",
326
326
  {
327
327
  type: "submit",
328
- disabled: q,
328
+ disabled: D,
329
329
  className: "w-full bg-primary text-primary-foreground font-bold py-4 px-6 rounded-2xl hover:opacity-90 transition-all text-sm shadow-lg hover:shadow-xl disabled:opacity-50 active:scale-[0.98]",
330
- children: q ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
330
+ children: D ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
331
331
  /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
332
332
  /* @__PURE__ */ e("span", { children: a("login.logging_in") })
333
333
  ] }) : a("login.submit")
@@ -341,58 +341,58 @@ function ht({ onLoginSuccess: t }) {
341
341
  ] });
342
342
  }
343
343
  function pt() {
344
- const { t, i18n: a } = Y(["admin", "translation"]), [o, u] = x([]), [g, p] = x(null), [_, N] = x([]), [v, $] = x(!1), [T, I] = x(!1), [A, q] = x(""), [k, U] = x(""), [O, y] = x(""), [D, E] = x(0), [J, K] = x(!0), B = a.language === "fa", P = B ? "fa-IR" : "en-US", h = async (s = !1) => {
345
- s ? I(!0) : ($(!0), E(0)), q("");
344
+ const { t, i18n: a } = ee(["admin", "translation"]), { app: i } = me(), m = i?.userMetadataFields || [], [f, p] = x([]), [y, _] = x(null), [N, J] = x([]), [T, j] = x(!1), [A, D] = x(!1), [S, O] = x(""), [R, w] = x(""), [I, P] = x(""), [H, V] = x(0), [K, B] = x(!0), h = a.language === "fa", z = h ? "fa-IR" : "en-US", d = async (s = !1) => {
345
+ s ? D(!0) : (j(!0), V(0)), O("");
346
346
  try {
347
- const b = s ? D + 50 : 0, S = await w.listThreads(
347
+ const b = s ? H + 50 : 0, C = await k.listThreads(
348
348
  b,
349
349
  50,
350
- k || void 0,
351
- O || void 0
350
+ R || void 0,
351
+ I || void 0
352
352
  );
353
- s ? (u((H) => [...H, ...S.threads]), E(b)) : (u(S.threads), E(0)), K(S.threads.length === 50);
353
+ s ? (p((o) => [...o, ...C.threads]), V(b)) : (p(C.threads), V(0)), B(C.threads.length === 50);
354
354
  } catch (b) {
355
- q(b instanceof Error ? b.message : t("error_loading"));
355
+ O(b instanceof Error ? b.message : t("error_loading"));
356
356
  } finally {
357
- $(!1), I(!1);
357
+ j(!1), D(!1);
358
358
  }
359
- }, F = async (s) => {
360
- p(s), $(!0), q("");
359
+ }, c = async (s) => {
360
+ _(s), j(!0), O("");
361
361
  try {
362
- const b = await w.getThreadItems(s.id);
363
- N(b.items);
362
+ const b = await k.getThreadItems(s.id);
363
+ J(b.items);
364
364
  } catch (b) {
365
- q(b instanceof Error ? b.message : t("error_loading"));
365
+ O(b instanceof Error ? b.message : t("error_loading"));
366
366
  } finally {
367
- $(!1);
367
+ j(!1);
368
368
  }
369
369
  }, l = async (s, b) => {
370
370
  s.stopPropagation();
371
371
  try {
372
- const S = await w.shareThread(b.id), H = `${window.location.origin}${S.url}`;
373
- navigator.clipboard.writeText(H), qe.success(t("sidebar.share_success"), {
372
+ const C = await k.shareThread(b.id), o = `${window.location.origin}${C.url}`;
373
+ navigator.clipboard.writeText(o), je.success(t("sidebar.share_success"), {
374
374
  description: t("sidebar.share_description")
375
375
  });
376
376
  } catch {
377
- qe.error(t("sidebar.share_failed"));
377
+ je.error(t("sidebar.share_failed"));
378
378
  }
379
379
  };
380
380
  G(() => {
381
381
  const s = setTimeout(() => {
382
- h();
382
+ d();
383
383
  }, 500);
384
384
  return () => clearTimeout(s);
385
- }, [k, O]);
386
- const c = (s) => {
385
+ }, [R, I]);
386
+ const g = (s) => {
387
387
  const b = new Date(s);
388
- return new Intl.DateTimeFormat(B ? "fa-IR" : "en-US", {
388
+ return new Intl.DateTimeFormat(h ? "fa-IR" : "en-US", {
389
389
  year: "numeric",
390
390
  month: "long",
391
391
  day: "numeric",
392
392
  hour: "2-digit",
393
393
  minute: "2-digit"
394
394
  }).format(b);
395
- }, i = (s) => {
395
+ }, u = (s) => {
396
396
  if (typeof s == "string")
397
397
  try {
398
398
  return JSON.stringify(JSON.parse(s), null, 2);
@@ -400,20 +400,20 @@ function pt() {
400
400
  return s;
401
401
  }
402
402
  return JSON.stringify(s, null, 2);
403
- }, f = ({ part: s, idx: b }) => {
404
- const [S, H] = x(!1), V = s.tool_name || (s.type && s.type.startsWith("tool-") ? s.type.slice(5) : "tool");
403
+ }, q = ({ part: s, idx: b }) => {
404
+ const [C, o] = x(!1), v = s.tool_name || (s.type && s.type.startsWith("tool-") ? s.type.slice(5) : "tool");
405
405
  return /* @__PURE__ */ r("div", { dir: "ltr", className: "my-2 border border-border/50 rounded-xl overflow-hidden bg-muted/20 text-left", children: [
406
406
  /* @__PURE__ */ r(
407
407
  "div",
408
408
  {
409
- onClick: () => H(!S),
409
+ onClick: () => o(!C),
410
410
  className: "px-2.5 py-1.5 bg-muted/50 border-b border-border/50 flex items-center justify-between cursor-pointer hover:bg-accent transition-colors",
411
411
  children: [
412
412
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
413
413
  /* @__PURE__ */ e(
414
414
  "svg",
415
415
  {
416
- className: `w-3 h-3 text-gray-400 transition-transform ${S ? "rotate-180" : ""}`,
416
+ className: `w-3 h-3 text-gray-400 transition-transform ${C ? "rotate-180" : ""}`,
417
417
  fill: "none",
418
418
  viewBox: "0 0 24 24",
419
419
  stroke: "currentColor",
@@ -421,34 +421,34 @@ function pt() {
421
421
  }
422
422
  ),
423
423
  /* @__PURE__ */ e("span", { className: "text-[10px] font-bold uppercase tracking-widest text-muted-foreground", children: "Tool" }),
424
- /* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: V })
424
+ /* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: v })
425
425
  ] }),
426
426
  /* @__PURE__ */ e("span", { className: `text-[10px] px-2 py-0.5 rounded-full ${s.state === "output-available" ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"}`, children: s.state === "output-available" ? t("chat_history.output_available") : t("chat_history.running") })
427
427
  ]
428
428
  }
429
429
  ),
430
- S && /* @__PURE__ */ r("div", { className: "p-2.5 space-y-2.5 animate-in fade-in slide-in-from-top-1 duration-200", children: [
430
+ C && /* @__PURE__ */ r("div", { className: "p-2.5 space-y-2.5 animate-in fade-in slide-in-from-top-1 duration-200", children: [
431
431
  /* @__PURE__ */ r("div", { children: [
432
432
  /* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: "Input" }),
433
- /* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children: i(s.input) })
433
+ /* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children: u(s.input) })
434
434
  ] }),
435
435
  (s.output || s.error_text || s.errorText) && /* @__PURE__ */ r("div", { children: [
436
436
  /* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: s.error_text || s.errorText ? "Error" : "Output" }),
437
- /* @__PURE__ */ e("pre", { className: `text-xs p-2 rounded-lg overflow-x-auto ${s.error_text || s.errorText ? "bg-destructive/10 text-destructive" : "bg-primary/5 text-foreground/80"}`, children: i(s.output || s.error_text || s.errorText) })
437
+ /* @__PURE__ */ e("pre", { className: `text-xs p-2 rounded-lg overflow-x-auto ${s.error_text || s.errorText ? "bg-destructive/10 text-destructive" : "bg-primary/5 text-foreground/80"}`, children: u(s.output || s.error_text || s.errorText) })
438
438
  ] })
439
439
  ] })
440
440
  ] }, b);
441
- }, m = async (s, b) => {
441
+ }, M = async (s, b) => {
442
442
  try {
443
- const S = await w.getAttachmentBlob(s), H = window.URL.createObjectURL(S), V = document.createElement("a");
444
- V.href = H, V.download = b || s.split("/").pop() || "download", document.body.appendChild(V), V.click(), window.URL.revokeObjectURL(H), document.body.removeChild(V);
445
- } catch (S) {
446
- console.error("Download failed:", S), q(S instanceof Error ? S.message : "Download failed");
443
+ const C = await k.getAttachmentBlob(s), o = window.URL.createObjectURL(C), v = document.createElement("a");
444
+ v.href = o, v.download = b || s.split("/").pop() || "download", document.body.appendChild(v), v.click(), window.URL.revokeObjectURL(o), document.body.removeChild(v);
445
+ } catch (C) {
446
+ console.error("Download failed:", C), O(C instanceof Error ? C.message : "Download failed");
447
447
  }
448
- }, j = (s, b) => typeof s == "string" ? /* @__PURE__ */ e("div", { children: s }, b) : s.type === "text" ? /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: s.text }, b) : s.type === "reasoning" ? /* @__PURE__ */ r("div", { className: "my-2 p-2.5 bg-muted/40 rounded-lg border border-border text-xs italic text-muted-foreground", dir: "auto", children: [
448
+ }, $ = (s, b) => typeof s == "string" ? /* @__PURE__ */ e("div", { children: s }, b) : s.type === "text" ? /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: s.text }, b) : s.type === "reasoning" ? /* @__PURE__ */ r("div", { className: "my-2 p-2.5 bg-muted/40 rounded-lg border border-border text-xs italic text-muted-foreground", dir: "auto", children: [
449
449
  /* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter opacity-70", children: "Reasoning" }),
450
450
  s.text
451
- ] }, b) : s.type === "dynamic-tool" || s.type && s.type.startsWith("tool-") || s.tool_call_id ? /* @__PURE__ */ e(f, { part: s, idx: b }, b) : s.type === "file" ? /* @__PURE__ */ r("div", { className: "my-2 flex items-center justify-between p-2.5 bg-muted/40 rounded-xl border border-border group hover:border-primary/30 transition-all", children: [
451
+ ] }, b) : s.type === "dynamic-tool" || s.type && s.type.startsWith("tool-") || s.tool_call_id ? /* @__PURE__ */ e(q, { part: s, idx: b }, b) : s.type === "file" ? /* @__PURE__ */ r("div", { className: "my-2 flex items-center justify-between p-2.5 bg-muted/40 rounded-xl border border-border group hover:border-primary/30 transition-all", children: [
452
452
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3 overflow-hidden", children: [
453
453
  /* @__PURE__ */ e("div", { className: "flex-shrink-0 w-8 h-8 flex items-center justify-center bg-primary/10 rounded-lg text-primary", children: /* @__PURE__ */ e("span", { className: "text-xl", children: "📎" }) }),
454
454
  /* @__PURE__ */ r("div", { className: "flex flex-col min-w-0", children: [
@@ -459,17 +459,17 @@ function pt() {
459
459
  s.object_name && /* @__PURE__ */ e(
460
460
  "button",
461
461
  {
462
- onClick: () => m(s.object_name, s.filename),
462
+ onClick: () => M(s.object_name, s.filename),
463
463
  className: "flex-shrink-0 p-2 hover:bg-card rounded-lg border border-transparent hover:border-border transition-all text-muted-foreground hover:text-primary",
464
464
  title: t("chat_history.download_file", "Download File"),
465
465
  children: /* @__PURE__ */ e("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) })
466
466
  }
467
467
  )
468
- ] }, b) : /* @__PURE__ */ e("div", { className: "my-2 p-2 bg-muted/40 rounded-lg border border-border text-xs font-mono opacity-60", children: JSON.stringify(s) }, b), M = (s) => {
469
- const { scrollTop: b, scrollHeight: S, clientHeight: H } = s.currentTarget;
470
- S - b <= H + 50 && !T && J && h(!0);
468
+ ] }, b) : /* @__PURE__ */ e("div", { className: "my-2 p-2 bg-muted/40 rounded-lg border border-border text-xs font-mono opacity-60", children: JSON.stringify(s) }, b), F = (s) => {
469
+ const { scrollTop: b, scrollHeight: C, clientHeight: o } = s.currentTarget;
470
+ C - b <= o + 50 && !A && K && d(!0);
471
471
  };
472
- return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: B ? "rtl" : "ltr", children: [
472
+ return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: h ? "rtl" : "ltr", children: [
473
473
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
474
474
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-4", children: [
475
475
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("chat_history.title") }),
@@ -478,7 +478,7 @@ function pt() {
478
478
  "form",
479
479
  {
480
480
  onSubmit: (s) => {
481
- s.preventDefault(), h();
481
+ s.preventDefault(), d();
482
482
  },
483
483
  className: "flex-1 flex gap-2",
484
484
  children: [
@@ -486,8 +486,8 @@ function pt() {
486
486
  "input",
487
487
  {
488
488
  type: "text",
489
- value: k,
490
- onChange: (s) => U(s.target.value),
489
+ value: R,
490
+ onChange: (s) => w(s.target.value),
491
491
  placeholder: t("chat_history.search_placeholder"),
492
492
  className: "flex-1 px-4 py-2.5 border-0 rounded-xl glass-surface text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm"
493
493
  }
@@ -506,8 +506,8 @@ function pt() {
506
506
  /* @__PURE__ */ r(
507
507
  "select",
508
508
  {
509
- value: O,
510
- onChange: (s) => y(s.target.value),
509
+ value: I,
510
+ onChange: (s) => P(s.target.value),
511
511
  className: "px-4 py-2.5 border-0 rounded-xl glass-surface text-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm min-w-[180px]",
512
512
  children: [
513
513
  /* @__PURE__ */ e("option", { value: "", children: t("chat_history.all_feedbacks", "All Feedbacks") }),
@@ -519,33 +519,33 @@ function pt() {
519
519
  )
520
520
  ] })
521
521
  ] }),
522
- A && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm", children: A })
522
+ S && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm", children: S })
523
523
  ] }),
524
524
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-[380px_1fr] gap-4 flex-1 min-h-0", children: [
525
525
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col min-w-0", children: [
526
526
  /* @__PURE__ */ e("div", { className: "px-5 py-2.5 border-b border-border/30", children: /* @__PURE__ */ r("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide", children: [
527
527
  t("chat_history.threads_list"),
528
528
  " (",
529
- (o.length || 0).toLocaleString(P),
529
+ (f.length || 0).toLocaleString(z),
530
530
  ")"
531
531
  ] }) }),
532
532
  /* @__PURE__ */ e(
533
533
  "div",
534
534
  {
535
535
  className: "flex-1 overflow-y-auto p-2 custom-scrollbar",
536
- onScroll: M,
537
- children: v && o.length === 0 ? /* @__PURE__ */ e("div", { className: "p-8 text-center text-muted-foreground text-sm", children: t("chat_history.no_threads") }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: [
538
- o.map((s) => /* @__PURE__ */ r(
536
+ onScroll: F,
537
+ children: T && f.length === 0 ? /* @__PURE__ */ e("div", { className: "p-8 text-center text-muted-foreground text-sm", children: t("chat_history.no_threads") }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: [
538
+ f.map((s) => /* @__PURE__ */ r(
539
539
  "div",
540
540
  {
541
- onClick: () => F(s),
542
- className: `p-2.5 cursor-pointer transition-all rounded-xl border ${g?.id === s.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
541
+ onClick: () => c(s),
542
+ className: `p-2.5 cursor-pointer transition-all rounded-xl border ${y?.id === s.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
543
543
  children: [
544
544
  /* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-1.5 gap-4", children: [
545
545
  /* @__PURE__ */ e(
546
546
  "h3",
547
547
  {
548
- className: `font-medium text-sm truncate flex-1 ${g?.id === s.id ? "text-primary" : "text-foreground"}`,
548
+ className: `font-medium text-sm truncate flex-1 ${y?.id === s.id ? "text-primary" : "text-foreground"}`,
549
549
  title: s.title || t("chat_history.no_thread_title"),
550
550
  children: s.title || t("chat_history.no_thread_title")
551
551
  }
@@ -556,53 +556,96 @@ function pt() {
556
556
  ] })
557
557
  ] }),
558
558
  /* @__PURE__ */ r("div", { className: "text-xs space-y-1.5 text-muted-foreground", children: [
559
- s.user_info && /* @__PURE__ */ r("div", { className: "font-medium text-foreground truncate", title: `${s.user_info.name} ${s.user_info.surname} ${s.user_info.phone ? ` • ${s.user_info.phone}` : ""}`, children: [
560
- s.user_info.name,
561
- " ",
562
- s.user_info.surname,
563
- s.user_info.phone && ` • ${s.user_info.phone}`
564
- ] }),
559
+ s.user_info && /* @__PURE__ */ r(
560
+ "div",
561
+ {
562
+ className: "flex flex-col gap-0.5 min-w-0",
563
+ title: `${s.user_info.name} ${s.user_info.surname} ${s.user_info.phone ? ` • ${s.user_info.phone}` : ""}${m.filter((b) => s.user_info?.metadata?.[b.key] !== void 0 && s.user_info?.metadata?.[b.key] !== "").map((b) => {
564
+ const C = s.user_info?.metadata?.[b.key];
565
+ if (b.type === "select") {
566
+ const o = b.options?.find((v) => String(v.value) === String(C));
567
+ return ` • ${o ? t(o.label) : C}`;
568
+ }
569
+ return ` • ${C}`;
570
+ }).join("")}${s.user_info.metadata?.values !== void 0 && !m.some((b) => b.key === "values") ? ` • ${s.user_info.metadata.values}` : ""}`,
571
+ children: [
572
+ /* @__PURE__ */ r("div", { className: "font-medium text-foreground truncate flex items-center gap-1.5", children: [
573
+ /* @__PURE__ */ r("span", { children: [
574
+ s.user_info.name,
575
+ " ",
576
+ s.user_info.surname
577
+ ] }),
578
+ s.user_info.phone && /* @__PURE__ */ r("span", { className: "text-[11px] text-foreground/70 font-normal", children: [
579
+ "•",
580
+ " ",
581
+ s.user_info.phone
582
+ ] })
583
+ ] }),
584
+ /* @__PURE__ */ r("div", { className: "text-[10px] text-muted-foreground/70 truncate flex items-center gap-1", children: [
585
+ m.filter((b) => {
586
+ const C = s.user_info?.metadata?.[b.key];
587
+ return C != null && C !== "";
588
+ }).map((b, C) => {
589
+ const o = s.user_info?.metadata?.[b.key];
590
+ let v = String(o);
591
+ if (b.type === "select") {
592
+ const U = b.options?.find((X) => String(X.value) === String(o));
593
+ U && (v = t(U.label));
594
+ } else b.type === "checkbox" && (v = o ? "✓" : "✗");
595
+ return /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
596
+ C > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
597
+ v
598
+ ] }, b.key);
599
+ }),
600
+ s.user_info.metadata?.values !== void 0 && !m.some((b) => b.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
601
+ m.some((b) => s.user_info?.metadata?.[b.key] !== void 0) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
602
+ String(s.user_info.metadata.values)
603
+ ] })
604
+ ] })
605
+ ]
606
+ }
607
+ ),
565
608
  s.metadata?.usage && /* @__PURE__ */ r("div", { className: "flex gap-2 mt-2 pt-2 border-border/30", children: [
566
- /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.input_tokens", { value: (s.metadata.usage.input_tokens || 0).toLocaleString(P) }) }),
567
- /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.output_tokens", { value: (s.metadata.usage.output_tokens || 0).toLocaleString(P) }) })
609
+ /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.input_tokens", { value: (s.metadata.usage.input_tokens || 0).toLocaleString(z) }) }),
610
+ /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.output_tokens", { value: (s.metadata.usage.output_tokens || 0).toLocaleString(z) }) })
568
611
  ] }),
569
- /* @__PURE__ */ e("div", { className: "text-[10px] text-muted-foreground mt-1", children: c(s.created_at) })
612
+ /* @__PURE__ */ e("div", { className: "text-[10px] text-muted-foreground mt-1", children: g(s.created_at) })
570
613
  ] })
571
614
  ]
572
615
  },
573
616
  s.id
574
617
  )),
575
- T && /* @__PURE__ */ e("div", { className: "p-4 text-center text-muted-foreground text-xs", children: t("loading_more") })
618
+ A && /* @__PURE__ */ e("div", { className: "p-4 text-center text-muted-foreground text-xs", children: t("loading_more") })
576
619
  ] })
577
620
  }
578
621
  )
579
622
  ] }),
580
623
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col", children: [
581
624
  /* @__PURE__ */ r("div", { className: "px-5 py-2.5 border-b border-border/30 flex items-center justify-between gap-4", children: [
582
- /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: g ? t("chat_history.messages_for", { title: g.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
583
- g && /* @__PURE__ */ e(
625
+ /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: y ? t("chat_history.messages_for", { title: y.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
626
+ y && /* @__PURE__ */ e(
584
627
  "button",
585
628
  {
586
- onClick: (s) => l(s, g),
629
+ onClick: (s) => l(s, y),
587
630
  className: "flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 text-primary flex items-center justify-center hover:bg-primary/20 transition-all shadow-sm",
588
631
  title: t("sidebar.share_conversation"),
589
632
  children: /* @__PURE__ */ e(st, { className: "w-4 h-4" })
590
633
  }
591
634
  )
592
635
  ] }),
593
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: g ? v ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : _.length === 0 ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.empty_thread") }) : /* @__PURE__ */ e("div", { className: "space-y-6", children: _.map((s) => {
594
- const b = s.role === "user", S = s.role === "assistant";
636
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: y ? T ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : N.length === 0 ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.empty_thread") }) : /* @__PURE__ */ e("div", { className: "space-y-6", children: N.map((s) => {
637
+ const b = s.role === "user", C = s.role === "assistant";
595
638
  return /* @__PURE__ */ r(
596
639
  "div",
597
640
  {
598
- className: `p-3.5 rounded-2xl transition-all relative ${b ? "bg-primary/10 ms-12 rounded-te-sm" : S ? "glass shadow-sm me-12 rounded-ts-sm" : "bg-muted/30 border border-border/50"}`,
641
+ className: `p-3.5 rounded-2xl transition-all relative ${b ? "bg-primary/10 ms-12 rounded-te-sm" : C ? "glass shadow-sm me-12 rounded-ts-sm" : "bg-muted/30 border border-border/50"}`,
599
642
  children: [
600
643
  s.feedback && /* @__PURE__ */ e("div", { className: "absolute -bottom-2 -left-2 flex items-center justify-center w-8 h-8 rounded-full shadow-md bg-card border border-border animate-in fade-in zoom-in duration-300 z-10", children: /* @__PURE__ */ e("span", { className: "text-base", children: s.feedback === "like" ? "👍" : "👎" }) }),
601
644
  /* @__PURE__ */ r("div", { className: "flex justify-between items-center mb-1.5", children: [
602
- /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${b || S ? "text-primary" : "text-muted-foreground"}`, children: b ? t("chat_history.user_label") : S ? t("chat_history.assistant_label") : `${s.role}` }),
603
- /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: c(s.created_at) })
645
+ /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${b || C ? "text-primary" : "text-muted-foreground"}`, children: b ? y?.user_info?.name ? `${y.user_info.name} ${y.user_info.surname || ""}`.trim() : t("chat_history.user_label") : C ? t("chat_history.assistant_label") : `${s.role}` }),
646
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: g(s.created_at) })
604
647
  ] }),
605
- /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: s.parts && s.parts.length > 0 ? s.parts.map((H, V) => j(H, V)) : typeof s.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(s.content, null, 2) }) : s.content })
648
+ /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: s.parts && s.parts.length > 0 ? s.parts.map((o, v) => $(o, v)) : typeof s.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(s.content, null, 2) }) : s.content })
606
649
  ]
607
650
  },
608
651
  s.id
@@ -616,94 +659,94 @@ function pt() {
616
659
  ] });
617
660
  }
618
661
  function gt() {
619
- const { t, i18n: a } = Y(["admin", "translation"]), [o, u] = x([]), [g, p] = x(!1), [_, N] = x(""), [v, $] = x(!1), [T, I] = x(null), [A, q] = x([]), [k, U] = x(null), O = a.language === "fa", [y, D] = x({
662
+ const { t, i18n: a } = ee(["admin", "translation"]), [i, m] = x([]), [f, p] = x(!1), [y, _] = x(""), [N, J] = x(!1), [T, j] = x(null), [A, D] = x([]), [S, O] = x(null), R = a.language === "fa", [w, I] = x({
620
663
  username: "",
621
664
  password: "",
622
665
  name: "",
623
666
  permissions: []
624
- }), E = async () => {
625
- p(!0), N("");
667
+ }), P = async () => {
668
+ p(!0), _("");
626
669
  try {
627
- const c = await w.listAdmins();
628
- u(c.admins || []);
629
- const i = localStorage.getItem("admin_info");
630
- i && U(JSON.parse(i).admin_id);
670
+ const c = await k.listAdmins();
671
+ m(c.admins || []);
672
+ const l = localStorage.getItem("admin_info");
673
+ l && O(JSON.parse(l).admin_id);
631
674
  } catch (c) {
632
- N(c instanceof Error ? c.message : t("error_loading"));
675
+ _(c instanceof Error ? c.message : t("error_loading"));
633
676
  } finally {
634
677
  p(!1);
635
678
  }
636
- }, J = async () => {
679
+ }, H = async () => {
637
680
  try {
638
- const c = await w.listPermissions();
639
- q(c.permissions);
681
+ const c = await k.listPermissions();
682
+ D(c.permissions);
640
683
  } catch (c) {
641
684
  console.error("Failed to load permissions", c);
642
685
  }
643
686
  };
644
687
  G(() => {
645
- E(), J();
688
+ P(), H();
646
689
  }, []);
647
- const K = async (c) => {
690
+ const V = async (c) => {
648
691
  c.preventDefault(), p(!0);
649
692
  try {
650
- await w.register(
651
- y.username,
652
- y.password,
653
- y.name,
654
- y.permissions
655
- ), $(!1), D({ username: "", password: "", name: "", permissions: [] }), E();
656
- } catch (i) {
657
- N(i instanceof Error ? i.message : t("error_loading"));
693
+ await k.register(
694
+ w.username,
695
+ w.password,
696
+ w.name,
697
+ w.permissions
698
+ ), J(!1), I({ username: "", password: "", name: "", permissions: [] }), P();
699
+ } catch (l) {
700
+ _(l instanceof Error ? l.message : t("error_loading"));
658
701
  } finally {
659
702
  p(!1);
660
703
  }
661
- }, B = async (c) => {
704
+ }, K = async (c) => {
662
705
  if (c.preventDefault(), !!T) {
663
706
  p(!0);
664
707
  try {
665
- const i = {
666
- name: y.name,
667
- permissions: y.permissions
708
+ const l = {
709
+ name: w.name,
710
+ permissions: w.permissions
668
711
  };
669
- if (y.password && (i.password = y.password), await w.updateAdmin(T.id, i), T.id === k) {
670
- const f = localStorage.getItem("admin_info");
671
- if (f) {
672
- const m = JSON.parse(f);
673
- m.name = y.name, m.permissions = y.permissions, localStorage.setItem("admin_info", JSON.stringify(m)), window.location.reload();
712
+ if (w.password && (l.password = w.password), await k.updateAdmin(T.id, l), T.id === S) {
713
+ const g = localStorage.getItem("admin_info");
714
+ if (g) {
715
+ const u = JSON.parse(g);
716
+ u.name = w.name, u.permissions = w.permissions, localStorage.setItem("admin_info", JSON.stringify(u)), window.location.reload();
674
717
  return;
675
718
  }
676
719
  }
677
- I(null), D({ username: "", password: "", name: "", permissions: [] }), E();
678
- } catch (i) {
679
- N(i instanceof Error ? i.message : t("error_loading"));
720
+ j(null), I({ username: "", password: "", name: "", permissions: [] }), P();
721
+ } catch (l) {
722
+ _(l instanceof Error ? l.message : t("error_loading"));
680
723
  } finally {
681
724
  p(!1);
682
725
  }
683
726
  }
684
- }, P = async (c) => {
727
+ }, B = async (c) => {
685
728
  if (confirm(t("admins.confirm_delete_admin")))
686
729
  try {
687
- await w.deleteAdmin(c), E();
688
- } catch (i) {
689
- N(i instanceof Error ? i.message : t("error_loading"));
730
+ await k.deleteAdmin(c), P();
731
+ } catch (l) {
732
+ _(l instanceof Error ? l.message : t("error_loading"));
690
733
  }
691
734
  }, h = (c) => {
692
- I(c), D({
735
+ j(c), I({
693
736
  username: c.username,
694
737
  password: "",
695
738
  name: c.name,
696
739
  permissions: c.permissions
697
- }), $(!0);
698
- }, F = (c) => {
699
- D((i) => ({
700
- ...i,
701
- permissions: i.permissions.includes(c) ? i.permissions.filter((f) => f !== c) : [...i.permissions, c]
740
+ }), J(!0);
741
+ }, z = (c) => {
742
+ I((l) => ({
743
+ ...l,
744
+ permissions: l.permissions.includes(c) ? l.permissions.filter((g) => g !== c) : [...l.permissions, c]
702
745
  }));
703
- }, l = (c) => {
704
- const i = `admins.perm_${c}`, f = t(i);
705
- if (f !== i)
706
- return f;
746
+ }, d = (c) => {
747
+ const l = `admins.perm_${c}`, g = t(l);
748
+ if (g !== l)
749
+ return g;
707
750
  switch (c) {
708
751
  case "chat_history":
709
752
  return t("admins.perm_chat_history");
@@ -719,16 +762,16 @@ function gt() {
719
762
  return c;
720
763
  }
721
764
  };
722
- return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: O ? "rtl" : "ltr", children: [
765
+ return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: R ? "rtl" : "ltr", children: [
723
766
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
724
767
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("admins.title") }),
725
768
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
726
- /* @__PURE__ */ e("div", { className: "glass-surface px-4 py-2.5 rounded-xl text-xs font-medium text-muted-foreground border border-border shadow-sm", children: t("admins.admin_count", { count: o.length }) }),
769
+ /* @__PURE__ */ e("div", { className: "glass-surface px-4 py-2.5 rounded-xl text-xs font-medium text-muted-foreground border border-border shadow-sm", children: t("admins.admin_count", { count: i.length }) }),
727
770
  /* @__PURE__ */ e(
728
771
  "button",
729
772
  {
730
773
  onClick: () => {
731
- I(null), D({ username: "", password: "", name: "", permissions: [] }), $(!0);
774
+ j(null), I({ username: "", password: "", name: "", permissions: [] }), J(!0);
732
775
  },
733
776
  className: "px-4 py-2.5 bg-primary text-primary-foreground rounded-xl text-sm font-semibold hover:opacity-90 transition-all shadow-sm hover:shadow-md whitespace-nowrap",
734
777
  children: t("admins.add_admin")
@@ -736,10 +779,10 @@ function gt() {
736
779
  )
737
780
  ] })
738
781
  ] }),
739
- _ && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0", children: _ }),
740
- v && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-md shadow-2xl overflow-hidden", children: [
782
+ y && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0", children: y }),
783
+ N && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-md shadow-2xl overflow-hidden", children: [
741
784
  /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(T ? "admins.edit_admin" : "admins.add_admin") }) }),
742
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: T ? B : K, className: "space-y-5", children: [
785
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: T ? K : V, className: "space-y-5", children: [
743
786
  /* @__PURE__ */ r("div", { children: [
744
787
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("admins.username") }),
745
788
  /* @__PURE__ */ e(
@@ -747,8 +790,8 @@ function gt() {
747
790
  {
748
791
  type: "text",
749
792
  disabled: !!T,
750
- value: y.username,
751
- onChange: (c) => D({ ...y, username: c.target.value }),
793
+ value: w.username,
794
+ onChange: (c) => I({ ...w, username: c.target.value }),
752
795
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground disabled:opacity-50 focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
753
796
  required: !0,
754
797
  dir: "ltr"
@@ -761,8 +804,8 @@ function gt() {
761
804
  "input",
762
805
  {
763
806
  type: "text",
764
- value: y.name,
765
- onChange: (c) => D({ ...y, name: c.target.value }),
807
+ value: w.name,
808
+ onChange: (c) => I({ ...w, name: c.target.value }),
766
809
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm",
767
810
  required: !0
768
811
  }
@@ -774,8 +817,8 @@ function gt() {
774
817
  "input",
775
818
  {
776
819
  type: "password",
777
- value: y.password,
778
- onChange: (c) => D({ ...y, password: c.target.value }),
820
+ value: w.password,
821
+ onChange: (c) => I({ ...w, password: c.target.value }),
779
822
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
780
823
  required: !T,
781
824
  dir: "ltr"
@@ -789,13 +832,13 @@ function gt() {
789
832
  "input",
790
833
  {
791
834
  type: "checkbox",
792
- checked: y.permissions.includes(c),
793
- onChange: () => F(c),
794
- disabled: y.username === "admin" && c === "admin_management",
835
+ checked: w.permissions.includes(c),
836
+ onChange: () => z(c),
837
+ disabled: w.username === "admin" && c === "admin_management",
795
838
  className: "peer h-4 w-4 rounded border-input text-primary focus:ring-ring transition-all disabled:opacity-50"
796
839
  }
797
840
  ) }),
798
- /* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: l(c) })
841
+ /* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: d(c) })
799
842
  ] }, c)) })
800
843
  ] }),
801
844
  /* @__PURE__ */ r("div", { className: "flex gap-3 pt-4", children: [
@@ -803,7 +846,7 @@ function gt() {
803
846
  "button",
804
847
  {
805
848
  type: "button",
806
- onClick: () => $(!1),
849
+ onClick: () => J(!1),
807
850
  className: "flex-1 px-4 py-3 bg-secondary text-secondary-foreground border border-border rounded-xl text-sm font-medium hover:bg-secondary/80 transition-colors",
808
851
  children: t("cancel")
809
852
  }
@@ -812,26 +855,26 @@ function gt() {
812
855
  "button",
813
856
  {
814
857
  type: "submit",
815
- disabled: g,
858
+ disabled: f,
816
859
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
817
- children: t(g ? "saving" : "save")
860
+ children: t(f ? "saving" : "save")
818
861
  }
819
862
  )
820
863
  ] })
821
864
  ] }) })
822
865
  ] }) }),
823
866
  /* @__PURE__ */ e("div", { className: "glass-surface border border-border rounded-2xl overflow-hidden shadow-sm flex-1 flex flex-col", children: /* @__PURE__ */ r("div", { className: "overflow-x-auto flex-1", children: [
824
- /* @__PURE__ */ r("table", { className: `w-full ${O ? "text-right" : "text-left"} border-collapse`, children: [
867
+ /* @__PURE__ */ r("table", { className: `w-full ${R ? "text-right" : "text-left"} border-collapse`, children: [
825
868
  /* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
826
869
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("admins.name") }),
827
870
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("admins.username") }),
828
871
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("admins.permissions") }),
829
872
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("users.actions") })
830
873
  ] }) }),
831
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: o.map((c) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
874
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: i.map((c) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
832
875
  /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: c.name }),
833
876
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children: c.username }),
834
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: c.permissions.map((i) => /* @__PURE__ */ e("span", { className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50", children: l(i) }, i)) }) }),
877
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: c.permissions.map((l) => /* @__PURE__ */ e("span", { className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50", children: d(l) }, l)) }) }),
835
878
  /* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
836
879
  /* @__PURE__ */ e(
837
880
  "button",
@@ -842,10 +885,10 @@ function gt() {
842
885
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" }) })
843
886
  }
844
887
  ),
845
- c.id !== k && /* @__PURE__ */ e(
888
+ c.id !== S && /* @__PURE__ */ e(
846
889
  "button",
847
890
  {
848
- onClick: () => P(c.id),
891
+ onClick: () => B(c.id),
849
892
  className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
850
893
  title: t("delete"),
851
894
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" }) })
@@ -854,11 +897,11 @@ function gt() {
854
897
  ] }) })
855
898
  ] }, c.id)) })
856
899
  ] }),
857
- o.length === 0 && !g && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
900
+ i.length === 0 && !f && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
858
901
  /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1, stroke: "currentColor", className: "w-12 h-12 opacity-20", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" }) }),
859
902
  t("admins.no_admins")
860
903
  ] }),
861
- g && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
904
+ f && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
862
905
  /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
863
906
  /* @__PURE__ */ e("span", { children: t("loading") })
864
907
  ] })
@@ -866,7 +909,7 @@ function gt() {
866
909
  ] });
867
910
  }
868
911
  function ft() {
869
- const { t, i18n: a } = Y(["admin", "translation"]), { app: o } = he(), [u, g] = x([]), [p, _] = x(!1), [N, v] = x(""), [$, T] = x(!1), [I, A] = x(null), [q, k] = x(""), [U, O] = x(0), y = ue(() => o?.userMetadataFields || [], [o?.userMetadataFields]), [D, E] = x(null), [J, K] = x(""), [B, P] = x(""), [h, F] = x(""), [l, c] = x(""), i = a.language === "fa", f = i ? "text-right" : "text-left", [m, j] = x({
912
+ const { t, i18n: a } = ee(["admin", "translation"]), { app: i } = me(), [m, f] = x([]), [p, y] = x(!1), [_, N] = x(""), [J, T] = x(!1), [j, A] = x(null), [D, S] = x(""), [O, R] = x(0), w = pe(() => i?.userMetadataFields || [], [i?.userMetadataFields]), [I, P] = x(null), [H, V] = x(""), [K, B] = x(""), [h, z] = x(""), [d, c] = x(""), l = a.language === "fa", g = l ? "text-right" : "text-left", [u, q] = x({
870
913
  phone: "",
871
914
  name: "",
872
915
  surname: "",
@@ -876,143 +919,143 @@ function ft() {
876
919
  requestsLimit: "",
877
920
  metadata: ""
878
921
  // Keep raw JSON for advanced users
879
- }), [M, s] = x({}), b = async () => {
880
- _(!0), v("");
922
+ }), [M, $] = x({}), F = async () => {
923
+ y(!0), N("");
881
924
  try {
882
- const n = await w.listUsers(0, 100, q);
883
- g(n.users || []), O(n.count || 0);
925
+ const n = await k.listUsers(0, 100, D);
926
+ f(n.users || []), R(n.count || 0);
884
927
  } catch (n) {
885
- v(n instanceof Error ? n.message : t("error_loading"));
928
+ N(n instanceof Error ? n.message : t("error_loading"));
886
929
  } finally {
887
- _(!1);
930
+ y(!1);
888
931
  }
889
932
  };
890
933
  G(() => {
891
934
  const n = setTimeout(() => {
892
- b();
935
+ F();
893
936
  }, 500);
894
937
  return () => clearTimeout(n);
895
- }, [q]), G(() => {
938
+ }, [D]), G(() => {
896
939
  try {
897
- const L = { ...m.metadata ? JSON.parse(m.metadata) : {}, ...M }, R = JSON.stringify(L, null, 2);
898
- R !== m.metadata && j((Q) => ({ ...Q, metadata: R }));
940
+ const L = { ...u.metadata ? JSON.parse(u.metadata) : {}, ...M }, E = JSON.stringify(L, null, 2);
941
+ E !== u.metadata && q((Z) => ({ ...Z, metadata: E }));
899
942
  } catch {
900
943
  }
901
944
  }, [M]), G(() => {
902
945
  const n = { ...M };
903
946
  let L = !1;
904
- y.forEach((R) => {
905
- R.condition && !ke(R.condition, M) && n[R.key] !== void 0 && (delete n[R.key], L = !0);
906
- }), L && s(n);
907
- }, [M, y]);
908
- const S = async (n) => {
947
+ w.forEach((E) => {
948
+ E.condition && !ke(E.condition, M) && n[E.key] !== void 0 && (delete n[E.key], L = !0);
949
+ }), L && $(n);
950
+ }, [M, w]);
951
+ const s = async (n) => {
909
952
  n.preventDefault();
910
- const L = m.tokens ? parseInt(m.tokens) : 0, R = m.requests ? parseInt(m.requests) : 0, Q = m.tokensLimit ? parseInt(m.tokensLimit) : L, ge = m.requestsLimit ? parseInt(m.requestsLimit) : R;
911
- if (L > Q) {
912
- v(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
953
+ const L = u.tokens ? parseInt(u.tokens) : 0, E = u.requests ? parseInt(u.requests) : 0, Z = u.tokensLimit ? parseInt(u.tokensLimit) : L, de = u.requestsLimit ? parseInt(u.requestsLimit) : E;
954
+ if (L > Z) {
955
+ N(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
913
956
  return;
914
957
  }
915
- if (R > ge) {
916
- v(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
958
+ if (E > de) {
959
+ N(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
917
960
  return;
918
961
  }
919
- let ce = {};
920
- if (m.metadata)
962
+ let le = {};
963
+ if (u.metadata)
921
964
  try {
922
- ce = JSON.parse(m.metadata);
965
+ le = JSON.parse(u.metadata);
923
966
  } catch {
924
- v(t("users.invalid_json", "Invalid JSON format"));
967
+ N(t("users.invalid_json", "Invalid JSON format"));
925
968
  return;
926
969
  }
927
- _(!0);
970
+ y(!0);
928
971
  try {
929
- await w.createUser(
930
- m.phone,
931
- m.name,
932
- m.surname,
933
- m.tokens ? parseInt(m.tokens) : void 0,
934
- m.requests ? parseInt(m.requests) : void 0,
935
- m.tokensLimit ? parseInt(m.tokensLimit) : void 0,
936
- m.requestsLimit ? parseInt(m.requestsLimit) : void 0,
937
- ce
938
- ), T(!1), V(), b();
972
+ await k.createUser(
973
+ u.phone,
974
+ u.name,
975
+ u.surname,
976
+ u.tokens ? parseInt(u.tokens) : void 0,
977
+ u.requests ? parseInt(u.requests) : void 0,
978
+ u.tokensLimit ? parseInt(u.tokensLimit) : void 0,
979
+ u.requestsLimit ? parseInt(u.requestsLimit) : void 0,
980
+ le
981
+ ), T(!1), C(), F();
939
982
  } catch (fe) {
940
- v(fe instanceof Error ? fe.message : t("error_loading"));
983
+ N(fe instanceof Error ? fe.message : t("error_loading"));
941
984
  } finally {
942
- _(!1);
985
+ y(!1);
943
986
  }
944
- }, H = async (n) => {
945
- if (n.preventDefault(), !I) return;
987
+ }, b = async (n) => {
988
+ if (n.preventDefault(), !j) return;
946
989
  let L = {};
947
- if (m.metadata)
990
+ if (u.metadata)
948
991
  try {
949
- L = JSON.parse(m.metadata);
992
+ L = JSON.parse(u.metadata);
950
993
  } catch {
951
- v(t("users.invalid_json", "Invalid JSON format"));
994
+ N(t("users.invalid_json", "Invalid JSON format"));
952
995
  return;
953
996
  }
954
- _(!0);
997
+ y(!0);
955
998
  try {
956
- await w.updateUser(I.id, {
957
- phone: m.phone,
958
- name: m.name,
959
- surname: m.surname,
999
+ await k.updateUser(j.id, {
1000
+ phone: u.phone,
1001
+ name: u.name,
1002
+ surname: u.surname,
960
1003
  metadata: L
961
- }), A(null), T(!1), V(), b();
962
- } catch (R) {
963
- v(R instanceof Error ? R.message : t("error_loading"));
1004
+ }), A(null), T(!1), C(), F();
1005
+ } catch (E) {
1006
+ N(E instanceof Error ? E.message : t("error_loading"));
964
1007
  } finally {
965
- _(!1);
1008
+ y(!1);
966
1009
  }
967
- }, V = () => {
968
- j({ phone: "", name: "", surname: "", tokens: "", requests: "", tokensLimit: "", requestsLimit: "", metadata: "" }), s({});
969
- }, d = async (n) => {
1010
+ }, C = () => {
1011
+ q({ phone: "", name: "", surname: "", tokens: "", requests: "", tokensLimit: "", requestsLimit: "", metadata: "" }), $({});
1012
+ }, o = async (n) => {
970
1013
  if (confirm(t("users.confirm_delete_user")))
971
1014
  try {
972
- await w.deleteUser(n), b();
1015
+ await k.deleteUser(n), F();
973
1016
  } catch (L) {
974
- v(L instanceof Error ? L.message : t("error_loading"));
1017
+ N(L instanceof Error ? L.message : t("error_loading"));
975
1018
  }
976
- }, C = async (n) => {
1019
+ }, v = async (n) => {
977
1020
  try {
978
- const R = (await w.refreshUserToken(n.id))?.user?.token;
979
- if (!R) {
980
- v(t("users.no_token"));
1021
+ const E = (await k.refreshUserToken(n.id))?.user?.token;
1022
+ if (!E) {
1023
+ N(t("users.no_token"));
981
1024
  return;
982
1025
  }
983
- await navigator.clipboard.writeText(R), alert(t("users.token_copied"));
1026
+ await navigator.clipboard.writeText(E), alert(t("users.token_copied"));
984
1027
  } catch (L) {
985
- v(L instanceof Error ? L.message : t("error_loading"));
1028
+ N(L instanceof Error ? L.message : t("error_loading"));
986
1029
  }
987
- }, z = async (n) => {
988
- if (n.preventDefault(), !D) return;
989
- const L = parseInt(J) || 0, R = parseInt(B) || 0, Q = h ? parseInt(h) : D.balance?.token_limit || 0, ge = l ? parseInt(l) : D.balance?.request_limit || 0;
990
- if (L > Q) {
991
- v(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1030
+ }, U = async (n) => {
1031
+ if (n.preventDefault(), !I) return;
1032
+ const L = parseInt(H) || 0, E = parseInt(K) || 0, Z = h ? parseInt(h) : I.balance?.token_limit || 0, de = d ? parseInt(d) : I.balance?.request_limit || 0;
1033
+ if (L > Z) {
1034
+ N(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
992
1035
  return;
993
1036
  }
994
- if (R > ge) {
995
- v(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1037
+ if (E > de) {
1038
+ N(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
996
1039
  return;
997
1040
  }
998
- _(!0);
1041
+ y(!0);
999
1042
  try {
1000
- await w.updateUserBalance(
1001
- D.id,
1043
+ await k.updateUserBalance(
1044
+ I.id,
1002
1045
  L,
1003
- R,
1046
+ E,
1004
1047
  h ? parseInt(h) : void 0,
1005
- l ? parseInt(l) : void 0
1006
- ), E(null), K(""), P(""), F(""), c(""), b();
1007
- } catch (ce) {
1008
- v(ce instanceof Error ? ce.message : t("error_loading"));
1048
+ d ? parseInt(d) : void 0
1049
+ ), P(null), V(""), B(""), z(""), c(""), F();
1050
+ } catch (le) {
1051
+ N(le instanceof Error ? le.message : t("error_loading"));
1009
1052
  } finally {
1010
- _(!1);
1053
+ y(!1);
1011
1054
  }
1012
- }, re = (n) => {
1055
+ }, X = (n) => {
1013
1056
  A(n);
1014
1057
  const L = n.metadata ? JSON.stringify(n.metadata, null, 2) : "";
1015
- if (j({
1058
+ if (q({
1016
1059
  phone: n.phone,
1017
1060
  name: n.name,
1018
1061
  surname: n.surname,
@@ -1022,14 +1065,14 @@ function ft() {
1022
1065
  requestsLimit: "",
1023
1066
  metadata: L
1024
1067
  }), n.metadata) {
1025
- const R = {};
1026
- y.forEach((Q) => {
1027
- n.metadata?.[Q.key] !== void 0 ? R[Q.key] = n.metadata[Q.key] : Q.defaultValue !== void 0 && (R[Q.key] = Q.defaultValue);
1028
- }), s(R);
1068
+ const E = {};
1069
+ w.forEach((Z) => {
1070
+ n.metadata?.[Z.key] !== void 0 ? E[Z.key] = n.metadata[Z.key] : Z.defaultValue !== void 0 && (E[Z.key] = Z.defaultValue);
1071
+ }), $(E);
1029
1072
  }
1030
1073
  T(!0);
1031
1074
  };
1032
- return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: i ? "rtl" : "ltr", children: [
1075
+ return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: l ? "rtl" : "ltr", children: [
1033
1076
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
1034
1077
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("users.title") }),
1035
1078
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row items-center gap-2 flex-1 max-w-4xl justify-end", children: [
@@ -1037,19 +1080,19 @@ function ft() {
1037
1080
  "input",
1038
1081
  {
1039
1082
  type: "text",
1040
- value: q,
1041
- onChange: (n) => k(n.target.value),
1083
+ value: D,
1084
+ onChange: (n) => S(n.target.value),
1042
1085
  placeholder: t("chat_history.search_placeholder"),
1043
1086
  className: "w-full px-4 py-2.5 border-0 rounded-xl glass-surface text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm"
1044
1087
  }
1045
1088
  ) }),
1046
1089
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 shrink-0", children: [
1047
- /* @__PURE__ */ e("div", { className: "glass-surface px-4 py-2.5 rounded-xl text-xs font-medium text-muted-foreground border border-border shadow-sm", children: t("users.user_count", { count: U }) }),
1090
+ /* @__PURE__ */ e("div", { className: "glass-surface px-4 py-2.5 rounded-xl text-xs font-medium text-muted-foreground border border-border shadow-sm", children: t("users.user_count", { count: O }) }),
1048
1091
  /* @__PURE__ */ e(
1049
1092
  "button",
1050
1093
  {
1051
1094
  onClick: () => {
1052
- A(null), V(), T(!0);
1095
+ A(null), C(), T(!0);
1053
1096
  },
1054
1097
  className: "px-4 py-2.5 bg-primary text-primary-foreground rounded-xl text-sm font-semibold hover:opacity-90 transition-all shadow-sm hover:shadow-md whitespace-nowrap",
1055
1098
  children: t("users.add_user")
@@ -1058,13 +1101,13 @@ function ft() {
1058
1101
  ] })
1059
1102
  ] })
1060
1103
  ] }),
1061
- N && /* @__PURE__ */ r("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0 flex justify-between items-center group", children: [
1062
- /* @__PURE__ */ e("span", { children: N }),
1063
- /* @__PURE__ */ e("button", { onClick: () => v(""), className: "opacity-50 hover:opacity-100 transition-opacity p-1", children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) })
1104
+ _ && /* @__PURE__ */ r("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0 flex justify-between items-center group", children: [
1105
+ /* @__PURE__ */ e("span", { children: _ }),
1106
+ /* @__PURE__ */ e("button", { onClick: () => N(""), className: "opacity-50 hover:opacity-100 transition-opacity p-1", children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) })
1064
1107
  ] }),
1065
- $ && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-xl shadow-2xl overflow-hidden", children: [
1066
- /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(I ? "users.edit_user" : "users.add_user") }) }),
1067
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: I ? H : S, children: [
1108
+ J && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-xl shadow-2xl overflow-hidden", children: [
1109
+ /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(j ? "users.edit_user" : "users.add_user") }) }),
1110
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: j ? b : s, children: [
1068
1111
  /* @__PURE__ */ r("div", { className: "space-y-6 max-h-[60vh] overflow-y-auto px-1 custom-scrollbar", children: [
1069
1112
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1070
1113
  /* @__PURE__ */ r("div", { children: [
@@ -1073,8 +1116,8 @@ function ft() {
1073
1116
  "input",
1074
1117
  {
1075
1118
  type: "text",
1076
- value: m.phone,
1077
- onChange: (n) => j({ ...m, phone: n.target.value }),
1119
+ value: u.phone,
1120
+ onChange: (n) => q({ ...u, phone: n.target.value }),
1078
1121
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1079
1122
  placeholder: t("users.phone_placeholder"),
1080
1123
  required: !0,
@@ -1089,9 +1132,9 @@ function ft() {
1089
1132
  "input",
1090
1133
  {
1091
1134
  type: "text",
1092
- value: m.name,
1093
- onChange: (n) => j({ ...m, name: n.target.value }),
1094
- className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${f}`,
1135
+ value: u.name,
1136
+ onChange: (n) => q({ ...u, name: n.target.value }),
1137
+ className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${g}`,
1095
1138
  required: !0
1096
1139
  }
1097
1140
  )
@@ -1102,17 +1145,17 @@ function ft() {
1102
1145
  "input",
1103
1146
  {
1104
1147
  type: "text",
1105
- value: m.surname,
1106
- onChange: (n) => j({ ...m, surname: n.target.value }),
1107
- className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${f}`,
1148
+ value: u.surname,
1149
+ onChange: (n) => q({ ...u, surname: n.target.value }),
1150
+ className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${g}`,
1108
1151
  required: !0
1109
1152
  }
1110
1153
  )
1111
1154
  ] })
1112
1155
  ] })
1113
1156
  ] }),
1114
- !I && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1115
- /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.initial_balance", "Initial Balance") }),
1157
+ !j && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1158
+ /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.initial_balance") }),
1116
1159
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1117
1160
  /* @__PURE__ */ r("div", { children: [
1118
1161
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("users.initial_tokens") }),
@@ -1120,8 +1163,8 @@ function ft() {
1120
1163
  "input",
1121
1164
  {
1122
1165
  type: "number",
1123
- value: m.tokens,
1124
- onChange: (n) => j({ ...m, tokens: n.target.value }),
1166
+ value: u.tokens,
1167
+ onChange: (n) => q({ ...u, tokens: n.target.value }),
1125
1168
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1126
1169
  dir: "ltr",
1127
1170
  placeholder: "0"
@@ -1134,11 +1177,11 @@ function ft() {
1134
1177
  "input",
1135
1178
  {
1136
1179
  type: "number",
1137
- value: m.tokensLimit,
1138
- onChange: (n) => j({ ...m, tokensLimit: n.target.value }),
1180
+ value: u.tokensLimit,
1181
+ onChange: (n) => q({ ...u, tokensLimit: n.target.value }),
1139
1182
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1140
1183
  dir: "ltr",
1141
- placeholder: m.tokens || "250000"
1184
+ placeholder: u.tokens || "250000"
1142
1185
  }
1143
1186
  )
1144
1187
  ] })
@@ -1150,8 +1193,8 @@ function ft() {
1150
1193
  "input",
1151
1194
  {
1152
1195
  type: "number",
1153
- value: m.requests,
1154
- onChange: (n) => j({ ...m, requests: n.target.value }),
1196
+ value: u.requests,
1197
+ onChange: (n) => q({ ...u, requests: n.target.value }),
1155
1198
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1156
1199
  dir: "ltr",
1157
1200
  placeholder: "0"
@@ -1164,19 +1207,19 @@ function ft() {
1164
1207
  "input",
1165
1208
  {
1166
1209
  type: "number",
1167
- value: m.requestsLimit,
1168
- onChange: (n) => j({ ...m, requestsLimit: n.target.value }),
1210
+ value: u.requestsLimit,
1211
+ onChange: (n) => q({ ...u, requestsLimit: n.target.value }),
1169
1212
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1170
1213
  dir: "ltr",
1171
- placeholder: m.requests || "100"
1214
+ placeholder: u.requests || "100"
1172
1215
  }
1173
1216
  )
1174
1217
  ] })
1175
1218
  ] })
1176
1219
  ] }),
1177
- y.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1178
- /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.custom_fields", "Custom Metadata Fields") }),
1179
- /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: y.map((n) => ke(n.condition, M) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1220
+ w.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1221
+ /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.custom_fields") }),
1222
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: w.map((n) => ke(n.condition, M) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1180
1223
  /* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
1181
1224
  t(n.label),
1182
1225
  " ",
@@ -1186,11 +1229,11 @@ function ft() {
1186
1229
  ae,
1187
1230
  {
1188
1231
  value: String(M[n.key] || ""),
1189
- onValueChange: (L) => s({ ...M, [n.key]: L }),
1232
+ onValueChange: (L) => $({ ...M, [n.key]: L }),
1190
1233
  required: n.required,
1191
- dir: i ? "rtl" : "ltr",
1234
+ dir: l ? "rtl" : "ltr",
1192
1235
  children: [
1193
- /* @__PURE__ */ e(ne, { className: be("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", f), children: /* @__PURE__ */ e(oe, { placeholder: t(n.placeholder || "select_placeholder") }) }),
1236
+ /* @__PURE__ */ e(ne, { className: be("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", g), children: /* @__PURE__ */ e(oe, { placeholder: t(n.placeholder || "select_placeholder") }) }),
1194
1237
  /* @__PURE__ */ e(ie, { className: "rounded-xl border-border bg-card", children: n.options?.map((L) => /* @__PURE__ */ e(W, { value: String(L.value), children: t(L.label) }, String(L.value))) })
1195
1238
  ]
1196
1239
  }
@@ -1200,7 +1243,7 @@ function ft() {
1200
1243
  {
1201
1244
  id: `admin-md-${n.key}`,
1202
1245
  checked: !!M[n.key],
1203
- onCheckedChange: (L) => s({ ...M, [n.key]: !!L }),
1246
+ onCheckedChange: (L) => $({ ...M, [n.key]: !!L }),
1204
1247
  required: n.required
1205
1248
  }
1206
1249
  ),
@@ -1210,8 +1253,8 @@ function ft() {
1210
1253
  {
1211
1254
  type: n.type,
1212
1255
  value: M[n.key] || "",
1213
- onChange: (L) => s({ ...M, [n.key]: L.target.value }),
1214
- className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${f}`,
1256
+ onChange: (L) => $({ ...M, [n.key]: L.target.value }),
1257
+ className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${g}`,
1215
1258
  placeholder: t(n.placeholder || ""),
1216
1259
  required: n.required
1217
1260
  }
@@ -1220,14 +1263,14 @@ function ft() {
1220
1263
  ] }),
1221
1264
  /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4", children: [
1222
1265
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between mb-2", children: [
1223
- /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider", children: t("users.metadata_raw", "Metadata (Raw JSON)") }),
1224
- /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground opacity-60", children: "Advanced usage" })
1266
+ /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider", children: t("users.metadata_raw") }),
1267
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground opacity-60", children: t("users.advanced_usage") })
1225
1268
  ] }),
1226
1269
  /* @__PURE__ */ e(
1227
1270
  "textarea",
1228
1271
  {
1229
- value: m.metadata,
1230
- onChange: (n) => j({ ...m, metadata: n.target.value }),
1272
+ value: u.metadata,
1273
+ onChange: (n) => q({ ...u, metadata: n.target.value }),
1231
1274
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-xs font-mono min-h-[100px] custom-scrollbar",
1232
1275
  placeholder: '{ "key": "value" }',
1233
1276
  dir: "ltr"
@@ -1259,13 +1302,13 @@ function ft() {
1259
1302
  ] })
1260
1303
  ] }) })
1261
1304
  ] }) }),
1262
- D && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-sm shadow-2xl overflow-hidden", children: [
1305
+ I && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-sm shadow-2xl overflow-hidden", children: [
1263
1306
  /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ r("h3", { className: "text-lg font-bold text-foreground", children: [
1264
1307
  t("users.update_balance_for"),
1265
1308
  " ",
1266
- D.name
1309
+ I.name
1267
1310
  ] }) }),
1268
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: z, children: [
1311
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: U, children: [
1269
1312
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1270
1313
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1271
1314
  /* @__PURE__ */ r("div", { children: [
@@ -1274,8 +1317,8 @@ function ft() {
1274
1317
  "input",
1275
1318
  {
1276
1319
  type: "number",
1277
- value: J,
1278
- onChange: (n) => K(n.target.value),
1320
+ value: H,
1321
+ onChange: (n) => V(n.target.value),
1279
1322
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1280
1323
  required: !0,
1281
1324
  dir: "ltr"
@@ -1289,10 +1332,10 @@ function ft() {
1289
1332
  {
1290
1333
  type: "number",
1291
1334
  value: h,
1292
- onChange: (n) => F(n.target.value),
1335
+ onChange: (n) => z(n.target.value),
1293
1336
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1294
1337
  dir: "ltr",
1295
- placeholder: J
1338
+ placeholder: H
1296
1339
  }
1297
1340
  )
1298
1341
  ] })
@@ -1304,8 +1347,8 @@ function ft() {
1304
1347
  "input",
1305
1348
  {
1306
1349
  type: "number",
1307
- value: B,
1308
- onChange: (n) => P(n.target.value),
1350
+ value: K,
1351
+ onChange: (n) => B(n.target.value),
1309
1352
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1310
1353
  required: !0,
1311
1354
  dir: "ltr"
@@ -1318,11 +1361,11 @@ function ft() {
1318
1361
  "input",
1319
1362
  {
1320
1363
  type: "number",
1321
- value: l,
1364
+ value: d,
1322
1365
  onChange: (n) => c(n.target.value),
1323
1366
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono text-left",
1324
1367
  dir: "ltr",
1325
- placeholder: B
1368
+ placeholder: K
1326
1369
  }
1327
1370
  )
1328
1371
  ] })
@@ -1334,7 +1377,7 @@ function ft() {
1334
1377
  {
1335
1378
  type: "button",
1336
1379
  onClick: () => {
1337
- E(null), v("");
1380
+ P(null), N("");
1338
1381
  },
1339
1382
  className: "flex-1 px-4 py-3 bg-secondary text-secondary-foreground border border-border rounded-xl text-sm font-medium hover:bg-secondary/80 transition-colors",
1340
1383
  children: t("cancel")
@@ -1353,20 +1396,28 @@ function ft() {
1353
1396
  ] }) })
1354
1397
  ] }) }),
1355
1398
  /* @__PURE__ */ e("div", { className: "glass-surface border border-border rounded-2xl overflow-hidden shadow-sm flex-1 flex flex-col", children: /* @__PURE__ */ r("div", { className: "overflow-x-auto flex-1 custom-scrollbar", children: [
1356
- /* @__PURE__ */ r("table", { className: `w-full ${i ? "text-right" : "text-left"} border-collapse`, children: [
1399
+ /* @__PURE__ */ r("table", { className: `w-full ${l ? "text-right" : "text-left"} border-collapse`, children: [
1357
1400
  /* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
1358
1401
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("users.phone") }),
1359
1402
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("users.name") }),
1360
1403
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("users.surname") }),
1361
- y.map((n) => /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t(n.label) }, n.key)),
1404
+ w.map((n) => /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t(n.label) }, n.key)),
1362
1405
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50 w-[120px]", children: t("users.balance") }),
1363
1406
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("users.actions") })
1364
1407
  ] }) }),
1365
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: u.map((n) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
1408
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: m.map((n) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
1366
1409
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground font-mono", dir: "ltr", children: n.phone }),
1367
1410
  /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: n.name }),
1368
1411
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: n.surname }),
1369
- y.map((L) => /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: L.type === "checkbox" ? n.metadata?.[L.key] ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : String(n.metadata?.[L.key] ?? "") }, L.key)),
1412
+ w.map((L) => {
1413
+ const E = n.metadata?.[L.key];
1414
+ let Z = String(E ?? "");
1415
+ if (L.type === "select" && E !== void 0) {
1416
+ const de = L.options?.find((le) => String(le.value) === String(E));
1417
+ de && (Z = t(de.label));
1418
+ }
1419
+ return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: L.type === "checkbox" ? E ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : Z }, L.key);
1420
+ }),
1370
1421
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground w-[120px]", children: n.balance ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 min-w-0 py-1", children: [
1371
1422
  /* @__PURE__ */ r("div", { className: "space-y-1", children: [
1372
1423
  /* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
@@ -1405,7 +1456,7 @@ function ft() {
1405
1456
  /* @__PURE__ */ e(
1406
1457
  "button",
1407
1458
  {
1408
- onClick: () => re(n),
1459
+ onClick: () => X(n),
1409
1460
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1410
1461
  title: t("edit"),
1411
1462
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" }) })
@@ -1415,7 +1466,7 @@ function ft() {
1415
1466
  "button",
1416
1467
  {
1417
1468
  onClick: () => {
1418
- E(n), K(String(n.balance?.tokens || 0)), P(String(n.balance?.requests || 0)), F(String(n.balance?.token_limit || 0)), c(String(n.balance?.request_limit || 0)), v("");
1469
+ P(n), V(String(n.balance?.tokens || 0)), B(String(n.balance?.requests || 0)), z(String(n.balance?.token_limit || 0)), c(String(n.balance?.request_limit || 0)), N("");
1419
1470
  },
1420
1471
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1421
1472
  title: t("users.recharge"),
@@ -1425,7 +1476,7 @@ function ft() {
1425
1476
  /* @__PURE__ */ e(
1426
1477
  "button",
1427
1478
  {
1428
- onClick: () => C(n),
1479
+ onClick: () => v(n),
1429
1480
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1430
1481
  title: t("users.copy_token"),
1431
1482
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" }) })
@@ -1434,7 +1485,7 @@ function ft() {
1434
1485
  /* @__PURE__ */ e(
1435
1486
  "button",
1436
1487
  {
1437
- onClick: () => d(n.id),
1488
+ onClick: () => o(n.id),
1438
1489
  className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
1439
1490
  title: t("delete"),
1440
1491
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" }) })
@@ -1443,7 +1494,7 @@ function ft() {
1443
1494
  ] }) })
1444
1495
  ] }, n.id)) })
1445
1496
  ] }),
1446
- u.length === 0 && !p && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1497
+ m.length === 0 && !p && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1447
1498
  /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/xl", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1, stroke: "currentColor", className: "w-12 h-12 opacity-20", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" }) }),
1448
1499
  t("users.no_users")
1449
1500
  ] }),
@@ -1455,149 +1506,149 @@ function ft() {
1455
1506
  ] });
1456
1507
  }
1457
1508
  function xt() {
1458
- const { t, i18n: a } = Y(["admin", "translation"]), [o, u] = x(null), [g, p] = x(!0), [_, N] = x(""), [v, $] = x(30), [T, I] = x(0), A = Me(null), q = a.language === "fa", k = q ? "fa-IR" : "en-US", U = q ? "fa-IR-u-ca-persian" : "en-US";
1509
+ const { t, i18n: a } = ee(["admin", "translation"]), [i, m] = x(null), [f, p] = x(!0), [y, _] = x(""), [N, J] = x(30), [T, j] = x(0), A = Me(null), D = a.language === "fa", S = D ? "fa-IR" : "en-US", O = D ? "fa-IR-u-ca-persian" : "en-US";
1459
1510
  G(() => {
1460
- D();
1461
- }, [v]), G(() => {
1511
+ I();
1512
+ }, [N]), G(() => {
1462
1513
  if (!A.current) return;
1463
- const l = new ResizeObserver((c) => {
1464
- for (const i of c)
1465
- I(i.contentRect.width);
1514
+ const d = new ResizeObserver((c) => {
1515
+ for (const l of c)
1516
+ j(l.contentRect.width);
1466
1517
  });
1467
- return l.observe(A.current), () => l.disconnect();
1518
+ return d.observe(A.current), () => d.disconnect();
1468
1519
  }, []);
1469
- const O = (l, c, i) => {
1470
- const f = [], m = /* @__PURE__ */ new Date(), j = l || [], M = new Map(j.map((s) => [s.date, s]));
1471
- for (let s = c - 1; s >= 0; s--) {
1472
- const S = new Date(m.getTime() - s * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1473
- if (M.has(S))
1474
- f.push(M.get(S));
1520
+ const R = (d, c, l) => {
1521
+ const g = [], u = /* @__PURE__ */ new Date(), q = d || [], M = new Map(q.map(($) => [$.date, $]));
1522
+ for (let $ = c - 1; $ >= 0; $--) {
1523
+ const s = new Date(u.getTime() - $ * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1524
+ if (M.has(s))
1525
+ g.push(M.get(s));
1475
1526
  else {
1476
- const H = { date: S };
1477
- i.forEach((V) => H[V] = 0), f.push(H);
1527
+ const b = { date: s };
1528
+ l.forEach((C) => b[C] = 0), g.push(b);
1478
1529
  }
1479
1530
  }
1480
- return f;
1481
- }, y = (l) => {
1482
- if (!l || l.length === 0) return null;
1483
- const c = l.length, i = new Intl.DateTimeFormat(U, { month: "short" });
1484
- let f = [];
1485
- if (v <= 14)
1486
- f = Array.from({ length: c }, (m, j) => j);
1531
+ return g;
1532
+ }, w = (d) => {
1533
+ if (!d || d.length === 0) return null;
1534
+ const c = d.length, l = new Intl.DateTimeFormat(O, { month: "short" });
1535
+ let g = [];
1536
+ if (N <= 14)
1537
+ g = Array.from({ length: c }, (u, q) => q);
1487
1538
  else {
1488
- const m = q ? 45 : 35, j = T > 0 ? Math.floor(T / m) : 6, M = Math.max(1, Math.ceil(c / Math.max(1, j)));
1489
- for (let s = 0; s < c; s += M)
1490
- f.push(s);
1491
- f.length > 0 && f[f.length - 1] !== c - 1 && (c - 1 - f[f.length - 1] > M / 2 ? f.push(c - 1) : f[f.length - 1] = c - 1);
1539
+ const u = D ? 45 : 35, q = T > 0 ? Math.floor(T / u) : 6, M = Math.max(1, Math.ceil(c / Math.max(1, q)));
1540
+ for (let $ = 0; $ < c; $ += M)
1541
+ g.push($);
1542
+ g.length > 0 && g[g.length - 1] !== c - 1 && (c - 1 - g[g.length - 1] > M / 2 ? g.push(c - 1) : g[g.length - 1] = c - 1);
1492
1543
  }
1493
- return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: q ? "rtl" : "ltr", children: f.map((m) => {
1494
- const j = l[m];
1495
- if (!j) return null;
1496
- const M = new Date(j.date), s = M.toLocaleDateString(U, { day: "numeric" }), b = i.format(M), S = c > 1 ? m / (c - 1) * 100 : 50;
1544
+ return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: D ? "rtl" : "ltr", children: g.map((u) => {
1545
+ const q = d[u];
1546
+ if (!q) return null;
1547
+ const M = new Date(q.date), $ = M.toLocaleDateString(O, { day: "numeric" }), F = l.format(M), s = c > 1 ? u / (c - 1) * 100 : 50;
1497
1548
  return /* @__PURE__ */ r(
1498
1549
  "div",
1499
1550
  {
1500
1551
  className: "absolute top-0 transform -translate-x-1/2 flex flex-col items-center",
1501
- style: { left: `${S}%` },
1552
+ style: { left: `${s}%` },
1502
1553
  children: [
1503
- /* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: s }),
1504
- /* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: b })
1554
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: $ }),
1555
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: F })
1505
1556
  ]
1506
1557
  },
1507
- m
1558
+ u
1508
1559
  );
1509
1560
  }) });
1510
- }, D = async () => {
1511
- p(!0), N("");
1561
+ }, I = async () => {
1562
+ p(!0), _("");
1512
1563
  try {
1513
- const l = await w.getAnalytics(v), c = {
1514
- ...l,
1515
- overview: l.overview || {
1564
+ const d = await k.getAnalytics(N), c = {
1565
+ ...d,
1566
+ overview: d.overview || {
1516
1567
  total_users: 0,
1517
1568
  total_threads: 0,
1518
1569
  total_messages: 0,
1519
1570
  total_token_usage: 0
1520
1571
  },
1521
1572
  trends: {
1522
- ...l.trends || {},
1523
- users: O(l.trends?.users, v, ["count"]),
1524
- threads: O(l.trends?.threads, v, ["count"]),
1525
- messages: O(l.trends?.messages, v, ["count"]),
1526
- token_usage: O(l.trends?.token_usage, v, ["tokens", "requests"])
1573
+ ...d.trends || {},
1574
+ users: R(d.trends?.users, N, ["count"]),
1575
+ threads: R(d.trends?.threads, N, ["count"]),
1576
+ messages: R(d.trends?.messages, N, ["count"]),
1577
+ token_usage: R(d.trends?.token_usage, N, ["tokens", "requests"])
1527
1578
  },
1528
1579
  distributions: {
1529
- ...l.distributions || {},
1530
- feedback_sentiment: l.distributions?.feedback_sentiment || []
1580
+ ...d.distributions || {},
1581
+ feedback_sentiment: d.distributions?.feedback_sentiment || []
1531
1582
  },
1532
- active_users: l.active_users || []
1583
+ active_users: d.active_users || []
1533
1584
  };
1534
- u(c);
1535
- } catch (l) {
1536
- N(l instanceof Error ? l.message : t("analytics.error_loading"));
1585
+ m(c);
1586
+ } catch (d) {
1587
+ _(d instanceof Error ? d.message : t("analytics.error_loading"));
1537
1588
  } finally {
1538
1589
  p(!1);
1539
1590
  }
1540
1591
  };
1541
- if (g)
1592
+ if (f)
1542
1593
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground", children: t("analytics.loading_analytics") });
1543
- if (_)
1594
+ if (y)
1544
1595
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
1545
- /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: _ }),
1596
+ /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: y }),
1546
1597
  /* @__PURE__ */ e(
1547
1598
  "button",
1548
1599
  {
1549
- onClick: D,
1600
+ onClick: I,
1550
1601
  className: "px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-colors",
1551
1602
  children: t("retry")
1552
1603
  }
1553
1604
  )
1554
1605
  ] }) });
1555
- if (!o) return null;
1556
- const E = (l) => {
1557
- if (l <= 0) return 10;
1558
- const c = l * 1.15, i = Math.pow(10, Math.floor(Math.log10(c))), f = c / i;
1559
- let m;
1560
- return f <= 1.2 ? m = 0.2 : f <= 2.5 ? m = 0.5 : f <= 5 ? m = 1 : m = 2, Math.ceil(c / (m * i)) * (m * i);
1561
- }, J = Math.max(...o.trends.threads.map((l) => l.count) || [1]), K = Math.max(...o.trends.messages.map((l) => l.count) || [1]), B = Math.max(...o.trends.token_usage.map((l) => l.tokens) || [1]), P = E(J), h = E(K), F = E(B);
1562
- return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: q ? "rtl" : "ltr", children: [
1606
+ if (!i) return null;
1607
+ const P = (d) => {
1608
+ if (d <= 0) return 10;
1609
+ const c = d * 1.15, l = Math.pow(10, Math.floor(Math.log10(c))), g = c / l;
1610
+ let u;
1611
+ return g <= 1.2 ? u = 0.2 : g <= 2.5 ? u = 0.5 : g <= 5 ? u = 1 : u = 2, Math.ceil(c / (u * l)) * (u * l);
1612
+ }, H = Math.max(...i.trends.threads.map((d) => d.count) || [1]), V = Math.max(...i.trends.messages.map((d) => d.count) || [1]), K = Math.max(...i.trends.token_usage.map((d) => d.tokens) || [1]), B = P(H), h = P(V), z = P(K);
1613
+ return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: D ? "rtl" : "ltr", children: [
1563
1614
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3", children: [
1564
1615
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("analytics.title") }),
1565
- /* @__PURE__ */ e("div", { className: "flex gap-2", children: [7, 14, 30, 90].map((l) => /* @__PURE__ */ e(
1616
+ /* @__PURE__ */ e("div", { className: "flex gap-2", children: [7, 14, 30, 90].map((d) => /* @__PURE__ */ e(
1566
1617
  "button",
1567
1618
  {
1568
- onClick: () => $(l),
1569
- className: `px-4 py-2 text-sm font-medium rounded-xl transition-all shadow-sm ${v === l ? "bg-primary text-primary-foreground shadow-md" : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground border border-border/50"}`,
1570
- children: t("analytics.days", { count: l })
1619
+ onClick: () => J(d),
1620
+ className: `px-4 py-2 text-sm font-medium rounded-xl transition-all shadow-sm ${N === d ? "bg-primary text-primary-foreground shadow-md" : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground border border-border/50"}`,
1621
+ children: t("analytics.days", { count: d })
1571
1622
  },
1572
- l
1623
+ d
1573
1624
  )) })
1574
1625
  ] }),
1575
1626
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", children: [
1576
1627
  /* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
1577
1628
  /* @__PURE__ */ r("div", { children: [
1578
1629
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_users") }),
1579
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (o.overview.total_users || 0).toLocaleString(k) })
1630
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_users || 0).toLocaleString(S) })
1580
1631
  ] }),
1581
1632
  /* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-5 h-5 text-primary", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" }) }) })
1582
1633
  ] }) }),
1583
1634
  /* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
1584
1635
  /* @__PURE__ */ r("div", { children: [
1585
1636
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_threads") }),
1586
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (o.overview.total_threads || 0).toLocaleString(k) })
1637
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_threads || 0).toLocaleString(S) })
1587
1638
  ] }),
1588
1639
  /* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-5 h-5 text-primary", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }) })
1589
1640
  ] }) }),
1590
1641
  /* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
1591
1642
  /* @__PURE__ */ r("div", { children: [
1592
1643
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_messages") }),
1593
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (o.overview.total_messages || 0).toLocaleString(k) })
1644
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_messages || 0).toLocaleString(S) })
1594
1645
  ] }),
1595
1646
  /* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-5 h-5 text-primary", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z" }) }) })
1596
1647
  ] }) }),
1597
1648
  /* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
1598
1649
  /* @__PURE__ */ r("div", { children: [
1599
1650
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_token_usage") }),
1600
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (o.overview.total_token_usage || 0).toLocaleString(k) })
1651
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_token_usage || 0).toLocaleString(S) })
1601
1652
  ] }),
1602
1653
  /* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-5 h-5 text-primary", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) })
1603
1654
  ] }) })
@@ -1608,8 +1659,8 @@ function xt() {
1608
1659
  /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: A, children: [
1609
1660
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1610
1661
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1611
- /* @__PURE__ */ e("span", { children: (P || 0).toLocaleString(k) }),
1612
- /* @__PURE__ */ e("span", { children: Math.floor((P || 0) / 2).toLocaleString(k) }),
1662
+ /* @__PURE__ */ e("span", { children: (B || 0).toLocaleString(S) }),
1663
+ /* @__PURE__ */ e("span", { children: Math.floor((B || 0) / 2).toLocaleString(S) }),
1613
1664
  /* @__PURE__ */ e("span", { children: "0" })
1614
1665
  ] }),
1615
1666
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1617,14 +1668,14 @@ function xt() {
1617
1668
  /* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
1618
1669
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
1619
1670
  ] }),
1620
- o.trends.threads.length > 0 ? o.trends.threads.map((l, c) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1671
+ i.trends.threads.length > 0 ? i.trends.threads.map((d, c) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1621
1672
  "div",
1622
1673
  {
1623
1674
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1624
- style: { height: `${l.count / P * 100}%` },
1675
+ style: { height: `${d.count / B * 100}%` },
1625
1676
  children: /* @__PURE__ */ r("div", { className: "absolute bottom-full mb-1 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-card px-2 py-1 rounded border border-border shadow-sm z-20 pointer-events-none flex flex-col items-center", children: [
1626
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: l.count.toLocaleString(k) }),
1627
- /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(l.date).toLocaleDateString(U, { month: "short", day: "numeric" }) })
1677
+ /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: d.count.toLocaleString(S) }),
1678
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(O, { month: "short", day: "numeric" }) })
1628
1679
  ] })
1629
1680
  }
1630
1681
  ) }, c)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
@@ -1632,7 +1683,7 @@ function xt() {
1632
1683
  ] }),
1633
1684
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1634
1685
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1635
- y(o.trends.threads)
1686
+ w(i.trends.threads)
1636
1687
  ] })
1637
1688
  ] })
1638
1689
  ] }),
@@ -1641,8 +1692,8 @@ function xt() {
1641
1692
  /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: A, children: [
1642
1693
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1643
1694
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1644
- /* @__PURE__ */ e("span", { children: (h || 0).toLocaleString(k) }),
1645
- /* @__PURE__ */ e("span", { children: Math.floor((h || 0) / 2).toLocaleString(k) }),
1695
+ /* @__PURE__ */ e("span", { children: (h || 0).toLocaleString(S) }),
1696
+ /* @__PURE__ */ e("span", { children: Math.floor((h || 0) / 2).toLocaleString(S) }),
1646
1697
  /* @__PURE__ */ e("span", { children: "0" })
1647
1698
  ] }),
1648
1699
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1650,14 +1701,14 @@ function xt() {
1650
1701
  /* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
1651
1702
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
1652
1703
  ] }),
1653
- o.trends.messages.length > 0 ? o.trends.messages.map((l, c) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1704
+ i.trends.messages.length > 0 ? i.trends.messages.map((d, c) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1654
1705
  "div",
1655
1706
  {
1656
1707
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1657
- style: { height: `${l.count / h * 100}%` },
1708
+ style: { height: `${d.count / h * 100}%` },
1658
1709
  children: /* @__PURE__ */ r("div", { className: "absolute bottom-full mb-1 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-card px-2 py-1 rounded border border-border shadow-sm z-20 pointer-events-none flex flex-col items-center", children: [
1659
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: l.count.toLocaleString(k) }),
1660
- /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(l.date).toLocaleDateString(U, { month: "short", day: "numeric" }) })
1710
+ /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: d.count.toLocaleString(S) }),
1711
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(O, { month: "short", day: "numeric" }) })
1661
1712
  ] })
1662
1713
  }
1663
1714
  ) }, c)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
@@ -1665,7 +1716,7 @@ function xt() {
1665
1716
  ] }),
1666
1717
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1667
1718
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1668
- y(o.trends.messages)
1719
+ w(i.trends.messages)
1669
1720
  ] })
1670
1721
  ] })
1671
1722
  ] }),
@@ -1674,8 +1725,8 @@ function xt() {
1674
1725
  /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: A, children: [
1675
1726
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1676
1727
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1677
- /* @__PURE__ */ e("span", { children: (F || 0).toLocaleString(k) }),
1678
- /* @__PURE__ */ e("span", { children: Math.floor((F || 0) / 2).toLocaleString(k) }),
1728
+ /* @__PURE__ */ e("span", { children: (z || 0).toLocaleString(S) }),
1729
+ /* @__PURE__ */ e("span", { children: Math.floor((z || 0) / 2).toLocaleString(S) }),
1679
1730
  /* @__PURE__ */ e("span", { children: "0" })
1680
1731
  ] }),
1681
1732
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1683,14 +1734,14 @@ function xt() {
1683
1734
  /* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
1684
1735
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
1685
1736
  ] }),
1686
- o.trends.token_usage.length > 0 ? o.trends.token_usage.map((l, c) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1737
+ i.trends.token_usage.length > 0 ? i.trends.token_usage.map((d, c) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1687
1738
  "div",
1688
1739
  {
1689
1740
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1690
- style: { height: `${l.tokens / F * 100}%` },
1741
+ style: { height: `${d.tokens / z * 100}%` },
1691
1742
  children: /* @__PURE__ */ r("div", { className: "absolute bottom-full mb-1 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-card px-2 py-1 rounded border border-border shadow-sm z-20 pointer-events-none flex flex-col items-center", children: [
1692
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: (l.tokens || 0).toLocaleString(k) }),
1693
- /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(l.date).toLocaleDateString(U, { month: "short", day: "numeric" }) })
1743
+ /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: (d.tokens || 0).toLocaleString(S) }),
1744
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(O, { month: "short", day: "numeric" }) })
1694
1745
  ] })
1695
1746
  }
1696
1747
  ) }, c)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
@@ -1698,27 +1749,27 @@ function xt() {
1698
1749
  ] }),
1699
1750
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1700
1751
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1701
- y(o.trends.token_usage)
1752
+ w(i.trends.token_usage)
1702
1753
  ] })
1703
1754
  ] })
1704
1755
  ] }),
1705
1756
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
1706
1757
  /* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.feedback") }),
1707
- /* @__PURE__ */ e("div", { className: "h-64 flex flex-col justify-center", children: o.distributions.feedback_sentiment.length > 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row items-center justify-center gap-8 lg:gap-12", children: [
1758
+ /* @__PURE__ */ e("div", { className: "h-64 flex flex-col justify-center", children: i.distributions.feedback_sentiment.length > 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row items-center justify-center gap-8 lg:gap-12", children: [
1708
1759
  /* @__PURE__ */ r("div", { className: "relative w-56 h-56 lg:w-60 lg:h-60", children: [
1709
1760
  /* @__PURE__ */ e("svg", { viewBox: "0 0 100 100", className: "w-full h-full -rotate-90 drop-shadow-md", children: (() => {
1710
- const l = o.distributions.feedback_sentiment.filter(
1711
- (b) => b.sentiment === "positive" || b.sentiment === "negative"
1712
- ), c = l.reduce((b, S) => b + S.count, 0);
1761
+ const d = i.distributions.feedback_sentiment.filter(
1762
+ (F) => F.sentiment === "positive" || F.sentiment === "negative"
1763
+ ), c = d.reduce((F, s) => F + s.count, 0);
1713
1764
  if (c === 0) return null;
1714
- const i = l.find((b) => b.sentiment === "positive")?.count || 0, f = l.find((b) => b.sentiment === "negative")?.count || 0, m = 40, j = 2 * Math.PI * m, M = i / c * 100, s = f / c * 100;
1715
- return /* @__PURE__ */ r(De, { children: [
1765
+ const l = d.find((F) => F.sentiment === "positive")?.count || 0, g = d.find((F) => F.sentiment === "negative")?.count || 0, u = 40, q = 2 * Math.PI * u, M = l / c * 100, $ = g / c * 100;
1766
+ return /* @__PURE__ */ r(Ie, { children: [
1716
1767
  /* @__PURE__ */ e(
1717
1768
  "circle",
1718
1769
  {
1719
1770
  cx: "50",
1720
1771
  cy: "50",
1721
- r: m,
1772
+ r: u,
1722
1773
  fill: "transparent",
1723
1774
  stroke: "currentColor",
1724
1775
  strokeWidth: "10",
@@ -1740,11 +1791,11 @@ function xt() {
1740
1791
  {
1741
1792
  cx: "50",
1742
1793
  cy: "50",
1743
- r: m,
1794
+ r: u,
1744
1795
  fill: "transparent",
1745
1796
  stroke: "url(#posGradient)",
1746
1797
  strokeWidth: "10",
1747
- strokeDasharray: `${M / 100 * j} ${j}`,
1798
+ strokeDasharray: `${M / 100 * q} ${q}`,
1748
1799
  strokeLinecap: M > 0 ? "round" : "butt",
1749
1800
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
1750
1801
  }
@@ -1754,78 +1805,78 @@ function xt() {
1754
1805
  {
1755
1806
  cx: "50",
1756
1807
  cy: "50",
1757
- r: m,
1808
+ r: u,
1758
1809
  fill: "transparent",
1759
1810
  stroke: "url(#negGradient)",
1760
1811
  strokeWidth: "10",
1761
- strokeDasharray: `${s / 100 * j} ${j}`,
1762
- strokeDashoffset: -(M / 100 * j),
1763
- strokeLinecap: s > 0 ? "round" : "butt",
1812
+ strokeDasharray: `${$ / 100 * q} ${q}`,
1813
+ strokeDashoffset: -(M / 100 * q),
1814
+ strokeLinecap: $ > 0 ? "round" : "butt",
1764
1815
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
1765
1816
  }
1766
1817
  )
1767
1818
  ] });
1768
1819
  })() }),
1769
1820
  /* @__PURE__ */ r("div", { className: "absolute inset-0 flex flex-col items-center justify-center pointer-events-none", children: [
1770
- /* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children: o.distributions.feedback_sentiment.filter((l) => l.sentiment === "positive" || l.sentiment === "negative").reduce((l, c) => l + (c.count || 0), 0).toLocaleString(k) }),
1821
+ /* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children: i.distributions.feedback_sentiment.filter((d) => d.sentiment === "positive" || d.sentiment === "negative").reduce((d, c) => d + (c.count || 0), 0).toLocaleString(S) }),
1771
1822
  /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground uppercase tracking-widest mt-1", children: t("analytics.total_feedback") })
1772
1823
  ] })
1773
1824
  ] }),
1774
- /* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...o.distributions.feedback_sentiment].filter((l) => l.sentiment === "positive" || l.sentiment === "negative").sort((l, c) => l.sentiment === "positive" ? -1 : 1).map((l) => {
1775
- const i = o.distributions.feedback_sentiment.filter(
1776
- (s) => s.sentiment === "positive" || s.sentiment === "negative"
1777
- ).reduce((s, b) => s + b.count, 0), f = i > 0 ? l.count / i * 100 : 0, m = l.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), j = l.sentiment === "positive" ? "bg-primary" : "bg-destructive", M = l.sentiment === "positive" ? "👍" : "👎";
1825
+ /* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...i.distributions.feedback_sentiment].filter((d) => d.sentiment === "positive" || d.sentiment === "negative").sort((d, c) => d.sentiment === "positive" ? -1 : 1).map((d) => {
1826
+ const l = i.distributions.feedback_sentiment.filter(
1827
+ ($) => $.sentiment === "positive" || $.sentiment === "negative"
1828
+ ).reduce(($, F) => $ + F.count, 0), g = l > 0 ? d.count / l * 100 : 0, u = d.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), q = d.sentiment === "positive" ? "bg-primary" : "bg-destructive", M = d.sentiment === "positive" ? "👍" : "👎";
1778
1829
  return /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-6 group", children: [
1779
1830
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
1780
- /* @__PURE__ */ e("div", { className: `w-3 h-3 rounded-full ${j} shadow-sm group-hover:scale-110 transition-transform` }),
1831
+ /* @__PURE__ */ e("div", { className: `w-3 h-3 rounded-full ${q} shadow-sm group-hover:scale-110 transition-transform` }),
1781
1832
  /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground font-medium", children: [
1782
- m,
1833
+ u,
1783
1834
  " ",
1784
1835
  M
1785
1836
  ] })
1786
1837
  ] }),
1787
1838
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
1788
1839
  /* @__PURE__ */ r("span", { className: "text-sm font-semibold text-foreground bg-muted/50 px-2.5 py-1 rounded-lg min-w-[50px] text-center", children: [
1789
- (f || 0).toLocaleString(k, { maximumFractionDigits: 0 }),
1840
+ (g || 0).toLocaleString(S, { maximumFractionDigits: 0 }),
1790
1841
  "%"
1791
1842
  ] }),
1792
1843
  /* @__PURE__ */ r("span", { className: "text-[13px] font-normal text-muted-foreground w-12 text-right", children: [
1793
1844
  "(",
1794
- (l.count || 0).toLocaleString(k),
1845
+ (d.count || 0).toLocaleString(S),
1795
1846
  ")"
1796
1847
  ] })
1797
1848
  ] })
1798
- ] }, l.sentiment);
1849
+ ] }, d.sentiment);
1799
1850
  }) })
1800
1851
  ] }) : /* @__PURE__ */ e("p", { className: "text-center text-muted-foreground py-8", children: t("no_data") }) })
1801
1852
  ] })
1802
1853
  ] }),
1803
1854
  /* @__PURE__ */ e("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
1804
1855
  /* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.active_users") }),
1805
- /* @__PURE__ */ e("div", { className: "space-y-2.5", children: o.active_users.length > 0 ? o.active_users.map((l) => /* @__PURE__ */ r(
1856
+ /* @__PURE__ */ e("div", { className: "space-y-2.5", children: i.active_users.length > 0 ? i.active_users.map((d) => /* @__PURE__ */ r(
1806
1857
  "div",
1807
1858
  {
1808
1859
  className: "flex items-center justify-between p-3 bg-muted/30 rounded-xl hover:bg-muted/50 transition-colors",
1809
1860
  children: [
1810
1861
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
1811
- /* @__PURE__ */ e("div", { className: "w-9 h-9 rounded-full bg-primary/10 flex items-center justify-center text-primary text-sm font-medium", children: l.name.charAt(0) }),
1812
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: l.name }) })
1862
+ /* @__PURE__ */ e("div", { className: "w-9 h-9 rounded-full bg-primary/10 flex items-center justify-center text-primary text-sm font-medium", children: d.name.charAt(0) }),
1863
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: d.name }) })
1813
1864
  ] }),
1814
1865
  /* @__PURE__ */ r("div", { className: "text-sm font-semibold text-primary", children: [
1815
- (l.thread_count || 0).toLocaleString(k),
1866
+ (d.thread_count || 0).toLocaleString(S),
1816
1867
  " ",
1817
1868
  t("analytics.threads")
1818
1869
  ] })
1819
1870
  ]
1820
1871
  },
1821
- l.user_id
1872
+ d.user_id
1822
1873
  )) : /* @__PURE__ */ e("p", { className: "text-center text-muted-foreground py-8", children: t("no_data") }) })
1823
1874
  ] }) })
1824
1875
  ] });
1825
1876
  }
1826
- function X({ className: t, ...a }) {
1877
+ function Y({ className: t, ...a }) {
1827
1878
  return /* @__PURE__ */ e(
1828
- je.Root,
1879
+ qe.Root,
1829
1880
  {
1830
1881
  "data-slot": "switch",
1831
1882
  className: be(
@@ -1834,7 +1885,7 @@ function X({ className: t, ...a }) {
1834
1885
  ),
1835
1886
  ...a,
1836
1887
  children: /* @__PURE__ */ e(
1837
- je.Thumb,
1888
+ qe.Thumb,
1838
1889
  {
1839
1890
  "data-slot": "switch-thumb",
1840
1891
  className: be(
@@ -1846,146 +1897,146 @@ function X({ className: t, ...a }) {
1846
1897
  );
1847
1898
  }
1848
1899
  function bt() {
1849
- const { t, i18n: a } = Y(["admin", "translation", "settings"]), { app: o, welcome: u, disclaimer: g, history: p, threadActions: _, composer: N, settings: v } = he(), [$, T] = x(!1), [I, A] = x(!1), [q, k] = x(""), [U, O] = x(""), [y, D] = x("fa"), [E, J] = x("translation"), [K, B] = x("{}"), [P, h] = x(""), [F, l] = x(!1), c = ue(() => ({
1850
- app_name: o?.name || "Gentiq",
1851
- admin_title: o?.adminTitle || "",
1852
- welcome_greeting: u?.greeting || "",
1853
- welcome_subtitle: u?.subtitle || "",
1854
- disclaimer: typeof g == "string" ? g : "",
1855
- show_tool_details: o?.showToolDetails ?? !0,
1856
- show_settings: o?.showSettings ?? !0,
1857
- composer_attachments: N?.attachments?.enabled ?? !0,
1858
- thread_actions_feedback: _?.feedback ?? !0,
1859
- thread_actions_retry: _?.retry ?? !0,
1900
+ const { t, i18n: a } = ee(["admin", "translation", "settings"]), { app: i, welcome: m, disclaimer: f, history: p, threadActions: y, composer: _, settings: N } = me(), [J, T] = x(!1), [j, A] = x(!1), [D, S] = x(""), [O, R] = x(""), [w, I] = x("fa"), [P, H] = x("translation"), [V, K] = x("{}"), [B, h] = x(""), [z, d] = x(!1), c = pe(() => ({
1901
+ app_name: i?.name || "Gentiq",
1902
+ admin_title: i?.adminTitle || "",
1903
+ welcome_greeting: m?.greeting || "",
1904
+ welcome_subtitle: m?.subtitle || "",
1905
+ disclaimer: typeof f == "string" ? f : "",
1906
+ show_tool_details: i?.showToolDetails ?? !0,
1907
+ show_settings: i?.showSettings ?? !0,
1908
+ composer_attachments: _?.attachments?.enabled ?? !0,
1909
+ thread_actions_feedback: y?.feedback ?? !0,
1910
+ thread_actions_retry: y?.retry ?? !0,
1860
1911
  history_enabled: p?.enabled ?? !0,
1861
1912
  history_show_delete: p?.showDelete ?? !0,
1862
1913
  history_show_rename: p?.showRename ?? !0,
1863
1914
  history_show_share: p?.showShare ?? !0,
1864
1915
  history_show_pin: p?.showPin ?? !0,
1865
- settings_general_mode: o?.settingsGeneralMode || "editable",
1866
- settings_profile_mode: o?.settingsProfileMode || "editable",
1867
- settings_account_mode: o?.settingsAccountMode || "editable",
1868
- settings_general_fields: v?.sections?.general?.fields || {},
1869
- settings_profile_fields: v?.sections?.profile?.fields || {},
1870
- settings_account_fields: v?.sections?.account?.fields || {},
1916
+ settings_general_mode: i?.settingsGeneralMode || "editable",
1917
+ settings_profile_mode: i?.settingsProfileMode || "editable",
1918
+ settings_account_mode: i?.settingsAccountMode || "editable",
1919
+ settings_general_fields: N?.sections?.general?.fields || {},
1920
+ settings_profile_fields: N?.sections?.profile?.fields || {},
1921
+ settings_account_fields: N?.sections?.account?.fields || {},
1871
1922
  language: a.language || "fa",
1872
1923
  translations: {}
1873
- }), [o, u, g, p, _, N, a.language, v]), [i, f] = x(c), m = a.language === "fa";
1924
+ }), [i, m, f, p, y, _, a.language, N]), [l, g] = x(c), u = a.language === "fa";
1874
1925
  G(() => {
1875
1926
  (async () => {
1876
1927
  T(!0);
1877
1928
  try {
1878
- const C = await w.getSettings();
1879
- if (C && Object.keys(C).length > 0) {
1880
- const z = JSON.parse(JSON.stringify(a.store.data));
1881
- C.translations && Object.keys(C.translations).forEach((re) => {
1882
- z[re] || (z[re] = {}), Object.assign(z[re], C.translations[re]);
1883
- }), f((re) => ({
1884
- ...re,
1885
- ...C,
1886
- translations: z
1929
+ const v = await k.getSettings();
1930
+ if (v && Object.keys(v).length > 0) {
1931
+ const U = JSON.parse(JSON.stringify(a.store.data));
1932
+ v.translations && Object.keys(v.translations).forEach((X) => {
1933
+ U[X] || (U[X] = {}), Object.assign(U[X], v.translations[X]);
1934
+ }), g((X) => ({
1935
+ ...X,
1936
+ ...v,
1937
+ translations: U
1887
1938
  }));
1888
1939
  } else {
1889
- const z = { ...c, translations: a.store.data };
1890
- f(z), C || w.updateSettings(z).catch(console.error);
1940
+ const U = { ...c, translations: a.store.data };
1941
+ g(U), v || k.updateSettings(U).catch(console.error);
1891
1942
  }
1892
- } catch (C) {
1893
- console.error("Failed to fetch settings", C), k(t("app_settings.save_error"));
1943
+ } catch (v) {
1944
+ console.error("Failed to fetch settings", v), S(t("app_settings.save_error"));
1894
1945
  } finally {
1895
1946
  T(!1);
1896
1947
  }
1897
1948
  })();
1898
1949
  }, [t, c, a.store.data]);
1899
- const j = async (d) => {
1900
- d && d.preventDefault(), A(!0), O(""), k("");
1950
+ const q = async (o) => {
1951
+ o && o.preventDefault(), A(!0), R(""), S("");
1901
1952
  try {
1902
- await w.updateSettings(i), O(t("app_settings.save_success")), setTimeout(() => O(""), 3e3);
1903
- } catch (C) {
1904
- k(C instanceof Error ? C.message : t("app_settings.save_error"));
1953
+ await k.updateSettings(l), R(t("app_settings.save_success")), setTimeout(() => R(""), 3e3);
1954
+ } catch (v) {
1955
+ S(v instanceof Error ? v.message : t("app_settings.save_error"));
1905
1956
  } finally {
1906
1957
  A(!1);
1907
1958
  }
1908
1959
  }, M = async () => {
1909
- T(!0), k("");
1960
+ T(!0), S("");
1910
1961
  try {
1911
- await w.resetSettings(), l(!1), window.location.reload();
1912
- } catch (d) {
1913
- k(d instanceof Error ? d.message : t("app_settings.save_error"));
1962
+ await k.resetSettings(), d(!1), window.location.reload();
1963
+ } catch (o) {
1964
+ S(o instanceof Error ? o.message : t("app_settings.save_error"));
1914
1965
  } finally {
1915
1966
  T(!1);
1916
1967
  }
1917
1968
  };
1918
1969
  G(() => {
1919
- const d = i.translations?.[y]?.[E] || {};
1920
- B(JSON.stringify(d, null, 2)), h("");
1921
- }, [y, E, i.translations]);
1922
- const s = (d) => {
1923
- B(d);
1970
+ const o = l.translations?.[w]?.[P] || {};
1971
+ K(JSON.stringify(o, null, 2)), h("");
1972
+ }, [w, P, l.translations]);
1973
+ const $ = (o) => {
1974
+ K(o);
1924
1975
  try {
1925
- const C = JSON.parse(d);
1926
- f((z) => ({
1927
- ...z,
1976
+ const v = JSON.parse(o);
1977
+ g((U) => ({
1978
+ ...U,
1928
1979
  translations: {
1929
- ...z.translations,
1930
- [y]: {
1931
- ...z.translations?.[y],
1932
- [E]: C
1980
+ ...U.translations,
1981
+ [w]: {
1982
+ ...U.translations?.[w],
1983
+ [P]: v
1933
1984
  }
1934
1985
  }
1935
1986
  })), h("");
1936
1987
  } catch {
1937
1988
  h("Invalid JSON format");
1938
1989
  }
1939
- }, b = ({ title: d, icon: C }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
1990
+ }, F = ({ title: o, icon: v }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
1940
1991
  /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center", "aria-hidden": "true", children: /* @__PURE__ */ e("div", { className: "w-full border-t border-border/60" }) }),
1941
1992
  /* @__PURE__ */ e("div", { className: "relative flex justify-center", children: /* @__PURE__ */ r("span", { className: "bg-background px-6 text-sm font-bold text-muted-foreground uppercase tracking-[0.2em] flex items-center gap-3", children: [
1942
- /* @__PURE__ */ e(C, { className: "size-4 text-primary/60" }),
1943
- d
1993
+ /* @__PURE__ */ e(v, { className: "size-4 text-primary/60" }),
1994
+ o
1944
1995
  ] }) })
1945
- ] }), S = ({ value: d }) => {
1946
- if (!d || !d.includes(":") && !d.includes(".")) return null;
1947
- const C = t(d);
1948
- return C === d ? null : /* @__PURE__ */ r("div", { className: "mt-1.5 px-3 py-1 bg-primary/5 rounded-lg border border-primary/10 inline-flex items-center gap-2", children: [
1996
+ ] }), s = ({ value: o }) => {
1997
+ if (!o || !o.includes(":") && !o.includes(".")) return null;
1998
+ const v = t(o);
1999
+ return v === o ? null : /* @__PURE__ */ r("div", { className: "mt-1.5 px-3 py-1 bg-primary/5 rounded-lg border border-primary/10 inline-flex items-center gap-2", children: [
1949
2000
  /* @__PURE__ */ r("span", { className: "text-[10px] font-bold text-primary/60 uppercase tracking-tighter", children: [
1950
2001
  t("app_settings.preview", { defaultValue: "Preview" }),
1951
2002
  ":"
1952
2003
  ] }),
1953
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: C })
2004
+ /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: v })
1954
2005
  ] });
1955
- }, H = () => {
1956
- const d = prompt("Enter language code (e.g. en, fa, fr):");
1957
- d && !i.translations?.[d] && (f((C) => ({
1958
- ...C,
2006
+ }, b = () => {
2007
+ const o = prompt("Enter language code (e.g. en, fa, fr):");
2008
+ o && !l.translations?.[o] && (g((v) => ({
2009
+ ...v,
1959
2010
  translations: {
1960
- ...C.translations,
1961
- [d]: {}
2011
+ ...v.translations,
2012
+ [o]: {}
1962
2013
  }
1963
- })), D(d));
1964
- }, V = () => {
1965
- const d = prompt("Enter namespace (e.g. chat, admin):");
1966
- d && !i.translations?.[y]?.[d] && (f((C) => ({
1967
- ...C,
2014
+ })), I(o));
2015
+ }, C = () => {
2016
+ const o = prompt("Enter namespace (e.g. chat, admin):");
2017
+ o && !l.translations?.[w]?.[o] && (g((v) => ({
2018
+ ...v,
1968
2019
  translations: {
1969
- ...C.translations,
1970
- [y]: {
1971
- ...C.translations?.[y],
1972
- [d]: {}
2020
+ ...v.translations,
2021
+ [w]: {
2022
+ ...v.translations?.[w],
2023
+ [o]: {}
1973
2024
  }
1974
2025
  }
1975
- })), J(d));
2026
+ })), H(o));
1976
2027
  };
1977
- return $ ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-3", children: [
2028
+ return J ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-3", children: [
1978
2029
  /* @__PURE__ */ e("div", { className: "w-10 h-10 border-3 border-primary/20 border-t-primary rounded-full animate-spin" }),
1979
2030
  /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground font-medium", children: t("loading") })
1980
- ] }) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col overflow-hidden", dir: m ? "rtl" : "ltr", children: [
2031
+ ] }) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col overflow-hidden", dir: u ? "rtl" : "ltr", children: [
1981
2032
  /* @__PURE__ */ r("div", { className: "px-8 py-6 border-b border-border bg-background/50 backdrop-blur-md z-20 flex items-center justify-between flex-shrink-0", children: [
1982
2033
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: [
1983
2034
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight", children: t("app_settings.title") }),
1984
2035
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("app_settings.subtitle") })
1985
2036
  ] }),
1986
2037
  /* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
1987
- /* @__PURE__ */ r(Ue, { open: F, onOpenChange: l, children: [
1988
- /* @__PURE__ */ e(Fe, { asChild: !0, children: /* @__PURE__ */ r(
2038
+ /* @__PURE__ */ r(Fe, { open: z, onOpenChange: d, children: [
2039
+ /* @__PURE__ */ e(Ue, { asChild: !0, children: /* @__PURE__ */ r(
1989
2040
  "button",
1990
2041
  {
1991
2042
  type: "button",
@@ -2002,8 +2053,8 @@ function bt() {
2002
2053
  /* @__PURE__ */ e(He, { children: t("app_settings.reset_confirm_description") })
2003
2054
  ] }),
2004
2055
  /* @__PURE__ */ r(Be, { children: [
2005
- /* @__PURE__ */ e(Ve, { asChild: !0, children: /* @__PURE__ */ e(me, { variant: "ghost", children: t("cancel") }) }),
2006
- /* @__PURE__ */ e(me, { variant: "destructive", onClick: M, children: t("app_settings.reset_button") })
2056
+ /* @__PURE__ */ e(Ve, { asChild: !0, children: /* @__PURE__ */ e(he, { variant: "ghost", children: t("cancel") }) }),
2057
+ /* @__PURE__ */ e(he, { variant: "destructive", onClick: M, children: t("app_settings.reset_button") })
2007
2058
  ] })
2008
2059
  ] })
2009
2060
  ] }),
@@ -2012,61 +2063,61 @@ function bt() {
2012
2063
  {
2013
2064
  type: "submit",
2014
2065
  form: "settings-form",
2015
- disabled: I,
2066
+ disabled: j,
2016
2067
  className: "px-8 py-2.5 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50 flex items-center gap-2",
2017
2068
  children: [
2018
- I && /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin" }),
2019
- t(I ? "saving" : "app_settings.save")
2069
+ j && /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin" }),
2070
+ t(j ? "saving" : "app_settings.save")
2020
2071
  ]
2021
2072
  }
2022
2073
  )
2023
2074
  ] })
2024
2075
  ] }),
2025
2076
  /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto custom-scrollbar", children: /* @__PURE__ */ r("div", { className: "max-w-4xl mx-auto py-10 px-8", children: [
2026
- (q || U) && /* @__PURE__ */ e("div", { className: `mb-12 px-4 py-3 rounded-xl text-sm border animate-in fade-in slide-in-from-top-1 duration-300 ${q ? "bg-destructive/10 border-destructive/20 text-destructive" : "bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400"}`, children: q || U }),
2027
- /* @__PURE__ */ r("form", { id: "settings-form", onSubmit: j, className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500", children: [
2077
+ (D || O) && /* @__PURE__ */ e("div", { className: `mb-12 px-4 py-3 rounded-xl text-sm border animate-in fade-in slide-in-from-top-1 duration-300 ${D ? "bg-destructive/10 border-destructive/20 text-destructive" : "bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400"}`, children: D || O }),
2078
+ /* @__PURE__ */ r("form", { id: "settings-form", onSubmit: q, className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500", children: [
2028
2079
  /* @__PURE__ */ r("section", { children: [
2029
- /* @__PURE__ */ e(b, { title: t("app_settings.sections.general"), icon: xe }),
2080
+ /* @__PURE__ */ e(F, { title: t("app_settings.sections.general"), icon: xe }),
2030
2081
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2031
2082
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2032
2083
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2033
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.app_name") }),
2084
+ /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.app_name") }),
2034
2085
  /* @__PURE__ */ e(
2035
- pe,
2086
+ ge,
2036
2087
  {
2037
2088
  type: "text",
2038
- value: i.app_name,
2039
- onChange: (d) => f({ ...i, app_name: d.target.value }),
2089
+ value: l.app_name,
2090
+ onChange: (o) => g({ ...l, app_name: o.target.value }),
2040
2091
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2041
2092
  placeholder: "Gentiq AI",
2042
2093
  dir: "auto"
2043
2094
  }
2044
2095
  ),
2045
- /* @__PURE__ */ e(S, { value: i.app_name })
2096
+ /* @__PURE__ */ e(s, { value: l.app_name })
2046
2097
  ] }),
2047
2098
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2048
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.admin_title") }),
2099
+ /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.admin_title") }),
2049
2100
  /* @__PURE__ */ e(
2050
- pe,
2101
+ ge,
2051
2102
  {
2052
2103
  type: "text",
2053
- value: i.admin_title || "",
2054
- onChange: (d) => f({ ...i, admin_title: d.target.value }),
2104
+ value: l.admin_title || "",
2105
+ onChange: (o) => g({ ...l, admin_title: o.target.value }),
2055
2106
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2056
2107
  placeholder: "Gentiq Admin",
2057
2108
  dir: "auto"
2058
2109
  }
2059
2110
  ),
2060
- /* @__PURE__ */ e(S, { value: i.admin_title || "" })
2111
+ /* @__PURE__ */ e(s, { value: l.admin_title || "" })
2061
2112
  ] })
2062
2113
  ] }),
2063
2114
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2064
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.language") }),
2115
+ /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.language") }),
2065
2116
  /* @__PURE__ */ r(
2066
2117
  ae,
2067
2118
  {
2068
- value: i.language,
2069
- onValueChange: (d) => f({ ...i, language: d }),
2119
+ value: l.language,
2120
+ onValueChange: (o) => g({ ...l, language: o }),
2070
2121
  children: [
2071
2122
  /* @__PURE__ */ e(ne, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(oe, {}) }),
2072
2123
  /* @__PURE__ */ r(ie, { children: [
@@ -2084,51 +2135,51 @@ function bt() {
2084
2135
  ] })
2085
2136
  ] }),
2086
2137
  /* @__PURE__ */ r("section", { children: [
2087
- /* @__PURE__ */ e(b, { title: t("app_settings.sections.chat"), icon: at }),
2138
+ /* @__PURE__ */ e(F, { title: t("app_settings.sections.chat"), icon: at }),
2088
2139
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2089
2140
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2090
2141
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2091
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_greeting") }),
2142
+ /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_greeting") }),
2092
2143
  /* @__PURE__ */ e(
2093
- pe,
2144
+ ge,
2094
2145
  {
2095
2146
  type: "text",
2096
- value: i.welcome_greeting || "",
2097
- onChange: (d) => f({ ...i, welcome_greeting: d.target.value }),
2147
+ value: l.welcome_greeting || "",
2148
+ onChange: (o) => g({ ...l, welcome_greeting: o.target.value }),
2098
2149
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2099
2150
  placeholder: "e.g. chat:welcome",
2100
2151
  dir: "auto"
2101
2152
  }
2102
2153
  ),
2103
- /* @__PURE__ */ e(S, { value: i.welcome_greeting || "" })
2154
+ /* @__PURE__ */ e(s, { value: l.welcome_greeting || "" })
2104
2155
  ] }),
2105
2156
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2106
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_subtitle") }),
2157
+ /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_subtitle") }),
2107
2158
  /* @__PURE__ */ e(
2108
- pe,
2159
+ ge,
2109
2160
  {
2110
2161
  type: "text",
2111
- value: i.welcome_subtitle || "",
2112
- onChange: (d) => f({ ...i, welcome_subtitle: d.target.value }),
2162
+ value: l.welcome_subtitle || "",
2163
+ onChange: (o) => g({ ...l, welcome_subtitle: o.target.value }),
2113
2164
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2114
2165
  dir: "auto"
2115
2166
  }
2116
2167
  ),
2117
- /* @__PURE__ */ e(S, { value: i.welcome_subtitle || "" })
2168
+ /* @__PURE__ */ e(s, { value: l.welcome_subtitle || "" })
2118
2169
  ] })
2119
2170
  ] }),
2120
2171
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2121
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.disclaimer") }),
2172
+ /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.disclaimer") }),
2122
2173
  /* @__PURE__ */ e(
2123
2174
  Se,
2124
2175
  {
2125
- value: i.disclaimer || "",
2126
- onChange: (d) => f({ ...i, disclaimer: d.target.value }),
2176
+ value: l.disclaimer || "",
2177
+ onChange: (o) => g({ ...l, disclaimer: o.target.value }),
2127
2178
  className: "bg-muted/20 border-transparent focus:bg-background min-h-[120px] py-4 resize-none leading-relaxed",
2128
2179
  dir: "auto"
2129
2180
  }
2130
2181
  ),
2131
- /* @__PURE__ */ e(S, { value: i.disclaimer || "" })
2182
+ /* @__PURE__ */ e(s, { value: l.disclaimer || "" })
2132
2183
  ] }),
2133
2184
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-6 pt-2", children: [
2134
2185
  /* @__PURE__ */ r("div", { className: "p-5 border border-border/40 rounded-2xl flex items-center justify-between hover:bg-muted/5 transition-colors", children: [
@@ -2137,10 +2188,10 @@ function bt() {
2137
2188
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.show_tool_details_help") })
2138
2189
  ] }),
2139
2190
  /* @__PURE__ */ e(
2140
- X,
2191
+ Y,
2141
2192
  {
2142
- checked: i.show_tool_details,
2143
- onCheckedChange: (d) => f({ ...i, show_tool_details: d })
2193
+ checked: l.show_tool_details,
2194
+ onCheckedChange: (o) => g({ ...l, show_tool_details: o })
2144
2195
  }
2145
2196
  )
2146
2197
  ] }),
@@ -2150,10 +2201,10 @@ function bt() {
2150
2201
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.show_settings_help") })
2151
2202
  ] }),
2152
2203
  /* @__PURE__ */ e(
2153
- X,
2204
+ Y,
2154
2205
  {
2155
- checked: i.show_settings,
2156
- onCheckedChange: (d) => f({ ...i, show_settings: d })
2206
+ checked: l.show_settings,
2207
+ onCheckedChange: (o) => g({ ...l, show_settings: o })
2157
2208
  }
2158
2209
  )
2159
2210
  ] }),
@@ -2163,10 +2214,10 @@ function bt() {
2163
2214
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.composer_attachments_help") })
2164
2215
  ] }),
2165
2216
  /* @__PURE__ */ e(
2166
- X,
2217
+ Y,
2167
2218
  {
2168
- checked: i.composer_attachments,
2169
- onCheckedChange: (d) => f({ ...i, composer_attachments: d })
2219
+ checked: l.composer_attachments,
2220
+ onCheckedChange: (o) => g({ ...l, composer_attachments: o })
2170
2221
  }
2171
2222
  )
2172
2223
  ] }),
@@ -2176,10 +2227,10 @@ function bt() {
2176
2227
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.thread_actions_feedback_help") })
2177
2228
  ] }),
2178
2229
  /* @__PURE__ */ e(
2179
- X,
2230
+ Y,
2180
2231
  {
2181
- checked: i.thread_actions_feedback,
2182
- onCheckedChange: (d) => f({ ...i, thread_actions_feedback: d })
2232
+ checked: l.thread_actions_feedback,
2233
+ onCheckedChange: (o) => g({ ...l, thread_actions_feedback: o })
2183
2234
  }
2184
2235
  )
2185
2236
  ] }),
@@ -2189,10 +2240,10 @@ function bt() {
2189
2240
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.thread_actions_retry_help") })
2190
2241
  ] }),
2191
2242
  /* @__PURE__ */ e(
2192
- X,
2243
+ Y,
2193
2244
  {
2194
- checked: i.thread_actions_retry,
2195
- onCheckedChange: (d) => f({ ...i, thread_actions_retry: d })
2245
+ checked: l.thread_actions_retry,
2246
+ onCheckedChange: (o) => g({ ...l, thread_actions_retry: o })
2196
2247
  }
2197
2248
  )
2198
2249
  ] }),
@@ -2202,51 +2253,51 @@ function bt() {
2202
2253
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.history_enabled_help") })
2203
2254
  ] }),
2204
2255
  /* @__PURE__ */ e(
2205
- X,
2256
+ Y,
2206
2257
  {
2207
- checked: i.history_enabled,
2208
- onCheckedChange: (d) => f({ ...i, history_enabled: d })
2258
+ checked: l.history_enabled,
2259
+ onCheckedChange: (o) => g({ ...l, history_enabled: o })
2209
2260
  }
2210
2261
  )
2211
2262
  ] }),
2212
- i.history_enabled && /* @__PURE__ */ r("div", { className: "sm:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-4 p-6 bg-muted/10 rounded-2xl border border-border/40 animate-in fade-in slide-in-from-top-2 duration-300", children: [
2263
+ l.history_enabled && /* @__PURE__ */ r("div", { className: "sm:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-4 p-6 bg-muted/10 rounded-2xl border border-border/40 animate-in fade-in slide-in-from-top-2 duration-300", children: [
2213
2264
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2214
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_delete") }),
2265
+ /* @__PURE__ */ e(Q, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_delete") }),
2215
2266
  /* @__PURE__ */ e(
2216
- X,
2267
+ Y,
2217
2268
  {
2218
- checked: i.history_show_delete,
2219
- onCheckedChange: (d) => f({ ...i, history_show_delete: d })
2269
+ checked: l.history_show_delete,
2270
+ onCheckedChange: (o) => g({ ...l, history_show_delete: o })
2220
2271
  }
2221
2272
  )
2222
2273
  ] }),
2223
2274
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2224
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_rename") }),
2275
+ /* @__PURE__ */ e(Q, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_rename") }),
2225
2276
  /* @__PURE__ */ e(
2226
- X,
2277
+ Y,
2227
2278
  {
2228
- checked: i.history_show_rename,
2229
- onCheckedChange: (d) => f({ ...i, history_show_rename: d })
2279
+ checked: l.history_show_rename,
2280
+ onCheckedChange: (o) => g({ ...l, history_show_rename: o })
2230
2281
  }
2231
2282
  )
2232
2283
  ] }),
2233
2284
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2234
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_share") }),
2285
+ /* @__PURE__ */ e(Q, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_share") }),
2235
2286
  /* @__PURE__ */ e(
2236
- X,
2287
+ Y,
2237
2288
  {
2238
- checked: i.history_show_share,
2239
- onCheckedChange: (d) => f({ ...i, history_show_share: d })
2289
+ checked: l.history_show_share,
2290
+ onCheckedChange: (o) => g({ ...l, history_show_share: o })
2240
2291
  }
2241
2292
  )
2242
2293
  ] }),
2243
2294
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2244
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_pin") }),
2295
+ /* @__PURE__ */ e(Q, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_pin") }),
2245
2296
  /* @__PURE__ */ e(
2246
- X,
2297
+ Y,
2247
2298
  {
2248
- checked: i.history_show_pin,
2249
- onCheckedChange: (d) => f({ ...i, history_show_pin: d })
2299
+ checked: l.history_show_pin,
2300
+ onCheckedChange: (o) => g({ ...l, history_show_pin: o })
2250
2301
  }
2251
2302
  )
2252
2303
  ] })
@@ -2261,14 +2312,14 @@ function bt() {
2261
2312
  { id: "settings_general_mode", label: "app_settings.chat.general_tab" },
2262
2313
  { id: "settings_profile_mode", label: "app_settings.chat.profile_tab" },
2263
2314
  { id: "settings_account_mode", label: "app_settings.chat.account_tab" }
2264
- ].map((d) => /* @__PURE__ */ r("div", { className: "p-4 border border-border/40 rounded-2xl space-y-3 bg-muted/5", children: [
2265
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70", children: t(d.label) }),
2315
+ ].map((o) => /* @__PURE__ */ r("div", { className: "p-4 border border-border/40 rounded-2xl space-y-3 bg-muted/5", children: [
2316
+ /* @__PURE__ */ e(Q, { className: "text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70", children: t(o.label) }),
2266
2317
  /* @__PURE__ */ r(
2267
2318
  ae,
2268
2319
  {
2269
- value: i[d.id],
2270
- onValueChange: (C) => f({ ...i, [d.id]: C }),
2271
- dir: m ? "rtl" : "ltr",
2320
+ value: l[o.id],
2321
+ onValueChange: (v) => g({ ...l, [o.id]: v }),
2322
+ dir: u ? "rtl" : "ltr",
2272
2323
  children: [
2273
2324
  /* @__PURE__ */ e(ne, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(oe, {}) }),
2274
2325
  /* @__PURE__ */ r(ie, { children: [
@@ -2279,7 +2330,7 @@ function bt() {
2279
2330
  ]
2280
2331
  }
2281
2332
  )
2282
- ] }, d.id)) })
2333
+ ] }, o.id)) })
2283
2334
  ] }),
2284
2335
  /* @__PURE__ */ r("div", { className: "pt-10 space-y-8", children: [
2285
2336
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: [
@@ -2297,17 +2348,17 @@ function bt() {
2297
2348
  { id: "accent", label: t("settings:general.accent") },
2298
2349
  { id: "radius", label: t("settings:general.radius") },
2299
2350
  { id: "language", label: t("settings:general.language") }
2300
- ].map((d) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2301
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-medium text-muted-foreground/70", children: d.label }),
2351
+ ].map((o) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2352
+ /* @__PURE__ */ e(Q, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2302
2353
  /* @__PURE__ */ r(
2303
2354
  ae,
2304
2355
  {
2305
- value: i.settings_general_fields?.[d.id] || "editable",
2306
- onValueChange: (C) => f((z) => ({
2307
- ...z,
2308
- settings_general_fields: { ...z.settings_general_fields, [d.id]: C }
2356
+ value: l.settings_general_fields?.[o.id] || "editable",
2357
+ onValueChange: (v) => g((U) => ({
2358
+ ...U,
2359
+ settings_general_fields: { ...U.settings_general_fields, [o.id]: v }
2309
2360
  })),
2310
- dir: m ? "rtl" : "ltr",
2361
+ dir: u ? "rtl" : "ltr",
2311
2362
  children: [
2312
2363
  /* @__PURE__ */ e(ne, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(oe, {}) }),
2313
2364
  /* @__PURE__ */ r(ie, { children: [
@@ -2318,7 +2369,7 @@ function bt() {
2318
2369
  ]
2319
2370
  }
2320
2371
  )
2321
- ] }, d.id)) })
2372
+ ] }, o.id)) })
2322
2373
  ] }),
2323
2374
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
2324
2375
  /* @__PURE__ */ r("h4", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground/50 flex items-center gap-2", children: [
@@ -2330,18 +2381,18 @@ function bt() {
2330
2381
  { id: "surname", label: t("settings:profile.surname") },
2331
2382
  { id: "phone", label: t("settings:profile.phone") },
2332
2383
  { id: "password", label: t("settings:profile.password") },
2333
- ...(o?.userMetadataFields || []).map((d) => ({ id: d.key, label: t(d.label) }))
2334
- ].map((d) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2335
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-medium text-muted-foreground/70", children: d.label }),
2384
+ ...(i?.userMetadataFields || []).map((o) => ({ id: o.key, label: t(o.label) }))
2385
+ ].map((o) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2386
+ /* @__PURE__ */ e(Q, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2336
2387
  /* @__PURE__ */ r(
2337
2388
  ae,
2338
2389
  {
2339
- value: i.settings_profile_fields?.[d.id] || "editable",
2340
- onValueChange: (C) => f((z) => ({
2341
- ...z,
2342
- settings_profile_fields: { ...z.settings_profile_fields, [d.id]: C }
2390
+ value: l.settings_profile_fields?.[o.id] || "editable",
2391
+ onValueChange: (v) => g((U) => ({
2392
+ ...U,
2393
+ settings_profile_fields: { ...U.settings_profile_fields, [o.id]: v }
2343
2394
  })),
2344
- dir: m ? "rtl" : "ltr",
2395
+ dir: u ? "rtl" : "ltr",
2345
2396
  children: [
2346
2397
  /* @__PURE__ */ e(ne, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(oe, {}) }),
2347
2398
  /* @__PURE__ */ r(ie, { children: [
@@ -2352,7 +2403,7 @@ function bt() {
2352
2403
  ]
2353
2404
  }
2354
2405
  )
2355
- ] }, d.id)) })
2406
+ ] }, o.id)) })
2356
2407
  ] }),
2357
2408
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
2358
2409
  /* @__PURE__ */ r("h4", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground/50 flex items-center gap-2", children: [
@@ -2362,17 +2413,17 @@ function bt() {
2362
2413
  /* @__PURE__ */ e("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
2363
2414
  { id: "balance", label: t("settings:account.balance") },
2364
2415
  { id: "logout", label: t("settings:account.logout") }
2365
- ].map((d) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2366
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-medium text-muted-foreground/70", children: d.label }),
2416
+ ].map((o) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2417
+ /* @__PURE__ */ e(Q, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2367
2418
  /* @__PURE__ */ r(
2368
2419
  ae,
2369
2420
  {
2370
- value: i.settings_account_fields?.[d.id] || "editable",
2371
- onValueChange: (C) => f((z) => ({
2372
- ...z,
2373
- settings_account_fields: { ...z.settings_account_fields, [d.id]: C }
2421
+ value: l.settings_account_fields?.[o.id] || "editable",
2422
+ onValueChange: (v) => g((U) => ({
2423
+ ...U,
2424
+ settings_account_fields: { ...U.settings_account_fields, [o.id]: v }
2374
2425
  })),
2375
- dir: m ? "rtl" : "ltr",
2426
+ dir: u ? "rtl" : "ltr",
2376
2427
  children: [
2377
2428
  /* @__PURE__ */ e(ne, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(oe, {}) }),
2378
2429
  /* @__PURE__ */ r(ie, { children: [
@@ -2383,31 +2434,31 @@ function bt() {
2383
2434
  ]
2384
2435
  }
2385
2436
  )
2386
- ] }, d.id)) })
2437
+ ] }, o.id)) })
2387
2438
  ] })
2388
2439
  ] })
2389
2440
  ] })
2390
2441
  ] })
2391
2442
  ] }),
2392
2443
  /* @__PURE__ */ r("section", { children: [
2393
- /* @__PURE__ */ e(b, { title: t("app_settings.translations_management"), icon: nt }),
2444
+ /* @__PURE__ */ e(F, { title: t("app_settings.translations_management"), icon: nt }),
2394
2445
  /* @__PURE__ */ r("div", { className: "border border-border/60 rounded-2xl overflow-hidden bg-background", children: [
2395
2446
  /* @__PURE__ */ r("div", { className: "p-6 border-b border-border/50 bg-muted/5 flex flex-col sm:flex-row items-center gap-4", children: [
2396
2447
  /* @__PURE__ */ r("div", { className: "flex-1 flex items-center gap-4 p-1.5 bg-background border border-border/60 rounded-xl w-full", children: [
2397
2448
  /* @__PURE__ */ e("div", { className: "p-2 px-3 bg-muted/20 rounded-lg border border-border/40 ml-1", children: /* @__PURE__ */ e(xe, { className: "size-4 text-muted-foreground" }) }),
2398
- /* @__PURE__ */ r(ae, { value: y, onValueChange: D, children: [
2449
+ /* @__PURE__ */ r(ae, { value: w, onValueChange: I, children: [
2399
2450
  /* @__PURE__ */ e(ne, { size: "sm", className: "border-none shadow-none bg-transparent h-8 font-black uppercase tracking-wider", children: /* @__PURE__ */ e(oe, {}) }),
2400
- /* @__PURE__ */ e(ie, { children: Object.keys(i.translations || {}).sort().map((d) => /* @__PURE__ */ e(W, { value: d, children: d.toUpperCase() }, d)) })
2451
+ /* @__PURE__ */ e(ie, { children: Object.keys(l.translations || {}).sort().map((o) => /* @__PURE__ */ e(W, { value: o, children: o.toUpperCase() }, o)) })
2401
2452
  ] }),
2402
2453
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-border/60" }),
2403
- /* @__PURE__ */ r(ae, { value: E, onValueChange: J, children: [
2454
+ /* @__PURE__ */ r(ae, { value: P, onValueChange: H, children: [
2404
2455
  /* @__PURE__ */ e(ne, { size: "sm", className: "border-none shadow-none bg-transparent h-8 flex-1 font-bold", children: /* @__PURE__ */ e(oe, {}) }),
2405
- /* @__PURE__ */ e(ie, { children: Object.keys(i.translations?.[y] || {}).sort().map((d) => /* @__PURE__ */ e(W, { value: d, children: d }, d)) })
2456
+ /* @__PURE__ */ e(ie, { children: Object.keys(l.translations?.[w] || {}).sort().map((o) => /* @__PURE__ */ e(W, { value: o, children: o }, o)) })
2406
2457
  ] })
2407
2458
  ] }),
2408
2459
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
2409
- /* @__PURE__ */ e("button", { type: "button", onClick: H, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(ot, { className: "size-4" }) }),
2410
- /* @__PURE__ */ e("button", { type: "button", onClick: V, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(xe, { className: "size-4" }) })
2460
+ /* @__PURE__ */ e("button", { type: "button", onClick: b, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(ot, { className: "size-4" }) }),
2461
+ /* @__PURE__ */ e("button", { type: "button", onClick: C, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(xe, { className: "size-4" }) })
2411
2462
  ] })
2412
2463
  ] }),
2413
2464
  /* @__PURE__ */ r("div", { className: "relative p-6", children: [
@@ -2418,16 +2469,16 @@ function bt() {
2418
2469
  /* @__PURE__ */ e(
2419
2470
  Se,
2420
2471
  {
2421
- value: K,
2422
- onChange: (d) => s(d.target.value),
2472
+ value: V,
2473
+ onChange: (o) => $(o.target.value),
2423
2474
  dir: "ltr",
2424
- className: `w-full min-h-[500px] bg-muted/5 font-mono text-[13px] p-8 rounded-xl border focus:ring-1 focus:outline-none leading-relaxed resize-y text-left ${P ? "border-destructive/40 focus:ring-destructive/20" : "border-border/40 focus:ring-primary/20"}`,
2475
+ className: `w-full min-h-[500px] bg-muted/5 font-mono text-[13px] p-8 rounded-xl border focus:ring-1 focus:outline-none leading-relaxed resize-y text-left ${B ? "border-destructive/40 focus:ring-destructive/20" : "border-border/40 focus:ring-primary/20"}`,
2425
2476
  spellCheck: !1
2426
2477
  }
2427
2478
  ),
2428
- P && /* @__PURE__ */ r("div", { className: "mt-2 text-[11px] text-destructive font-bold flex items-center gap-2 px-2", children: [
2479
+ B && /* @__PURE__ */ r("div", { className: "mt-2 text-[11px] text-destructive font-bold flex items-center gap-2 px-2", children: [
2429
2480
  /* @__PURE__ */ e("div", { className: "size-1.5 rounded-full bg-destructive animate-pulse" }),
2430
- P
2481
+ B
2431
2482
  ] })
2432
2483
  ] }),
2433
2484
  /* @__PURE__ */ e("div", { className: "p-6 bg-muted/5 border-t border-border/40 flex items-center justify-between", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
@@ -2440,9 +2491,9 @@ function bt() {
2440
2491
  ] }) })
2441
2492
  ] });
2442
2493
  }
2443
- function le() {
2444
- const { t, i18n: a } = Y(["admin"]), o = a.language === "fa";
2445
- return /* @__PURE__ */ r("div", { className: "h-full flex flex-col items-center justify-center p-6 text-center gap-4 animate-in fade-in duration-500", dir: o ? "rtl" : "ltr", children: [
2494
+ function ce() {
2495
+ const { t, i18n: a } = ee(["admin"]), i = a.language === "fa";
2496
+ return /* @__PURE__ */ r("div", { className: "h-full flex flex-col items-center justify-center p-6 text-center gap-4 animate-in fade-in duration-500", dir: i ? "rtl" : "ltr", children: [
2446
2497
  /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(lt, { className: "size-10 text-destructive/70" }) }),
2447
2498
  /* @__PURE__ */ r("div", { className: "space-y-1 max-w-sm", children: [
2448
2499
  /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground tracking-tight", children: t("errors.access_denied_title", "Access Denied") }),
@@ -2451,10 +2502,10 @@ function le() {
2451
2502
  ] });
2452
2503
  }
2453
2504
  const vt = ({ className: t }) => {
2454
- const { t: a } = Y(["theme"]), { theme: o, setTheme: u } = we(), g = () => {
2455
- u(o === "system" ? "light" : o === "light" ? "dark" : "system");
2505
+ const { t: a } = ee(["theme"]), { theme: i, setTheme: m } = we(), f = () => {
2506
+ m(i === "system" ? "light" : i === "light" ? "dark" : "system");
2456
2507
  }, p = () => {
2457
- switch (o) {
2508
+ switch (i) {
2458
2509
  case "light":
2459
2510
  return /* @__PURE__ */ e(ct, { className: "h-[1.2rem] w-[1.2rem]" });
2460
2511
  case "dark":
@@ -2464,8 +2515,8 @@ const vt = ({ className: t }) => {
2464
2515
  default:
2465
2516
  return /* @__PURE__ */ e(Te, { className: "h-[1.2rem] w-[1.2rem]" });
2466
2517
  }
2467
- }, _ = () => {
2468
- switch (o) {
2518
+ }, y = () => {
2519
+ switch (i) {
2469
2520
  case "light":
2470
2521
  return a("dark");
2471
2522
  case "dark":
@@ -2477,108 +2528,108 @@ const vt = ({ className: t }) => {
2477
2528
  }
2478
2529
  };
2479
2530
  return /* @__PURE__ */ r(ve, { children: [
2480
- /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ r(me, { variant: "ghost", size: "icon", onClick: g, className: t, children: [
2531
+ /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ r(he, { variant: "ghost", size: "icon", onClick: f, className: t, children: [
2481
2532
  p(),
2482
2533
  /* @__PURE__ */ e("span", { className: "sr-only", children: a("toggle") })
2483
2534
  ] }) }),
2484
- /* @__PURE__ */ e(Ne, { children: _() })
2535
+ /* @__PURE__ */ e(Ne, { children: y() })
2485
2536
  ] });
2486
2537
  };
2487
2538
  function yt({ extraPages: t = [], disabledPages: a = [] }) {
2488
- const o = et(), u = tt(), { t: g, i18n: p } = Y(["admin", "settings", "translation"]), { app: _ } = he(), { theme: N } = we(), [v, $] = x([]), [T, I] = x(!1), A = Me(!1), [q, k] = x("light");
2539
+ const i = et(), m = tt(), { t: f, i18n: p } = ee(["admin", "settings", "translation"]), { app: y } = me(), { theme: _ } = we(), [N, J] = x([]), [T, j] = x(!1), A = Me(!1), [D, S] = x("light");
2489
2540
  G(() => {
2490
- if (N === "system") {
2541
+ if (_ === "system") {
2491
2542
  const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
2492
- k(h ? "dark" : "light");
2543
+ S(h ? "dark" : "light");
2493
2544
  } else
2494
- k(N);
2495
- }, [N]);
2496
- const U = ue(() => _?.logo ? typeof _.logo == "string" ? _.logo : q === "dark" ? _.logo.dark : _.logo.light : Ie, [_?.logo, q]), O = _?.adminTitle || _?.name, y = p.language === "fa";
2545
+ S(_);
2546
+ }, [_]);
2547
+ const O = pe(() => y?.logo ? typeof y.logo == "string" ? y.logo : D === "dark" ? y.logo.dark : y.logo.light : $e, [y?.logo, D]), R = y?.adminTitle || y?.name, w = p.language === "fa";
2497
2548
  G(() => {
2498
2549
  const h = localStorage.getItem("admin_info");
2499
2550
  if (h)
2500
2551
  try {
2501
- const l = JSON.parse(h).permissions || [];
2502
- if ($(l), u.pathname === "/admin" || u.pathname === "/admin/")
2503
- if (l.includes("analytics") && !a.includes("analytics"))
2504
- o("/admin/analytics", { replace: !0 });
2505
- else if (l.includes("chat_history") && !a.includes("chat_history"))
2506
- o("/admin/chat-history", { replace: !0 });
2507
- else if (l.includes("user_management") && !a.includes("user_management"))
2508
- o("/admin/users", { replace: !0 });
2509
- else if (l.includes("admin_management") && !a.includes("admin_management"))
2510
- o("/admin/admins", { replace: !0 });
2511
- else if (l.includes("settings") && !a.includes("settings"))
2512
- o("/admin/settings", { replace: !0 });
2552
+ const d = JSON.parse(h).permissions || [];
2553
+ if (J(d), m.pathname === "/admin" || m.pathname === "/admin/")
2554
+ if (d.includes("analytics") && !a.includes("analytics"))
2555
+ i("/admin/analytics", { replace: !0 });
2556
+ else if (d.includes("chat_history") && !a.includes("chat_history"))
2557
+ i("/admin/chat-history", { replace: !0 });
2558
+ else if (d.includes("user_management") && !a.includes("user_management"))
2559
+ i("/admin/users", { replace: !0 });
2560
+ else if (d.includes("admin_management") && !a.includes("admin_management"))
2561
+ i("/admin/admins", { replace: !0 });
2562
+ else if (d.includes("settings") && !a.includes("settings"))
2563
+ i("/admin/settings", { replace: !0 });
2513
2564
  else {
2514
- const c = t.find((i) => !i.permission || l.includes(i.permission));
2515
- c && o(`/admin/${c.path}`, { replace: !0 });
2565
+ const c = t.find((l) => !l.permission || d.includes(l.permission));
2566
+ c && i(`/admin/${c.path}`, { replace: !0 });
2516
2567
  }
2517
- } catch (F) {
2518
- console.error("Failed to parse admin_info", F);
2568
+ } catch (z) {
2569
+ console.error("Failed to parse admin_info", z);
2519
2570
  }
2520
2571
  else
2521
2572
  console.warn("DashboardPage: No adminInfo found in localStorage");
2522
- }, [o, u.pathname]);
2523
- const D = () => {
2524
- w.clearToken(), window.location.reload();
2525
- }, E = (h) => v.includes(h), J = (h) => v.includes(h) && !a.includes(h), K = Object.keys(p.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), B = K.length > 0 ? K : ["en", "fa"], P = (h) => {
2526
- localStorage.setItem("gentiq-admin-language", h), p.changeLanguage(h), I(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
2573
+ }, [i, m.pathname]);
2574
+ const I = () => {
2575
+ k.clearToken(), window.location.reload();
2576
+ }, P = (h) => N.includes(h), H = (h) => N.includes(h) && !a.includes(h), V = Object.keys(p.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), K = V.length > 0 ? V : ["en", "fa"], B = (h) => {
2577
+ localStorage.setItem("gentiq-admin-language", h), p.changeLanguage(h), j(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
2527
2578
  };
2528
- return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: y ? "rtl" : "ltr", children: [
2579
+ return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: w ? "rtl" : "ltr", children: [
2529
2580
  /* @__PURE__ */ e("header", { className: "glass border-b border-border sticky top-0 z-50", children: /* @__PURE__ */ e("div", { className: "px-8", children: /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch justify-between min-h-[72px] gap-y-4", children: [
2530
2581
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch gap-x-12", children: [
2531
2582
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3 py-4 md:py-0", children: [
2532
- /* @__PURE__ */ e("img", { src: U, alt: O, className: "size-8 object-contain" }),
2533
- /* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: O })
2583
+ /* @__PURE__ */ e("img", { src: O, alt: R, className: "size-8 object-contain" }),
2584
+ /* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: R })
2534
2585
  ] }),
2535
2586
  /* @__PURE__ */ r("nav", { className: "flex items-stretch gap-8", children: [
2536
2587
  !a.includes("analytics") && /* @__PURE__ */ e(
2537
2588
  "button",
2538
2589
  {
2539
- onClick: () => o("/admin/analytics"),
2540
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${u.pathname === "/admin/analytics" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2541
- children: g("dashboard.tabs.analytics")
2590
+ onClick: () => i("/admin/analytics"),
2591
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/analytics" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2592
+ children: f("dashboard.tabs.analytics")
2542
2593
  }
2543
2594
  ),
2544
2595
  !a.includes("chat_history") && /* @__PURE__ */ e(
2545
2596
  "button",
2546
2597
  {
2547
- onClick: () => o("/admin/chat-history"),
2548
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${u.pathname === "/admin/chat-history" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2549
- children: g("dashboard.tabs.chat_history")
2598
+ onClick: () => i("/admin/chat-history"),
2599
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/chat-history" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2600
+ children: f("dashboard.tabs.chat_history")
2550
2601
  }
2551
2602
  ),
2552
2603
  !a.includes("user_management") && /* @__PURE__ */ e(
2553
2604
  "button",
2554
2605
  {
2555
- onClick: () => o("/admin/users"),
2556
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${u.pathname === "/admin/users" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2557
- children: g("dashboard.tabs.users")
2606
+ onClick: () => i("/admin/users"),
2607
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/users" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2608
+ children: f("dashboard.tabs.users")
2558
2609
  }
2559
2610
  ),
2560
2611
  !a.includes("admin_management") && /* @__PURE__ */ e(
2561
2612
  "button",
2562
2613
  {
2563
- onClick: () => o("/admin/admins"),
2564
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${u.pathname === "/admin/admins" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2565
- children: g("dashboard.tabs.admins")
2614
+ onClick: () => i("/admin/admins"),
2615
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/admins" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2616
+ children: f("dashboard.tabs.admins")
2566
2617
  }
2567
2618
  ),
2568
2619
  !a.includes("settings") && /* @__PURE__ */ e(
2569
2620
  "button",
2570
2621
  {
2571
- onClick: () => o("/admin/settings"),
2572
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${u.pathname === "/admin/settings" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2573
- children: g("dashboard.tabs.settings")
2622
+ onClick: () => i("/admin/settings"),
2623
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/settings" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2624
+ children: f("dashboard.tabs.settings")
2574
2625
  }
2575
2626
  ),
2576
2627
  t.map((h) => /* @__PURE__ */ e(
2577
2628
  "button",
2578
2629
  {
2579
- onClick: () => o(`/admin/${h.path}`),
2580
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${u.pathname === `/admin/${h.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2581
- children: typeof h.label == "string" ? g(h.label) : h.label
2630
+ onClick: () => i(`/admin/${h.path}`),
2631
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === `/admin/${h.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2632
+ children: typeof h.label == "string" ? f(h.label) : h.label
2582
2633
  },
2583
2634
  `tab-${h.path}`
2584
2635
  ))
@@ -2586,7 +2637,7 @@ function yt({ extraPages: t = [], disabledPages: a = [] }) {
2586
2637
  ] }),
2587
2638
  /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 py-4 md:py-0", children: [
2588
2639
  /* @__PURE__ */ r(We, { onOpenChange: (h) => {
2589
- h ? I(!1) : (A.current = !0, setTimeout(() => {
2640
+ h ? j(!1) : (A.current = !0, setTimeout(() => {
2590
2641
  A.current = !1;
2591
2642
  }, 200));
2592
2643
  }, children: [
@@ -2595,29 +2646,29 @@ function yt({ extraPages: t = [], disabledPages: a = [] }) {
2595
2646
  {
2596
2647
  open: T,
2597
2648
  onOpenChange: (h) => {
2598
- h && A.current || I(h);
2649
+ h && A.current || j(h);
2599
2650
  },
2600
2651
  children: [
2601
2652
  /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ e(Ke, { asChild: !0, children: /* @__PURE__ */ e(
2602
- me,
2653
+ he,
2603
2654
  {
2604
2655
  variant: "ghost",
2605
2656
  size: "icon",
2606
2657
  className: "font-bold text-xs text-muted-foreground hover:bg-muted",
2607
- onPointerDown: () => I(!1),
2658
+ onPointerDown: () => j(!1),
2608
2659
  children: (p.language?.split("-")[0] || "").toUpperCase()
2609
2660
  }
2610
2661
  ) }) }),
2611
- /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: g("dashboard.language", "Change Language") })
2662
+ /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: f("dashboard.language", "Change Language") })
2612
2663
  ]
2613
2664
  }
2614
2665
  ),
2615
- /* @__PURE__ */ e(Ge, { align: "center", className: "min-w-[8rem]", children: B.map((h) => /* @__PURE__ */ e(
2666
+ /* @__PURE__ */ e(Ge, { align: "center", className: "min-w-[8rem]", children: K.map((h) => /* @__PURE__ */ e(
2616
2667
  Ze,
2617
2668
  {
2618
- onClick: () => P(h),
2669
+ onClick: () => B(h),
2619
2670
  className: h === p.language ? "bg-primary/10" : "",
2620
- children: g(`general.languages.${h}`, h.toUpperCase())
2671
+ children: f(`general.languages.${h}`, h.toUpperCase())
2621
2672
  },
2622
2673
  h
2623
2674
  )) })
@@ -2626,31 +2677,31 @@ function yt({ extraPages: t = [], disabledPages: a = [] }) {
2626
2677
  /* @__PURE__ */ e("div", { className: "w-px h-5 bg-border mx-1" }),
2627
2678
  /* @__PURE__ */ r(ve, { children: [
2628
2679
  /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ e(
2629
- me,
2680
+ he,
2630
2681
  {
2631
2682
  variant: "ghost",
2632
2683
  size: "icon",
2633
2684
  className: "hover:bg-destructive/10 hover:scale-105 active:scale-95 text-muted-foreground hover:text-destructive",
2634
- onClick: D,
2685
+ onClick: I,
2635
2686
  children: /* @__PURE__ */ e(mt, { className: "size-5" })
2636
2687
  }
2637
2688
  ) }),
2638
- /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: g("dashboard.logout") })
2689
+ /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: f("dashboard.logout") })
2639
2690
  ] })
2640
2691
  ] })
2641
2692
  ] }) }) }),
2642
2693
  /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(rt, { children: [
2643
2694
  /* @__PURE__ */ e(se, { path: "/", element: /* @__PURE__ */ e(Ce, { to: "/admin/analytics", replace: !0 }) }),
2644
- /* @__PURE__ */ e(se, { path: "/analytics", element: J("analytics") ? /* @__PURE__ */ e(xt, {}) : /* @__PURE__ */ e(le, {}) }),
2645
- /* @__PURE__ */ e(se, { path: "/chat-history", element: J("chat_history") ? /* @__PURE__ */ e(pt, {}) : /* @__PURE__ */ e(le, {}) }),
2646
- /* @__PURE__ */ e(se, { path: "/admins", element: J("admin_management") ? /* @__PURE__ */ e(gt, {}) : /* @__PURE__ */ e(le, {}) }),
2647
- /* @__PURE__ */ e(se, { path: "/settings", element: J("settings") ? /* @__PURE__ */ e(bt, {}) : /* @__PURE__ */ e(le, {}) }),
2648
- /* @__PURE__ */ e(se, { path: "/users", element: J("user_management") ? /* @__PURE__ */ e(ft, {}) : /* @__PURE__ */ e(le, {}) }),
2695
+ /* @__PURE__ */ e(se, { path: "/analytics", element: H("analytics") ? /* @__PURE__ */ e(xt, {}) : /* @__PURE__ */ e(ce, {}) }),
2696
+ /* @__PURE__ */ e(se, { path: "/chat-history", element: H("chat_history") ? /* @__PURE__ */ e(pt, {}) : /* @__PURE__ */ e(ce, {}) }),
2697
+ /* @__PURE__ */ e(se, { path: "/admins", element: H("admin_management") ? /* @__PURE__ */ e(gt, {}) : /* @__PURE__ */ e(ce, {}) }),
2698
+ /* @__PURE__ */ e(se, { path: "/settings", element: H("settings") ? /* @__PURE__ */ e(bt, {}) : /* @__PURE__ */ e(ce, {}) }),
2699
+ /* @__PURE__ */ e(se, { path: "/users", element: H("user_management") ? /* @__PURE__ */ e(ft, {}) : /* @__PURE__ */ e(ce, {}) }),
2649
2700
  t.map((h) => /* @__PURE__ */ e(
2650
2701
  se,
2651
2702
  {
2652
2703
  path: `/${h.path}`,
2653
- element: h.permission && !E(h.permission) ? /* @__PURE__ */ e(le, {}) : h.element
2704
+ element: h.permission && !P(h.permission) ? /* @__PURE__ */ e(ce, {}) : h.element
2654
2705
  },
2655
2706
  `route-${h.path}`
2656
2707
  )),
@@ -2659,9 +2710,9 @@ function yt({ extraPages: t = [], disabledPages: a = [] }) {
2659
2710
  ] });
2660
2711
  }
2661
2712
  function At(t) {
2662
- const a = ue(() => {
2663
- const o = $e.createInstance();
2664
- return o.use(Qe).use(Oe).init({
2713
+ const a = pe(() => {
2714
+ const i = De.createInstance();
2715
+ return i.use(Qe).use(Ee).init({
2665
2716
  resources: Xe,
2666
2717
  fallbackLng: "en",
2667
2718
  interpolation: { escapeValue: !1 },
@@ -2670,133 +2721,133 @@ function At(t) {
2670
2721
  lookupLocalStorage: "gentiq-admin-language",
2671
2722
  caches: ["localStorage"]
2672
2723
  }
2673
- }), o;
2724
+ }), i;
2674
2725
  }, []);
2675
- return /* @__PURE__ */ e(Ee, { i18n: a, children: /* @__PURE__ */ e(Nt, { ...t }) });
2726
+ return /* @__PURE__ */ e(Oe, { i18n: a, children: /* @__PURE__ */ e(Nt, { ...t }) });
2676
2727
  }
2677
2728
  function Nt({ extraPages: t, disabledPages: a = [] }) {
2678
- const { app: o, i18n: u } = he(), { t: g, i18n: p } = Y(["admin", "translation"]), [_, N] = x(!1), [v, $] = x(!0), [T, I] = x(!1);
2729
+ const { app: i, i18n: m } = me(), { t: f, i18n: p } = ee(["admin", "translation"]), [y, _] = x(!1), [N, J] = x(!0), [T, j] = x(!1);
2679
2730
  G(() => {
2680
- u?.resources && Object.entries(u.resources).forEach(([k, U]) => {
2681
- Object.entries(U).forEach(([O, y]) => {
2682
- p.addResourceBundle(k, O, y, !0, !0);
2731
+ m?.resources && Object.entries(m.resources).forEach(([S, O]) => {
2732
+ Object.entries(O).forEach(([R, w]) => {
2733
+ p.addResourceBundle(S, R, w, !0, !0);
2683
2734
  });
2684
- }), !localStorage.getItem("gentiq-admin-language") && o?.language && p.language !== o.language && p.changeLanguage(o.language), I(!0);
2685
- }, [u?.resources, p, o?.language]), G(() => {
2686
- const q = w.getToken();
2687
- return N(!!q), $(!1), document.body.classList.add("admin-theme-root"), () => {
2735
+ }), !localStorage.getItem("gentiq-admin-language") && i?.language && p.language !== i.language && p.changeLanguage(i.language), j(!0);
2736
+ }, [m?.resources, p, i?.language]), G(() => {
2737
+ const D = k.getToken();
2738
+ return _(!!D), J(!1), document.body.classList.add("admin-theme-root"), () => {
2688
2739
  document.body.classList.remove("admin-theme-root");
2689
2740
  };
2690
2741
  }, []), G(() => {
2691
2742
  T && (document.documentElement.dir = p.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = p.language);
2692
2743
  }, [T, p.language]);
2693
2744
  const A = () => {
2694
- N(!0);
2745
+ _(!0);
2695
2746
  };
2696
- return v || !T ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: g("loading") }) }) : /* @__PURE__ */ e(Ye, { storageKey: "gentiq-admin-theme", children: _ ? /* @__PURE__ */ e(yt, { extraPages: t, disabledPages: a }) : /* @__PURE__ */ e(ht, { onLoginSuccess: A }) });
2747
+ return N || !T ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: f("loading") }) }) : /* @__PURE__ */ e(Ye, { storageKey: "gentiq-admin-theme", children: y ? /* @__PURE__ */ e(yt, { extraPages: t, disabledPages: a }) : /* @__PURE__ */ e(ht, { onLoginSuccess: A }) });
2697
2748
  }
2698
- const te = "gentiq_admin";
2699
- function Mt(t = 0, a = 100, o = "") {
2700
- return de({
2701
- queryKey: [te, "users", t, a, o],
2702
- queryFn: () => w.listUsers(t, a, o)
2749
+ const re = "gentiq_admin";
2750
+ function Mt(t = 0, a = 100, i = "") {
2751
+ return ue({
2752
+ queryKey: [re, "users", t, a, i],
2753
+ queryFn: () => k.listUsers(t, a, i)
2703
2754
  });
2704
2755
  }
2705
- function It() {
2756
+ function $t() {
2706
2757
  const t = _e(), a = () => {
2707
- t.invalidateQueries({ queryKey: [te, "users"] });
2708
- }, o = ee({
2709
- mutationFn: (N) => w.createUser(N.phone, N.name, N.surname, N.tokens, N.requests),
2758
+ t.invalidateQueries({ queryKey: [re, "users"] });
2759
+ }, i = te({
2760
+ mutationFn: (_) => k.createUser(_.phone, _.name, _.surname, _.tokens, _.requests),
2710
2761
  onSuccess: a
2711
- }), u = ee({
2712
- mutationFn: ({ userId: N, data: v }) => w.updateUser(N, v),
2762
+ }), m = te({
2763
+ mutationFn: ({ userId: _, data: N }) => k.updateUser(_, N),
2713
2764
  onSuccess: a
2714
- }), g = ee({
2715
- mutationFn: (N) => w.deleteUser(N),
2765
+ }), f = te({
2766
+ mutationFn: (_) => k.deleteUser(_),
2716
2767
  onSuccess: a
2717
- }), p = ee({
2718
- mutationFn: ({ userId: N, tokens: v, requests: $ }) => w.updateUserBalance(N, v, $),
2768
+ }), p = te({
2769
+ mutationFn: ({ userId: _, tokens: N, requests: J }) => k.updateUserBalance(_, N, J),
2719
2770
  onSuccess: a
2720
- }), _ = ee({
2721
- mutationFn: (N) => w.refreshUserToken(N)
2771
+ }), y = te({
2772
+ mutationFn: (_) => k.refreshUserToken(_)
2722
2773
  });
2723
- return { createUser: o, updateUser: u, deleteUser: g, updateBalance: p, refreshToken: _ };
2774
+ return { createUser: i, updateUser: m, deleteUser: f, updateBalance: p, refreshToken: y };
2724
2775
  }
2725
- function Dt(t = 30) {
2726
- return de({
2727
- queryKey: [te, "analytics", t],
2728
- queryFn: () => w.getAnalytics(t)
2776
+ function It(t = 30) {
2777
+ return ue({
2778
+ queryKey: [re, "analytics", t],
2779
+ queryFn: () => k.getAnalytics(t)
2729
2780
  });
2730
2781
  }
2731
- function $t() {
2732
- return de({
2733
- queryKey: [te, "admins"],
2734
- queryFn: () => w.listAdmins()
2782
+ function Dt() {
2783
+ return ue({
2784
+ queryKey: [re, "admins"],
2785
+ queryFn: () => k.listAdmins()
2735
2786
  });
2736
2787
  }
2737
- function Ot() {
2788
+ function Et() {
2738
2789
  const t = _e(), a = () => {
2739
- t.invalidateQueries({ queryKey: [te, "admins"] });
2740
- }, o = ee({
2741
- mutationFn: (p) => w.register(p.username, p.password, p.name, p.permissions),
2790
+ t.invalidateQueries({ queryKey: [re, "admins"] });
2791
+ }, i = te({
2792
+ mutationFn: (p) => k.register(p.username, p.password, p.name, p.permissions),
2742
2793
  onSuccess: a
2743
- }), u = ee({
2744
- mutationFn: ({ adminId: p, data: _ }) => w.updateAdmin(p, _),
2794
+ }), m = te({
2795
+ mutationFn: ({ adminId: p, data: y }) => k.updateAdmin(p, y),
2745
2796
  onSuccess: a
2746
- }), g = ee({
2747
- mutationFn: (p) => w.deleteAdmin(p),
2797
+ }), f = te({
2798
+ mutationFn: (p) => k.deleteAdmin(p),
2748
2799
  onSuccess: a
2749
2800
  });
2750
- return { createAdmin: o, updateAdmin: u, deleteAdmin: g };
2801
+ return { createAdmin: i, updateAdmin: m, deleteAdmin: f };
2751
2802
  }
2752
- function Et(t = 0, a = 50, o, u) {
2753
- return de({
2754
- queryKey: [te, "threads", t, a, o, u],
2755
- queryFn: () => w.listThreads(t, a, o, u)
2803
+ function Ot(t = 0, a = 50, i, m) {
2804
+ return ue({
2805
+ queryKey: [re, "threads", t, a, i, m],
2806
+ queryFn: () => k.listThreads(t, a, i, m)
2756
2807
  });
2757
2808
  }
2758
2809
  function Rt(t) {
2759
- return de({
2760
- queryKey: [te, "threadItems", t],
2761
- queryFn: () => w.getThreadItems(t),
2810
+ return ue({
2811
+ queryKey: [re, "threadItems", t],
2812
+ queryFn: () => k.getThreadItems(t),
2762
2813
  enabled: !!t
2763
2814
  });
2764
2815
  }
2765
- function Ut(t = 20, a) {
2766
- return de({
2767
- queryKey: [te, "jobs", t, a],
2768
- queryFn: () => w.listJobs(t, a),
2816
+ function Ft(t = 20, a) {
2817
+ return ue({
2818
+ queryKey: [re, "jobs", t, a],
2819
+ queryFn: () => k.listJobs(t, a),
2769
2820
  refetchInterval: 5e3
2770
2821
  // Auto-refresh jobs every 5 seconds
2771
2822
  });
2772
2823
  }
2773
- function Ft() {
2824
+ function Ut() {
2774
2825
  const t = _e();
2775
- return { cancelJob: ee({
2776
- mutationFn: (u) => w.cancelJob(u),
2826
+ return { cancelJob: te({
2827
+ mutationFn: (m) => k.cancelJob(m),
2777
2828
  onSuccess: () => {
2778
- t.invalidateQueries({ queryKey: [te, "jobs"] });
2829
+ t.invalidateQueries({ queryKey: [re, "jobs"] });
2779
2830
  }
2780
2831
  }) };
2781
2832
  }
2782
2833
  function zt() {
2783
2834
  return {
2784
- login: async (t, a) => w.login(t, a),
2785
- logout: () => w.clearToken(),
2786
- getToken: () => w.getToken(),
2787
- isAuthenticated: !!w.getToken()
2835
+ login: async (t, a) => k.login(t, a),
2836
+ logout: () => k.clearToken(),
2837
+ getToken: () => k.getToken(),
2838
+ isAuthenticated: !!k.getToken()
2788
2839
  };
2789
2840
  }
2790
2841
  export {
2791
2842
  At as AdminPanel,
2792
- $t as useAdminAdmins,
2793
- Ot as useAdminAdminsMutations,
2794
- Dt as useAdminAnalytics,
2843
+ Dt as useAdminAdmins,
2844
+ Et as useAdminAdminsMutations,
2845
+ It as useAdminAnalytics,
2795
2846
  zt as useAdminAuth,
2796
- Ut as useAdminJobs,
2797
- Ft as useAdminJobsMutations,
2847
+ Ft as useAdminJobs,
2848
+ Ut as useAdminJobsMutations,
2798
2849
  Rt as useAdminThreadItems,
2799
- Et as useAdminThreads,
2850
+ Ot as useAdminThreads,
2800
2851
  Mt as useAdminUsers,
2801
- It as useAdminUsersMutations
2852
+ $t as useAdminUsersMutations
2802
2853
  };