gentiq 0.7.25 → 0.7.27

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