gentiq 0.7.32 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- import { jsx as e, jsxs as r, Fragment as Ue } from "react/jsx-runtime";
2
- import { useState as b, useEffect as Q, useMemo as xe, useRef as Ee } from "react";
3
- import ze from "i18next";
4
- import { useTranslation as te, initReactI18next as Pe, I18nextProvider as Je } from "react-i18next";
5
- import { G as Le, a as pe, m as Se, w as Oe, n as qe, S as se, q as ae, r as ne, e as Ne, s as ie, t as B, M as He, D as Ve, o as Be, p as We, F as Ge, H as Ke, J as Ze, K as Qe, a2 as Xe, B as fe, L as Z, I as ue, a3 as je, i as _e, k as we, l as ke, y as Ye, z as et, A as tt, E as rt, a4 as st, d as at, T as nt } from "./checkbox-CdPG-d34.js";
6
- import { useNavigate as it, useLocation as ot, Routes as lt, Route as me, Navigate as Te } from "react-router-dom";
7
- import { Share2 as dt, RefreshCcw as Ae, Globe as ye, Palette as ct, Keyboard as mt, Wallet as ut, Languages as ht, Plus as pt, Hash as gt, ShieldAlert as ft, Monitor as Me, Moon as xt, Sun as bt, LogOut as vt } from "lucide-react";
8
- import { toast as Ie } from "sonner";
9
- import * as $e from "@radix-ui/react-switch";
10
- import { useQuery as ge, useQueryClient as Ce, useMutation as oe } from "@tanstack/react-query";
11
- const De = "/api";
12
- class yt {
1
+ import { jsx as e, jsxs as r, Fragment as mt } from "react/jsx-runtime";
2
+ import { useState as p, useEffect as Y, useMemo as Se, useRef as Ce } from "react";
3
+ import ut from "i18next";
4
+ import { useTranslation as me, initReactI18next as ht, I18nextProvider as pt } from "react-i18next";
5
+ import { G as Ue, a as _e, m as Me, w as Be, e as je, n as Oe, D as We, p as Ge, F as Ke, H as Ze, J as Qe, S as oe, q as le, r as de, s as ce, t as Z, M as gt, o as ft, K as xt, a2 as bt, B as ke, L as X, I as ge, a3 as Fe, i as Ae, k as Te, l as Ie, y as vt, z as yt, A as _t, E as Nt, a4 as wt, d as kt, T as St } from "./checkbox-CjhpdOWd.js";
6
+ import { useNavigate as Ct, useLocation as Lt, Routes as qt, Route as pe, Navigate as Re } from "react-router-dom";
7
+ import { Share2 as jt, Info as At, ArrowUpDown as Tt, ArrowUp as It, ArrowDown as Mt, RefreshCcw as Pe, Globe as qe, Palette as Dt, Keyboard as $t, Wallet as Et, Languages as Ut, Plus as Ot, Hash as Ft, ShieldAlert as Rt, Monitor as ze, Moon as Pt, Sun as zt, LogOut as Jt } from "lucide-react";
8
+ import { toast as Je } from "sonner";
9
+ import * as Ve from "@radix-ui/react-switch";
10
+ import { useQuery as Ne, useQueryClient as De, useMutation as ue } from "@tanstack/react-query";
11
+ const He = "/api";
12
+ class Vt {
13
13
  token = null;
14
14
  constructor() {
15
15
  this.token = localStorage.getItem("admin_token");
@@ -24,48 +24,48 @@ class yt {
24
24
  return this.token;
25
25
  }
26
26
  async request(n, 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 x = await fetch(`${De}${n}`, {
27
+ const c = new Headers(i.headers);
28
+ c.has("Content-Type") || c.set("Content-Type", "application/json"), this.token && c.set("Authorization", `Bearer ${this.token}`);
29
+ const f = await fetch(`${He}${n}`, {
30
30
  ...i,
31
- headers: m
31
+ headers: c
32
32
  });
33
- if (!x.ok) {
34
- const u = await x.json().catch(() => ({}));
33
+ if (!f.ok) {
34
+ const u = await f.json().catch(() => ({}));
35
35
  if (u.error && (typeof u.error.code == "string" || typeof u.error.message == "string"))
36
- throw new Le(u, x.status);
37
- let v = `HTTP ${x.status}`, _ = "error", N = null;
38
- throw typeof u.detail == "string" ? v = u.detail : typeof u.message == "string" ? v = u.message : typeof u.error == "string" ? v = u.error : Array.isArray(u.detail) ? (v = "Validation failed", N = u.detail, _ = "validation_error") : u.error && typeof u.error.message == "string" && (v = u.error.message), new Le({
36
+ throw new Ue(u, f.status);
37
+ let b = `HTTP ${f.status}`, w = "error", _ = null;
38
+ throw typeof u.detail == "string" ? b = u.detail : typeof u.message == "string" ? b = u.message : typeof u.error == "string" ? b = u.error : Array.isArray(u.detail) ? (b = "Validation failed", _ = u.detail, w = "validation_error") : u.error && typeof u.error.message == "string" && (b = u.error.message), new Ue({
39
39
  error: {
40
- code: _,
41
- message: v,
42
- details: N
40
+ code: w,
41
+ message: b,
42
+ details: _
43
43
  }
44
- }, x.status);
44
+ }, f.status);
45
45
  }
46
- return x.json();
46
+ return f.json();
47
47
  }
48
48
  async login(n, i) {
49
- const m = await this.request("/admin/login", {
49
+ const c = await this.request("/admin/login", {
50
50
  method: "POST",
51
51
  body: JSON.stringify({ username: n, password: i })
52
52
  });
53
- this.setToken(m.token);
54
- const x = {
55
- admin_id: m.admin_id,
56
- username: m.username,
57
- name: m.name,
58
- permissions: m.permissions
53
+ this.setToken(c.token);
54
+ const f = {
55
+ admin_id: c.admin_id,
56
+ username: c.username,
57
+ name: c.name,
58
+ permissions: c.permissions
59
59
  };
60
- return localStorage.setItem("admin_info", JSON.stringify(x)), m;
60
+ return localStorage.setItem("admin_info", JSON.stringify(f)), c;
61
61
  }
62
62
  async checkSetupStatus() {
63
63
  return this.request("/admin/setup-status");
64
64
  }
65
- async register(n, i, m, x) {
65
+ async register(n, i, c, f) {
66
66
  return this.request("/admin/admins", {
67
67
  method: "POST",
68
- body: JSON.stringify({ username: n, password: i, name: m, permissions: x })
68
+ body: JSON.stringify({ username: n, password: i, name: c, permissions: f })
69
69
  });
70
70
  }
71
71
  async listAdmins() {
@@ -85,9 +85,9 @@ class yt {
85
85
  async listPermissions() {
86
86
  return this.request("/admin/permissions");
87
87
  }
88
- async listThreads(n = 0, i = 50, m, x) {
88
+ async listThreads(n = 0, i = 50, c, f) {
89
89
  const u = new URLSearchParams({ skip: n.toString(), limit: i.toString() });
90
- return m && u.append("query", m), x && u.append("feedback", x), this.request(`/admin/chat-history/threads?${u}`);
90
+ return c && u.append("query", c), f && u.append("feedback", f), this.request(`/admin/chat-history/threads?${u}`);
91
91
  }
92
92
  async getThreadItems(n) {
93
93
  return this.request(`/admin/chat-history/threads/${n}/items`);
@@ -97,20 +97,25 @@ class yt {
97
97
  method: "POST"
98
98
  });
99
99
  }
100
- async listUsers(n = 0, i = 100, m = "") {
101
- const x = new URLSearchParams({ skip: n.toString(), limit: i.toString() });
102
- return m && x.append("query", m), this.request(`/admin/users?${x.toString()}`);
100
+ async listUsers(n = 0, i = 100, c = "", f = "name", u = "asc") {
101
+ const b = new URLSearchParams({
102
+ skip: n.toString(),
103
+ limit: i.toString(),
104
+ sort_by: f,
105
+ sort_order: u
106
+ });
107
+ return c && b.append("query", c), this.request(`/admin/users?${b.toString()}`);
103
108
  }
104
- async createUser(n, i, m, x, u, v, _, N) {
105
- const P = x !== void 0 || u !== void 0 || v !== void 0 || _ !== void 0 ? {
106
- tokens: x || 0,
109
+ async createUser(n, i, c, f, u, b, w, _, V) {
110
+ const D = f !== void 0 || u !== void 0 || b !== void 0 || w !== void 0 ? {
111
+ tokens: f || 0,
107
112
  requests: u || 0,
108
- token_limit: v || x || 0,
109
- request_limit: _ || u || 0
113
+ token_limit: b || f || 0,
114
+ request_limit: w || u || 0
110
115
  } : void 0;
111
116
  return this.request("/admin/users", {
112
117
  method: "POST",
113
- body: JSON.stringify({ phone: n, name: i, surname: m, balance: P, metadata: N })
118
+ body: JSON.stringify({ phone: n, name: i, surname: c, balance: D, metadata: _, recharge_policy: V })
114
119
  });
115
120
  }
116
121
  async updateUser(n, i) {
@@ -124,10 +129,10 @@ class yt {
124
129
  method: "DELETE"
125
130
  });
126
131
  }
127
- async updateUserBalance(n, i, m, x, u) {
132
+ async updateUserBalance(n, i, c, f, u) {
128
133
  return this.request(`/admin/users/${n}/balance`, {
129
134
  method: "POST",
130
- body: JSON.stringify({ tokens: i, requests: m, token_limit: x, request_limit: u })
135
+ body: JSON.stringify({ tokens: i, requests: c, token_limit: f, request_limit: u })
131
136
  });
132
137
  }
133
138
  async refreshUserToken(n) {
@@ -135,12 +140,15 @@ class yt {
135
140
  method: "POST"
136
141
  });
137
142
  }
143
+ async getUserUsageSummary(n) {
144
+ return this.request(`/admin/users/${n}/usage-summary`);
145
+ }
138
146
  async getAnalytics(n = 30) {
139
147
  return this.request(`/admin/analytics?days=${n}`);
140
148
  }
141
149
  async listJobs(n = 20, i) {
142
- const m = new URLSearchParams({ limit: n.toString() });
143
- return i && m.append("type", i), this.request(`/admin/jobs?${m}`);
150
+ const c = new URLSearchParams({ limit: n.toString() });
151
+ return i && c.append("type", i), this.request(`/admin/jobs?${c}`);
144
152
  }
145
153
  async cancelJob(n) {
146
154
  return this.request(`/admin/jobs/${n}/cancel`, {
@@ -164,78 +172,78 @@ class yt {
164
172
  async getAttachmentBlob(n) {
165
173
  const i = {};
166
174
  this.token && (i.Authorization = `Bearer ${this.token}`);
167
- const m = await fetch(`${De}/admin/chat-history/attachments/${n}`, {
175
+ const c = await fetch(`${He}/admin/chat-history/attachments/${n}`, {
168
176
  method: "GET",
169
177
  headers: i
170
178
  });
171
- if (!m.ok) {
172
- const x = await m.json().catch(() => ({ error: "Request failed" }));
173
- throw new Error(x.error || `HTTP ${m.status}`);
179
+ if (!c.ok) {
180
+ const f = await c.json().catch(() => ({ error: "Request failed" }));
181
+ throw new Error(f.error || `HTTP ${c.status}`);
174
182
  }
175
- return m.blob();
183
+ return c.blob();
176
184
  }
177
185
  }
178
- const k = new yt();
179
- function Nt({ onLoginSuccess: t }) {
180
- const { t: n, i18n: i } = te(["admin", "translation"]), { app: m } = pe(), { theme: x } = Se(), [u, v] = b(""), [_, N] = b(""), [P, D] = b(""), [T, A] = b(""), [F, q] = b(!1), [I, H] = b(null), [w, M] = b("light");
181
- Q(() => {
182
- if (x === "system") {
186
+ const k = new Vt();
187
+ function Ht({ onLoginSuccess: t }) {
188
+ const { t: n, i18n: i } = me(["admin", "translation"]), { app: c } = _e(), { theme: f } = Me(), [u, b] = p(""), [w, _] = p(""), [V, D] = p(""), [j, $] = p(""), [O, S] = p(!1), [E, H] = p(null), [C, U] = p("light");
189
+ Y(() => {
190
+ if (f === "system") {
183
191
  const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
184
- M(h ? "dark" : "light");
192
+ U(h ? "dark" : "light");
185
193
  } else
186
- M(x);
187
- }, [x]);
188
- const J = xe(() => m?.logo ? typeof m.logo == "string" ? m.logo : w === "dark" ? m.logo.dark : m.logo.light : Oe, [m?.logo, w]), E = m?.adminTitle || m?.name, W = i.language === "fa";
189
- Q(() => {
194
+ U(f);
195
+ }, [f]);
196
+ const B = Se(() => c?.logo ? typeof c.logo == "string" ? c.logo : C === "dark" ? c.logo.dark : c.logo.light : Be, [c?.logo, C]), G = c?.adminTitle || c?.name, F = i.language === "fa";
197
+ Y(() => {
190
198
  k.checkSetupStatus().then((h) => H(h.needs_setup)).catch(() => H(!1));
191
199
  }, []);
192
- const Y = async (h) => {
193
- h.preventDefault(), A(""), q(!0);
200
+ const ae = async (h) => {
201
+ h.preventDefault(), $(""), S(!0);
194
202
  try {
195
- await k.login(u, _), t();
196
- } catch (U) {
197
- A(U instanceof Error ? U.message : n("login.error"));
203
+ await k.login(u, w), t();
204
+ } catch (I) {
205
+ $(I instanceof Error ? I.message : n("login.error"));
198
206
  } finally {
199
- q(!1);
207
+ S(!1);
200
208
  }
201
- }, G = async (h) => {
202
- if (h.preventDefault(), A(""), _ !== P) {
203
- A(n("login.passwords_mismatch"));
209
+ }, K = async (h) => {
210
+ if (h.preventDefault(), $(""), w !== V) {
211
+ $(n("login.passwords_mismatch"));
204
212
  return;
205
213
  }
206
- if (_.length < 4) {
207
- A(n("login.password_too_short"));
214
+ if (w.length < 4) {
215
+ $(n("login.password_too_short"));
208
216
  return;
209
217
  }
210
- q(!0);
218
+ S(!0);
211
219
  try {
212
220
  await k.register(
213
221
  "admin",
214
- _,
222
+ w,
215
223
  "Admin",
216
224
  ["chat_history", "admin_management", "user_management", "analytics"]
217
- ), await k.login("admin", _), t();
218
- } catch (U) {
219
- A(U instanceof Error ? U.message : n("login.error"));
225
+ ), await k.login("admin", w), t();
226
+ } catch (I) {
227
+ $(I instanceof Error ? I.message : n("login.error"));
220
228
  } finally {
221
- q(!1);
229
+ S(!1);
222
230
  }
223
231
  };
224
- return I === 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: W ? "rtl" : "ltr", children: [
232
+ return E === 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: F ? "rtl" : "ltr", children: [
225
233
  /* @__PURE__ */ e("div", { className: "absolute top-[-10%] right-[-10%] w-[50%] h-[50%] bg-primary/10 rounded-full blur-3xl animate-pulse" }),
226
234
  /* @__PURE__ */ e("div", { className: "absolute bottom-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/5 dark:bg-primary/10 rounded-full blur-3xl" }),
227
235
  /* @__PURE__ */ r("div", { className: "w-full max-w-md z-10", children: [
228
236
  /* @__PURE__ */ r("div", { className: "glass rounded-3xl p-10 shadow-2xl", children: [
229
237
  /* @__PURE__ */ r("div", { className: "text-center mb-10", children: [
230
238
  /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-4 mb-6", children: [
231
- /* @__PURE__ */ e("img", { src: J, alt: E, className: "size-16 object-contain" }),
232
- /* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: I ? n("login.setup_title") : E })
239
+ /* @__PURE__ */ e("img", { src: B, alt: G, className: "size-16 object-contain" }),
240
+ /* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: E ? n("login.setup_title") : G })
233
241
  ] }),
234
- I && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-3", children: n("login.setup_description") })
242
+ E && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-3", children: n("login.setup_description") })
235
243
  ] }),
236
- I ? (
244
+ E ? (
237
245
  /* ---- SETUP FORM ---- */
238
- /* @__PURE__ */ r("form", { onSubmit: G, className: "space-y-7", children: [
246
+ /* @__PURE__ */ r("form", { onSubmit: K, className: "space-y-7", children: [
239
247
  /* @__PURE__ */ r("div", { children: [
240
248
  /* @__PURE__ */ e("label", { className: "block text-xs font-bold text-muted-foreground uppercase tracking-widest mb-3.5 mx-1", children: n("login.username") }),
241
249
  /* @__PURE__ */ e(
@@ -255,8 +263,8 @@ function Nt({ onLoginSuccess: t }) {
255
263
  {
256
264
  id: "setup-password",
257
265
  type: "password",
258
- value: _,
259
- onChange: (h) => N(h.target.value),
266
+ value: w,
267
+ onChange: (h) => _(h.target.value),
260
268
  required: !0,
261
269
  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",
262
270
  placeholder: n("login.set_password_placeholder"),
@@ -271,7 +279,7 @@ function Nt({ onLoginSuccess: t }) {
271
279
  {
272
280
  id: "setup-confirm",
273
281
  type: "password",
274
- value: P,
282
+ value: V,
275
283
  onChange: (h) => D(h.target.value),
276
284
  required: !0,
277
285
  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",
@@ -280,14 +288,14 @@ function Nt({ onLoginSuccess: t }) {
280
288
  }
281
289
  )
282
290
  ] }),
283
- T && /* @__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: T }),
291
+ 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 }),
284
292
  /* @__PURE__ */ e(
285
293
  "button",
286
294
  {
287
295
  type: "submit",
288
- disabled: F,
296
+ disabled: O,
289
297
  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]",
290
- children: F ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
298
+ children: O ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
291
299
  /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
292
300
  /* @__PURE__ */ e("span", { children: n("login.setting_up") })
293
301
  ] }) : n("login.create_admin")
@@ -296,7 +304,7 @@ function Nt({ onLoginSuccess: t }) {
296
304
  ] })
297
305
  ) : (
298
306
  /* ---- LOGIN FORM ---- */
299
- /* @__PURE__ */ r("form", { onSubmit: Y, className: "space-y-7", children: [
307
+ /* @__PURE__ */ r("form", { onSubmit: ae, className: "space-y-7", children: [
300
308
  /* @__PURE__ */ r("div", { children: [
301
309
  /* @__PURE__ */ e("label", { htmlFor: "username", className: "block text-xs font-bold text-muted-foreground uppercase tracking-widest mb-3.5 mx-1", children: n("login.username") }),
302
310
  /* @__PURE__ */ e(
@@ -305,7 +313,7 @@ function Nt({ onLoginSuccess: t }) {
305
313
  id: "username",
306
314
  type: "text",
307
315
  value: u,
308
- onChange: (h) => v(h.target.value),
316
+ onChange: (h) => b(h.target.value),
309
317
  required: !0,
310
318
  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",
311
319
  placeholder: n("login.username_placeholder"),
@@ -320,8 +328,8 @@ function Nt({ onLoginSuccess: t }) {
320
328
  {
321
329
  id: "password",
322
330
  type: "password",
323
- value: _,
324
- onChange: (h) => N(h.target.value),
331
+ value: w,
332
+ onChange: (h) => _(h.target.value),
325
333
  required: !0,
326
334
  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",
327
335
  placeholder: n("login.password_placeholder"),
@@ -329,14 +337,14 @@ function Nt({ onLoginSuccess: t }) {
329
337
  }
330
338
  )
331
339
  ] }),
332
- T && /* @__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: T }),
340
+ 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 }),
333
341
  /* @__PURE__ */ e(
334
342
  "button",
335
343
  {
336
344
  type: "submit",
337
- disabled: F,
345
+ disabled: O,
338
346
  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]",
339
- children: F ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
347
+ children: O ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
340
348
  /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
341
349
  /* @__PURE__ */ e("span", { children: n("login.logging_in") })
342
350
  ] }) : n("login.submit")
@@ -349,58 +357,87 @@ function Nt({ onLoginSuccess: t }) {
349
357
  ] })
350
358
  ] });
351
359
  }
352
- function _t() {
353
- const { t, i18n: n } = te(["admin", "translation"]), { app: i } = pe(), m = i?.userMetadataFields || [], [x, u] = b([]), [v, _] = b(null), [N, P] = b([]), [D, T] = b(!1), [A, F] = b(!1), [q, I] = b(""), [H, w] = b(""), [M, J] = b(""), [E, W] = b(0), [Y, G] = b(!0), h = n.language === "fa", U = h ? "fa-IR" : "en-US", d = async (s = !1) => {
354
- s ? F(!0) : (T(!0), W(0)), I("");
360
+ function $e(t, n, i) {
361
+ const c = (t || 0) / 1e6;
362
+ try {
363
+ return new Intl.NumberFormat(i, {
364
+ style: "currency",
365
+ currency: n,
366
+ minimumFractionDigits: c > 0 && c < 0.01 ? 6 : 2,
367
+ maximumFractionDigits: 6
368
+ }).format(c);
369
+ } catch {
370
+ return `${n} ${c.toLocaleString(i, { maximumFractionDigits: 6 })}`;
371
+ }
372
+ }
373
+ function Xe(t, n, i) {
374
+ const c = (t || 0) / 1e6;
375
+ try {
376
+ return new Intl.NumberFormat(i, {
377
+ style: "currency",
378
+ currency: n,
379
+ minimumFractionDigits: 2,
380
+ maximumFractionDigits: 2
381
+ }).format(c);
382
+ } catch {
383
+ return `${n} ${c.toLocaleString(i, {
384
+ minimumFractionDigits: 2,
385
+ maximumFractionDigits: 2
386
+ })}`;
387
+ }
388
+ }
389
+ function Bt() {
390
+ const { t, i18n: n } = me(["admin", "translation"]), { app: i } = _e(), c = i?.userMetadataFields || [], [f, u] = p([]), [b, w] = p(null), [_, V] = p([]), [D, j] = p(!1), [$, O] = p(!1), [S, E] = p(""), [H, C] = p(""), [U, B] = p(""), [G, F] = p(0), [ae, K] = p(!0), h = n.language === "fa", I = h ? "fa-IR" : "en-US", l = async (s = !1) => {
391
+ s ? O(!0) : (j(!0), F(0)), E("");
355
392
  try {
356
- const f = s ? E + 50 : 0, L = await k.listThreads(
357
- f,
393
+ const x = s ? G + 50 : 0, L = await k.listThreads(
394
+ x,
358
395
  50,
359
396
  H || void 0,
360
- M || void 0
397
+ U || void 0
361
398
  );
362
- s ? (u((z) => [...z, ...L.threads]), W(f)) : (u(L.threads), W(0)), G(L.threads.length === 50);
363
- } catch (f) {
364
- I(f instanceof Error ? f.message : t("error_loading"));
399
+ s ? (u((T) => [...T, ...L.threads]), F(x)) : (u(L.threads), F(0)), K(L.threads.length === 50);
400
+ } catch (x) {
401
+ E(x instanceof Error ? x.message : t("error_loading"));
365
402
  } finally {
366
- T(!1), F(!1);
403
+ j(!1), O(!1);
367
404
  }
368
- }, c = async (s) => {
369
- _(s), T(!0), I("");
405
+ }, m = async (s) => {
406
+ w(s), j(!0), E("");
370
407
  try {
371
- const f = await k.getThreadItems(s.id);
372
- P(f.items);
373
- } catch (f) {
374
- I(f instanceof Error ? f.message : t("error_loading"));
408
+ const x = await k.getThreadItems(s.id);
409
+ V(x.items);
410
+ } catch (x) {
411
+ E(x instanceof Error ? x.message : t("error_loading"));
375
412
  } finally {
376
- T(!1);
413
+ j(!1);
377
414
  }
378
- }, y = async (s, f) => {
415
+ }, N = async (s, x) => {
379
416
  s.stopPropagation();
380
417
  try {
381
- const L = await k.shareThread(f.id), z = `${window.location.origin}${L.url}`;
382
- navigator.clipboard.writeText(z), Ie.success(t("sidebar.share_success"), {
418
+ const L = await k.shareThread(x.id), T = `${window.location.origin}${L.url}`;
419
+ navigator.clipboard.writeText(T), Je.success(t("sidebar.share_success"), {
383
420
  description: t("sidebar.share_description")
384
421
  });
385
422
  } catch {
386
- Ie.error(t("sidebar.share_failed"));
423
+ Je.error(t("sidebar.share_failed"));
387
424
  }
388
425
  };
389
- Q(() => {
426
+ Y(() => {
390
427
  const s = setTimeout(() => {
391
- d();
428
+ l();
392
429
  }, 500);
393
430
  return () => clearTimeout(s);
394
- }, [H, M]);
395
- const l = (s) => {
396
- const f = new Date(s);
431
+ }, [H, U]);
432
+ const d = (s) => {
433
+ const x = new Date(s);
397
434
  return new Intl.DateTimeFormat(h ? "fa-IR" : "en-US", {
398
435
  year: "numeric",
399
436
  month: "long",
400
437
  day: "numeric",
401
438
  hour: "2-digit",
402
439
  minute: "2-digit"
403
- }).format(f);
440
+ }).format(x);
404
441
  }, g = (s) => {
405
442
  if (typeof s == "string")
406
443
  try {
@@ -409,13 +446,13 @@ function _t() {
409
446
  return s;
410
447
  }
411
448
  return JSON.stringify(s, null, 2);
412
- }, R = ({ part: s, idx: f }) => {
413
- const [L, z] = b(!1), K = s.tool_name || (s.type && s.type.startsWith("tool-") ? s.type.slice(5) : "tool");
449
+ }, R = ({ part: s, idx: x }) => {
450
+ const [L, T] = p(!1), Q = s.tool_name || (s.type && s.type.startsWith("tool-") ? s.type.slice(5) : "tool");
414
451
  return /* @__PURE__ */ r("div", { dir: "ltr", className: "my-2 border border-border/50 rounded-xl overflow-hidden bg-muted/20 text-left", children: [
415
452
  /* @__PURE__ */ r(
416
453
  "div",
417
454
  {
418
- onClick: () => z(!L),
455
+ onClick: () => T(!L),
419
456
  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",
420
457
  children: [
421
458
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
@@ -430,7 +467,7 @@ function _t() {
430
467
  }
431
468
  ),
432
469
  /* @__PURE__ */ e("span", { className: "text-[10px] font-bold uppercase tracking-widest text-muted-foreground", children: "Tool" }),
433
- /* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: K })
470
+ /* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: Q })
434
471
  ] }),
435
472
  /* @__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") })
436
473
  ]
@@ -446,18 +483,18 @@ function _t() {
446
483
  /* @__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: g(s.output || s.error_text || s.errorText) })
447
484
  ] })
448
485
  ] })
449
- ] }, f);
450
- }, p = async (s, f) => {
486
+ ] }, x);
487
+ }, P = async (s, x) => {
451
488
  try {
452
- const L = await k.getAttachmentBlob(s), z = window.URL.createObjectURL(L), K = document.createElement("a");
453
- K.href = z, K.download = f || s.split("/").pop() || "download", document.body.appendChild(K), K.click(), window.URL.revokeObjectURL(z), document.body.removeChild(K);
489
+ const L = await k.getAttachmentBlob(s), T = window.URL.createObjectURL(L), Q = document.createElement("a");
490
+ Q.href = T, Q.download = x || s.split("/").pop() || "download", document.body.appendChild(Q), Q.click(), window.URL.revokeObjectURL(T), document.body.removeChild(Q);
454
491
  } catch (L) {
455
- console.error("Download failed:", L), I(L instanceof Error ? L.message : "Download failed");
492
+ console.error("Download failed:", L), E(L instanceof Error ? L.message : "Download failed");
456
493
  }
457
- }, S = (s, f) => typeof s == "string" ? /* @__PURE__ */ e("div", { children: s }, f) : s.type === "text" ? /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: s.text }, f) : 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: [
494
+ }, M = (s, x) => typeof s == "string" ? /* @__PURE__ */ e("div", { children: s }, x) : s.type === "text" ? /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: s.text }, x) : 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: [
458
495
  /* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter opacity-70", children: "Reasoning" }),
459
496
  s.text
460
- ] }, f) : s.type === "dynamic-tool" || s.type && s.type.startsWith("tool-") || s.tool_call_id ? /* @__PURE__ */ e(R, { part: s, idx: f }, f) : 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: [
497
+ ] }, x) : s.type === "dynamic-tool" || s.type && s.type.startsWith("tool-") || s.tool_call_id ? /* @__PURE__ */ e(R, { part: s, idx: x }, x) : 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: [
461
498
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3 overflow-hidden", children: [
462
499
  /* @__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: "📎" }) }),
463
500
  /* @__PURE__ */ r("div", { className: "flex flex-col min-w-0", children: [
@@ -468,15 +505,15 @@ function _t() {
468
505
  s.object_name && /* @__PURE__ */ e(
469
506
  "button",
470
507
  {
471
- onClick: () => p(s.object_name, s.filename),
508
+ onClick: () => P(s.object_name, s.filename),
472
509
  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",
473
510
  title: t("chat_history.download_file", "Download File"),
474
511
  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" }) })
475
512
  }
476
513
  )
477
- ] }, f) : /* @__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) }, f), O = (s) => {
478
- const { scrollTop: f, scrollHeight: L, clientHeight: z } = s.currentTarget;
479
- L - f <= z + 50 && !A && Y && d(!0);
514
+ ] }, x) : /* @__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) }, x), W = (s) => {
515
+ const { scrollTop: x, scrollHeight: L, clientHeight: T } = s.currentTarget;
516
+ L - x <= T + 50 && !$ && ae && l(!0);
480
517
  };
481
518
  return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: h ? "rtl" : "ltr", children: [
482
519
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
@@ -487,7 +524,7 @@ function _t() {
487
524
  "form",
488
525
  {
489
526
  onSubmit: (s) => {
490
- s.preventDefault(), d();
527
+ s.preventDefault(), l();
491
528
  },
492
529
  className: "flex-1 flex gap-2",
493
530
  children: [
@@ -496,7 +533,7 @@ function _t() {
496
533
  {
497
534
  type: "text",
498
535
  value: H,
499
- onChange: (s) => w(s.target.value),
536
+ onChange: (s) => C(s.target.value),
500
537
  placeholder: t("chat_history.search_placeholder"),
501
538
  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"
502
539
  }
@@ -515,8 +552,8 @@ function _t() {
515
552
  /* @__PURE__ */ r(
516
553
  "select",
517
554
  {
518
- value: M,
519
- onChange: (s) => J(s.target.value),
555
+ value: U,
556
+ onChange: (s) => B(s.target.value),
520
557
  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]",
521
558
  children: [
522
559
  /* @__PURE__ */ e("option", { value: "", children: t("chat_history.all_feedbacks", "All Feedbacks") }),
@@ -528,33 +565,33 @@ function _t() {
528
565
  )
529
566
  ] })
530
567
  ] }),
531
- q && /* @__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: q })
568
+ 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 })
532
569
  ] }),
533
570
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-[380px_1fr] gap-4 flex-1 min-h-0", children: [
534
571
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col min-w-0", children: [
535
572
  /* @__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: [
536
573
  t("chat_history.threads_list"),
537
574
  " (",
538
- (x.length || 0).toLocaleString(U),
575
+ (f.length || 0).toLocaleString(I),
539
576
  ")"
540
577
  ] }) }),
541
578
  /* @__PURE__ */ e(
542
579
  "div",
543
580
  {
544
581
  className: "flex-1 overflow-y-auto p-2 custom-scrollbar",
545
- onScroll: O,
546
- children: D && x.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: [
547
- x.map((s) => /* @__PURE__ */ r(
582
+ onScroll: W,
583
+ children: D && 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: [
584
+ f.map((s) => /* @__PURE__ */ r(
548
585
  "div",
549
586
  {
550
- onClick: () => c(s),
551
- className: `p-2.5 cursor-pointer transition-all rounded-xl border ${v?.id === s.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
587
+ onClick: () => m(s),
588
+ className: `p-2.5 cursor-pointer transition-all rounded-xl border ${b?.id === s.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
552
589
  children: [
553
590
  /* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-1.5 gap-4", children: [
554
591
  /* @__PURE__ */ e(
555
592
  "h3",
556
593
  {
557
- className: `font-medium text-sm truncate flex-1 ${v?.id === s.id ? "text-primary" : "text-foreground"}`,
594
+ className: `font-medium text-sm truncate flex-1 ${b?.id === s.id ? "text-primary" : "text-foreground"}`,
558
595
  title: s.title || t("chat_history.no_thread_title"),
559
596
  children: s.title || t("chat_history.no_thread_title")
560
597
  }
@@ -569,14 +606,14 @@ function _t() {
569
606
  "div",
570
607
  {
571
608
  className: "flex flex-col gap-0.5 min-w-0",
572
- title: `${s.user_info.name} ${s.user_info.surname} ${s.user_info.phone ? ` • ${s.user_info.phone}` : ""}${m.filter((f) => s.user_info?.metadata?.[f.key] !== void 0 && s.user_info?.metadata?.[f.key] !== "").map((f) => {
573
- const L = s.user_info?.metadata?.[f.key];
574
- if (f.type === "select") {
575
- const z = f.options?.find((K) => String(K.value) === String(L));
576
- return ` • ${z ? t(z.label) : L}`;
609
+ title: `${s.user_info.name} ${s.user_info.surname} ${s.user_info.phone ? ` • ${s.user_info.phone}` : ""}${c.filter((x) => s.user_info?.metadata?.[x.key] !== void 0 && s.user_info?.metadata?.[x.key] !== "").map((x) => {
610
+ const L = s.user_info?.metadata?.[x.key];
611
+ if (x.type === "select") {
612
+ const T = x.options?.find((Q) => String(Q.value) === String(L));
613
+ return ` • ${T ? t(T.label) : L}`;
577
614
  }
578
615
  return ` • ${L}`;
579
- }).join("")}${s.user_info.metadata?.values !== void 0 && !m.some((f) => f.key === "values") ? ` • ${s.user_info.metadata.values}` : ""}`,
616
+ }).join("")}${s.user_info.metadata?.values !== void 0 && !c.some((x) => x.key === "values") ? ` • ${s.user_info.metadata.values}` : ""}`,
580
617
  children: [
581
618
  /* @__PURE__ */ r("div", { className: "font-medium text-foreground truncate flex items-center gap-1.5", children: [
582
619
  /* @__PURE__ */ r("span", { children: [
@@ -591,23 +628,23 @@ function _t() {
591
628
  ] })
592
629
  ] }),
593
630
  /* @__PURE__ */ r("div", { className: "text-[10px] text-muted-foreground/70 truncate flex items-center gap-1", children: [
594
- m.filter((f) => {
595
- const L = s.user_info?.metadata?.[f.key];
631
+ c.filter((x) => {
632
+ const L = s.user_info?.metadata?.[x.key];
596
633
  return L != null && L !== "";
597
- }).map((f, L) => {
598
- const z = s.user_info?.metadata?.[f.key];
599
- let K = String(z);
600
- if (f.type === "select") {
601
- const de = f.options?.find((o) => String(o.value) === String(z));
602
- de && (K = t(de.label));
603
- } else f.type === "checkbox" && (K = z ? "✓" : "✗");
634
+ }).map((x, L) => {
635
+ const T = s.user_info?.metadata?.[x.key];
636
+ let Q = String(T);
637
+ if (x.type === "select") {
638
+ const fe = x.options?.find((o) => String(o.value) === String(T));
639
+ fe && (Q = t(fe.label));
640
+ } else x.type === "checkbox" && (Q = T ? "✓" : "✗");
604
641
  return /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
605
642
  L > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
606
- K
607
- ] }, f.key);
643
+ Q
644
+ ] }, x.key);
608
645
  }),
609
- s.user_info.metadata?.values !== void 0 && !m.some((f) => f.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
610
- m.some((f) => s.user_info?.metadata?.[f.key] !== void 0) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
646
+ s.user_info.metadata?.values !== void 0 && !c.some((x) => x.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
647
+ c.some((x) => s.user_info?.metadata?.[x.key] !== void 0) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
611
648
  String(s.user_info.metadata.values)
612
649
  ] })
613
650
  ] })
@@ -615,46 +652,66 @@ function _t() {
615
652
  }
616
653
  ),
617
654
  s.metadata?.usage && /* @__PURE__ */ r("div", { className: "flex gap-2 mt-2 pt-2 border-border/30", children: [
618
- /* @__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(U) }) }),
619
- /* @__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(U) }) })
655
+ /* @__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", {
656
+ value: (s.metadata.usage.cumulative_input_tokens ?? s.metadata.usage.input_tokens ?? 0).toLocaleString(I)
657
+ }) }),
658
+ /* @__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(I) }) }),
659
+ /* @__PURE__ */ e(
660
+ "span",
661
+ {
662
+ className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground",
663
+ title: s.metadata.usage.cost_incomplete || s.metadata.usage.total_cost_microunits === void 0 ? void 0 : $e(
664
+ s.metadata.usage.total_cost_microunits || 0,
665
+ s.metadata.usage.currency || "USD",
666
+ I
667
+ ),
668
+ children: s.metadata.usage.cost_incomplete || s.metadata.usage.total_cost_microunits === void 0 ? t("chat_history.unpriced") : t("chat_history.cost", {
669
+ value: Xe(
670
+ s.metadata.usage.total_cost_microunits || 0,
671
+ s.metadata.usage.currency || "USD",
672
+ I
673
+ )
674
+ })
675
+ }
676
+ )
620
677
  ] }),
621
- /* @__PURE__ */ e("div", { className: "text-[10px] text-muted-foreground mt-1", children: l(s.created_at) })
678
+ /* @__PURE__ */ e("div", { className: "text-[10px] text-muted-foreground mt-1", children: d(s.created_at) })
622
679
  ] })
623
680
  ]
624
681
  },
625
682
  s.id
626
683
  )),
627
- A && /* @__PURE__ */ e("div", { className: "p-4 text-center text-muted-foreground text-xs", children: t("loading_more") })
684
+ $ && /* @__PURE__ */ e("div", { className: "p-4 text-center text-muted-foreground text-xs", children: t("loading_more") })
628
685
  ] })
629
686
  }
630
687
  )
631
688
  ] }),
632
689
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col", children: [
633
690
  /* @__PURE__ */ r("div", { className: "px-5 py-2.5 border-b border-border/30 flex items-center justify-between gap-4", children: [
634
- /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: v ? t("chat_history.messages_for", { title: v.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
635
- v && /* @__PURE__ */ e(
691
+ /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: b ? t("chat_history.messages_for", { title: b.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
692
+ b && /* @__PURE__ */ e(
636
693
  "button",
637
694
  {
638
- onClick: (s) => y(s, v),
695
+ onClick: (s) => N(s, b),
639
696
  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",
640
697
  title: t("sidebar.share_conversation"),
641
- children: /* @__PURE__ */ e(dt, { className: "w-4 h-4" })
698
+ children: /* @__PURE__ */ e(jt, { className: "w-4 h-4" })
642
699
  }
643
700
  )
644
701
  ] }),
645
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: v ? D ? /* @__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) => {
646
- const f = s.role === "user", L = s.role === "assistant";
702
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: b ? D ? /* @__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) => {
703
+ const x = s.role === "user", L = s.role === "assistant";
647
704
  return /* @__PURE__ */ r(
648
705
  "div",
649
706
  {
650
- className: `p-3.5 rounded-2xl transition-all relative ${f ? "bg-primary/10 ms-12 rounded-te-sm" : L ? "glass shadow-sm me-12 rounded-ts-sm" : "bg-muted/30 border border-border/50"}`,
707
+ className: `p-3.5 rounded-2xl transition-all relative ${x ? "bg-primary/10 ms-12 rounded-te-sm" : L ? "glass shadow-sm me-12 rounded-ts-sm" : "bg-muted/30 border border-border/50"}`,
651
708
  children: [
652
709
  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" ? "👍" : "👎" }) }),
653
710
  /* @__PURE__ */ r("div", { className: "flex justify-between items-center mb-1.5", children: [
654
- /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${f || L ? "text-primary" : "text-muted-foreground"}`, children: f ? v?.user_info?.name ? `${v.user_info.name} ${v.user_info.surname || ""}`.trim() : t("chat_history.user_label") : L ? t("chat_history.assistant_label") : `${s.role}` }),
655
- /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: l(s.created_at) })
711
+ /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${x || L ? "text-primary" : "text-muted-foreground"}`, children: x ? b?.user_info?.name ? `${b.user_info.name} ${b.user_info.surname || ""}`.trim() : t("chat_history.user_label") : L ? t("chat_history.assistant_label") : `${s.role}` }),
712
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: d(s.created_at) })
656
713
  ] }),
657
- /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: s.parts && s.parts.length > 0 ? s.parts.map((z, K) => S(z, K)) : 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 })
714
+ /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: s.parts && s.parts.length > 0 ? s.parts.map((T, Q) => M(T, Q)) : 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 })
658
715
  ]
659
716
  },
660
717
  s.id
@@ -667,96 +724,96 @@ function _t() {
667
724
  ] })
668
725
  ] });
669
726
  }
670
- function wt() {
671
- const { t, i18n: n } = te(["admin", "translation"]), [i, m] = b([]), [x, u] = b(!1), [v, _] = b(""), [N, P] = b(!1), [D, T] = b(null), [A, F] = b([]), [q, I] = b(null), H = n.language === "fa", [w, M] = b({
727
+ function Wt() {
728
+ const { t, i18n: n } = me(["admin", "translation"]), [i, c] = p([]), [f, u] = p(!1), [b, w] = p(""), [_, V] = p(!1), [D, j] = p(null), [$, O] = p([]), [S, E] = p(null), H = n.language === "fa", [C, U] = p({
672
729
  username: "",
673
730
  password: "",
674
731
  name: "",
675
732
  permissions: []
676
- }), J = async () => {
677
- u(!0), _("");
733
+ }), B = async () => {
734
+ u(!0), w("");
678
735
  try {
679
- const c = await k.listAdmins();
680
- m(c.admins || []);
681
- const y = localStorage.getItem("admin_info");
682
- y && I(JSON.parse(y).admin_id);
683
- } catch (c) {
684
- _(c instanceof Error ? c.message : t("error_loading"));
736
+ const m = await k.listAdmins();
737
+ c(m.admins || []);
738
+ const N = localStorage.getItem("admin_info");
739
+ N && E(JSON.parse(N).admin_id);
740
+ } catch (m) {
741
+ w(m instanceof Error ? m.message : t("error_loading"));
685
742
  } finally {
686
743
  u(!1);
687
744
  }
688
- }, E = async () => {
745
+ }, G = async () => {
689
746
  try {
690
- const c = await k.listPermissions();
691
- F(c.permissions);
692
- } catch (c) {
693
- console.error("Failed to load permissions", c);
747
+ const m = await k.listPermissions();
748
+ O(m.permissions);
749
+ } catch (m) {
750
+ console.error("Failed to load permissions", m);
694
751
  }
695
752
  };
696
- Q(() => {
697
- J(), E();
753
+ Y(() => {
754
+ B(), G();
698
755
  }, []);
699
- const W = async (c) => {
700
- c.preventDefault(), u(!0);
756
+ const F = async (m) => {
757
+ m.preventDefault(), u(!0);
701
758
  try {
702
759
  await k.register(
703
- w.username,
704
- w.password,
705
- w.name,
706
- w.permissions
707
- ), P(!1), M({ username: "", password: "", name: "", permissions: [] }), J();
708
- } catch (y) {
709
- _(y instanceof Error ? y.message : t("error_loading"));
760
+ C.username,
761
+ C.password,
762
+ C.name,
763
+ C.permissions
764
+ ), V(!1), U({ username: "", password: "", name: "", permissions: [] }), B();
765
+ } catch (N) {
766
+ w(N instanceof Error ? N.message : t("error_loading"));
710
767
  } finally {
711
768
  u(!1);
712
769
  }
713
- }, Y = async (c) => {
714
- if (c.preventDefault(), !!D) {
770
+ }, ae = async (m) => {
771
+ if (m.preventDefault(), !!D) {
715
772
  u(!0);
716
773
  try {
717
- const y = {
718
- name: w.name,
719
- permissions: w.permissions
774
+ const N = {
775
+ name: C.name,
776
+ permissions: C.permissions
720
777
  };
721
- if (w.password && (y.password = w.password), await k.updateAdmin(D.id, y), D.id === q) {
722
- const l = localStorage.getItem("admin_info");
723
- if (l) {
724
- const g = JSON.parse(l);
725
- g.name = w.name, g.permissions = w.permissions, localStorage.setItem("admin_info", JSON.stringify(g)), window.location.reload();
778
+ if (C.password && (N.password = C.password), await k.updateAdmin(D.id, N), D.id === S) {
779
+ const d = localStorage.getItem("admin_info");
780
+ if (d) {
781
+ const g = JSON.parse(d);
782
+ g.name = C.name, g.permissions = C.permissions, localStorage.setItem("admin_info", JSON.stringify(g)), window.location.reload();
726
783
  return;
727
784
  }
728
785
  }
729
- T(null), M({ username: "", password: "", name: "", permissions: [] }), J();
730
- } catch (y) {
731
- _(y instanceof Error ? y.message : t("error_loading"));
786
+ j(null), U({ username: "", password: "", name: "", permissions: [] }), B();
787
+ } catch (N) {
788
+ w(N instanceof Error ? N.message : t("error_loading"));
732
789
  } finally {
733
790
  u(!1);
734
791
  }
735
792
  }
736
- }, G = async (c) => {
793
+ }, K = async (m) => {
737
794
  if (confirm(t("admins.confirm_delete_admin")))
738
795
  try {
739
- await k.deleteAdmin(c), J();
740
- } catch (y) {
741
- _(y instanceof Error ? y.message : t("error_loading"));
796
+ await k.deleteAdmin(m), B();
797
+ } catch (N) {
798
+ w(N instanceof Error ? N.message : t("error_loading"));
742
799
  }
743
- }, h = (c) => {
744
- T(c), M({
745
- username: c.username,
800
+ }, h = (m) => {
801
+ j(m), U({
802
+ username: m.username,
746
803
  password: "",
747
- name: c.name,
748
- permissions: c.permissions
749
- }), P(!0);
750
- }, U = (c) => {
751
- M((y) => ({
752
- ...y,
753
- permissions: y.permissions.includes(c) ? y.permissions.filter((l) => l !== c) : [...y.permissions, c]
804
+ name: m.name,
805
+ permissions: m.permissions
806
+ }), V(!0);
807
+ }, I = (m) => {
808
+ U((N) => ({
809
+ ...N,
810
+ permissions: N.permissions.includes(m) ? N.permissions.filter((d) => d !== m) : [...N.permissions, m]
754
811
  }));
755
- }, d = (c) => {
756
- const y = `admins.perm_${c}`, l = t(y);
757
- if (l !== y)
758
- return l;
759
- switch (c) {
812
+ }, l = (m) => {
813
+ const N = `admins.perm_${m}`, d = t(N);
814
+ if (d !== N)
815
+ return d;
816
+ switch (m) {
760
817
  case "chat_history":
761
818
  return t("admins.perm_chat_history");
762
819
  case "admin_management":
@@ -768,7 +825,7 @@ function wt() {
768
825
  case "settings":
769
826
  return t("admins.perm_settings");
770
827
  default:
771
- return c;
828
+ return m;
772
829
  }
773
830
  };
774
831
  return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: H ? "rtl" : "ltr", children: [
@@ -780,7 +837,7 @@ function wt() {
780
837
  "button",
781
838
  {
782
839
  onClick: () => {
783
- T(null), M({ username: "", password: "", name: "", permissions: [] }), P(!0);
840
+ j(null), U({ username: "", password: "", name: "", permissions: [] }), V(!0);
784
841
  },
785
842
  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",
786
843
  children: t("admins.add_admin")
@@ -788,10 +845,10 @@ function wt() {
788
845
  )
789
846
  ] })
790
847
  ] }),
791
- v && /* @__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: v }),
792
- 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: [
848
+ b && /* @__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: b }),
849
+ _ && /* @__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: [
793
850
  /* @__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(D ? "admins.edit_admin" : "admins.add_admin") }) }),
794
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: D ? Y : W, className: "space-y-5", children: [
851
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: D ? ae : F, className: "space-y-5", children: [
795
852
  /* @__PURE__ */ r("div", { children: [
796
853
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("admins.username") }),
797
854
  /* @__PURE__ */ e(
@@ -799,8 +856,8 @@ function wt() {
799
856
  {
800
857
  type: "text",
801
858
  disabled: !!D,
802
- value: w.username,
803
- onChange: (c) => M({ ...w, username: c.target.value }),
859
+ value: C.username,
860
+ onChange: (m) => U({ ...C, username: m.target.value }),
804
861
  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",
805
862
  required: !0,
806
863
  dir: "ltr"
@@ -813,8 +870,8 @@ function wt() {
813
870
  "input",
814
871
  {
815
872
  type: "text",
816
- value: w.name,
817
- onChange: (c) => M({ ...w, name: c.target.value }),
873
+ value: C.name,
874
+ onChange: (m) => U({ ...C, name: m.target.value }),
818
875
  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",
819
876
  required: !0
820
877
  }
@@ -826,8 +883,8 @@ function wt() {
826
883
  "input",
827
884
  {
828
885
  type: "password",
829
- value: w.password,
830
- onChange: (c) => M({ ...w, password: c.target.value }),
886
+ value: C.password,
887
+ onChange: (m) => U({ ...C, password: m.target.value }),
831
888
  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",
832
889
  required: !D,
833
890
  dir: "ltr"
@@ -836,26 +893,26 @@ function wt() {
836
893
  ] }),
837
894
  /* @__PURE__ */ r("div", { children: [
838
895
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("admins.permissions") }),
839
- /* @__PURE__ */ e("div", { className: "space-y-3 p-4 bg-muted/30 rounded-xl border border-border", children: A.map((c) => /* @__PURE__ */ r("label", { className: "flex items-center gap-3 cursor-pointer group", children: [
896
+ /* @__PURE__ */ e("div", { className: "space-y-3 p-4 bg-muted/30 rounded-xl border border-border", children: $.map((m) => /* @__PURE__ */ r("label", { className: "flex items-center gap-3 cursor-pointer group", children: [
840
897
  /* @__PURE__ */ e("div", { className: "relative flex items-center", children: /* @__PURE__ */ e(
841
898
  "input",
842
899
  {
843
900
  type: "checkbox",
844
- checked: w.permissions.includes(c),
845
- onChange: () => U(c),
846
- disabled: w.username === "admin" && c === "admin_management",
901
+ checked: C.permissions.includes(m),
902
+ onChange: () => I(m),
903
+ disabled: C.username === "admin" && m === "admin_management",
847
904
  className: "peer h-4 w-4 rounded border-input text-primary focus:ring-ring transition-all disabled:opacity-50"
848
905
  }
849
906
  ) }),
850
- /* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: d(c) })
851
- ] }, c)) })
907
+ /* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: l(m) })
908
+ ] }, m)) })
852
909
  ] }),
853
910
  /* @__PURE__ */ r("div", { className: "flex gap-3 pt-4", children: [
854
911
  /* @__PURE__ */ e(
855
912
  "button",
856
913
  {
857
914
  type: "button",
858
- onClick: () => P(!1),
915
+ onClick: () => V(!1),
859
916
  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",
860
917
  children: t("cancel")
861
918
  }
@@ -864,9 +921,9 @@ function wt() {
864
921
  "button",
865
922
  {
866
923
  type: "submit",
867
- disabled: x,
924
+ disabled: f,
868
925
  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",
869
- children: t(x ? "saving" : "save")
926
+ children: t(f ? "saving" : "save")
870
927
  }
871
928
  )
872
929
  ] })
@@ -880,46 +937,68 @@ function wt() {
880
937
  /* @__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") }),
881
938
  /* @__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") })
882
939
  ] }) }),
883
- /* @__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: [
884
- /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: c.name }),
885
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children: c.username }),
886
- /* @__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((y) => /* @__PURE__ */ e("span", { className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50", children: d(y) }, y)) }) }),
940
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: i.map((m) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
941
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: m.name }),
942
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children: m.username }),
943
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: m.permissions.map((N) => /* @__PURE__ */ e("span", { className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50", children: l(N) }, N)) }) }),
887
944
  /* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
888
945
  /* @__PURE__ */ e(
889
946
  "button",
890
947
  {
891
- onClick: () => h(c),
948
+ onClick: () => h(m),
892
949
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
893
950
  title: t("edit"),
894
951
  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" }) })
895
952
  }
896
953
  ),
897
- c.id !== q && /* @__PURE__ */ e(
954
+ m.id !== S && /* @__PURE__ */ e(
898
955
  "button",
899
956
  {
900
- onClick: () => G(c.id),
957
+ onClick: () => K(m.id),
901
958
  className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
902
959
  title: t("delete"),
903
960
  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" }) })
904
961
  }
905
962
  )
906
963
  ] }) })
907
- ] }, c.id)) })
964
+ ] }, m.id)) })
908
965
  ] }),
909
- i.length === 0 && !x && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
966
+ 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: [
910
967
  /* @__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" }) }),
911
968
  t("admins.no_admins")
912
969
  ] }),
913
- x && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
970
+ f && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
914
971
  /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
915
972
  /* @__PURE__ */ e("span", { children: t("loading") })
916
973
  ] })
917
974
  ] }) })
918
975
  ] });
919
976
  }
920
- const kt = (t) => t.replace(/[^0-9]/g, "");
921
- function St() {
922
- const { t, i18n: n } = te(["admin", "translation"]), { app: i } = pe(), [m, x] = b([]), [u, v] = b(!1), [_, N] = b(""), [P, D] = b(!1), [T, A] = b(null), [F, q] = b(""), [I, H] = b(0), [w, M] = b(null), J = xe(() => i?.userMetadataFields || [], [i?.userMetadataFields]), [E, W] = b(null), [Y, G] = b(""), [h, U] = b(""), [d, c] = b(""), [y, l] = b(""), g = n.language === "fa", R = g ? "text-right" : "text-left", [p, S] = b({
977
+ function re({ className: t, ...n }) {
978
+ return /* @__PURE__ */ e(
979
+ Ve.Root,
980
+ {
981
+ "data-slot": "switch",
982
+ className: je(
983
+ "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
984
+ t
985
+ ),
986
+ ...n,
987
+ children: /* @__PURE__ */ e(
988
+ Ve.Thumb,
989
+ {
990
+ "data-slot": "switch-thumb",
991
+ className: je(
992
+ "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] rtl:data-[state=checked]:-translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
993
+ )
994
+ }
995
+ )
996
+ }
997
+ );
998
+ }
999
+ const Gt = (t) => t.replace(/[^0-9]/g, ""), Kt = 25;
1000
+ function Zt() {
1001
+ const { t, i18n: n } = me(["admin", "translation"]), { app: i } = _e(), [c, f] = p([]), [u, b] = p(!1), [w, _] = p(""), [V, D] = p(!1), [j, $] = p(null), [O, S] = p(""), [E, H] = p(0), [C, U] = p("name"), [B, G] = p("asc"), [F, ae] = p(null), K = Ce(0), h = Ce(!1), I = Se(() => i?.userMetadataFields || [], [i?.userMetadataFields]), [l, m] = p(null), [N, d] = p(""), [g, R] = p(""), [P, M] = p(""), [W, s] = p(""), [x, L] = p(null), [T, Q] = p(null), [fe, o] = p(!1), q = n.language === "fa", z = q ? "fa-IR" : "en-US", ie = q ? "text-right" : "text-left", [v, te] = p({
923
1002
  phone: "",
924
1003
  name: "",
925
1004
  surname: "",
@@ -927,184 +1006,231 @@ function St() {
927
1006
  requests: "",
928
1007
  tokensLimit: "",
929
1008
  requestsLimit: "",
930
- metadata: ""
1009
+ metadata: "",
931
1010
  // Keep raw JSON for advanced users
932
- }), [O, s] = b({}), f = async () => {
933
- v(!0), N("");
1011
+ rechargeEnabled: !1,
1012
+ rechargeIntervalValue: "1",
1013
+ rechargeIntervalUnit: "month",
1014
+ rechargeAnchorAt: ""
1015
+ }), [se, xe] = p({}), we = async (a = !1, y = O, A = C, J = B) => {
1016
+ if (h.current) return;
1017
+ h.current = !0;
1018
+ const ee = ++K.current;
1019
+ b(!0), _("");
934
1020
  try {
935
- const a = await k.listUsers(0, 100, F);
936
- x(a.users || []), H(a.count || 0);
937
- } catch (a) {
938
- N(a instanceof Error ? a.message : t("error_loading"));
1021
+ const ne = await k.listUsers(
1022
+ a ? c.length : 0,
1023
+ Kt,
1024
+ y,
1025
+ A,
1026
+ J
1027
+ );
1028
+ if (ee !== K.current) return;
1029
+ f((be) => a ? [...be, ...ne.users || []] : ne.users || []), H(ne.count || 0);
1030
+ } catch (ne) {
1031
+ if (ee !== K.current) return;
1032
+ _(ne instanceof Error ? ne.message : t("error_loading"));
939
1033
  } finally {
940
- v(!1);
1034
+ ee === K.current && (b(!1), h.current = !1);
941
1035
  }
942
- }, L = async () => {
1036
+ }, Ye = async () => {
943
1037
  try {
944
1038
  const a = await k.getSettings();
945
- M(a);
1039
+ ae(a);
946
1040
  } catch (a) {
947
1041
  console.error("Failed to load app settings", a);
948
1042
  }
949
1043
  };
950
- Q(() => {
951
- L();
952
- }, []), Q(() => {
953
- w && !T && !p.tokens && !p.requests && S((a) => ({
1044
+ Y(() => {
1045
+ Ye();
1046
+ }, []), Y(() => {
1047
+ F && !j && !v.tokens && !v.requests && te((a) => ({
954
1048
  ...a,
955
- tokens: w.initial_balance_tokens?.toString() || "",
956
- requests: w.initial_balance_requests?.toString() || "",
957
- tokensLimit: w.initial_balance_tokens?.toString() || "",
958
- requestsLimit: w.initial_balance_requests?.toString() || ""
1049
+ tokens: F.initial_balance_tokens?.toString() || "",
1050
+ requests: F.initial_balance_requests?.toString() || "",
1051
+ tokensLimit: F.initial_balance_tokens?.toString() || "",
1052
+ requestsLimit: F.initial_balance_requests?.toString() || ""
959
1053
  }));
960
- }, [w]), Q(() => {
1054
+ }, [F]), Y(() => {
1055
+ K.current += 1, h.current = !1, f([]), H(0), b(!0);
961
1056
  const a = setTimeout(() => {
962
- f();
1057
+ we(!1, O, C, B);
963
1058
  }, 500);
964
- return () => clearTimeout(a);
965
- }, [F]), Q(() => {
1059
+ return () => {
1060
+ clearTimeout(a), K.current += 1, h.current = !1;
1061
+ };
1062
+ }, [O, C, B]);
1063
+ const et = (a) => {
1064
+ C === a ? G((y) => y === "asc" ? "desc" : "asc") : (U(a), G("asc"));
1065
+ }, tt = (a) => C !== a ? /* @__PURE__ */ e(Tt, { className: "w-3.5 h-3.5 opacity-50" }) : B === "asc" ? /* @__PURE__ */ e(It, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ e(Mt, { className: "w-3.5 h-3.5" });
1066
+ Y(() => {
966
1067
  try {
967
- const C = { ...p.metadata ? JSON.parse(p.metadata) : {}, ...O }, $ = JSON.stringify(C, null, 2);
968
- $ !== p.metadata && S((X) => ({ ...X, metadata: $ }));
1068
+ const y = { ...v.metadata ? JSON.parse(v.metadata) : {}, ...se }, A = JSON.stringify(y, null, 2);
1069
+ A !== v.metadata && te((J) => ({ ...J, metadata: A }));
969
1070
  } catch {
970
1071
  }
971
- }, [O]), Q(() => {
972
- const a = { ...O };
973
- let C = !1;
974
- J.forEach(($) => {
975
- $.condition && !qe($.condition, O) && a[$.key] !== void 0 && (delete a[$.key], C = !0);
976
- }), C && s(a);
977
- }, [O, J]);
978
- const z = async (a) => {
1072
+ }, [se]), Y(() => {
1073
+ const a = { ...se };
1074
+ let y = !1;
1075
+ I.forEach((A) => {
1076
+ A.condition && !Oe(A.condition, se) && a[A.key] !== void 0 && (delete a[A.key], y = !0);
1077
+ }), y && xe(a);
1078
+ }, [se, I]);
1079
+ const rt = async (a) => {
979
1080
  a.preventDefault();
980
- const C = p.tokens ? parseInt(p.tokens) : 0, $ = p.requests ? parseInt(p.requests) : 0, X = p.tokensLimit ? parseInt(p.tokensLimit) : C, re = p.requestsLimit ? parseInt(p.requestsLimit) : $;
981
- if (C > X) {
982
- N(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1081
+ const y = v.tokens ? parseInt(v.tokens) : 0, A = v.requests ? parseInt(v.requests) : 0, J = v.tokensLimit ? parseInt(v.tokensLimit) : y, ee = v.requestsLimit ? parseInt(v.requestsLimit) : A;
1082
+ if (y > J) {
1083
+ _(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
983
1084
  return;
984
1085
  }
985
- if ($ > re) {
986
- N(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1086
+ if (A > ee) {
1087
+ _(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
987
1088
  return;
988
1089
  }
989
- let be = {};
990
- if (p.metadata)
1090
+ let ne = {};
1091
+ if (v.metadata)
991
1092
  try {
992
- be = JSON.parse(p.metadata);
1093
+ ne = JSON.parse(v.metadata);
993
1094
  } catch {
994
- N(t("users.invalid_json", "Invalid JSON format"));
1095
+ _(t("users.invalid_json", "Invalid JSON format"));
995
1096
  return;
996
1097
  }
997
- v(!0);
998
- try {
999
- await k.createUser(
1000
- p.phone,
1001
- p.name,
1002
- p.surname,
1003
- p.tokens ? parseInt(p.tokens) : void 0,
1004
- p.requests ? parseInt(p.requests) : void 0,
1005
- p.tokensLimit ? parseInt(p.tokensLimit) : void 0,
1006
- p.requestsLimit ? parseInt(p.requestsLimit) : void 0,
1007
- be
1008
- ), D(!1), de(), f();
1009
- } catch (ve) {
1010
- N(ve instanceof Error ? ve.message : t("error_loading"));
1011
- } finally {
1012
- v(!1);
1098
+ const be = Ee();
1099
+ if (be) {
1100
+ b(!0);
1101
+ try {
1102
+ await k.createUser(
1103
+ v.phone,
1104
+ v.name,
1105
+ v.surname,
1106
+ v.tokens ? parseInt(v.tokens) : void 0,
1107
+ v.requests ? parseInt(v.requests) : void 0,
1108
+ v.tokensLimit ? parseInt(v.tokensLimit) : void 0,
1109
+ v.requestsLimit ? parseInt(v.requestsLimit) : void 0,
1110
+ ne,
1111
+ be
1112
+ ), D(!1), Le(), we();
1113
+ } catch (ve) {
1114
+ _(ve instanceof Error ? ve.message : t("error_loading"));
1115
+ } finally {
1116
+ b(!1);
1117
+ }
1013
1118
  }
1014
- }, K = async (a) => {
1015
- if (a.preventDefault(), !T) return;
1016
- let C = {};
1017
- if (p.metadata)
1119
+ }, at = async (a) => {
1120
+ if (a.preventDefault(), !j) return;
1121
+ let y = {};
1122
+ if (v.metadata)
1018
1123
  try {
1019
- C = JSON.parse(p.metadata);
1124
+ y = JSON.parse(v.metadata);
1020
1125
  } catch {
1021
- N(t("users.invalid_json", "Invalid JSON format"));
1126
+ _(t("users.invalid_json", "Invalid JSON format"));
1022
1127
  return;
1023
1128
  }
1024
- v(!0);
1025
- try {
1026
- await k.updateUser(T.id, {
1027
- phone: p.phone,
1028
- name: p.name,
1029
- surname: p.surname,
1030
- metadata: C
1031
- }), A(null), D(!1), de(), f();
1032
- } catch ($) {
1033
- N($ instanceof Error ? $.message : t("error_loading"));
1034
- } finally {
1035
- v(!1);
1129
+ const A = Ee();
1130
+ if (A) {
1131
+ b(!0);
1132
+ try {
1133
+ const J = await k.updateUser(j.id, {
1134
+ phone: v.phone,
1135
+ name: v.name,
1136
+ surname: v.surname,
1137
+ metadata: y,
1138
+ recharge_policy: A
1139
+ }), ee = J.user.recharge_policy;
1140
+ if (!(ee?.enabled === A.enabled && (!A.enabled || ee.interval_value === A.interval_value && ee.interval_unit === A.interval_unit)))
1141
+ throw new Error(t("users.recharge_policy_not_saved"));
1142
+ K.current += 1, h.current = !1, f((be) => be.map((ve) => ve.id === J.user.id ? J.user : ve)), $(null), D(!1), Le();
1143
+ } catch (J) {
1144
+ _(J instanceof Error ? J.message : t("error_loading"));
1145
+ } finally {
1146
+ b(!1);
1147
+ }
1036
1148
  }
1037
- }, de = () => {
1038
- S({
1149
+ }, Le = () => {
1150
+ te({
1039
1151
  phone: "",
1040
1152
  name: "",
1041
1153
  surname: "",
1042
- tokens: w?.initial_balance_tokens?.toString() || "",
1043
- requests: w?.initial_balance_requests?.toString() || "",
1044
- tokensLimit: w?.initial_balance_tokens?.toString() || "",
1045
- requestsLimit: w?.initial_balance_requests?.toString() || "",
1046
- metadata: ""
1047
- }), s({});
1048
- }, o = async (a) => {
1154
+ tokens: F?.initial_balance_tokens?.toString() || "",
1155
+ requests: F?.initial_balance_requests?.toString() || "",
1156
+ tokensLimit: F?.initial_balance_tokens?.toString() || "",
1157
+ requestsLimit: F?.initial_balance_requests?.toString() || "",
1158
+ metadata: "",
1159
+ rechargeEnabled: !1,
1160
+ rechargeIntervalValue: "1",
1161
+ rechargeIntervalUnit: "month",
1162
+ rechargeAnchorAt: ""
1163
+ }), xe({});
1164
+ }, st = async (a) => {
1049
1165
  if (confirm(t("users.confirm_delete_user")))
1050
1166
  try {
1051
- await k.deleteUser(a), f();
1052
- } catch (C) {
1053
- N(C instanceof Error ? C.message : t("error_loading"));
1167
+ await k.deleteUser(a), we();
1168
+ } catch (y) {
1169
+ _(y instanceof Error ? y.message : t("error_loading"));
1054
1170
  }
1055
- }, j = async (a) => {
1171
+ }, Ee = () => {
1172
+ if (!v.rechargeEnabled)
1173
+ return { enabled: !1 };
1174
+ const a = Number(v.rechargeIntervalValue);
1175
+ return !Number.isInteger(a) || a <= 0 ? (_(t("users.recharge_interval_invalid")), null) : {
1176
+ enabled: !0,
1177
+ interval_value: a,
1178
+ interval_unit: v.rechargeIntervalUnit,
1179
+ anchor_at: v.rechargeAnchorAt || (/* @__PURE__ */ new Date()).toISOString()
1180
+ };
1181
+ }, nt = async (a) => {
1056
1182
  try {
1057
- const $ = (await k.refreshUserToken(a.id))?.user?.token;
1058
- if (!$) {
1059
- N(t("users.no_token"));
1183
+ const A = (await k.refreshUserToken(a.id))?.user?.token;
1184
+ if (!A) {
1185
+ _(t("users.no_token"));
1060
1186
  return;
1061
1187
  }
1062
- await navigator.clipboard.writeText($), alert(t("users.token_copied"));
1063
- } catch (C) {
1064
- N(C instanceof Error ? C.message : t("error_loading"));
1188
+ await navigator.clipboard.writeText(A), alert(t("users.token_copied"));
1189
+ } catch (y) {
1190
+ _(y instanceof Error ? y.message : t("error_loading"));
1065
1191
  }
1066
- }, V = async (a, C, $, X) => {
1067
- if (E) {
1068
- v(!0);
1192
+ }, it = async (a, y, A, J) => {
1193
+ if (l) {
1194
+ b(!0);
1069
1195
  try {
1070
1196
  await k.updateUserBalance(
1071
- E.id,
1197
+ l.id,
1072
1198
  a,
1073
- C,
1074
- $,
1075
- X
1076
- ), W(null), G(""), U(""), c(""), l(""), f();
1077
- } catch (re) {
1078
- N(re instanceof Error ? re.message : t("error_loading"));
1199
+ y,
1200
+ A,
1201
+ J
1202
+ ), m(null), d(""), R(""), M(""), s(""), we();
1203
+ } catch (ee) {
1204
+ _(ee instanceof Error ? ee.message : t("error_loading"));
1079
1205
  } finally {
1080
- v(!1);
1206
+ b(!1);
1081
1207
  }
1082
1208
  }
1083
- }, ce = async (a) => {
1084
- if (a.preventDefault(), !E) return;
1085
- const C = parseInt(Y) || 0, $ = parseInt(h) || 0, X = d ? parseInt(d) : E.balance?.token_limit || 0, re = y ? parseInt(y) : E.balance?.request_limit || 0;
1086
- if (C > X) {
1087
- N(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1209
+ }, ot = async (a) => {
1210
+ if (a.preventDefault(), !l) return;
1211
+ const y = parseInt(N) || 0, A = parseInt(g) || 0, J = P ? parseInt(P) : l.balance?.token_limit || 0, ee = W ? parseInt(W) : l.balance?.request_limit || 0;
1212
+ if (y > J) {
1213
+ _(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1088
1214
  return;
1089
1215
  }
1090
- if ($ > re) {
1091
- N(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1216
+ if (A > ee) {
1217
+ _(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1092
1218
  return;
1093
1219
  }
1094
- await V(
1095
- C,
1096
- $,
1097
- d ? parseInt(d) : void 0,
1098
- y ? parseInt(y) : void 0
1220
+ await it(
1221
+ y,
1222
+ A,
1223
+ P ? parseInt(P) : void 0,
1224
+ W ? parseInt(W) : void 0
1099
1225
  );
1100
- }, Re = () => {
1101
- if (!E) return;
1102
- const a = d || String(E.balance?.token_limit || 0), C = y || String(E.balance?.request_limit || 0);
1103
- G(a), U(C);
1104
- }, Fe = (a) => {
1105
- A(a);
1106
- const C = a.metadata ? JSON.stringify(a.metadata, null, 2) : "";
1107
- if (S({
1226
+ }, lt = () => {
1227
+ if (!l) return;
1228
+ const a = P || String(l.balance?.token_limit || 0), y = W || String(l.balance?.request_limit || 0);
1229
+ d(a), R(y);
1230
+ }, dt = (a) => {
1231
+ $(a);
1232
+ const y = a.metadata ? JSON.stringify(a.metadata, null, 2) : "";
1233
+ if (te({
1108
1234
  phone: a.phone,
1109
1235
  name: a.name,
1110
1236
  surname: a.surname,
@@ -1112,16 +1238,29 @@ function St() {
1112
1238
  requests: "",
1113
1239
  tokensLimit: "",
1114
1240
  requestsLimit: "",
1115
- metadata: C
1241
+ metadata: y,
1242
+ rechargeEnabled: a.recharge_policy?.enabled ?? !1,
1243
+ rechargeIntervalValue: String(a.recharge_policy?.interval_value ?? 1),
1244
+ rechargeIntervalUnit: a.recharge_policy?.interval_unit ?? "month",
1245
+ rechargeAnchorAt: a.recharge_policy?.anchor_at ?? ""
1116
1246
  }), a.metadata) {
1117
- const $ = {};
1118
- J.forEach((X) => {
1119
- a.metadata?.[X.key] !== void 0 ? $[X.key] = a.metadata[X.key] : X.defaultValue !== void 0 && ($[X.key] = X.defaultValue);
1120
- }), s($);
1247
+ const A = {};
1248
+ I.forEach((J) => {
1249
+ a.metadata?.[J.key] !== void 0 ? A[J.key] = a.metadata[J.key] : J.defaultValue !== void 0 && (A[J.key] = J.defaultValue);
1250
+ }), xe(A);
1121
1251
  }
1122
1252
  D(!0);
1253
+ }, ct = async (a) => {
1254
+ L(a), Q(null), o(!0);
1255
+ try {
1256
+ Q(await k.getUserUsageSummary(a.id));
1257
+ } catch (y) {
1258
+ _(y instanceof Error ? y.message : t("error_loading")), L(null);
1259
+ } finally {
1260
+ o(!1);
1261
+ }
1123
1262
  };
1124
- return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: g ? "rtl" : "ltr", children: [
1263
+ return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: q ? "rtl" : "ltr", children: [
1125
1264
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
1126
1265
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("users.title") }),
1127
1266
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row items-center gap-2 flex-1 max-w-4xl justify-end", children: [
@@ -1129,19 +1268,19 @@ function St() {
1129
1268
  "input",
1130
1269
  {
1131
1270
  type: "text",
1132
- value: F,
1133
- onChange: (a) => q(a.target.value),
1271
+ value: O,
1272
+ onChange: (a) => S(a.target.value),
1134
1273
  placeholder: t("chat_history.search_placeholder"),
1135
1274
  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"
1136
1275
  }
1137
1276
  ) }),
1138
1277
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 shrink-0", children: [
1139
- /* @__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: I }) }),
1278
+ /* @__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: E }) }),
1140
1279
  /* @__PURE__ */ e(
1141
1280
  "button",
1142
1281
  {
1143
1282
  onClick: () => {
1144
- A(null), de(), D(!0);
1283
+ $(null), Le(), D(!0);
1145
1284
  },
1146
1285
  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",
1147
1286
  children: t("users.add_user")
@@ -1150,13 +1289,41 @@ function St() {
1150
1289
  ] })
1151
1290
  ] })
1152
1291
  ] }),
1153
- _ && /* @__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: [
1154
- /* @__PURE__ */ e("span", { children: _ }),
1155
- /* @__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" }) }) })
1292
+ /* @__PURE__ */ e(We, { open: !!x, onOpenChange: (a) => !a && L(null), children: /* @__PURE__ */ r(Ge, { children: [
1293
+ /* @__PURE__ */ r(Ke, { children: [
1294
+ /* @__PURE__ */ e(Ze, { children: t("users.usage_summary") }),
1295
+ /* @__PURE__ */ e(Qe, { children: x ? `${x.name} ${x.surname}` : "" })
1296
+ ] }),
1297
+ fe ? /* @__PURE__ */ e("div", { className: "py-10 flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }) }) : T ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [
1298
+ [t("users.input_tokens"), T.input_tokens.toLocaleString(z)],
1299
+ [t("users.output_tokens"), T.output_tokens.toLocaleString(z)],
1300
+ [t("users.total_tokens"), T.total_tokens.toLocaleString(z)],
1301
+ [t("users.requests_made"), T.requests.toLocaleString(z)],
1302
+ [
1303
+ t("users.total_cost"),
1304
+ $e(
1305
+ T.total_cost_microunits,
1306
+ T.currency,
1307
+ z
1308
+ )
1309
+ ],
1310
+ [t("users.renewals"), T.renewal_count.toLocaleString(z)],
1311
+ [
1312
+ t("users.unpriced_requests"),
1313
+ T.unpriced_requests.toLocaleString(z)
1314
+ ]
1315
+ ].map(([a, y]) => /* @__PURE__ */ r("div", { className: "rounded-xl border border-border bg-muted/20 p-4", children: [
1316
+ /* @__PURE__ */ e("p", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children: a }),
1317
+ /* @__PURE__ */ e("p", { className: "mt-1 text-lg font-semibold text-foreground", children: y })
1318
+ ] }, a)) }) : null
1319
+ ] }) }),
1320
+ w && /* @__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: [
1321
+ /* @__PURE__ */ e("span", { children: w }),
1322
+ /* @__PURE__ */ e("button", { onClick: () => _(""), 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" }) }) })
1156
1323
  ] }),
1157
- P && /* @__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: [
1158
- /* @__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 ? "users.edit_user" : "users.add_user") }) }),
1159
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: T ? K : z, children: [
1324
+ 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-xl shadow-2xl overflow-hidden", children: [
1325
+ /* @__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") }) }),
1326
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: j ? at : rt, children: [
1160
1327
  /* @__PURE__ */ r("div", { className: "space-y-6 max-h-[60vh] overflow-y-auto px-1 custom-scrollbar", children: [
1161
1328
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1162
1329
  /* @__PURE__ */ r("div", { children: [
@@ -1165,8 +1332,8 @@ function St() {
1165
1332
  "input",
1166
1333
  {
1167
1334
  type: "text",
1168
- value: p.phone,
1169
- onChange: (a) => S({ ...p, phone: kt(a.target.value) }),
1335
+ value: v.phone,
1336
+ onChange: (a) => te({ ...v, phone: Gt(a.target.value) }),
1170
1337
  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 text-left",
1171
1338
  placeholder: t("users.phone_placeholder"),
1172
1339
  required: !0,
@@ -1181,9 +1348,9 @@ function St() {
1181
1348
  "input",
1182
1349
  {
1183
1350
  type: "text",
1184
- value: p.name,
1185
- onChange: (a) => S({ ...p, name: a.target.value }),
1186
- 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 ${R}`,
1351
+ value: v.name,
1352
+ onChange: (a) => te({ ...v, name: a.target.value }),
1353
+ 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 ${ie}`,
1187
1354
  required: !0
1188
1355
  }
1189
1356
  )
@@ -1194,16 +1361,16 @@ function St() {
1194
1361
  "input",
1195
1362
  {
1196
1363
  type: "text",
1197
- value: p.surname,
1198
- onChange: (a) => S({ ...p, surname: a.target.value }),
1199
- 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 ${R}`,
1364
+ value: v.surname,
1365
+ onChange: (a) => te({ ...v, surname: a.target.value }),
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 ${ie}`,
1200
1367
  required: !0
1201
1368
  }
1202
1369
  )
1203
1370
  ] })
1204
1371
  ] })
1205
1372
  ] }),
1206
- !T && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1373
+ !j && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1207
1374
  /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.initial_balance") }),
1208
1375
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1209
1376
  /* @__PURE__ */ r("div", { children: [
@@ -1212,8 +1379,8 @@ function St() {
1212
1379
  "input",
1213
1380
  {
1214
1381
  type: "number",
1215
- value: p.tokens,
1216
- onChange: (a) => S({ ...p, tokens: a.target.value }),
1382
+ value: v.tokens,
1383
+ onChange: (a) => te({ ...v, tokens: a.target.value }),
1217
1384
  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 text-left",
1218
1385
  dir: "ltr",
1219
1386
  placeholder: "0"
@@ -1226,11 +1393,11 @@ function St() {
1226
1393
  "input",
1227
1394
  {
1228
1395
  type: "number",
1229
- value: p.tokensLimit,
1230
- onChange: (a) => S({ ...p, tokensLimit: a.target.value }),
1396
+ value: v.tokensLimit,
1397
+ onChange: (a) => te({ ...v, tokensLimit: a.target.value }),
1231
1398
  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 text-left",
1232
1399
  dir: "ltr",
1233
- placeholder: p.tokens || String(w?.initial_balance_tokens ?? "250000")
1400
+ placeholder: v.tokens || String(F?.initial_balance_tokens ?? "250000")
1234
1401
  }
1235
1402
  )
1236
1403
  ] })
@@ -1242,11 +1409,11 @@ function St() {
1242
1409
  "input",
1243
1410
  {
1244
1411
  type: "number",
1245
- value: p.requests,
1246
- onChange: (a) => S({ ...p, requests: a.target.value }),
1412
+ value: v.requests,
1413
+ onChange: (a) => te({ ...v, requests: a.target.value }),
1247
1414
  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 text-left",
1248
1415
  dir: "ltr",
1249
- placeholder: p.requests || String(w?.initial_balance_requests ?? "0")
1416
+ placeholder: v.requests || String(F?.initial_balance_requests ?? "0")
1250
1417
  }
1251
1418
  )
1252
1419
  ] }),
@@ -1256,43 +1423,115 @@ function St() {
1256
1423
  "input",
1257
1424
  {
1258
1425
  type: "number",
1259
- value: p.requestsLimit,
1260
- onChange: (a) => S({ ...p, requestsLimit: a.target.value }),
1426
+ value: v.requestsLimit,
1427
+ onChange: (a) => te({ ...v, requestsLimit: a.target.value }),
1261
1428
  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 text-left",
1262
1429
  dir: "ltr",
1263
- placeholder: p.requests || String(w?.initial_balance_requests ?? "100")
1430
+ placeholder: v.requests || String(F?.initial_balance_requests ?? "100")
1264
1431
  }
1265
1432
  )
1266
1433
  ] })
1267
1434
  ] })
1268
1435
  ] }),
1269
- J.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1436
+ /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1437
+ /* @__PURE__ */ r("div", { className: "flex items-start gap-4", children: [
1438
+ /* @__PURE__ */ r("div", { children: [
1439
+ /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.auto_recharge") }),
1440
+ /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-muted-foreground", children: t("users.auto_recharge_help") })
1441
+ ] }),
1442
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2 shrink-0 pt-0.5", children: [
1443
+ /* @__PURE__ */ e(
1444
+ re,
1445
+ {
1446
+ id: "admin-recharge-enabled",
1447
+ checked: v.rechargeEnabled,
1448
+ onCheckedChange: (a) => te({
1449
+ ...v,
1450
+ rechargeEnabled: a
1451
+ }),
1452
+ "aria-label": t("users.auto_recharge")
1453
+ }
1454
+ ),
1455
+ /* @__PURE__ */ e("label", { htmlFor: "admin-recharge-enabled", className: "text-sm text-foreground cursor-pointer", children: t("users.enabled") })
1456
+ ] })
1457
+ ] }),
1458
+ v.rechargeEnabled && /* @__PURE__ */ r("div", { className: "space-y-4 rounded-xl border border-border/60 bg-muted/15 p-4", children: [
1459
+ /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1460
+ /* @__PURE__ */ r("div", { children: [
1461
+ /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("users.recharge_interval") }),
1462
+ /* @__PURE__ */ e(
1463
+ "input",
1464
+ {
1465
+ type: "number",
1466
+ min: "1",
1467
+ step: "1",
1468
+ value: v.rechargeIntervalValue,
1469
+ onChange: (a) => te({ ...v, rechargeIntervalValue: a.target.value }),
1470
+ 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 text-left",
1471
+ required: !0,
1472
+ dir: "ltr"
1473
+ }
1474
+ )
1475
+ ] }),
1476
+ /* @__PURE__ */ r("div", { children: [
1477
+ /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("users.recharge_unit") }),
1478
+ /* @__PURE__ */ r(
1479
+ oe,
1480
+ {
1481
+ value: v.rechargeIntervalUnit,
1482
+ onValueChange: (a) => te({
1483
+ ...v,
1484
+ rechargeIntervalUnit: a
1485
+ }),
1486
+ dir: q ? "rtl" : "ltr",
1487
+ children: [
1488
+ /* @__PURE__ */ e(le, { className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", children: /* @__PURE__ */ e(de, {}) }),
1489
+ /* @__PURE__ */ e(ce, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((a) => /* @__PURE__ */ e(Z, { value: a, children: t(`users.recharge_unit_${a}`) }, a)) })
1490
+ ]
1491
+ }
1492
+ )
1493
+ ] })
1494
+ ] }),
1495
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: t("users.recharge_schedule_help") }),
1496
+ j?.recharge_policy?.enabled && /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs", children: [
1497
+ /* @__PURE__ */ r("div", { className: "rounded-lg bg-background/50 border border-border/50 p-3", children: [
1498
+ /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: t("users.next_recharge") }),
1499
+ /* @__PURE__ */ e("p", { className: "mt-1 font-medium text-foreground", dir: "ltr", children: j.recharge_policy.next_recharge_at ? new Date(j.recharge_policy.next_recharge_at).toLocaleString(n.language) : t("users.not_available") })
1500
+ ] }),
1501
+ /* @__PURE__ */ r("div", { className: "rounded-lg bg-background/50 border border-border/50 p-3", children: [
1502
+ /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: t("users.last_recharge") }),
1503
+ /* @__PURE__ */ e("p", { className: "mt-1 font-medium text-foreground", dir: "ltr", children: j.recharge_policy.last_recharged_at ? new Date(j.recharge_policy.last_recharged_at).toLocaleString(n.language) : t("users.not_available") })
1504
+ ] })
1505
+ ] })
1506
+ ] })
1507
+ ] }),
1508
+ I.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1270
1509
  /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.custom_fields") }),
1271
- /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: J.map((a) => qe(a.condition, O) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1510
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: I.map((a) => Oe(a.condition, se) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1272
1511
  /* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
1273
1512
  t(a.label),
1274
1513
  " ",
1275
1514
  a.required && /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
1276
1515
  ] }),
1277
1516
  a.type === "select" ? /* @__PURE__ */ r(
1278
- se,
1517
+ oe,
1279
1518
  {
1280
- value: String(O[a.key] || ""),
1281
- onValueChange: (C) => s({ ...O, [a.key]: C }),
1519
+ value: String(se[a.key] || ""),
1520
+ onValueChange: (y) => xe({ ...se, [a.key]: y }),
1282
1521
  required: a.required,
1283
- dir: g ? "rtl" : "ltr",
1522
+ dir: q ? "rtl" : "ltr",
1284
1523
  children: [
1285
- /* @__PURE__ */ e(ae, { className: Ne("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", R), children: /* @__PURE__ */ e(ne, { placeholder: t(a.placeholder || "select_placeholder") }) }),
1286
- /* @__PURE__ */ e(ie, { className: "rounded-xl border-border bg-card", children: a.options?.map((C) => /* @__PURE__ */ e(B, { value: String(C.value), children: t(C.label) }, String(C.value))) })
1524
+ /* @__PURE__ */ e(le, { className: je("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", ie), children: /* @__PURE__ */ e(de, { placeholder: t(a.placeholder || "select_placeholder") }) }),
1525
+ /* @__PURE__ */ e(ce, { className: "rounded-xl border-border bg-card", children: a.options?.map((y) => /* @__PURE__ */ e(Z, { value: String(y.value), children: t(y.label) }, String(y.value))) })
1287
1526
  ]
1288
1527
  }
1289
1528
  ) : a.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 h-[46px] px-1", children: [
1290
1529
  /* @__PURE__ */ e(
1291
- He,
1530
+ gt,
1292
1531
  {
1293
1532
  id: `admin-md-${a.key}`,
1294
- checked: !!O[a.key],
1295
- onCheckedChange: (C) => s({ ...O, [a.key]: !!C }),
1533
+ checked: !!se[a.key],
1534
+ onCheckedChange: (y) => xe({ ...se, [a.key]: !!y }),
1296
1535
  required: a.required
1297
1536
  }
1298
1537
  ),
@@ -1301,9 +1540,9 @@ function St() {
1301
1540
  "input",
1302
1541
  {
1303
1542
  type: a.type,
1304
- value: O[a.key] || "",
1305
- onChange: (C) => s({ ...O, [a.key]: C.target.value }),
1306
- 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 ${R}`,
1543
+ value: se[a.key] || "",
1544
+ onChange: (y) => xe({ ...se, [a.key]: y.target.value }),
1545
+ 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 ${ie}`,
1307
1546
  placeholder: t(a.placeholder || ""),
1308
1547
  required: a.required
1309
1548
  }
@@ -1318,8 +1557,8 @@ function St() {
1318
1557
  /* @__PURE__ */ e(
1319
1558
  "textarea",
1320
1559
  {
1321
- value: p.metadata,
1322
- onChange: (a) => S({ ...p, metadata: a.target.value }),
1560
+ value: v.metadata,
1561
+ onChange: (a) => te({ ...v, metadata: a.target.value }),
1323
1562
  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",
1324
1563
  placeholder: '{ "key": "value" }',
1325
1564
  dir: "ltr"
@@ -1333,7 +1572,7 @@ function St() {
1333
1572
  {
1334
1573
  type: "button",
1335
1574
  onClick: () => {
1336
- D(!1), A(null);
1575
+ D(!1), $(null);
1337
1576
  },
1338
1577
  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",
1339
1578
  children: t("cancel")
@@ -1351,25 +1590,25 @@ function St() {
1351
1590
  ] })
1352
1591
  ] }) })
1353
1592
  ] }) }),
1354
- E && /* @__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: [
1593
+ l && /* @__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: [
1355
1594
  /* @__PURE__ */ r("div", { className: "px-6 py-5 border-b border-border bg-muted/20 flex items-center justify-between", children: [
1356
1595
  /* @__PURE__ */ r("h3", { className: "text-lg font-bold text-foreground", children: [
1357
1596
  t("users.update_balance_for"),
1358
1597
  " ",
1359
- E.name
1598
+ l.name
1360
1599
  ] }),
1361
1600
  /* @__PURE__ */ e(
1362
1601
  "button",
1363
1602
  {
1364
1603
  onClick: () => {
1365
- W(null), N("");
1604
+ m(null), _("");
1366
1605
  },
1367
1606
  className: "text-muted-foreground hover:text-foreground transition-colors",
1368
1607
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-5 h-5", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
1369
1608
  }
1370
1609
  )
1371
1610
  ] }),
1372
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: ce, children: [
1611
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: ot, children: [
1373
1612
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1374
1613
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1375
1614
  /* @__PURE__ */ r("div", { children: [
@@ -1378,8 +1617,8 @@ function St() {
1378
1617
  "input",
1379
1618
  {
1380
1619
  type: "number",
1381
- value: Y,
1382
- onChange: (a) => G(a.target.value),
1620
+ value: N,
1621
+ onChange: (a) => d(a.target.value),
1383
1622
  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 text-left",
1384
1623
  required: !0,
1385
1624
  dir: "ltr"
@@ -1392,11 +1631,11 @@ function St() {
1392
1631
  "input",
1393
1632
  {
1394
1633
  type: "number",
1395
- value: d,
1396
- onChange: (a) => c(a.target.value),
1634
+ value: P,
1635
+ onChange: (a) => M(a.target.value),
1397
1636
  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 text-left",
1398
1637
  dir: "ltr",
1399
- placeholder: Y
1638
+ placeholder: N
1400
1639
  }
1401
1640
  )
1402
1641
  ] })
@@ -1408,8 +1647,8 @@ function St() {
1408
1647
  "input",
1409
1648
  {
1410
1649
  type: "number",
1411
- value: h,
1412
- onChange: (a) => U(a.target.value),
1650
+ value: g,
1651
+ onChange: (a) => R(a.target.value),
1413
1652
  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 text-left",
1414
1653
  required: !0,
1415
1654
  dir: "ltr"
@@ -1422,11 +1661,11 @@ function St() {
1422
1661
  "input",
1423
1662
  {
1424
1663
  type: "number",
1425
- value: y,
1426
- onChange: (a) => l(a.target.value),
1664
+ value: W,
1665
+ onChange: (a) => s(a.target.value),
1427
1666
  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 text-left",
1428
1667
  dir: "ltr",
1429
- placeholder: h
1668
+ placeholder: g
1430
1669
  }
1431
1670
  )
1432
1671
  ] })
@@ -1437,7 +1676,7 @@ function St() {
1437
1676
  "button",
1438
1677
  {
1439
1678
  type: "button",
1440
- onClick: Re,
1679
+ onClick: lt,
1441
1680
  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",
1442
1681
  children: t("users.full_charge")
1443
1682
  }
@@ -1454,260 +1693,327 @@ function St() {
1454
1693
  ] })
1455
1694
  ] }) })
1456
1695
  ] }) }),
1457
- /* @__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: [
1458
- /* @__PURE__ */ r("table", { className: `w-full ${g ? "text-right" : "text-left"} border-collapse`, children: [
1459
- /* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
1460
- /* @__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") }),
1461
- /* @__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") }),
1462
- /* @__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") }),
1463
- J.map((a) => /* @__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(a.label) }, a.key)),
1464
- /* @__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") }),
1465
- /* @__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") })
1466
- ] }) }),
1467
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: m.map((a) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
1468
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground font-mono", dir: "ltr", children: a.phone }),
1469
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground", children: a.name }),
1470
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: a.surname }),
1471
- J.map((C) => {
1472
- const $ = a.metadata?.[C.key];
1473
- let X = String($ ?? "");
1474
- if (C.type === "select" && $ !== void 0) {
1475
- const re = C.options?.find((be) => String(be.value) === String($));
1476
- re && (X = t(re.label));
1477
- }
1478
- return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: C.type === "checkbox" ? $ ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : X }, C.key);
1479
- }),
1480
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground w-[120px]", children: a.balance ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 min-w-0 py-1", children: [
1481
- /* @__PURE__ */ r("div", { className: "space-y-1", children: [
1482
- /* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
1483
- /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: t("users.tokens_label") }),
1484
- /* @__PURE__ */ r("span", { className: "text-foreground", children: [
1485
- (a.balance.token_limit > 0 ? Math.round(a.balance.tokens / a.balance.token_limit * 100) : 0).toLocaleString(n.language),
1486
- "%"
1487
- ] })
1488
- ] }),
1489
- /* @__PURE__ */ e("div", { className: "h-1 w-full bg-muted rounded-full overflow-hidden", dir: "ltr", children: /* @__PURE__ */ e(
1490
- "div",
1696
+ /* @__PURE__ */ e("div", { className: "glass-surface border border-border rounded-2xl overflow-hidden shadow-sm flex-1 flex flex-col", children: /* @__PURE__ */ r(
1697
+ "div",
1698
+ {
1699
+ className: "overflow-auto flex-1 min-h-0 custom-scrollbar",
1700
+ onScroll: (a) => {
1701
+ const y = a.currentTarget;
1702
+ y.scrollHeight - y.scrollTop - y.clientHeight < 160 && !u && c.length < E && we(!0);
1703
+ },
1704
+ children: [
1705
+ /* @__PURE__ */ r("table", { className: `w-full ${q ? "text-right" : "text-left"} border-collapse`, children: [
1706
+ /* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
1707
+ ["phone", "name", "surname"].map((a) => /* @__PURE__ */ e(
1708
+ "th",
1491
1709
  {
1492
- className: `h-full rounded-full transition-all duration-500 ${a.balance.tokens / (a.balance.token_limit || 1) > 0.6 ? "bg-emerald-500" : a.balance.tokens / (a.balance.token_limit || 1) > 0.2 ? "bg-amber-500" : "bg-destructive"}`,
1493
- style: { width: `${Math.min(100, Math.max(0, a.balance.tokens / (a.balance.token_limit || 1) * 100))}%` }
1710
+ className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50",
1711
+ "aria-sort": C === a ? B === "asc" ? "ascending" : "descending" : "none",
1712
+ children: /* @__PURE__ */ r(
1713
+ "button",
1714
+ {
1715
+ type: "button",
1716
+ onClick: () => et(a),
1717
+ className: "inline-flex items-center gap-1.5 hover:text-foreground transition-colors",
1718
+ title: t(C === a && B === "asc" ? "users.sort_descending" : "users.sort_ascending"),
1719
+ children: [
1720
+ /* @__PURE__ */ e("span", { children: t(`users.${a}`) }),
1721
+ tt(a)
1722
+ ]
1723
+ }
1724
+ )
1725
+ },
1726
+ a
1727
+ )),
1728
+ I.map((a) => /* @__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(a.label) }, a.key)),
1729
+ /* @__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") }),
1730
+ /* @__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") })
1731
+ ] }) }),
1732
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: c.map((a) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
1733
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground font-mono", dir: "ltr", children: a.phone }),
1734
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground", children: a.name }),
1735
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: a.surname }),
1736
+ I.map((y) => {
1737
+ const A = a.metadata?.[y.key];
1738
+ let J = String(A ?? "");
1739
+ if (y.type === "select" && A !== void 0) {
1740
+ const ee = y.options?.find((ne) => String(ne.value) === String(A));
1741
+ ee && (J = t(ee.label));
1494
1742
  }
1495
- ) })
1496
- ] }),
1497
- /* @__PURE__ */ r("div", { className: "space-y-1", children: [
1498
- /* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
1499
- /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: t("users.requests_label") }),
1500
- /* @__PURE__ */ r("span", { className: "text-foreground", children: [
1501
- (a.balance.request_limit > 0 ? Math.round(a.balance.requests / a.balance.request_limit * 100) : 0).toLocaleString(n.language),
1502
- "%"
1743
+ return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: y.type === "checkbox" ? A ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : J }, y.key);
1744
+ }),
1745
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground w-[120px]", children: a.balance ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 min-w-0 py-1", children: [
1746
+ /* @__PURE__ */ r("div", { className: "space-y-1", children: [
1747
+ /* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
1748
+ /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: t("users.tokens_label") }),
1749
+ /* @__PURE__ */ r("span", { className: "text-foreground", children: [
1750
+ (a.balance.token_limit > 0 ? Math.round(a.balance.tokens / a.balance.token_limit * 100) : 0).toLocaleString(n.language),
1751
+ "%"
1752
+ ] })
1753
+ ] }),
1754
+ /* @__PURE__ */ e("div", { className: "h-1 w-full bg-muted rounded-full overflow-hidden", dir: "ltr", children: /* @__PURE__ */ e(
1755
+ "div",
1756
+ {
1757
+ className: `h-full rounded-full transition-all duration-500 ${a.balance.tokens / (a.balance.token_limit || 1) > 0.6 ? "bg-emerald-500" : a.balance.tokens / (a.balance.token_limit || 1) > 0.2 ? "bg-amber-500" : "bg-destructive"}`,
1758
+ style: { width: `${Math.min(100, Math.max(0, a.balance.tokens / (a.balance.token_limit || 1) * 100))}%` }
1759
+ }
1760
+ ) })
1761
+ ] }),
1762
+ /* @__PURE__ */ r("div", { className: "space-y-1", children: [
1763
+ /* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
1764
+ /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: t("users.requests_label") }),
1765
+ /* @__PURE__ */ r("span", { className: "text-foreground", children: [
1766
+ (a.balance.request_limit > 0 ? Math.round(a.balance.requests / a.balance.request_limit * 100) : 0).toLocaleString(n.language),
1767
+ "%"
1768
+ ] })
1769
+ ] }),
1770
+ /* @__PURE__ */ e("div", { className: "h-1 w-full bg-muted rounded-full overflow-hidden", dir: "ltr", children: /* @__PURE__ */ e(
1771
+ "div",
1772
+ {
1773
+ className: `h-full rounded-full transition-all duration-500 ${a.balance.requests / (a.balance.request_limit || 1) > 0.6 ? "bg-emerald-500" : a.balance.requests / (a.balance.request_limit || 1) > 0.2 ? "bg-amber-500" : "bg-destructive"}`,
1774
+ style: { width: `${Math.min(100, Math.max(0, a.balance.requests / (a.balance.request_limit || 1) * 100))}%` }
1775
+ }
1776
+ ) })
1503
1777
  ] })
1504
- ] }),
1505
- /* @__PURE__ */ e("div", { className: "h-1 w-full bg-muted rounded-full overflow-hidden", dir: "ltr", children: /* @__PURE__ */ e(
1506
- "div",
1507
- {
1508
- className: `h-full rounded-full transition-all duration-500 ${a.balance.requests / (a.balance.request_limit || 1) > 0.6 ? "bg-emerald-500" : a.balance.requests / (a.balance.request_limit || 1) > 0.2 ? "bg-amber-500" : "bg-destructive"}`,
1509
- style: { width: `${Math.min(100, Math.max(0, a.balance.requests / (a.balance.request_limit || 1) * 100))}%` }
1510
- }
1511
- ) })
1512
- ] })
1513
- ] }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground/40 text-[10px]", children: "—" }) }),
1514
- /* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
1515
- /* @__PURE__ */ e(
1516
- "button",
1517
- {
1518
- onClick: () => Fe(a),
1519
- className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1520
- title: t("edit"),
1521
- 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" }) })
1522
- }
1523
- ),
1524
- /* @__PURE__ */ e(
1525
- "button",
1526
- {
1527
- onClick: () => {
1528
- W(a), G(String(a.balance?.tokens || 0)), U(String(a.balance?.requests || 0)), c(String(a.balance?.token_limit || 0)), l(String(a.balance?.request_limit || 0)), N("");
1529
- },
1530
- className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1531
- title: t("users.recharge"),
1532
- 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: "M2.25 18.75a60.07 60.07 0 0 1 15.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 0 1 3 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 0 0-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 0 1-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 0 0 3 15h-.75M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm3 0h.008v.008H18V10.5Zm-12 0h.008v.008H6V10.5Z" }) })
1533
- }
1534
- ),
1535
- /* @__PURE__ */ e(
1536
- "button",
1537
- {
1538
- onClick: () => j(a),
1539
- className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1540
- title: t("users.copy_token"),
1541
- 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" }) })
1542
- }
1543
- ),
1544
- /* @__PURE__ */ e(
1545
- "button",
1546
- {
1547
- onClick: () => o(a.id),
1548
- className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
1549
- title: t("delete"),
1550
- 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" }) })
1551
- }
1552
- )
1553
- ] }) })
1554
- ] }, a.id)) })
1555
- ] }),
1556
- m.length === 0 && !u && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1557
- /* @__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" }) }),
1558
- t("users.no_users")
1559
- ] }),
1560
- u && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
1561
- /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
1562
- /* @__PURE__ */ e("span", { children: t("loading") })
1563
- ] })
1564
- ] }) })
1778
+ ] }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground/40 text-[10px]", children: "—" }) }),
1779
+ /* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
1780
+ /* @__PURE__ */ e(
1781
+ "button",
1782
+ {
1783
+ onClick: () => ct(a),
1784
+ className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1785
+ title: t("users.usage_summary"),
1786
+ children: /* @__PURE__ */ e(At, { className: "w-4 h-4" })
1787
+ }
1788
+ ),
1789
+ /* @__PURE__ */ e(
1790
+ "button",
1791
+ {
1792
+ onClick: () => dt(a),
1793
+ className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1794
+ title: t("edit"),
1795
+ 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" }) })
1796
+ }
1797
+ ),
1798
+ /* @__PURE__ */ e(
1799
+ "button",
1800
+ {
1801
+ onClick: () => {
1802
+ m(a), d(String(a.balance?.tokens || 0)), R(String(a.balance?.requests || 0)), M(String(a.balance?.token_limit || 0)), s(String(a.balance?.request_limit || 0)), _("");
1803
+ },
1804
+ className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1805
+ title: t("users.recharge"),
1806
+ 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: "M2.25 18.75a60.07 60.07 0 0 1 15.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 0 1 3 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 0 0-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 0 1-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 0 0 3 15h-.75M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm3 0h.008v.008H18V10.5Zm-12 0h.008v.008H6V10.5Z" }) })
1807
+ }
1808
+ ),
1809
+ /* @__PURE__ */ e(
1810
+ "button",
1811
+ {
1812
+ onClick: () => nt(a),
1813
+ className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1814
+ title: t("users.copy_token"),
1815
+ 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" }) })
1816
+ }
1817
+ ),
1818
+ /* @__PURE__ */ e(
1819
+ "button",
1820
+ {
1821
+ onClick: () => st(a.id),
1822
+ className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
1823
+ title: t("delete"),
1824
+ 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" }) })
1825
+ }
1826
+ )
1827
+ ] }) })
1828
+ ] }, a.id)) })
1829
+ ] }),
1830
+ c.length === 0 && !u && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1831
+ /* @__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" }) }),
1832
+ t("users.no_users")
1833
+ ] }),
1834
+ u && /* @__PURE__ */ r("div", { className: `${c.length > 0 ? "p-5" : "p-12"} text-center text-muted-foreground text-sm flex flex-col items-center gap-3`, children: [
1835
+ /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
1836
+ /* @__PURE__ */ e("span", { children: t("loading") })
1837
+ ] })
1838
+ ]
1839
+ }
1840
+ ) })
1565
1841
  ] });
