gentiq 0.7.26 → 0.7.28

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