gentiq 0.8.1 → 0.8.3

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