1566
1842
  }
1567
- function Ct() {
1568
- const { t, i18n: n } = te(["admin", "translation"]), [i, m] = b(null), [x, u] = b(!0), [v, _] = b(""), [N, P] = b(30), [D, T] = b(0), A = Ee(null), F = n.language === "fa", q = F ? "fa-IR" : "en-US", I = F ? "fa-IR-u-ca-persian" : "en-US";
1569
- Q(() => {
1570
- M();
1571
- }, [N]), Q(() => {
1572
- if (!A.current) return;
1573
- const d = new ResizeObserver((c) => {
1574
- for (const y of c)
1575
- T(y.contentRect.width);
1843
+ function Qt() {
1844
+ const { t, i18n: n } = me(["admin", "translation"]), [i, c] = p(null), [f, u] = p(!0), [b, w] = p(""), [_, V] = p(30), [D, j] = p(0), $ = Ce(null), O = n.language === "fa", S = O ? "fa-IR" : "en-US", E = O ? "fa-IR-u-ca-persian" : "en-US";
1845
+ Y(() => {
1846
+ U();
1847
+ }, [_]), Y(() => {
1848
+ if (!$.current) return;
1849
+ const l = new ResizeObserver((m) => {
1850
+ for (const N of m)
1851
+ j(N.contentRect.width);
1576
1852
  });
1577
- return d.observe(A.current), () => d.disconnect();
1853
+ return l.observe($.current), () => l.disconnect();
1578
1854
  }, []);
1579
- const H = (d, c, y) => {
1580
- const l = [], g = /* @__PURE__ */ new Date(), R = d || [], p = new Map(R.map((S) => [S.date, S]));
1581
- for (let S = c - 1; S >= 0; S--) {
1582
- const s = new Date(g.getTime() - S * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1583
- if (p.has(s))
1584
- l.push(p.get(s));
1855
+ const H = (l, m, N) => {
1856
+ const d = [], g = /* @__PURE__ */ new Date(), R = l || [], P = new Map(R.map((M) => [M.date, M]));
1857
+ for (let M = m - 1; M >= 0; M--) {
1858
+ const s = new Date(g.getTime() - M * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1859
+ if (P.has(s))
1860
+ d.push(P.get(s));
1585
1861
  else {
1586
- const f = { date: s };
1587
- y.forEach((L) => f[L] = 0), l.push(f);
1862
+ const x = { date: s };
1863
+ N.forEach((L) => x[L] = 0), d.push(x);
1588
1864
  }
1589
1865
  }
1590
- return l;
1591
- }, w = (d) => {
1592
- if (!d || d.length === 0) return null;
1593
- const c = d.length, y = new Intl.DateTimeFormat(I, { month: "short" });
1594
- let l = [];
1595
- if (N <= 14)
1596
- l = Array.from({ length: c }, (g, R) => R);
1866
+ return d;
1867
+ }, C = (l) => {
1868
+ if (!l || l.length === 0) return null;
1869
+ const m = l.length, N = new Intl.DateTimeFormat(E, { month: "short" });
1870
+ let d = [];
1871
+ if (_ <= 14)
1872
+ d = Array.from({ length: m }, (g, R) => R);
1597
1873
  else {
1598
- const g = F ? 45 : 35, R = D > 0 ? Math.floor(D / g) : 6, p = Math.max(1, Math.ceil(c / Math.max(1, R)));
1599
- for (let S = 0; S < c; S += p)
1600
- l.push(S);
1601
- l.length > 0 && l[l.length - 1] !== c - 1 && (c - 1 - l[l.length - 1] > p / 2 ? l.push(c - 1) : l[l.length - 1] = c - 1);
1874
+ const g = O ? 45 : 35, R = D > 0 ? Math.floor(D / g) : 6, P = Math.max(1, Math.ceil(m / Math.max(1, R)));
1875
+ for (let M = 0; M < m; M += P)
1876
+ d.push(M);
1877
+ d.length > 0 && d[d.length - 1] !== m - 1 && (m - 1 - d[d.length - 1] > P / 2 ? d.push(m - 1) : d[d.length - 1] = m - 1);
1602
1878
  }
1603
- return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: F ? "rtl" : "ltr", children: l.map((g) => {
1604
- const R = d[g];
1879
+ return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: O ? "rtl" : "ltr", children: d.map((g) => {
1880
+ const R = l[g];
1605
1881
  if (!R) return null;
1606
- const p = new Date(R.date), S = p.toLocaleDateString(I, { day: "numeric" }), O = y.format(p), s = c > 1 ? g / (c - 1) * 100 : 50;
1882
+ const P = new Date(R.date), M = P.toLocaleDateString(E, { day: "numeric" }), W = N.format(P), s = m > 1 ? g / (m - 1) * 100 : 50;
1607
1883
  return /* @__PURE__ */ r(
1608
1884
  "div",
1609
1885
  {
1610
1886
  className: "absolute top-0 transform -translate-x-1/2 flex flex-col items-center",
1611
1887
  style: { left: `${s}%` },
1612
1888
  children: [
1613
- /* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: S }),
1614
- /* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: O })
1889
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: M }),
1890
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: W })
1615
1891
  ]
1616
1892
  },
1617
1893
  g
1618
1894
  );
1619
1895
  }) });
1620
- }, M = async () => {
1621
- u(!0), _("");
1896
+ }, U = async () => {
1897
+ u(!0), w("");
1622
1898
  try {
1623
- const d = await k.getAnalytics(N), c = {
1624
- ...d,
1625
- overview: d.overview || {
1899
+ const l = await k.getAnalytics(_), m = {
1900
+ ...l,
1901
+ overview: l.overview || {
1626
1902
  total_users: 0,
1627
1903
  total_threads: 0,
1628
1904
  total_messages: 0,
1629
- total_token_usage: 0
1905
+ total_input_tokens: 0,
1906
+ total_output_tokens: 0,
1907
+ total_cost_microunits: 0,
1908
+ unpriced_requests: 0,
1909
+ currency: "USD"
1630
1910
  },
1631
1911
  trends: {
1632
- ...d.trends || {},
1633
- users: H(d.trends?.users, N, ["count"]),
1634
- threads: H(d.trends?.threads, N, ["count"]),
1635
- messages: H(d.trends?.messages, N, ["count"]),
1636
- token_usage: H(d.trends?.token_usage, N, ["tokens", "requests"])
1912
+ ...l.trends || {},
1913
+ users: H(l.trends?.users, _, ["count"]),
1914
+ threads: H(l.trends?.threads, _, ["count"]),
1915
+ messages: H(l.trends?.messages, _, ["count"]),
1916
+ token_usage: H(
1917
+ l.trends?.token_usage,
1918
+ _,
1919
+ ["input_tokens", "output_tokens", "requests", "cost_microunits", "unpriced_requests"]
1920
+ )
1637
1921
  },
1638
1922
  distributions: {
1639
- ...d.distributions || {},
1640
- feedback_sentiment: d.distributions?.feedback_sentiment || []
1923
+ ...l.distributions || {},
1924
+ feedback_sentiment: l.distributions?.feedback_sentiment || []
1641
1925
  },
1642
- active_users: d.active_users || []
1926
+ active_users: l.active_users || []
1643
1927
  };
1644
- m(c);
1645
- } catch (d) {
1646
- _(d instanceof Error ? d.message : t("analytics.error_loading"));
1928
+ c(m);
1929
+ } catch (l) {
1930
+ w(l instanceof Error ? l.message : t("analytics.error_loading"));
1647
1931
  } finally {
1648
1932
  u(!1);
1649
1933
  }
1650
1934
  };
1651
- if (x)
1935
+ if (f)
1652
1936
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground", children: t("analytics.loading_analytics") });
1653
- if (v)
1937
+ if (b)
1654
1938
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
1655
- /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: v }),
1939
+ /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: b }),
1656
1940
  /* @__PURE__ */ e(
1657
1941
  "button",
1658
1942
  {
1659
- onClick: M,
1943
+ onClick: U,
1660
1944
  className: "px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-colors",
1661
1945
  children: t("retry")
1662
1946
  }
1663
1947
  )
1664
1948
  ] }) });
1665
1949
  if (!i) return null;
1666
- const J = (d) => {
1667
- if (d <= 0) return 10;
1668
- const c = d * 1.15, y = Math.pow(10, Math.floor(Math.log10(c))), l = c / y;
1950
+ const B = (l) => {
1951
+ if (l <= 0) return 10;
1952
+ const m = l * 1.15, N = Math.pow(10, Math.floor(Math.log10(m))), d = m / N;
1669
1953
  let g;
1670
- return l <= 1.2 ? g = 0.2 : l <= 2.5 ? g = 0.5 : l <= 5 ? g = 1 : g = 2, Math.ceil(c / (g * y)) * (g * y);
1671
- }, E = Math.max(...i.trends.threads.map((d) => d.count) || [1]), W = Math.max(...i.trends.messages.map((d) => d.count) || [1]), Y = Math.max(...i.trends.token_usage.map((d) => d.tokens) || [1]), G = J(E), h = J(W), U = J(Y);
1672
- return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: F ? "rtl" : "ltr", children: [
1954
+ return d <= 1.2 ? g = 0.2 : d <= 2.5 ? g = 0.5 : d <= 5 ? g = 1 : g = 2, Math.ceil(m / (g * N)) * (g * N);
1955
+ }, G = Math.max(...i.trends.threads.map((l) => l.count) || [1]), F = Math.max(...i.trends.messages.map((l) => l.count) || [1]), ae = Math.max(
1956
+ ...i.trends.token_usage.map((l) => Math.max(l.input_tokens, l.output_tokens)) || [1]
1957
+ ), K = B(G), h = B(F), I = B(ae);
1958
+ return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: O ? "rtl" : "ltr", children: [
1673
1959
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3", children: [
1674
1960
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("analytics.title") }),
1675
- /* @__PURE__ */ e("div", { className: "flex gap-2", children: [7, 14, 30, 90].map((d) => /* @__PURE__ */ e(
1961
+ /* @__PURE__ */ e("div", { className: "flex gap-2", children: [7, 14, 30, 90].map((l) => /* @__PURE__ */ e(
1676
1962
  "button",
1677
1963
  {
1678
- onClick: () => P(d),
1679
- 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"}`,
1680
- children: t("analytics.days", { count: d })
1964
+ onClick: () => V(l),
1965
+ className: `px-4 py-2 text-sm font-medium rounded-xl transition-all shadow-sm ${_ === l ? "bg-primary text-primary-foreground shadow-md" : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground border border-border/50"}`,
1966
+ children: t("analytics.days", { count: l })
1681
1967
  },
1682
- d
1968
+ l
1683
1969
  )) })
1684
1970
  ] }),
1685
1971
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", children: [
1686
1972
  /* @__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: [
1687
1973
  /* @__PURE__ */ r("div", { children: [
1688
1974
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_users") }),
1689
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_users || 0).toLocaleString(q) })
1975
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_users || 0).toLocaleString(S) })
1690
1976
  ] }),
1691
1977
  /* @__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" }) }) })
1692
1978
  ] }) }),
1693
1979
  /* @__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: [
1694
1980
  /* @__PURE__ */ r("div", { children: [
1695
1981
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_threads") }),
1696
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_threads || 0).toLocaleString(q) })
1982
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_threads || 0).toLocaleString(S) })
1697
1983
  ] }),
1698
1984
  /* @__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" }) }) })
1699
1985
  ] }) }),
1700
1986
  /* @__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: [
1701
1987
  /* @__PURE__ */ r("div", { children: [
1702
1988
  /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_messages") }),
1703
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_messages || 0).toLocaleString(q) })
1989
+ /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_messages || 0).toLocaleString(S) })
1704
1990
  ] }),
