gentiq 0.8.0 → 0.8.2

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