1705
1991
  /* @__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" }) }) })
1706
1992
  ] }) }),
1707
1993
  /* @__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: [
1708
1994
  /* @__PURE__ */ r("div", { children: [
1709
- /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_token_usage") }),
1710
- /* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (i.overview.total_token_usage || 0).toLocaleString(q) })
1995
+ /* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-2", children: t("analytics.usage_cost") }),
1996
+ /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-3", children: [
1997
+ /* @__PURE__ */ r("div", { children: [
1998
+ /* @__PURE__ */ e("p", { className: "text-[9px] text-muted-foreground", children: t("analytics.input") }),
1999
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: (i.overview.total_input_tokens || 0).toLocaleString(S) })
2000
+ ] }),
2001
+ /* @__PURE__ */ r("div", { children: [
2002
+ /* @__PURE__ */ e("p", { className: "text-[9px] text-muted-foreground", children: t("analytics.output") }),
2003
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: (i.overview.total_output_tokens || 0).toLocaleString(S) })
2004
+ ] }),
2005
+ /* @__PURE__ */ r("div", { children: [
2006
+ /* @__PURE__ */ e("p", { className: "text-[9px] text-muted-foreground", children: t("analytics.cost") }),
2007
+ /* @__PURE__ */ e(
2008
+ "p",
2009
+ {
2010
+ className: "text-sm font-medium text-foreground",
2011
+ title: $e(i.overview.total_cost_microunits, i.overview.currency, S),
2012
+ children: Xe(i.overview.total_cost_microunits, i.overview.currency, S)
2013
+ }
2014
+ )
2015
+ ] })
2016
+ ] })
1711
2017
  ] }),
1712
2018
  /* @__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" }) }) })
1713
2019
  ] }) })
@@ -1715,11 +2021,11 @@ function Ct() {
1715
2021
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: [
1716
2022
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
1717
2023
  /* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.threads_chart") }),
1718
- /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: A, children: [
2024
+ /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: $, children: [
1719
2025
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1720
2026
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1721
- /* @__PURE__ */ e("span", { children: (G || 0).toLocaleString(q) }),
1722
- /* @__PURE__ */ e("span", { children: Math.floor((G || 0) / 2).toLocaleString(q) }),
2027
+ /* @__PURE__ */ e("span", { children: (K || 0).toLocaleString(S) }),
2028
+ /* @__PURE__ */ e("span", { children: Math.floor((K || 0) / 2).toLocaleString(S) }),
1723
2029
  /* @__PURE__ */ e("span", { children: "0" })
1724
2030
  ] }),
1725
2031
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1727,32 +2033,32 @@ function Ct() {
1727
2033
  /* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
1728
2034
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
1729
2035
  ] }),
1730
- 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(
2036
+ i.trends.threads.length > 0 ? i.trends.threads.map((l, m) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1731
2037
  "div",
1732
2038
  {
1733
2039
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1734
- style: { height: `${d.count / G * 100}%` },
2040
+ style: { height: `${l.count / K * 100}%` },
1735
2041
  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: [
1736
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: d.count.toLocaleString(q) }),
1737
- /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(I, { month: "short", day: "numeric" }) })
2042
+ /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: l.count.toLocaleString(S) }),
2043
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(l.date).toLocaleDateString(E, { month: "short", day: "numeric" }) })
1738
2044
  ] })
1739
2045
  }
1740
- ) }, c)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
2046
+ ) }, m)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
1741
2047
  ] })
1742
2048
  ] }),
1743
2049
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1744
2050
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1745
- w(i.trends.threads)
2051
+ C(i.trends.threads)
1746
2052
  ] })
1747
2053
  ] })
1748
2054
  ] }),
1749
2055
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
1750
2056
  /* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.messages_chart") }),
1751
- /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: A, children: [
2057
+ /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: $, children: [
1752
2058
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1753
2059
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1754
- /* @__PURE__ */ e("span", { children: (h || 0).toLocaleString(q) }),
1755
- /* @__PURE__ */ e("span", { children: Math.floor((h || 0) / 2).toLocaleString(q) }),
2060
+ /* @__PURE__ */ e("span", { children: (h || 0).toLocaleString(S) }),
2061
+ /* @__PURE__ */ e("span", { children: Math.floor((h || 0) / 2).toLocaleString(S) }),
1756
2062
  /* @__PURE__ */ e("span", { children: "0" })
1757
2063
  ] }),
1758
2064
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1760,32 +2066,32 @@ function Ct() {
1760
2066
  /* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
1761
2067
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
1762
2068
  ] }),
1763
- 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(
2069
+ i.trends.messages.length > 0 ? i.trends.messages.map((l, m) => /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
1764
2070
  "div",
1765
2071
  {
1766
2072
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1767
- style: { height: `${d.count / h * 100}%` },
2073
+ style: { height: `${l.count / h * 100}%` },
1768
2074
  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: [
1769
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: d.count.toLocaleString(q) }),
1770
- /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(I, { month: "short", day: "numeric" }) })
2075
+ /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: l.count.toLocaleString(S) }),
2076
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(l.date).toLocaleDateString(E, { month: "short", day: "numeric" }) })
1771
2077
  ] })
1772
2078
  }
1773
- ) }, c)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
2079
+ ) }, m)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
1774
2080
  ] })
1775
2081
  ] }),
1776
2082
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1777
2083
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1778
- w(i.trends.messages)
2084
+ C(i.trends.messages)
1779
2085
  ] })
1780
2086
  ] })
1781
2087
  ] }),
1782
2088
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
1783
2089
  /* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.token_usage_chart") }),
1784
- /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: A, children: [
2090
+ /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: $, children: [
1785
2091
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1786
2092
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1787
- /* @__PURE__ */ e("span", { children: (U || 0).toLocaleString(q) }),
1788
- /* @__PURE__ */ e("span", { children: Math.floor((U || 0) / 2).toLocaleString(q) }),
2093
+ /* @__PURE__ */ e("span", { children: (I || 0).toLocaleString(S) }),
2094
+ /* @__PURE__ */ e("span", { children: Math.floor((I || 0) / 2).toLocaleString(S) }),
1789
2095
  /* @__PURE__ */ e("span", { children: "0" })
1790
2096
  ] }),
1791
2097
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1793,22 +2099,40 @@ function Ct() {
1793
2099
  /* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
1794
2100
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
1795
2101
  ] }),
1796
- 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(
1797
- "div",
1798
- {
1799
- className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1800
- style: { height: `${d.tokens / U * 100}%` },
1801
- 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: [
1802
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: (d.tokens || 0).toLocaleString(q) }),
1803
- /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(I, { month: "short", day: "numeric" }) })
1804
- ] })
1805
- }
1806
- ) }, c)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
2102
+ i.trends.token_usage.length > 0 ? i.trends.token_usage.map((l, m) => /* @__PURE__ */ r("div", { className: "w-3 group relative flex items-end gap-0.5 h-full", children: [
2103
+ /* @__PURE__ */ e(
2104
+ "div",
2105
+ {
2106
+ className: "bg-primary/80 w-1/2 rounded-t-lg transition-all group-hover:bg-primary",
2107
+ style: { height: `${l.input_tokens / I * 100}%` }
2108
+ }
2109
+ ),
2110
+ /* @__PURE__ */ e(
2111
+ "div",
2112
+ {
2113
+ className: "bg-violet-500/80 w-1/2 rounded-t-lg transition-all group-hover:bg-violet-500",
2114
+ style: { height: `${l.output_tokens / I * 100}%` }
2115
+ }
2116
+ ),
2117
+ /* @__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: [
2118
+ /* @__PURE__ */ r("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: [
2119
+ t("analytics.input"),
2120
+ ": ",
2121
+ (l.input_tokens || 0).toLocaleString(S)
2122
+ ] }),
2123
+ /* @__PURE__ */ r("span", { className: "text-[10px] font-medium text-violet-500 leading-none mb-0.5", children: [
2124
+ t("analytics.output"),
2125
+ ": ",
2126
+ (l.output_tokens || 0).toLocaleString(S)
2127
+ ] }),
2128
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(l.date).toLocaleDateString(E, { month: "short", day: "numeric" }) })
2129
+ ] })
2130
+ ] }, m)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
1807
2131
  ] })
1808
2132
  ] }),
1809
2133
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1810
2134
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1811
- w(i.trends.token_usage)
2135
+ C(i.trends.token_usage)
1812
2136
  ] })
1813
2137
  ] })
1814
2138
  ] }),
@@ -1817,12 +2141,12 @@ function Ct() {
1817
2141
  /* @__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: [
1818
2142
  /* @__PURE__ */ r("div", { className: "relative w-56 h-56 lg:w-60 lg:h-60", children: [
1819
2143
  /* @__PURE__ */ e("svg", { viewBox: "0 0 100 100", className: "w-full h-full -rotate-90 drop-shadow-md", children: (() => {
1820
- const d = i.distributions.feedback_sentiment.filter(
1821
- (O) => O.sentiment === "positive" || O.sentiment === "negative"
1822
- ), c = d.reduce((O, s) => O + s.count, 0);
1823
- if (c === 0) return null;
1824
- const y = d.find((O) => O.sentiment === "positive")?.count || 0, l = d.find((O) => O.sentiment === "negative")?.count || 0, g = 40, R = 2 * Math.PI * g, p = y / c * 100, S = l / c * 100;
1825
- return /* @__PURE__ */ r(Ue, { children: [
2144
+ const l = i.distributions.feedback_sentiment.filter(
2145
+ (W) => W.sentiment === "positive" || W.sentiment === "negative"
2146
+ ), m = l.reduce((W, s) => W + s.count, 0);
2147
+ if (m === 0) return null;
2148
+ const N = l.find((W) => W.sentiment === "positive")?.count || 0, d = l.find((W) => W.sentiment === "negative")?.count || 0, g = 40, R = 2 * Math.PI * g, P = N / m * 100, M = d / m * 100;
2149
+ return /* @__PURE__ */ r(mt, { children: [
1826
2150
  /* @__PURE__ */ e(
1827
2151
  "circle",
1828
2152
  {
@@ -1854,8 +2178,8 @@ function Ct() {
1854
2178
  fill: "transparent",
1855
2179
  stroke: "url(#posGradient)",
1856
2180
  strokeWidth: "10",
1857
- strokeDasharray: `${p / 100 * R} ${R}`,
1858
- strokeLinecap: p > 0 ? "round" : "butt",
2181
+ strokeDasharray: `${P / 100 * R} ${R}`,
2182
+ strokeLinecap: P > 0 ? "round" : "butt",
1859
2183
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
1860
2184
  }
1861
2185
  ),
@@ -1868,110 +2192,88 @@ function Ct() {
1868
2192
  fill: "transparent",
1869
2193
  stroke: "url(#negGradient)",
1870
2194
  strokeWidth: "10",
1871
- strokeDasharray: `${S / 100 * R} ${R}`,
1872
- strokeDashoffset: -(p / 100 * R),
1873
- strokeLinecap: S > 0 ? "round" : "butt",
2195
+ strokeDasharray: `${M / 100 * R} ${R}`,
2196
+ strokeDashoffset: -(P / 100 * R),
2197
+ strokeLinecap: M > 0 ? "round" : "butt",
1874
2198
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
1875
2199
  }
1876
2200
  )
1877
2201
  ] });
1878
2202
  })() }),
1879
2203
  /* @__PURE__ */ r("div", { className: "absolute inset-0 flex flex-col items-center justify-center pointer-events-none", children: [
1880
- /* @__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(q) }),
2204
+ /* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children: i.distributions.feedback_sentiment.filter((l) => l.sentiment === "positive" || l.sentiment === "negative").reduce((l, m) => l + (m.count || 0), 0).toLocaleString(S) }),
1881
2205
  /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground uppercase tracking-widest mt-1", children: t("analytics.total_feedback") })
1882
2206
  ] })
1883
2207
  ] }),
1884
- /* @__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) => {
1885
- const y = i.distributions.feedback_sentiment.filter(
1886
- (S) => S.sentiment === "positive" || S.sentiment === "negative"
1887
- ).reduce((S, O) => S + O.count, 0), l = y > 0 ? d.count / y * 100 : 0, g = d.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), R = d.sentiment === "positive" ? "bg-primary" : "bg-destructive", p = d.sentiment === "positive" ? "👍" : "👎";
2208
+ /* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...i.distributions.feedback_sentiment].filter((l) => l.sentiment === "positive" || l.sentiment === "negative").sort((l, m) => l.sentiment === "positive" ? -1 : 1).map((l) => {
2209
+ const N = i.distributions.feedback_sentiment.filter(
2210
+ (M) => M.sentiment === "positive" || M.sentiment === "negative"
2211
+ ).reduce((M, W) => M + W.count, 0), d = N > 0 ? l.count / N * 100 : 0, g = l.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), R = l.sentiment === "positive" ? "bg-primary" : "bg-destructive", P = l.sentiment === "positive" ? "👍" : "👎";
1888
2212
  return /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-6 group", children: [
1889
2213
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
1890
2214
  /* @__PURE__ */ e("div", { className: `w-3 h-3 rounded-full ${R} shadow-sm group-hover:scale-110 transition-transform` }),
1891
2215
  /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground font-medium", children: [
1892
2216
  g,
1893
2217
  " ",
1894
- p
2218
+ P
1895
2219
  ] })
1896
2220
  ] }),
1897
2221
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
1898
2222
  /* @__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: [
1899
- (l || 0).toLocaleString(q, { maximumFractionDigits: 0 }),
2223
+ (d || 0).toLocaleString(S, { maximumFractionDigits: 0 }),
1900
2224
  "%"
1901
2225
  ] }),
1902
2226
  /* @__PURE__ */ r("span", { className: "text-[13px] font-normal text-muted-foreground w-12 text-right", children: [
1903
2227
  "(",
1904
- (d.count || 0).toLocaleString(q),
2228
+ (l.count || 0).toLocaleString(S),
1905
2229
  ")"
1906
2230
  ] })
1907
2231
  ] })
1908
- ] }, d.sentiment);
2232
+ ] }, l.sentiment);
1909
2233
  }) })
1910
2234
  ] }) : /* @__PURE__ */ e("p", { className: "text-center text-muted-foreground py-8", children: t("no_data") }) })
1911
2235
  ] })
1912
2236
  ] }),
1913
2237
  /* @__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: [
1914
2238
  /* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.active_users") }),
1915
- /* @__PURE__ */ e("div", { className: "h-64 overflow-y-auto pr-1", children: /* @__PURE__ */ e("div", { className: "space-y-2.5", children: i.active_users.length > 0 ? i.active_users.slice(0, 5).map((d) => /* @__PURE__ */ r(
2239
+ /* @__PURE__ */ e("div", { className: "h-64 overflow-y-auto pr-1", children: /* @__PURE__ */ e("div", { className: "space-y-2.5", children: i.active_users.length > 0 ? i.active_users.slice(0, 5).map((l) => /* @__PURE__ */ r(
1916
2240
  "div",
1917
2241
  {
1918
2242
  className: "flex items-center justify-between p-3 bg-muted/30 rounded-xl hover:bg-muted/50 transition-colors",
1919
2243
  children: [
1920
2244
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
1921
- /* @__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) }),
1922
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: d.name }) })
2245
+ /* @__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) }),
2246
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: l.name }) })
1923
2247
  ] }),
1924
2248
  /* @__PURE__ */ r("div", { className: "text-sm font-semibold text-primary", children: [
1925
- (d.thread_count || 0).toLocaleString(q),
2249
+ (l.thread_count || 0).toLocaleString(S),
1926
2250
  " ",
1927
2251
  t("analytics.threads")
1928
2252
  ] })
1929
2253
  ]
1930
2254
  },
1931
- d.user_id
2255
+ l.user_id
1932
2256
  )) : /* @__PURE__ */ e("p", { className: "text-center text-muted-foreground py-8", children: t("no_data") }) }) })
1933
2257
  ] }) })
1934
2258
  ] });
1935
2259
  }
1936
- function ee({ className: t, ...n }) {
1937
- return /* @__PURE__ */ e(
1938
- $e.Root,
1939
- {
1940
- "data-slot": "switch",
1941
- className: Ne(
1942
- "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
1943
- t
1944
- ),
1945
- ...n,
1946
- children: /* @__PURE__ */ e(
1947
- $e.Thumb,
1948
- {
1949
- "data-slot": "switch-thumb",
1950
- className: Ne(
1951
- "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] rtl:data-[state=checked]:-translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
1952
- )
1953
- }
1954
- )
1955
- }
1956
- );
1957
- }
1958
- function Lt() {
1959
- const { t, i18n: n } = te(["admin", "translation", "settings"]), { app: i, welcome: m, disclaimer: x, history: u, threadActions: v, composer: _, theme: N, settings: P } = pe(), [D, T] = b(!1), [A, F] = b(!1), [q, I] = b(""), [H, w] = b(""), [M, J] = b("fa"), [E, W] = b("translation"), [Y, G] = b("{}"), [h, U] = b(""), [d, c] = b(!1), y = xe(() => ({
2260
+ function Xt() {
2261
+ const { t, i18n: n } = me(["admin", "translation", "settings"]), { app: i, welcome: c, disclaimer: f, history: u, threadActions: b, composer: w, theme: _, settings: V } = _e(), [D, j] = p(!1), [$, O] = p(!1), [S, E] = p(""), [H, C] = p(""), [U, B] = p("fa"), [G, F] = p("translation"), [ae, K] = p("{}"), [h, I] = p(""), [l, m] = p(!1), N = Se(() => ({
1960
2262
  app_name: i?.name || "Gentiq",
1961
2263
  admin_title: i?.adminTitle || "",
1962
- default_theme: N?.defaultTheme || "system",
1963
- default_accent: N?.accent || "oklch(0.623 0.214 259.815)",
1964
- welcome_greeting: typeof m?.greeting == "string" ? m.greeting : "",
1965
- welcome_subtitle: m?.subtitle || "",
1966
- disclaimer: typeof x == "string" ? x : "",
2264
+ default_theme: _?.defaultTheme || "system",
2265
+ default_accent: _?.accent || "oklch(0.623 0.214 259.815)",
2266
+ welcome_greeting: typeof c?.greeting == "string" ? c.greeting : "",
2267
+ welcome_subtitle: c?.subtitle || "",
2268
+ disclaimer: typeof f == "string" ? f : "",
1967
2269
  show_tool_details: i?.showToolDetails ?? !0,
1968
2270
  show_settings: i?.showSettings ?? !0,
1969
2271
  show_version_in_settings: i?.showVersionInSettings ?? !0,
1970
2272
  disable_signup: i?.disableSignup ?? !1,
1971
2273
  disable_auth_page: i?.disableAuthPage ?? !1,
1972
- composer_attachments: _?.attachments?.enabled ?? !0,
1973
- thread_actions_feedback: v?.feedback ?? !0,
1974
- thread_actions_retry: v?.retry ?? !0,
2274
+ composer_attachments: w?.attachments?.enabled ?? !0,
2275
+ thread_actions_feedback: b?.feedback ?? !0,
2276
+ thread_actions_retry: b?.retry ?? !0,
1975
2277
  history_enabled: u?.enabled ?? !0,
1976
2278
  history_show_delete: u?.showDelete ?? !0,
1977
2279
  history_show_rename: u?.showRename ?? !0,
@@ -1980,123 +2282,123 @@ function Lt() {
1980
2282
  settings_general_mode: i?.settingsGeneralMode || "editable",
1981
2283
  settings_profile_mode: i?.settingsProfileMode || "editable",
1982
2284
  settings_account_mode: i?.settingsAccountMode || "editable",
1983
- settings_general_fields: P?.sections?.general?.fields || {},
1984
- settings_profile_fields: P?.sections?.profile?.fields || {},
1985
- settings_account_fields: P?.sections?.account?.fields || {},
2285
+ settings_general_fields: V?.sections?.general?.fields || {},
2286
+ settings_profile_fields: V?.sections?.profile?.fields || {},
2287
+ settings_account_fields: V?.sections?.account?.fields || {},
1986
2288
  language: n.language || "fa",
1987
2289
  initial_balance_tokens: 25e4,
1988
2290
  initial_balance_requests: 100,
1989
2291
  translations: {}
1990
- }), [i, m, x, u, v, _, N, n.language, P]), [l, g] = b(y), R = n.language === "fa", p = (l.default_accent || "").trim(), S = !p || typeof CSS < "u" && CSS.supports("color", p);
1991
- Q(() => {
2292
+ }), [i, c, f, u, b, w, _, n.language, V]), [d, g] = p(N), R = n.language === "fa", P = (d.default_accent || "").trim(), M = !P || typeof CSS < "u" && CSS.supports("color", P);
2293
+ Y(() => {
1992
2294
  (async () => {
1993
- T(!0);
2295
+ j(!0);
1994
2296
  try {
1995
- const j = await k.getSettings();
1996
- if (j && Object.keys(j).length > 0) {
1997
- const V = JSON.parse(JSON.stringify(n.store.data));
1998
- j.translations && Object.keys(j.translations).forEach((ce) => {
1999
- V[ce] || (V[ce] = {}), Object.assign(V[ce], j.translations[ce]);
2000
- }), g((ce) => ({
2001
- ...ce,
2002
- ...j,
2003
- translations: V
2297
+ const q = await k.getSettings();
2298
+ if (q && Object.keys(q).length > 0) {
2299
+ const z = JSON.parse(JSON.stringify(n.store.data));
2300
+ q.translations && Object.keys(q.translations).forEach((ie) => {
2301
+ z[ie] || (z[ie] = {}), Object.assign(z[ie], q.translations[ie]);
2302
+ }), g((ie) => ({
2303
+ ...ie,
2304
+ ...q,
2305
+ translations: z
2004
2306
  }));
2005
2307
  } else {
2006
- const V = { ...y, translations: n.store.data };
2007
- g(V), j || k.updateSettings(V).catch(console.error);
2308
+ const z = { ...N, translations: n.store.data };
2309
+ g(z), q || k.updateSettings(z).catch(console.error);
2008
2310
  }
2009
- } catch (j) {
2010
- console.error("Failed to fetch settings", j), I(t("app_settings.save_error"));
2311
+ } catch (q) {
2312
+ console.error("Failed to fetch settings", q), E(t("app_settings.save_error"));
2011
2313
  } finally {
2012
- T(!1);
2314
+ j(!1);
2013
2315
  }
2014
2316
  })();
2015
- }, [t, y, n.store.data]);
2016
- const O = async (o) => {
2017
- if (o && o.preventDefault(), !S) {
2018
- I(t("app_settings.general.default_accent_invalid"));
2317
+ }, [t, N, n.store.data]);
2318
+ const W = async (o) => {
2319
+ if (o && o.preventDefault(), !M) {
2320
+ E(t("app_settings.general.default_accent_invalid"));
2019
2321
  return;
2020
2322
  }
2021
- F(!0), w(""), I("");
2323
+ O(!0), C(""), E("");
2022
2324
  try {
2023
2325
  await k.updateSettings({
2024
- ...l,
2025
- default_accent: p || null
2026
- }), w(t("app_settings.save_success")), setTimeout(() => w(""), 3e3);
2027
- } catch (j) {
2028
- I(j instanceof Error ? j.message : t("app_settings.save_error"));
2326
+ ...d,
2327
+ default_accent: P || null
2328
+ }), C(t("app_settings.save_success")), setTimeout(() => C(""), 3e3);
2329
+ } catch (q) {
2330
+ E(q instanceof Error ? q.message : t("app_settings.save_error"));
2029
2331
  } finally {
2030
- F(!1);
2332
+ O(!1);
2031
2333
  }
2032
2334
  }, s = async () => {
2033
- T(!0), I("");
2335
+ j(!0), E("");
2034
2336
  try {
2035
- await k.resetSettings(), c(!1), window.location.reload();
2337
+ await k.resetSettings(), m(!1), window.location.reload();
2036
2338
  } catch (o) {
2037
- I(o instanceof Error ? o.message : t("app_settings.save_error"));
2339
+ E(o instanceof Error ? o.message : t("app_settings.save_error"));
2038
2340
  } finally {
2039
- T(!1);
2341
+ j(!1);
2040
2342
  }
2041
2343
  };
2042
- Q(() => {
2043
- const o = l.translations?.[M]?.[E] || {};
2044
- G(JSON.stringify(o, null, 2)), U("");
2045
- }, [M, E, l.translations]);
2046
- const f = (o) => {
2047
- G(o);
2344
+ Y(() => {
2345
+ const o = d.translations?.[U]?.[G] || {};
2346
+ K(JSON.stringify(o, null, 2)), I("");
2347
+ }, [U, G, d.translations]);
2348
+ const x = (o) => {
2349
+ K(o);
2048
2350
  try {
2049
- const j = JSON.parse(o);
2050
- g((V) => ({
2051
- ...V,
2351
+ const q = JSON.parse(o);
2352
+ g((z) => ({
2353
+ ...z,
2052
2354
  translations: {
2053
- ...V.translations,
2054
- [M]: {
2055
- ...V.translations?.[M],
2056
- [E]: j
2355
+ ...z.translations,
2356
+ [U]: {
2357
+ ...z.translations?.[U],
2358
+ [G]: q
2057
2359
  }
2058
2360
  }
2059
- })), U("");
2361
+ })), I("");
2060
2362
  } catch {
2061
- U("Invalid JSON format");
2363
+ I("Invalid JSON format");
2062
2364
  }
2063
- }, L = ({ title: o, icon: j }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
2365
+ }, L = ({ title: o, icon: q }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
2064
2366
  /* @__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" }) }),
2065
2367
  /* @__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: [
2066
- /* @__PURE__ */ e(j, { className: "size-4 text-primary/60" }),
2368
+ /* @__PURE__ */ e(q, { className: "size-4 text-primary/60" }),
2067
2369
  o
2068
2370
  ] }) })
2069
- ] }), z = ({ value: o }) => {
2371
+ ] }), T = ({ value: o }) => {
2070
2372
  if (!o || !o.includes(":") && !o.includes(".")) return null;
2071
- const j = t(o);
2072
- return j === 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: [
2373
+ const q = t(o);
2374
+ return q === 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: [
2073
2375
  /* @__PURE__ */ r("span", { className: "text-[10px] font-bold text-primary/60 uppercase tracking-tighter", children: [
2074
2376
  t("app_settings.preview", { defaultValue: "Preview" }),
2075
2377
  ":"
2076
2378
  ] }),
2077
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: j })
2379
+ /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: q })
2078
2380
  ] });
2079
- }, K = () => {
2381
+ }, Q = () => {
2080
2382
  const o = prompt("Enter language code (e.g. en, fa, fr):");
2081
- o && !l.translations?.[o] && (g((j) => ({
2082
- ...j,
2383
+ o && !d.translations?.[o] && (g((q) => ({
2384
+ ...q,
2083
2385
  translations: {
2084
- ...j.translations,
2386
+ ...q.translations,
2085
2387
  [o]: {}
2086
2388
  }
2087
- })), J(o));
2088
- }, de = () => {
2389
+ })), B(o));
2390
+ }, fe = () => {
2089
2391
  const o = prompt("Enter namespace (e.g. chat, admin):");
2090
- o && !l.translations?.[M]?.[o] && (g((j) => ({
2091
- ...j,
2392
+ o && !d.translations?.[U]?.[o] && (g((q) => ({
2393
+ ...q,
2092
2394
  translations: {
2093
- ...j.translations,
2094
- [M]: {
2095
- ...j.translations?.[M],
2395
+ ...q.translations,
2396
+ [U]: {
2397
+ ...q.translations?.[U],
2096
2398
  [o]: {}
2097
2399
  }
2098
2400
  }
2099
- })), W(o));
2401
+ })), F(o));
2100
2402
  };
2101
2403
  return D ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-3", children: [
2102
2404
  /* @__PURE__ */ e("div", { className: "w-10 h-10 border-3 border-primary/20 border-t-primary rounded-full animate-spin" }),
@@ -2114,26 +2416,26 @@ function Lt() {
2114
2416
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("app_settings.subtitle") })
2115
2417
  ] }),
2116
2418
  /* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
2117
- /* @__PURE__ */ r(Ve, { open: d, onOpenChange: c, children: [
2118
- /* @__PURE__ */ e(Be, { asChild: !0, children: /* @__PURE__ */ r(
2419
+ /* @__PURE__ */ r(We, { open: l, onOpenChange: m, children: [
2420
+ /* @__PURE__ */ e(ft, { asChild: !0, children: /* @__PURE__ */ r(
2119
2421
  "button",
2120
2422
  {
2121
2423
  type: "button",
2122
2424
  className: "px-4 py-2 bg-muted/20 text-muted-foreground hover:bg-muted/40 rounded-xl text-xs font-bold transition-all flex items-center gap-2 border border-border/50",
2123
2425
  children: [
2124
- /* @__PURE__ */ e(Ae, { className: "size-3.5" }),
2426
+ /* @__PURE__ */ e(Pe, { className: "size-3.5" }),
2125
2427
  t("app_settings.reset_button", { defaultValue: "Reset to Defaults" })
2126
2428
  ]
2127
2429
  }
2128
2430
  ) }),
2129
- /* @__PURE__ */ r(We, { children: [
2130
- /* @__PURE__ */ r(Ge, { children: [
2131
- /* @__PURE__ */ e(Ke, { children: t("app_settings.reset_confirm_title") }),
2132
- /* @__PURE__ */ e(Ze, { children: t("app_settings.reset_confirm_description") })
2431
+ /* @__PURE__ */ r(Ge, { children: [
2432
+ /* @__PURE__ */ r(Ke, { children: [
2433
+ /* @__PURE__ */ e(Ze, { children: t("app_settings.reset_confirm_title") }),
2434
+ /* @__PURE__ */ e(Qe, { children: t("app_settings.reset_confirm_description") })
2133
2435
  ] }),
2134
- /* @__PURE__ */ r(Qe, { children: [
2135
- /* @__PURE__ */ e(Xe, { asChild: !0, children: /* @__PURE__ */ e(fe, { variant: "ghost", children: t("cancel") }) }),
2136
- /* @__PURE__ */ e(fe, { variant: "destructive", onClick: s, children: t("app_settings.reset_button") })
2436
+ /* @__PURE__ */ r(xt, { children: [
2437
+ /* @__PURE__ */ e(bt, { asChild: !0, children: /* @__PURE__ */ e(ke, { variant: "ghost", children: t("cancel") }) }),
2438
+ /* @__PURE__ */ e(ke, { variant: "destructive", onClick: s, children: t("app_settings.reset_button") })
2137
2439
  ] })
2138
2440
  ] })
2139
2441
  ] }),
@@ -2142,78 +2444,78 @@ function Lt() {
2142
2444
  {
2143
2445
  type: "submit",
2144
2446
  form: "settings-form",
2145
- disabled: A || !S,
2447
+ disabled: $ || !M,
2146
2448
  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",
2147
2449
  children: [
2148
- A && /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin" }),
2149
- t(A ? "saving" : "app_settings.save")
2450
+ $ && /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin" }),
2451
+ t($ ? "saving" : "app_settings.save")
2150
2452
  ]
2151
2453
  }
2152
2454
  )
2153
2455
  ] })
2154
2456
  ] }),
2155
2457
  /* @__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: [
2156
- (q || H) && /* @__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 || H }),
2157
- /* @__PURE__ */ r("form", { id: "settings-form", onSubmit: O, className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500", children: [
2458
+ (S || H) && /* @__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 ${S ? "bg-destructive/10 border-destructive/20 text-destructive" : "bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400"}`, children: S || H }),
2459
+ /* @__PURE__ */ r("form", { id: "settings-form", onSubmit: W, className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500", children: [
2158
2460
  /* @__PURE__ */ r("section", { children: [
2159
- /* @__PURE__ */ e(L, { title: t("app_settings.sections.general"), icon: ye }),
2461
+ /* @__PURE__ */ e(L, { title: t("app_settings.sections.general"), icon: qe }),
2160
2462
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2161
2463
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2162
2464
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2163
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.app_name") }),
2465
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.app_name") }),
2164
2466
  /* @__PURE__ */ e(
2165
- ue,
2467
+ ge,
2166
2468
  {
2167
2469
  type: "text",
2168
- value: l.app_name,
2169
- onChange: (o) => g({ ...l, app_name: o.target.value }),
2470
+ value: d.app_name,
2471
+ onChange: (o) => g({ ...d, app_name: o.target.value }),
2170
2472
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2171
2473
  placeholder: "Gentiq AI",
2172
2474
  dir: "auto"
2173
2475
  }
2174
2476
  ),
2175
- /* @__PURE__ */ e(z, { value: l.app_name })
2477
+ /* @__PURE__ */ e(T, { value: d.app_name })
2176
2478
  ] }),
2177
2479
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2178
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.admin_title") }),
2480
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.admin_title") }),
2179
2481
  /* @__PURE__ */ e(
2180
- ue,
2482
+ ge,
2181
2483
  {
2182
2484
  type: "text",
2183
- value: l.admin_title || "",
2184
- onChange: (o) => g({ ...l, admin_title: o.target.value }),
2485
+ value: d.admin_title || "",
2486
+ onChange: (o) => g({ ...d, admin_title: o.target.value }),
2185
2487
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2186
2488
  placeholder: "Gentiq Admin",
2187
2489
  dir: "auto"
2188
2490
  }
2189
2491
  ),
2190
- /* @__PURE__ */ e(z, { value: l.admin_title || "" })
2492
+ /* @__PURE__ */ e(T, { value: d.admin_title || "" })
2191
2493
  ] })
2192
2494
  ] }),
2193
2495
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2194
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.language") }),
2496
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.language") }),
2195
2497
  /* @__PURE__ */ r(
2196
- se,
2498
+ oe,
2197
2499
  {
2198
- value: l.language,
2199
- onValueChange: (o) => g({ ...l, language: o }),
2500
+ value: d.language,
2501
+ onValueChange: (o) => g({ ...d, language: o }),
2200
2502
  children: [
2201
- /* @__PURE__ */ e(ae, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(ne, {}) }),
2202
- /* @__PURE__ */ r(ie, { children: [
2203
- /* @__PURE__ */ e(B, { value: "fa", children: "فارسی (Persian)" }),
2204
- /* @__PURE__ */ e(B, { value: "en", children: "English" })
2503
+ /* @__PURE__ */ e(le, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(de, {}) }),
2504
+ /* @__PURE__ */ r(ce, { children: [
2505
+ /* @__PURE__ */ e(Z, { value: "fa", children: "فارسی (Persian)" }),
2506
+ /* @__PURE__ */ e(Z, { value: "en", children: "English" })
2205
2507
  ] })
2206
2508
  ]
2207
2509
  }
2208
2510
  ),
2209
2511
  /* @__PURE__ */ r("p", { className: "mt-3 text-[10px] text-muted-foreground/50 italic flex items-center gap-1.5 ml-1", children: [
2210
- /* @__PURE__ */ e(Ae, { className: "size-3" }),
2512
+ /* @__PURE__ */ e(Pe, { className: "size-3" }),
2211
2513
  t("app_settings.general.language_help")
2212
2514
  ] })
2213
2515
  ] }),
2214
2516
  /* @__PURE__ */ r("div", { className: "space-y-5 rounded-2xl border border-border/50 bg-muted/10 p-5", children: [
2215
2517
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
2216
- /* @__PURE__ */ e(ct, { className: "size-4 text-primary" }),
2518
+ /* @__PURE__ */ e(Dt, { className: "size-4 text-primary" }),
2217
2519
  /* @__PURE__ */ r("div", { children: [
2218
2520
  /* @__PURE__ */ e("h3", { className: "text-sm font-bold text-foreground/80", children: t("app_settings.general.appearance") }),
2219
2521
  /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: t("app_settings.general.appearance_help") })
@@ -2221,99 +2523,99 @@ function Lt() {
2221
2523
  ] }),
2222
2524
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [
2223
2525
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2224
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.default_theme") }),
2526
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.default_theme") }),
2225
2527
  /* @__PURE__ */ r(
2226
- se,
2528
+ oe,
2227
2529
  {
2228
- value: l.default_theme || "system",
2229
- onValueChange: (o) => g({ ...l, default_theme: o }),
2530
+ value: d.default_theme || "system",
2531
+ onValueChange: (o) => g({ ...d, default_theme: o }),
2230
2532
  children: [
2231
- /* @__PURE__ */ e(ae, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full", children: /* @__PURE__ */ e(ne, {}) }),
2232
- /* @__PURE__ */ r(ie, { children: [
2233
- /* @__PURE__ */ e(B, { value: "system", children: t("settings:general.themes.system") }),
2234
- /* @__PURE__ */ e(B, { value: "light", children: t("settings:general.themes.light") }),
2235
- /* @__PURE__ */ e(B, { value: "dark", children: t("settings:general.themes.dark") })
2533
+ /* @__PURE__ */ e(le, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full", children: /* @__PURE__ */ e(de, {}) }),
2534
+ /* @__PURE__ */ r(ce, { children: [
2535
+ /* @__PURE__ */ e(Z, { value: "system", children: t("settings:general.themes.system") }),
2536
+ /* @__PURE__ */ e(Z, { value: "light", children: t("settings:general.themes.light") }),
2537
+ /* @__PURE__ */ e(Z, { value: "dark", children: t("settings:general.themes.dark") })
2236
2538
  ] })
2237
2539
  ]
2238
2540
  }
2239
2541
  )
2240
2542
  ] }),
2241
2543
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2242
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.default_accent") }),
2544
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.default_accent") }),
2243
2545
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
2244
2546
  /* @__PURE__ */ e(
2245
2547
  "div",
2246
2548
  {
2247
2549
  className: "size-10 shrink-0 rounded-xl border border-border shadow-sm",
2248
- style: { backgroundColor: S && p ? p : "transparent" },
2550
+ style: { backgroundColor: M && P ? P : "transparent" },
2249
2551
  "aria-label": t("app_settings.general.default_accent_preview")
2250
2552
  }
2251
2553
  ),
2252
2554
  /* @__PURE__ */ e(
2253
- ue,
2555
+ ge,
2254
2556
  {
2255
2557
  type: "text",
2256
- value: l.default_accent || "",
2257
- onChange: (o) => g({ ...l, default_accent: o.target.value }),
2558
+ value: d.default_accent || "",
2559
+ onChange: (o) => g({ ...d, default_accent: o.target.value }),
2258
2560
  className: "bg-muted/20 border-transparent focus:bg-background h-11 font-mono",
2259
2561
  placeholder: "oklch(0.623 0.214 259.815)",
2260
2562
  dir: "ltr",
2261
- "aria-invalid": !S
2563
+ "aria-invalid": !M
2262
2564
  }
2263
2565
  )
2264
2566
  ] }),
2265
- /* @__PURE__ */ e("p", { className: `text-[10px] ${S ? "text-muted-foreground/60" : "text-destructive"}`, children: t(S ? "app_settings.general.default_accent_help" : "app_settings.general.default_accent_invalid") })
2567
+ /* @__PURE__ */ e("p", { className: `text-[10px] ${M ? "text-muted-foreground/60" : "text-destructive"}`, children: t(M ? "app_settings.general.default_accent_help" : "app_settings.general.default_accent_invalid") })
2266
2568
  ] })
2267
2569
  ] })
2268
2570
  ] })
2269
2571
  ] })
2270
2572
  ] }),
2271
2573
  /* @__PURE__ */ r("section", { children: [
2272
- /* @__PURE__ */ e(L, { title: t("app_settings.sections.chat"), icon: mt }),
2574
+ /* @__PURE__ */ e(L, { title: t("app_settings.sections.chat"), icon: $t }),
2273
2575
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2274
2576
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2275
2577
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2276
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_greeting") }),
2578
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_greeting") }),
2277
2579
  /* @__PURE__ */ e(
2278
- ue,
2580
+ ge,
2279
2581
  {
2280
2582
  type: "text",
2281
- value: l.welcome_greeting || "",
2282
- onChange: (o) => g({ ...l, welcome_greeting: o.target.value }),
2583
+ value: d.welcome_greeting || "",
2584
+ onChange: (o) => g({ ...d, welcome_greeting: o.target.value }),
2283
2585
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2284
2586
  placeholder: "e.g. chat:welcome",
2285
2587
  dir: "auto"
2286
2588
  }
2287
2589
  ),
2288
- /* @__PURE__ */ e(z, { value: l.welcome_greeting || "" })
2590
+ /* @__PURE__ */ e(T, { value: d.welcome_greeting || "" })
2289
2591
  ] }),
2290
2592
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2291
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_subtitle") }),
2593
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_subtitle") }),
2292
2594
  /* @__PURE__ */ e(
2293
- ue,
2595
+ ge,
2294
2596
  {
2295
2597
  type: "text",
2296
- value: l.welcome_subtitle || "",
2297
- onChange: (o) => g({ ...l, welcome_subtitle: o.target.value }),
2598
+ value: d.welcome_subtitle || "",
2599
+ onChange: (o) => g({ ...d, welcome_subtitle: o.target.value }),
2298
2600
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2299
2601
  dir: "auto"
2300
2602
  }
2301
2603
  ),
2302
- /* @__PURE__ */ e(z, { value: l.welcome_subtitle || "" })
2604
+ /* @__PURE__ */ e(T, { value: d.welcome_subtitle || "" })
2303
2605
  ] })
2304
2606
  ] }),
2305
2607
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2306
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.disclaimer") }),
2608
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.disclaimer") }),
2307
2609
  /* @__PURE__ */ e(
2308
- je,
2610
+ Fe,
2309
2611
  {
2310
- value: l.disclaimer || "",
2311
- onChange: (o) => g({ ...l, disclaimer: o.target.value }),
2612
+ value: d.disclaimer || "",
2613
+ onChange: (o) => g({ ...d, disclaimer: o.target.value }),
2312
2614
  className: "bg-muted/20 border-transparent focus:bg-background min-h-[120px] py-4 resize-none leading-relaxed",
2313
2615
  dir: "auto"
2314
2616
  }
2315
2617
  ),
2316
- /* @__PURE__ */ e(z, { value: l.disclaimer || "" })
2618
+ /* @__PURE__ */ e(T, { value: d.disclaimer || "" })
2317
2619
  ] }),
2318
2620
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-6 pt-2", children: [
2319
2621
  /* @__PURE__ */ r("div", { className: "p-5 border border-border/40 rounded-2xl flex items-center justify-between hover:bg-muted/5 transition-colors", children: [
@@ -2322,10 +2624,10 @@ function Lt() {
2322
2624
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.show_tool_details_help") })
2323
2625
  ] }),
2324
2626
  /* @__PURE__ */ e(
2325
- ee,
2627
+ re,
2326
2628
  {
2327
- checked: l.show_tool_details,
2328
- onCheckedChange: (o) => g({ ...l, show_tool_details: o })
2629
+ checked: d.show_tool_details,
2630
+ onCheckedChange: (o) => g({ ...d, show_tool_details: o })
2329
2631
  }
2330
2632
  )
2331
2633
  ] }),
@@ -2335,10 +2637,10 @@ function Lt() {
2335
2637
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.show_settings_help") })
2336
2638
  ] }),
2337
2639
  /* @__PURE__ */ e(
2338
- ee,
2640
+ re,
2339
2641
  {
2340
- checked: l.show_settings,
2341
- onCheckedChange: (o) => g({ ...l, show_settings: o })
2642
+ checked: d.show_settings,
2643
+ onCheckedChange: (o) => g({ ...d, show_settings: o })
2342
2644
  }
2343
2645
  )
2344
2646
  ] }),
@@ -2348,10 +2650,10 @@ function Lt() {
2348
2650
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.show_version_in_settings_help") })
2349
2651
  ] }),
2350
2652
  /* @__PURE__ */ e(
2351
- ee,
2653
+ re,
2352
2654
  {
2353
- checked: l.show_version_in_settings,
2354
- onCheckedChange: (o) => g({ ...l, show_version_in_settings: o })
2655
+ checked: d.show_version_in_settings,
2656
+ onCheckedChange: (o) => g({ ...d, show_version_in_settings: o })
2355
2657
  }
2356
2658
  )
2357
2659
  ] }),
@@ -2361,10 +2663,10 @@ function Lt() {
2361
2663
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.disable_signup_help") })
2362
2664
  ] }),
2363
2665
  /* @__PURE__ */ e(
2364
- ee,
2666
+ re,
2365
2667
  {
2366
- checked: l.disable_signup,
2367
- onCheckedChange: (o) => g({ ...l, disable_signup: o })
2668
+ checked: d.disable_signup,
2669
+ onCheckedChange: (o) => g({ ...d, disable_signup: o })
2368
2670
  }
2369
2671
  )
2370
2672
  ] }),
@@ -2374,10 +2676,10 @@ function Lt() {
2374
2676
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.disable_auth_page_help") })
2375
2677
  ] }),
2376
2678
  /* @__PURE__ */ e(
2377
- ee,
2679
+ re,
2378
2680
  {
2379
- checked: l.disable_auth_page,
2380
- onCheckedChange: (o) => g({ ...l, disable_auth_page: o })
2681
+ checked: d.disable_auth_page,
2682
+ onCheckedChange: (o) => g({ ...d, disable_auth_page: o })
2381
2683
  }
2382
2684
  )
2383
2685
  ] }),
@@ -2387,10 +2689,10 @@ function Lt() {
2387
2689
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.composer_attachments_help") })
2388
2690
  ] }),
2389
2691
  /* @__PURE__ */ e(
2390
- ee,
2692
+ re,
2391
2693
  {
2392
- checked: l.composer_attachments,
2393
- onCheckedChange: (o) => g({ ...l, composer_attachments: o })
2694
+ checked: d.composer_attachments,
2695
+ onCheckedChange: (o) => g({ ...d, composer_attachments: o })
2394
2696
  }
2395
2697
  )
2396
2698
  ] }),
@@ -2400,10 +2702,10 @@ function Lt() {
2400
2702
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.thread_actions_feedback_help") })
2401
2703
  ] }),
2402
2704
  /* @__PURE__ */ e(
2403
- ee,
2705
+ re,
2404
2706
  {
2405
- checked: l.thread_actions_feedback,
2406
- onCheckedChange: (o) => g({ ...l, thread_actions_feedback: o })
2707
+ checked: d.thread_actions_feedback,
2708
+ onCheckedChange: (o) => g({ ...d, thread_actions_feedback: o })
2407
2709
  }
2408
2710
  )
2409
2711
  ] }),
@@ -2413,10 +2715,10 @@ function Lt() {
2413
2715
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.thread_actions_retry_help") })
2414
2716
  ] }),
2415
2717
  /* @__PURE__ */ e(
2416
- ee,
2718
+ re,
2417
2719
  {
2418
- checked: l.thread_actions_retry,
2419
- onCheckedChange: (o) => g({ ...l, thread_actions_retry: o })
2720
+ checked: d.thread_actions_retry,
2721
+ onCheckedChange: (o) => g({ ...d, thread_actions_retry: o })
2420
2722
  }
2421
2723
  )
2422
2724
  ] }),
@@ -2426,51 +2728,51 @@ function Lt() {
2426
2728
  /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: t("app_settings.chat.history_enabled_help") })
2427
2729
  ] }),
2428
2730
  /* @__PURE__ */ e(
2429
- ee,
2731
+ re,
2430
2732
  {
2431
- checked: l.history_enabled,
2432
- onCheckedChange: (o) => g({ ...l, history_enabled: o })
2733
+ checked: d.history_enabled,
2734
+ onCheckedChange: (o) => g({ ...d, history_enabled: o })
2433
2735
  }
2434
2736
  )
2435
2737
  ] }),
2436
- 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: [
2738
+ d.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: [
2437
2739
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2438
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_delete") }),
2740
+ /* @__PURE__ */ e(X, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_delete") }),
2439
2741
  /* @__PURE__ */ e(
2440
- ee,
2742
+ re,
2441
2743
  {
2442
- checked: l.history_show_delete,
2443
- onCheckedChange: (o) => g({ ...l, history_show_delete: o })
2744
+ checked: d.history_show_delete,
2745
+ onCheckedChange: (o) => g({ ...d, history_show_delete: o })
2444
2746
  }
2445
2747
  )
2446
2748
  ] }),
2447
2749
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2448
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_rename") }),
2750
+ /* @__PURE__ */ e(X, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_rename") }),
2449
2751
  /* @__PURE__ */ e(
2450
- ee,
2752
+ re,
2451
2753
  {
2452
- checked: l.history_show_rename,
2453
- onCheckedChange: (o) => g({ ...l, history_show_rename: o })
2754
+ checked: d.history_show_rename,
2755
+ onCheckedChange: (o) => g({ ...d, history_show_rename: o })
2454
2756
  }
2455
2757
  )
2456
2758
  ] }),
2457
2759
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2458
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_share") }),
2760
+ /* @__PURE__ */ e(X, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_share") }),
2459
2761
  /* @__PURE__ */ e(
2460
- ee,
2762
+ re,
2461
2763
  {
2462
- checked: l.history_show_share,
2463
- onCheckedChange: (o) => g({ ...l, history_show_share: o })
2764
+ checked: d.history_show_share,
2765
+ onCheckedChange: (o) => g({ ...d, history_show_share: o })
2464
2766
  }
2465
2767
  )
2466
2768
  ] }),
2467
2769
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
2468
- /* @__PURE__ */ e(Z, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_pin") }),
2770
+ /* @__PURE__ */ e(X, { className: "text-xs font-medium text-foreground/70", children: t("app_settings.chat.history_show_pin") }),
2469
2771
  /* @__PURE__ */ e(
2470
- ee,
2772
+ re,
2471
2773
  {
2472
- checked: l.history_show_pin,
2473
- onCheckedChange: (o) => g({ ...l, history_show_pin: o })
2774
+ checked: d.history_show_pin,
2775
+ onCheckedChange: (o) => g({ ...d, history_show_pin: o })
2474
2776
  }
2475
2777
  )
2476
2778
  ] })
@@ -2486,19 +2788,19 @@ function Lt() {
2486
2788
  { id: "settings_profile_mode", label: "app_settings.chat.profile_tab" },
2487
2789
  { id: "settings_account_mode", label: "app_settings.chat.account_tab" }
2488
2790
  ].map((o) => /* @__PURE__ */ r("div", { className: "p-4 border border-border/40 rounded-2xl space-y-3 bg-muted/5", children: [
2489
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70", children: t(o.label) }),
2791
+ /* @__PURE__ */ e(X, { className: "text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70", children: t(o.label) }),
2490
2792
  /* @__PURE__ */ r(
2491
- se,
2793
+ oe,
2492
2794
  {
2493
- value: l[o.id],
2494
- onValueChange: (j) => g({ ...l, [o.id]: j }),
2795
+ value: d[o.id],
2796
+ onValueChange: (q) => g({ ...d, [o.id]: q }),
2495
2797
  dir: R ? "rtl" : "ltr",
2496
2798
  children: [
2497
- /* @__PURE__ */ e(ae, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(ne, {}) }),
2498
- /* @__PURE__ */ r(ie, { children: [
2499
- /* @__PURE__ */ e(B, { value: "editable", children: t("app_settings.chat.mode_editable") }),
2500
- /* @__PURE__ */ e(B, { value: "faded", children: t("app_settings.chat.mode_faded") }),
2501
- /* @__PURE__ */ e(B, { value: "hidden", children: t("app_settings.chat.mode_hidden") })
2799
+ /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(de, {}) }),
2800
+ /* @__PURE__ */ r(ce, { children: [
2801
+ /* @__PURE__ */ e(Z, { value: "editable", children: t("app_settings.chat.mode_editable") }),
2802
+ /* @__PURE__ */ e(Z, { value: "faded", children: t("app_settings.chat.mode_faded") }),
2803
+ /* @__PURE__ */ e(Z, { value: "hidden", children: t("app_settings.chat.mode_hidden") })
2502
2804
  ] })
2503
2805
  ]
2504
2806
  }
@@ -2522,22 +2824,22 @@ function Lt() {
2522
2824
  { id: "radius", label: t("settings:general.radius") },
2523
2825
  { id: "language", label: t("settings:general.language") }
2524
2826
  ].map((o) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2525
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2827
+ /* @__PURE__ */ e(X, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2526
2828
  /* @__PURE__ */ r(
2527
- se,
2829
+ oe,
2528
2830
  {
2529
- value: l.settings_general_fields?.[o.id] || "editable",
2530
- onValueChange: (j) => g((V) => ({
2531
- ...V,
2532
- settings_general_fields: { ...V.settings_general_fields, [o.id]: j }
2831
+ value: d.settings_general_fields?.[o.id] || "editable",
2832
+ onValueChange: (q) => g((z) => ({
2833
+ ...z,
2834
+ settings_general_fields: { ...z.settings_general_fields, [o.id]: q }
2533
2835
  })),
2534
2836
  dir: R ? "rtl" : "ltr",
2535
2837
  children: [
2536
- /* @__PURE__ */ e(ae, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ne, {}) }),
2537
- /* @__PURE__ */ r(ie, { children: [
2538
- /* @__PURE__ */ e(B, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2539
- /* @__PURE__ */ e(B, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2540
- /* @__PURE__ */ e(B, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2838
+ /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(de, {}) }),
2839
+ /* @__PURE__ */ r(ce, { children: [
2840
+ /* @__PURE__ */ e(Z, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2841
+ /* @__PURE__ */ e(Z, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2842
+ /* @__PURE__ */ e(Z, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2541
2843
  ] })
2542
2844
  ]
2543
2845
  }
@@ -2556,22 +2858,22 @@ function Lt() {
2556
2858
  { id: "password", label: t("settings:profile.password") },
2557
2859
  ...(i?.userMetadataFields || []).map((o) => ({ id: o.key, label: t(o.label) }))
2558
2860
  ].map((o) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2559
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2861
+ /* @__PURE__ */ e(X, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2560
2862
  /* @__PURE__ */ r(
2561
- se,
2863
+ oe,
2562
2864
  {
2563
- value: l.settings_profile_fields?.[o.id] || "editable",
2564
- onValueChange: (j) => g((V) => ({
2565
- ...V,
2566
- settings_profile_fields: { ...V.settings_profile_fields, [o.id]: j }
2865
+ value: d.settings_profile_fields?.[o.id] || "editable",
2866
+ onValueChange: (q) => g((z) => ({
2867
+ ...z,
2868
+ settings_profile_fields: { ...z.settings_profile_fields, [o.id]: q }
2567
2869
  })),
2568
2870
  dir: R ? "rtl" : "ltr",
2569
2871
  children: [
2570
- /* @__PURE__ */ e(ae, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ne, {}) }),
2571
- /* @__PURE__ */ r(ie, { children: [
2572
- /* @__PURE__ */ e(B, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2573
- /* @__PURE__ */ e(B, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2574
- /* @__PURE__ */ e(B, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2872
+ /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(de, {}) }),
2873
+ /* @__PURE__ */ r(ce, { children: [
2874
+ /* @__PURE__ */ e(Z, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2875
+ /* @__PURE__ */ e(Z, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2876
+ /* @__PURE__ */ e(Z, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2575
2877
  ] })
2576
2878
  ]
2577
2879
  }
@@ -2587,22 +2889,22 @@ function Lt() {
2587
2889
  { id: "balance", label: t("settings:account.balance") },
2588
2890
  { id: "logout", label: t("settings:account.logout") }
2589
2891
  ].map((o) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2590
- /* @__PURE__ */ e(Z, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2892
+ /* @__PURE__ */ e(X, { className: "text-[10px] font-medium text-muted-foreground/70", children: o.label }),
2591
2893
  /* @__PURE__ */ r(
2592
- se,
2894
+ oe,
2593
2895
  {
2594
- value: l.settings_account_fields?.[o.id] || "editable",
2595
- onValueChange: (j) => g((V) => ({
2596
- ...V,
2597
- settings_account_fields: { ...V.settings_account_fields, [o.id]: j }
2896
+ value: d.settings_account_fields?.[o.id] || "editable",
2897
+ onValueChange: (q) => g((z) => ({
2898
+ ...z,
2899
+ settings_account_fields: { ...z.settings_account_fields, [o.id]: q }
2598
2900
  })),
2599
2901
  dir: R ? "rtl" : "ltr",
2600
2902
  children: [
2601
- /* @__PURE__ */ e(ae, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ne, {}) }),
2602
- /* @__PURE__ */ r(ie, { children: [
2603
- /* @__PURE__ */ e(B, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2604
- /* @__PURE__ */ e(B, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2605
- /* @__PURE__ */ e(B, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2903
+ /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(de, {}) }),
2904
+ /* @__PURE__ */ r(ce, { children: [
2905
+ /* @__PURE__ */ e(Z, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2906
+ /* @__PURE__ */ e(Z, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2907
+ /* @__PURE__ */ e(Z, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2606
2908
  ] })
2607
2909
  ]
2608
2910
  }
@@ -2614,30 +2916,30 @@ function Lt() {
2614
2916
  ] })
2615
2917
  ] }),
2616
2918
  /* @__PURE__ */ r("section", { children: [
2617
- /* @__PURE__ */ e(L, { title: t("app_settings.sections.user_billing"), icon: ut }),
2919
+ /* @__PURE__ */ e(L, { title: t("app_settings.sections.user_billing"), icon: Et }),
2618
2920
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2619
2921
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2620
2922
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2621
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.user_billing.initial_balance_tokens") }),
2923
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.user_billing.initial_balance_tokens") }),
2622
2924
  /* @__PURE__ */ e(
2623
- ue,
2925
+ ge,
2624
2926
  {
2625
2927
  type: "number",
2626
- value: l.initial_balance_tokens ?? "",
2627
- onChange: (o) => g({ ...l, initial_balance_tokens: parseInt(o.target.value) || 0 }),
2928
+ value: d.initial_balance_tokens ?? "",
2929
+ onChange: (o) => g({ ...d, initial_balance_tokens: parseInt(o.target.value) || 0 }),
2628
2930
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2629
2931
  placeholder: "250000"
2630
2932
  }
2631
2933
  )
2632
2934
  ] }),
2633
2935
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2634
- /* @__PURE__ */ e(Z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.user_billing.initial_balance_requests") }),
2936
+ /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.user_billing.initial_balance_requests") }),
2635
2937
  /* @__PURE__ */ e(
2636
- ue,
2938
+ ge,
2637
2939
  {
2638
2940
  type: "number",
2639
- value: l.initial_balance_requests ?? "",
2640
- onChange: (o) => g({ ...l, initial_balance_requests: parseInt(o.target.value) || 0 }),
2941
+ value: d.initial_balance_requests ?? "",
2942
+ onChange: (o) => g({ ...d, initial_balance_requests: parseInt(o.target.value) || 0 }),
2641
2943
  className: "bg-muted/20 border-transparent focus:bg-background h-11",
2642
2944
  placeholder: "100"
2643
2945
  }
@@ -2648,36 +2950,36 @@ function Lt() {
2648
2950
  ] })
2649
2951
  ] }),
2650
2952
  /* @__PURE__ */ r("section", { children: [
2651
- /* @__PURE__ */ e(L, { title: t("app_settings.translations_management"), icon: ht }),
2953
+ /* @__PURE__ */ e(L, { title: t("app_settings.translations_management"), icon: Ut }),
2652
2954
  /* @__PURE__ */ r("div", { className: "border border-border/60 rounded-2xl overflow-hidden bg-background", children: [
2653
2955
  /* @__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: [
2654
2956
  /* @__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: [
2655
- /* @__PURE__ */ e("div", { className: "p-2 px-3 bg-muted/20 rounded-lg border border-border/40 ml-1", children: /* @__PURE__ */ e(ye, { className: "size-4 text-muted-foreground" }) }),
2656
- /* @__PURE__ */ r(se, { value: M, onValueChange: J, children: [
2657
- /* @__PURE__ */ e(ae, { size: "sm", className: "border-none shadow-none bg-transparent h-8 font-black uppercase tracking-wider", children: /* @__PURE__ */ e(ne, {}) }),
2658
- /* @__PURE__ */ e(ie, { children: Object.keys(l.translations || {}).sort().map((o) => /* @__PURE__ */ e(B, { value: o, children: o.toUpperCase() }, o)) })
2957
+ /* @__PURE__ */ e("div", { className: "p-2 px-3 bg-muted/20 rounded-lg border border-border/40 ml-1", children: /* @__PURE__ */ e(qe, { className: "size-4 text-muted-foreground" }) }),
2958
+ /* @__PURE__ */ r(oe, { value: U, onValueChange: B, children: [
2959
+ /* @__PURE__ */ e(le, { size: "sm", className: "border-none shadow-none bg-transparent h-8 font-black uppercase tracking-wider", children: /* @__PURE__ */ e(de, {}) }),
2960
+ /* @__PURE__ */ e(ce, { children: Object.keys(d.translations || {}).sort().map((o) => /* @__PURE__ */ e(Z, { value: o, children: o.toUpperCase() }, o)) })
2659
2961
  ] }),
2660
2962
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-border/60" }),
2661
- /* @__PURE__ */ r(se, { value: E, onValueChange: W, children: [
2662
- /* @__PURE__ */ e(ae, { size: "sm", className: "border-none shadow-none bg-transparent h-8 flex-1 font-bold", children: /* @__PURE__ */ e(ne, {}) }),
2663
- /* @__PURE__ */ e(ie, { children: Object.keys(l.translations?.[M] || {}).sort().map((o) => /* @__PURE__ */ e(B, { value: o, children: o }, o)) })
2963
+ /* @__PURE__ */ r(oe, { value: G, onValueChange: F, children: [
2964
+ /* @__PURE__ */ e(le, { size: "sm", className: "border-none shadow-none bg-transparent h-8 flex-1 font-bold", children: /* @__PURE__ */ e(de, {}) }),
2965
+ /* @__PURE__ */ e(ce, { children: Object.keys(d.translations?.[U] || {}).sort().map((o) => /* @__PURE__ */ e(Z, { value: o, children: o }, o)) })
2664
2966
  ] })
2665
2967
  ] }),
2666
2968
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
2667
- /* @__PURE__ */ e("button", { type: "button", onClick: K, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(pt, { className: "size-4" }) }),
2668
- /* @__PURE__ */ e("button", { type: "button", onClick: de, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(ye, { className: "size-4" }) })
2969
+ /* @__PURE__ */ e("button", { type: "button", onClick: Q, 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" }) }),
2970
+ /* @__PURE__ */ e("button", { type: "button", onClick: fe, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(qe, { className: "size-4" }) })
2669
2971
  ] })
2670
2972
  ] }),
2671
2973
  /* @__PURE__ */ r("div", { className: "relative p-6", children: [
2672
2974
  /* @__PURE__ */ r("div", { className: "absolute top-8 right-10 flex items-center gap-2", children: [
2673
2975
  /* @__PURE__ */ e("span", { className: "text-[10px] font-bold text-muted-foreground/40 uppercase tracking-widest", children: "JSON EDITOR" }),
2674
- /* @__PURE__ */ e(gt, { className: "size-3 text-muted-foreground/30" })
2976
+ /* @__PURE__ */ e(Ft, { className: "size-3 text-muted-foreground/30" })
2675
2977
  ] }),
2676
2978
  /* @__PURE__ */ e(
2677
- je,
2979
+ Fe,
2678
2980
  {
2679
- value: Y,
2680
- onChange: (o) => f(o.target.value),
2981
+ value: ae,
2982
+ onChange: (o) => x(o.target.value),
2681
2983
  dir: "ltr",
2682
2984
  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 ${h ? "border-destructive/40 focus:ring-destructive/20" : "border-border/40 focus:ring-primary/20"}`,
2683
2985
  spellCheck: !1
@@ -2698,31 +3000,31 @@ function Lt() {
2698
3000
  ] }) })
2699
3001
  ] });
2700
3002
  }
2701
- function he() {
2702
- const { t, i18n: n } = te(["admin"]), i = n.language === "fa";
3003
+ function ye() {
3004
+ const { t, i18n: n } = me(["admin"]), i = n.language === "fa";
2703
3005
  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: [
2704
- /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(ft, { className: "size-10 text-destructive/70" }) }),
3006
+ /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(Rt, { className: "size-10 text-destructive/70" }) }),
2705
3007
  /* @__PURE__ */ r("div", { className: "space-y-1 max-w-sm", children: [
2706
3008
  /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground tracking-tight", children: t("errors.access_denied_title", "Access Denied") }),
2707
3009
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground leading-relaxed", children: t("errors.access_denied_message", "You don't have permission to access this page.") })
2708
3010
  ] })
2709
3011
  ] });
2710
3012
  }
2711
- const qt = ({ className: t }) => {
2712
- const { t: n } = te(["theme"]), { theme: i, setTheme: m } = Se(), x = () => {
2713
- m(i === "system" ? "light" : i === "light" ? "dark" : "system");
3013
+ const Yt = ({ className: t }) => {
3014
+ const { t: n } = me(["theme"]), { theme: i, setTheme: c } = Me(), f = () => {
3015
+ c(i === "system" ? "light" : i === "light" ? "dark" : "system");
2714
3016
  }, u = () => {
2715
3017
  switch (i) {
2716
3018
  case "light":
2717
- return /* @__PURE__ */ e(bt, { className: "h-[1.2rem] w-[1.2rem]" });
3019
+ return /* @__PURE__ */ e(zt, { className: "h-[1.2rem] w-[1.2rem]" });
2718
3020
  case "dark":
2719
- return /* @__PURE__ */ e(xt, { className: "h-[1.2rem] w-[1.2rem]" });
3021
+ return /* @__PURE__ */ e(Pt, { className: "h-[1.2rem] w-[1.2rem]" });
2720
3022
  case "system":
2721
- return /* @__PURE__ */ e(Me, { className: "h-[1.2rem] w-[1.2rem]" });
3023
+ return /* @__PURE__ */ e(ze, { className: "h-[1.2rem] w-[1.2rem]" });
2722
3024
  default:
2723
- return /* @__PURE__ */ e(Me, { className: "h-[1.2rem] w-[1.2rem]" });
3025
+ return /* @__PURE__ */ e(ze, { className: "h-[1.2rem] w-[1.2rem]" });
2724
3026
  }
2725
- }, v = () => {
3027
+ }, b = () => {
2726
3028
  switch (i) {
2727
3029
  case "light":
2728
3030
  return n("dark");
@@ -2734,60 +3036,60 @@ const qt = ({ className: t }) => {
2734
3036
  return n("toggle");
2735
3037
  }
2736
3038
  };
2737
- return /* @__PURE__ */ r(_e, { children: [
2738
- /* @__PURE__ */ e(we, { asChild: !0, children: /* @__PURE__ */ r(fe, { variant: "ghost", size: "icon", onClick: x, className: t, children: [
3039
+ return /* @__PURE__ */ r(Ae, { children: [
3040
+ /* @__PURE__ */ e(Te, { asChild: !0, children: /* @__PURE__ */ r(ke, { variant: "ghost", size: "icon", onClick: f, className: t, children: [
2739
3041
  u(),
2740
3042
  /* @__PURE__ */ e("span", { className: "sr-only", children: n("toggle") })
2741
3043
  ] }) }),
2742
- /* @__PURE__ */ e(ke, { children: v() })
3044
+ /* @__PURE__ */ e(Ie, { children: b() })
2743
3045
  ] });
2744
3046
  };
2745
- function jt({ extraPages: t = [], disabledPages: n = [] }) {
2746
- const i = it(), m = ot(), { t: x, i18n: u } = te(["admin", "settings", "translation"]), { app: v } = pe(), { theme: _ } = Se(), [N, P] = b([]), [D, T] = b(!1), A = Ee(!1), [F, q] = b("light");
2747
- Q(() => {
2748
- if (_ === "system") {
3047
+ function er({ extraPages: t = [], disabledPages: n = [] }) {
3048
+ const i = Ct(), c = Lt(), { t: f, i18n: u } = me(["admin", "settings", "translation"]), { app: b } = _e(), { theme: w } = Me(), [_, V] = p([]), [D, j] = p(!1), $ = Ce(!1), [O, S] = p("light");
3049
+ Y(() => {
3050
+ if (w === "system") {
2749
3051
  const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
2750
- q(h ? "dark" : "light");
3052
+ S(h ? "dark" : "light");
2751
3053
  } else
2752
- q(_);
2753
- }, [_]);
2754
- const I = xe(() => v?.logo ? typeof v.logo == "string" ? v.logo : F === "dark" ? v.logo.dark : v.logo.light : Oe, [v?.logo, F]), H = v?.adminTitle || v?.name, w = u.language === "fa";
2755
- Q(() => {
3054
+ S(w);
3055
+ }, [w]);
3056
+ const E = Se(() => b?.logo ? typeof b.logo == "string" ? b.logo : O === "dark" ? b.logo.dark : b.logo.light : Be, [b?.logo, O]), H = b?.adminTitle || b?.name, C = u.language === "fa";
3057
+ Y(() => {
2756
3058
  const h = localStorage.getItem("admin_info");
2757
3059
  if (h)
2758
3060
  try {
2759
- const d = JSON.parse(h).permissions || [];
2760
- if (P(d), m.pathname === "/admin" || m.pathname === "/admin/")
2761
- if (d.includes("analytics") && !n.includes("analytics"))
3061
+ const l = JSON.parse(h).permissions || [];
3062
+ if (V(l), c.pathname === "/admin" || c.pathname === "/admin/")
3063
+ if (l.includes("analytics") && !n.includes("analytics"))
2762
3064
  i("/admin/analytics", { replace: !0 });
2763
- else if (d.includes("chat_history") && !n.includes("chat_history"))
3065
+ else if (l.includes("chat_history") && !n.includes("chat_history"))
2764
3066
  i("/admin/chat-history", { replace: !0 });
2765
- else if (d.includes("user_management") && !n.includes("user_management"))
3067
+ else if (l.includes("user_management") && !n.includes("user_management"))
2766
3068
  i("/admin/users", { replace: !0 });
2767
- else if (d.includes("admin_management") && !n.includes("admin_management"))
3069
+ else if (l.includes("admin_management") && !n.includes("admin_management"))
2768
3070
  i("/admin/admins", { replace: !0 });
2769
- else if (d.includes("settings") && !n.includes("settings"))
3071
+ else if (l.includes("settings") && !n.includes("settings"))
2770
3072
  i("/admin/settings", { replace: !0 });
2771
3073
  else {
2772
- const c = t.find((y) => !y.permission || d.includes(y.permission));
2773
- c && i(`/admin/${c.path}`, { replace: !0 });
3074
+ const m = t.find((N) => !N.permission || l.includes(N.permission));
3075
+ m && i(`/admin/${m.path}`, { replace: !0 });
2774
3076
  }
2775
- } catch (U) {
2776
- console.error("Failed to parse admin_info", U);
3077
+ } catch (I) {
3078
+ console.error("Failed to parse admin_info", I);
2777
3079
  }
2778
3080
  else
2779
3081
  console.warn("DashboardPage: No adminInfo found in localStorage");
2780
- }, [i, m.pathname]);
2781
- const M = () => {
3082
+ }, [i, c.pathname]);
3083
+ const U = () => {
2782
3084
  k.clearToken(), window.location.reload();
2783
- }, J = (h) => N.includes(h), E = (h) => N.includes(h) && !n.includes(h), W = Object.keys(u.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), Y = W.length > 0 ? W : ["en", "fa"], G = (h) => {
2784
- localStorage.setItem("gentiq-admin-language", h), u.changeLanguage(h), T(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
3085
+ }, B = (h) => _.includes(h), G = (h) => _.includes(h) && !n.includes(h), F = Object.keys(u.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), ae = F.length > 0 ? F : ["en", "fa"], K = (h) => {
3086
+ localStorage.setItem("gentiq-admin-language", h), u.changeLanguage(h), j(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
2785
3087
  };
2786
- return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: w ? "rtl" : "ltr", children: [
3088
+ return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: C ? "rtl" : "ltr", children: [
2787
3089
  /* @__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: [
2788
3090
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch gap-x-12", children: [
2789
3091
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3 py-4 md:py-0", children: [
2790
- /* @__PURE__ */ e("img", { src: I, alt: H, className: "size-8 object-contain" }),
3092
+ /* @__PURE__ */ e("img", { src: E, alt: H, className: "size-8 object-contain" }),
2791
3093
  /* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: H })
2792
3094
  ] }),
2793
3095
  /* @__PURE__ */ r("nav", { className: "flex items-stretch gap-8", children: [
@@ -2795,132 +3097,132 @@ function jt({ extraPages: t = [], disabledPages: n = [] }) {
2795
3097
  "button",
2796
3098
  {
2797
3099
  onClick: () => i("/admin/analytics"),
2798
- 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"}`,
2799
- children: x("dashboard.tabs.analytics")
3100
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${c.pathname === "/admin/analytics" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3101
+ children: f("dashboard.tabs.analytics")
2800
3102
  }
2801
3103
  ),
2802
3104
  !n.includes("chat_history") && /* @__PURE__ */ e(
2803
3105
  "button",
2804
3106
  {
2805
3107
  onClick: () => i("/admin/chat-history"),
2806
- 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"}`,
2807
- children: x("dashboard.tabs.chat_history")
3108
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${c.pathname === "/admin/chat-history" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3109
+ children: f("dashboard.tabs.chat_history")
2808
3110
  }
2809
3111
  ),
2810
3112
  !n.includes("user_management") && /* @__PURE__ */ e(
2811
3113
  "button",
2812
3114
  {
2813
3115
  onClick: () => i("/admin/users"),
2814
- 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"}`,
2815
- children: x("dashboard.tabs.users")
3116
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${c.pathname === "/admin/users" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3117
+ children: f("dashboard.tabs.users")
2816
3118
  }
2817
3119
  ),
2818
3120
  !n.includes("admin_management") && /* @__PURE__ */ e(
2819
3121
  "button",
2820
3122
  {
2821
3123
  onClick: () => i("/admin/admins"),
2822
- 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"}`,
2823
- children: x("dashboard.tabs.admins")
3124
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${c.pathname === "/admin/admins" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3125
+ children: f("dashboard.tabs.admins")
2824
3126
  }
2825
3127
  ),
2826
3128
  !n.includes("settings") && /* @__PURE__ */ e(
2827
3129
  "button",
2828
3130
  {
2829
3131
  onClick: () => i("/admin/settings"),
2830
- 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"}`,
2831
- children: x("dashboard.tabs.settings")
3132
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${c.pathname === "/admin/settings" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3133
+ children: f("dashboard.tabs.settings")
2832
3134
  }
2833
3135
  ),
2834
3136
  t.map((h) => /* @__PURE__ */ e(
2835
3137
  "button",
2836
3138
  {
2837
3139
  onClick: () => i(`/admin/${h.path}`),
2838
- 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"}`,
2839
- children: typeof h.label == "string" ? x(h.label) : h.label
3140
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${c.pathname === `/admin/${h.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3141
+ children: typeof h.label == "string" ? f(h.label) : h.label
2840
3142
  },
2841
3143
  `tab-${h.path}`
2842
3144
  ))
2843
3145
  ] })
2844
3146
  ] }),
2845
3147
  /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 py-4 md:py-0", children: [
2846
- /* @__PURE__ */ r(Ye, { onOpenChange: (h) => {
2847
- h ? T(!1) : (A.current = !0, setTimeout(() => {
2848
- A.current = !1;
3148
+ /* @__PURE__ */ r(vt, { onOpenChange: (h) => {
3149
+ h ? j(!1) : ($.current = !0, setTimeout(() => {
3150
+ $.current = !1;
2849
3151
  }, 200));
2850
3152
  }, children: [
2851
3153
  /* @__PURE__ */ r(
2852
- _e,
3154
+ Ae,
2853
3155
  {
2854
3156
  open: D,
2855
3157
  onOpenChange: (h) => {
2856
- h && A.current || T(h);
3158
+ h && $.current || j(h);
2857
3159
  },
2858
3160
  children: [
2859
- /* @__PURE__ */ e(we, { asChild: !0, children: /* @__PURE__ */ e(et, { asChild: !0, children: /* @__PURE__ */ e(
2860
- fe,
3161
+ /* @__PURE__ */ e(Te, { asChild: !0, children: /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ e(
3162
+ ke,
2861
3163
  {
2862
3164
  variant: "ghost",
2863
3165
  size: "icon",
2864
3166
  className: "font-bold text-xs text-muted-foreground hover:bg-muted",
2865
- onPointerDown: () => T(!1),
3167
+ onPointerDown: () => j(!1),
2866
3168
  children: (u.language?.split("-")[0] || "").toUpperCase()
2867
3169
  }
2868
3170
  ) }) }),
2869
- /* @__PURE__ */ e(ke, { side: "bottom", className: "text-xs", children: x("dashboard.language", "Change Language") })
3171
+ /* @__PURE__ */ e(Ie, { side: "bottom", className: "text-xs", children: f("dashboard.language", "Change Language") })
2870
3172
  ]
2871
3173
  }
2872
3174
  ),
2873
- /* @__PURE__ */ e(tt, { align: "center", className: "min-w-[8rem]", children: Y.map((h) => /* @__PURE__ */ e(
2874
- rt,
3175
+ /* @__PURE__ */ e(_t, { align: "center", className: "min-w-[8rem]", children: ae.map((h) => /* @__PURE__ */ e(
3176
+ Nt,
2875
3177
  {
2876
- onClick: () => G(h),
3178
+ onClick: () => K(h),
2877
3179
  className: h === u.language ? "bg-primary/10" : "",
2878
- children: x(`general.languages.${h}`, h.toUpperCase())
3180
+ children: f(`general.languages.${h}`, h.toUpperCase())
2879
3181
  },
2880
3182
  h
2881
3183
  )) })
2882
3184
  ] }),
2883
- /* @__PURE__ */ e(qt, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
3185
+ /* @__PURE__ */ e(Yt, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
2884
3186
  /* @__PURE__ */ e("div", { className: "w-px h-5 bg-border mx-1" }),
2885
- /* @__PURE__ */ r(_e, { children: [
2886
- /* @__PURE__ */ e(we, { asChild: !0, children: /* @__PURE__ */ e(
2887
- fe,
3187
+ /* @__PURE__ */ r(Ae, { children: [
3188
+ /* @__PURE__ */ e(Te, { asChild: !0, children: /* @__PURE__ */ e(
3189
+ ke,
2888
3190
  {
2889
3191
  variant: "ghost",
2890
3192
  size: "icon",
2891
3193
  className: "hover:bg-destructive/10 hover:scale-105 active:scale-95 text-muted-foreground hover:text-destructive",
2892
- onClick: M,
2893
- children: /* @__PURE__ */ e(vt, { className: "size-5" })
3194
+ onClick: U,
3195
+ children: /* @__PURE__ */ e(Jt, { className: "size-5" })
2894
3196
  }
2895
3197
  ) }),
2896
- /* @__PURE__ */ e(ke, { side: "bottom", className: "text-xs", children: x("dashboard.logout") })
3198
+ /* @__PURE__ */ e(Ie, { side: "bottom", className: "text-xs", children: f("dashboard.logout") })
2897
3199
  ] })
2898
3200
  ] })
2899
3201
  ] }) }) }),
2900
- /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(lt, { children: [
2901
- /* @__PURE__ */ e(me, { path: "/", element: /* @__PURE__ */ e(Te, { to: "/admin/analytics", replace: !0 }) }),
2902
- /* @__PURE__ */ e(me, { path: "/analytics", element: E("analytics") ? /* @__PURE__ */ e(Ct, {}) : /* @__PURE__ */ e(he, {}) }),
2903
- /* @__PURE__ */ e(me, { path: "/chat-history", element: E("chat_history") ? /* @__PURE__ */ e(_t, {}) : /* @__PURE__ */ e(he, {}) }),
2904
- /* @__PURE__ */ e(me, { path: "/admins", element: E("admin_management") ? /* @__PURE__ */ e(wt, {}) : /* @__PURE__ */ e(he, {}) }),
2905
- /* @__PURE__ */ e(me, { path: "/settings", element: E("settings") ? /* @__PURE__ */ e(Lt, {}) : /* @__PURE__ */ e(he, {}) }),
2906
- /* @__PURE__ */ e(me, { path: "/users", element: E("user_management") ? /* @__PURE__ */ e(St, {}) : /* @__PURE__ */ e(he, {}) }),
3202
+ /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(qt, { children: [
3203
+ /* @__PURE__ */ e(pe, { path: "/", element: /* @__PURE__ */ e(Re, { to: "/admin/analytics", replace: !0 }) }),
3204
+ /* @__PURE__ */ e(pe, { path: "/analytics", element: G("analytics") ? /* @__PURE__ */ e(Qt, {}) : /* @__PURE__ */ e(ye, {}) }),
3205
+ /* @__PURE__ */ e(pe, { path: "/chat-history", element: G("chat_history") ? /* @__PURE__ */ e(Bt, {}) : /* @__PURE__ */ e(ye, {}) }),
3206
+ /* @__PURE__ */ e(pe, { path: "/admins", element: G("admin_management") ? /* @__PURE__ */ e(Wt, {}) : /* @__PURE__ */ e(ye, {}) }),
3207
+ /* @__PURE__ */ e(pe, { path: "/settings", element: G("settings") ? /* @__PURE__ */ e(Xt, {}) : /* @__PURE__ */ e(ye, {}) }),
3208
+ /* @__PURE__ */ e(pe, { path: "/users", element: G("user_management") ? /* @__PURE__ */ e(Zt, {}) : /* @__PURE__ */ e(ye, {}) }),
2907
3209
  t.map((h) => /* @__PURE__ */ e(
2908
- me,
3210
+ pe,
2909
3211
  {
2910
3212
  path: `/${h.path}`,
2911
- element: h.permission && !J(h.permission) ? /* @__PURE__ */ e(he, {}) : h.element
3213
+ element: h.permission && !B(h.permission) ? /* @__PURE__ */ e(ye, {}) : h.element
2912
3214
  },
2913
3215
  `route-${h.path}`
2914
3216
  )),
2915
- /* @__PURE__ */ e(me, { path: "*", element: /* @__PURE__ */ e(Te, { to: "/admin/analytics", replace: !0 }) })
3217
+ /* @__PURE__ */ e(pe, { path: "*", element: /* @__PURE__ */ e(Re, { to: "/admin/analytics", replace: !0 }) })
2916
3218
  ] }) }) })
2917
3219
  ] });
2918
3220
  }
2919
- function Ut(t) {
2920
- const n = xe(() => {
2921
- const i = ze.createInstance();
2922
- return i.use(st).use(Pe).init({
2923
- resources: at,
3221
+ function mr(t) {
3222
+ const n = Se(() => {
3223
+ const i = ut.createInstance();
3224
+ return i.use(wt).use(ht).init({
3225
+ resources: kt,
2924
3226
  fallbackLng: "en",
2925
3227
  interpolation: { escapeValue: !1 },
2926
3228
  detection: {
@@ -2930,114 +3232,114 @@ function Ut(t) {
2930
3232
  }
2931
3233
  }), i;
2932
3234
  }, []);
2933
- return /* @__PURE__ */ e(Je, { i18n: n, children: /* @__PURE__ */ e(Tt, { ...t }) });
3235
+ return /* @__PURE__ */ e(pt, { i18n: n, children: /* @__PURE__ */ e(tr, { ...t }) });
2934
3236
  }
2935
- function Tt({ extraPages: t, disabledPages: n = [] }) {
2936
- const { app: i, i18n: m } = pe(), { t: x, i18n: u } = te(["admin", "translation"]), [v, _] = b(!1), [N, P] = b(!0), [D, T] = b(!1);
2937
- Q(() => {
2938
- m?.resources && Object.entries(m.resources).forEach(([q, I]) => {
2939
- Object.entries(I).forEach(([H, w]) => {
2940
- u.addResourceBundle(q, H, w, !0, !0);
3237
+ function tr({ extraPages: t, disabledPages: n = [] }) {
3238
+ const { app: i, i18n: c } = _e(), { t: f, i18n: u } = me(["admin", "translation"]), [b, w] = p(!1), [_, V] = p(!0), [D, j] = p(!1);
3239
+ Y(() => {
3240
+ c?.resources && Object.entries(c.resources).forEach(([S, E]) => {
3241
+ Object.entries(E).forEach(([H, C]) => {
3242
+ u.addResourceBundle(S, H, C, !0, !0);
2941
3243
  });
2942
- }), !localStorage.getItem("gentiq-admin-language") && i?.language && u.language !== i.language && u.changeLanguage(i.language), T(!0);
2943
- }, [m?.resources, u, i?.language]), Q(() => {
2944
- const F = k.getToken();
2945
- return _(!!F), P(!1), document.body.classList.add("admin-theme-root"), () => {
3244
+ }), !localStorage.getItem("gentiq-admin-language") && i?.language && u.language !== i.language && u.changeLanguage(i.language), j(!0);
3245
+ }, [c?.resources, u, i?.language]), Y(() => {
3246
+ const O = k.getToken();
3247
+ return w(!!O), V(!1), document.body.classList.add("admin-theme-root"), () => {
2946
3248
  document.body.classList.remove("admin-theme-root");
2947
3249
  };
2948
- }, []), Q(() => {
3250
+ }, []), Y(() => {
2949
3251
  D && (document.documentElement.dir = u.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = u.language);
2950
3252
  }, [D, u.language]);
2951
- const A = () => {
2952
- _(!0);
3253
+ const $ = () => {
3254
+ w(!0);
2953
3255
  };
2954
- return N || !D ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: x("loading") }) }) : /* @__PURE__ */ e(nt, { storageKey: "gentiq-admin-theme", children: v ? /* @__PURE__ */ e(jt, { extraPages: t, disabledPages: n }) : /* @__PURE__ */ e(Nt, { onLoginSuccess: A }) });
3256
+ return _ || !D ? /* @__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(St, { storageKey: "gentiq-admin-theme", children: b ? /* @__PURE__ */ e(er, { extraPages: t, disabledPages: n }) : /* @__PURE__ */ e(Ht, { onLoginSuccess: $ }) });
2955
3257
  }
2956
- const le = "gentiq_admin";
2957
- function zt(t = 0, n = 100, i = "") {
2958
- return ge({
2959
- queryKey: [le, "users", t, n, i],
3258
+ const he = "gentiq_admin";
3259
+ function ur(t = 0, n = 100, i = "") {
3260
+ return Ne({
3261
+ queryKey: [he, "users", t, n, i],
2960
3262
  queryFn: () => k.listUsers(t, n, i)
2961
3263
  });
2962
3264
  }
2963
- function Pt() {
2964
- const t = Ce(), n = () => {
2965
- t.invalidateQueries({ queryKey: [le, "users"] });
2966
- }, i = oe({
2967
- mutationFn: (_) => k.createUser(_.phone, _.name, _.surname, _.tokens, _.requests),
3265
+ function hr() {
3266
+ const t = De(), n = () => {
3267
+ t.invalidateQueries({ queryKey: [he, "users"] });
3268
+ }, i = ue({
3269
+ mutationFn: (w) => k.createUser(w.phone, w.name, w.surname, w.tokens, w.requests),
2968
3270
  onSuccess: n
2969
- }), m = oe({
2970
- mutationFn: ({ userId: _, data: N }) => k.updateUser(_, N),
3271
+ }), c = ue({
3272
+ mutationFn: ({ userId: w, data: _ }) => k.updateUser(w, _),
2971
3273
  onSuccess: n
2972
- }), x = oe({
2973
- mutationFn: (_) => k.deleteUser(_),
3274
+ }), f = ue({
3275
+ mutationFn: (w) => k.deleteUser(w),
2974
3276
  onSuccess: n
2975
- }), u = oe({
2976
- mutationFn: ({ userId: _, tokens: N, requests: P }) => k.updateUserBalance(_, N, P),
3277
+ }), u = ue({
3278
+ mutationFn: ({ userId: w, tokens: _, requests: V }) => k.updateUserBalance(w, _, V),
2977
3279
  onSuccess: n
2978
- }), v = oe({
2979
- mutationFn: (_) => k.refreshUserToken(_)
3280
+ }), b = ue({
3281
+ mutationFn: (w) => k.refreshUserToken(w)
2980
3282
  });
2981
- return { createUser: i, updateUser: m, deleteUser: x, updateBalance: u, refreshToken: v };
3283
+ return { createUser: i, updateUser: c, deleteUser: f, updateBalance: u, refreshToken: b };
2982
3284
  }
2983
- function Jt(t = 30) {
2984
- return ge({
2985
- queryKey: [le, "analytics", t],
3285
+ function pr(t = 30) {
3286
+ return Ne({
3287
+ queryKey: [he, "analytics", t],
2986
3288
  queryFn: () => k.getAnalytics(t)
2987
3289
  });
2988
3290
  }
2989
- function Ht() {
2990
- return ge({
2991
- queryKey: [le, "admins"],
3291
+ function gr() {
3292
+ return Ne({
3293
+ queryKey: [he, "admins"],
2992
3294
  queryFn: () => k.listAdmins()
2993
3295
  });
2994
3296
  }
2995
- function Vt() {
2996
- const t = Ce(), n = () => {
2997
- t.invalidateQueries({ queryKey: [le, "admins"] });
2998
- }, i = oe({
3297
+ function fr() {
3298
+ const t = De(), n = () => {
3299
+ t.invalidateQueries({ queryKey: [he, "admins"] });
3300
+ }, i = ue({
2999
3301
  mutationFn: (u) => k.register(u.username, u.password, u.name, u.permissions),
3000
3302
  onSuccess: n
3001
- }), m = oe({
3002
- mutationFn: ({ adminId: u, data: v }) => k.updateAdmin(u, v),
3303
+ }), c = ue({
3304
+ mutationFn: ({ adminId: u, data: b }) => k.updateAdmin(u, b),
3003
3305
  onSuccess: n
3004
- }), x = oe({
3306
+ }), f = ue({
3005
3307
  mutationFn: (u) => k.deleteAdmin(u),
3006
3308
  onSuccess: n
3007
3309
  });
3008
- return { createAdmin: i, updateAdmin: m, deleteAdmin: x };
3310
+ return { createAdmin: i, updateAdmin: c, deleteAdmin: f };
3009
3311
  }
3010
- function Bt(t = 0, n = 50, i, m) {
3011
- return ge({
3012
- queryKey: [le, "threads", t, n, i, m],
3013
- queryFn: () => k.listThreads(t, n, i, m)
3312
+ function xr(t = 0, n = 50, i, c) {
3313
+ return Ne({
3314
+ queryKey: [he, "threads", t, n, i, c],
3315
+ queryFn: () => k.listThreads(t, n, i, c)
3014
3316
  });
3015
3317
  }
3016
- function Wt(t) {
3017
- return ge({
3018
- queryKey: [le, "threadItems", t],
3318
+ function br(t) {
3319
+ return Ne({
3320
+ queryKey: [he, "threadItems", t],
3019
3321
  queryFn: () => k.getThreadItems(t),
3020
3322
  enabled: !!t
3021
3323
  });
3022
3324
  }
3023
- function Gt(t = 20, n) {
3024
- return ge({
3025
- queryKey: [le, "jobs", t, n],
3325
+ function vr(t = 20, n) {
3326
+ return Ne({
3327
+ queryKey: [he, "jobs", t, n],
3026
3328
  queryFn: () => k.listJobs(t, n),
3027
3329
  refetchInterval: 5e3
3028
3330
  // Auto-refresh jobs every 5 seconds
3029
3331
  });
3030
3332
  }
3031
- function Kt() {
3032
- const t = Ce();
3033
- return { cancelJob: oe({
3034
- mutationFn: (m) => k.cancelJob(m),
3333
+ function yr() {
3334
+ const t = De();
3335
+ return { cancelJob: ue({
3336
+ mutationFn: (c) => k.cancelJob(c),
3035
3337
  onSuccess: () => {
3036
- t.invalidateQueries({ queryKey: [le, "jobs"] });
3338
+ t.invalidateQueries({ queryKey: [he, "jobs"] });
3037
3339
  }
3038
3340
  }) };
3039
3341
  }
3040
- function Zt() {
3342
+ function _r() {
3041
3343
  return {
3042
3344
  login: async (t, n) => k.login(t, n),
3043
3345
  logout: () => k.clearToken(),
@@ -3046,15 +3348,15 @@ function Zt() {
3046
3348
  };
3047
3349
  }
3048
3350
  export {
3049
- Ut as AdminPanel,
3050
- Ht as useAdminAdmins,
3051
- Vt as useAdminAdminsMutations,
3052
- Jt as useAdminAnalytics,
3053
- Zt as useAdminAuth,
3054
- Gt as useAdminJobs,
3055
- Kt as useAdminJobsMutations,
3056
- Wt as useAdminThreadItems,
3057
- Bt as useAdminThreads,
3058
- zt as useAdminUsers,
3059
- Pt as useAdminUsersMutations
3351
+ mr as AdminPanel,
3352
+ gr as useAdminAdmins,
3353
+ fr as useAdminAdminsMutations,
3354
+ pr as useAdminAnalytics,
3355
+ _r as useAdminAuth,
3356
+ vr as useAdminJobs,
3357
+ yr as useAdminJobsMutations,
3358
+ br as useAdminThreadItems,
3359
+ xr as useAdminThreads,
3360
+ ur as useAdminUsers,
3361
+ hr as useAdminUsersMutations
3060
3362
  };