gentiq 0.7.27 → 0.7.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- import { jsx as e, jsxs as r, Fragment as Fe } from "react/jsx-runtime";
2
- import { useState as x, useEffect as W, useMemo as pe, useRef as Me } from "react";
3
- import Ue from "i18next";
4
- import { useTranslation as ee, initReactI18next as ze, I18nextProvider as Je } from "react-i18next";
5
- import { a as me, m as we, v as Ie, n as ke, S as ne, q as ie, r as oe, e as be, s as le, t as G, K as Pe, D as He, o as Be, p as Ve, E as We, F as Ke, H as Ge, J as Ze, a0 as Qe, B as he, L as Q, I as de, a1 as Se, i as ve, k as ye, l as Ne, x as Xe, y as Ye, z as et, A as tt, a2 as rt, d as st, T as at } from "./checkbox-plYm_Rxp.js";
6
- import { useNavigate as nt, useLocation as it, Routes as ot, Route as ae, Navigate as Ce } from "react-router-dom";
7
- import { Share2 as lt, RefreshCcw as Le, Globe as xe, Keyboard as dt, Wallet as ct, Languages as mt, Plus as ut, Hash as ht, ShieldAlert as pt, Monitor as qe, Moon as gt, Sun as ft, LogOut as xt } from "lucide-react";
8
- import { toast as je } from "sonner";
9
- import * as Te from "@radix-ui/react-switch";
1
+ import { jsx as e, jsxs as r, Fragment as Ue } from "react/jsx-runtime";
2
+ import { useState as b, useEffect as W, useMemo as pe, useRef as Ie } from "react";
3
+ import ze from "i18next";
4
+ import { useTranslation as ee, initReactI18next as Je, I18nextProvider as Pe } from "react-i18next";
5
+ import { G as ke, a as me, m as we, v as $e, n as Se, S as ne, q as ie, r as oe, e as be, s as le, t as K, K as He, D as Be, o as Ve, p as We, E as Ge, F as Ke, H as Ze, J as Qe, a0 as Xe, B as he, L as Q, I as de, a1 as Ce, i as ve, k as ye, l as Ne, x as Ye, y as et, z as tt, A as rt, a2 as st, d as at, T as nt } from "./checkbox-DIJ7BlxY.js";
6
+ import { useNavigate as it, useLocation as ot, Routes as lt, Route as ae, Navigate as Le } from "react-router-dom";
7
+ import { Share2 as dt, RefreshCcw as qe, Globe as xe, Keyboard as ct, Wallet as mt, Languages as ut, Plus as ht, Hash as pt, ShieldAlert as gt, Monitor as je, Moon as ft, Sun as xt, LogOut as bt } from "lucide-react";
8
+ import { toast as Te } from "sonner";
9
+ import * as Ae from "@radix-ui/react-switch";
10
10
  import { useQuery as ue, useQueryClient as _e, useMutation as re } from "@tanstack/react-query";
11
- const Ae = "/api";
12
- class bt {
11
+ const Me = "/api";
12
+ class vt {
13
13
  token = null;
14
14
  constructor() {
15
15
  this.token = localStorage.getItem("admin_token");
@@ -26,15 +26,24 @@ class bt {
26
26
  async request(n, o = {}) {
27
27
  const m = new Headers(o.headers);
28
28
  m.has("Content-Type") || m.set("Content-Type", "application/json"), this.token && m.set("Authorization", `Bearer ${this.token}`);
29
- const b = await fetch(`${Ae}${n}`, {
29
+ const x = await fetch(`${Me}${n}`, {
30
30
  ...o,
31
31
  headers: m
32
32
  });
33
- if (!b.ok) {
34
- const p = await b.json().catch(() => ({ error: "Request failed" }));
35
- throw new Error(p.error || `HTTP ${b.status}`);
33
+ if (!x.ok) {
34
+ const u = await x.json().catch(() => ({}));
35
+ if (u.error && (typeof u.error.code == "string" || typeof u.error.message == "string"))
36
+ throw new ke(u, x.status);
37
+ let v = `HTTP ${x.status}`, _ = "error", N = null;
38
+ throw typeof u.detail == "string" ? v = u.detail : typeof u.message == "string" ? v = u.message : typeof u.error == "string" ? v = u.error : Array.isArray(u.detail) ? (v = "Validation failed", N = u.detail, _ = "validation_error") : u.error && typeof u.error.message == "string" && (v = u.error.message), new ke({
39
+ error: {
40
+ code: _,
41
+ message: v,
42
+ details: N
43
+ }
44
+ }, x.status);
36
45
  }
37
- return b.json();
46
+ return x.json();
38
47
  }
39
48
  async login(n, o) {
40
49
  const m = await this.request("/admin/login", {
@@ -42,21 +51,21 @@ class bt {
42
51
  body: JSON.stringify({ username: n, password: o })
43
52
  });
44
53
  this.setToken(m.token);
45
- const b = {
54
+ const x = {
46
55
  admin_id: m.admin_id,
47
56
  username: m.username,
48
57
  name: m.name,
49
58
  permissions: m.permissions
50
59
  };
51
- return localStorage.setItem("admin_info", JSON.stringify(b)), m;
60
+ return localStorage.setItem("admin_info", JSON.stringify(x)), m;
52
61
  }
53
62
  async checkSetupStatus() {
54
63
  return this.request("/admin/setup-status");
55
64
  }
56
- async register(n, o, m, b) {
65
+ async register(n, o, m, x) {
57
66
  return this.request("/admin/admins", {
58
67
  method: "POST",
59
- body: JSON.stringify({ username: n, password: o, name: m, permissions: b })
68
+ body: JSON.stringify({ username: n, password: o, name: m, permissions: x })
60
69
  });
61
70
  }
62
71
  async listAdmins() {
@@ -76,9 +85,9 @@ class bt {
76
85
  async listPermissions() {
77
86
  return this.request("/admin/permissions");
78
87
  }
79
- async listThreads(n = 0, o = 50, m, b) {
80
- const p = new URLSearchParams({ skip: n.toString(), limit: o.toString() });
81
- return m && p.append("query", m), b && p.append("feedback", b), this.request(`/admin/chat-history/threads?${p}`);
88
+ async listThreads(n = 0, o = 50, m, x) {
89
+ const u = new URLSearchParams({ skip: n.toString(), limit: o.toString() });
90
+ return m && u.append("query", m), x && u.append("feedback", x), this.request(`/admin/chat-history/threads?${u}`);
82
91
  }
83
92
  async getThreadItems(n) {
84
93
  return this.request(`/admin/chat-history/threads/${n}/items`);
@@ -89,19 +98,19 @@ class bt {
89
98
  });
90
99
  }
91
100
  async listUsers(n = 0, o = 100, m = "") {
92
- const b = new URLSearchParams({ skip: n.toString(), limit: o.toString() });
93
- return m && b.append("query", m), this.request(`/admin/users?${b.toString()}`);
101
+ const x = new URLSearchParams({ skip: n.toString(), limit: o.toString() });
102
+ return m && x.append("query", m), this.request(`/admin/users?${x.toString()}`);
94
103
  }
95
- async createUser(n, o, m, b, p, N, _, w) {
96
- const H = b !== void 0 || p !== void 0 || N !== void 0 || _ !== void 0 ? {
97
- tokens: b || 0,
98
- requests: p || 0,
99
- token_limit: N || b || 0,
100
- request_limit: _ || p || 0
104
+ async createUser(n, o, m, x, u, v, _, N) {
105
+ const H = x !== void 0 || u !== void 0 || v !== void 0 || _ !== void 0 ? {
106
+ tokens: x || 0,
107
+ requests: u || 0,
108
+ token_limit: v || x || 0,
109
+ request_limit: _ || u || 0
101
110
  } : void 0;
102
111
  return this.request("/admin/users", {
103
112
  method: "POST",
104
- body: JSON.stringify({ phone: n, name: o, surname: m, balance: H, metadata: w })
113
+ body: JSON.stringify({ phone: n, name: o, surname: m, balance: H, metadata: N })
105
114
  });
106
115
  }
107
116
  async updateUser(n, o) {
@@ -115,10 +124,10 @@ class bt {
115
124
  method: "DELETE"
116
125
  });
117
126
  }
118
- async updateUserBalance(n, o, m, b, p) {
127
+ async updateUserBalance(n, o, m, x, u) {
119
128
  return this.request(`/admin/users/${n}/balance`, {
120
129
  method: "POST",
121
- body: JSON.stringify({ tokens: o, requests: m, token_limit: b, request_limit: p })
130
+ body: JSON.stringify({ tokens: o, requests: m, token_limit: x, request_limit: u })
122
131
  });
123
132
  }
124
133
  async refreshUserToken(n) {
@@ -155,42 +164,42 @@ class bt {
155
164
  async getAttachmentBlob(n) {
156
165
  const o = {};
157
166
  this.token && (o.Authorization = `Bearer ${this.token}`);
158
- const m = await fetch(`${Ae}/admin/chat-history/attachments/${n}`, {
167
+ const m = await fetch(`${Me}/admin/chat-history/attachments/${n}`, {
159
168
  method: "GET",
160
169
  headers: o
161
170
  });
162
171
  if (!m.ok) {
163
- const b = await m.json().catch(() => ({ error: "Request failed" }));
164
- throw new Error(b.error || `HTTP ${m.status}`);
172
+ const x = await m.json().catch(() => ({ error: "Request failed" }));
173
+ throw new Error(x.error || `HTTP ${m.status}`);
165
174
  }
166
175
  return m.blob();
167
176
  }
168
177
  }
169
- const k = new bt();
170
- function vt({ onLoginSuccess: t }) {
171
- const { t: n, i18n: o } = ee(["admin", "translation"]), { app: m } = me(), { theme: b } = we(), [p, N] = x(""), [_, w] = x(""), [H, T] = x(""), [A, I] = x(""), [D, C] = x(!1), [O, U] = x(null), [v, z] = x("light");
178
+ const k = new vt();
179
+ function yt({ onLoginSuccess: t }) {
180
+ const { t: n, i18n: o } = ee(["admin", "translation"]), { app: m } = me(), { theme: x } = we(), [u, v] = b(""), [_, N] = b(""), [H, T] = b(""), [A, I] = b(""), [D, C] = b(!1), [O, U] = b(null), [y, z] = b("light");
172
181
  W(() => {
173
- if (b === "system") {
174
- const u = window.matchMedia("(prefers-color-scheme: dark)").matches;
175
- z(u ? "dark" : "light");
182
+ if (x === "system") {
183
+ const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
184
+ z(h ? "dark" : "light");
176
185
  } else
177
- z(b);
178
- }, [b]);
179
- const R = pe(() => m?.logo ? typeof m.logo == "string" ? m.logo : v === "dark" ? m.logo.dark : m.logo.light : Ie, [m?.logo, v]), E = m?.adminTitle || m?.name, V = o.language === "fa";
186
+ z(x);
187
+ }, [x]);
188
+ const R = pe(() => m?.logo ? typeof m.logo == "string" ? m.logo : y === "dark" ? m.logo.dark : m.logo.light : $e, [m?.logo, y]), E = m?.adminTitle || m?.name, V = o.language === "fa";
180
189
  W(() => {
181
- k.checkSetupStatus().then((u) => U(u.needs_setup)).catch(() => U(!1));
190
+ k.checkSetupStatus().then((h) => U(h.needs_setup)).catch(() => U(!1));
182
191
  }, []);
183
- const Z = async (u) => {
184
- u.preventDefault(), I(""), C(!0);
192
+ const Z = async (h) => {
193
+ h.preventDefault(), I(""), C(!0);
185
194
  try {
186
- await k.login(p, _), t();
195
+ await k.login(u, _), t();
187
196
  } catch (J) {
188
197
  I(J instanceof Error ? J.message : n("login.error"));
189
198
  } finally {
190
199
  C(!1);
191
200
  }
192
- }, B = async (u) => {
193
- if (u.preventDefault(), I(""), _ !== H) {
201
+ }, B = async (h) => {
202
+ if (h.preventDefault(), I(""), _ !== H) {
194
203
  I(n("login.passwords_mismatch"));
195
204
  return;
196
205
  }
@@ -247,7 +256,7 @@ function vt({ onLoginSuccess: t }) {
247
256
  id: "setup-password",
248
257
  type: "password",
249
258
  value: _,
250
- onChange: (u) => w(u.target.value),
259
+ onChange: (h) => N(h.target.value),
251
260
  required: !0,
252
261
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
253
262
  placeholder: n("login.set_password_placeholder"),
@@ -263,7 +272,7 @@ function vt({ onLoginSuccess: t }) {
263
272
  id: "setup-confirm",
264
273
  type: "password",
265
274
  value: H,
266
- onChange: (u) => T(u.target.value),
275
+ onChange: (h) => T(h.target.value),
267
276
  required: !0,
268
277
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
269
278
  placeholder: n("login.confirm_password_placeholder"),
@@ -295,8 +304,8 @@ function vt({ onLoginSuccess: t }) {
295
304
  {
296
305
  id: "username",
297
306
  type: "text",
298
- value: p,
299
- onChange: (u) => N(u.target.value),
307
+ value: u,
308
+ onChange: (h) => v(h.target.value),
300
309
  required: !0,
301
310
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
302
311
  placeholder: n("login.username_placeholder"),
@@ -312,7 +321,7 @@ function vt({ onLoginSuccess: t }) {
312
321
  id: "password",
313
322
  type: "password",
314
323
  value: _,
315
- onChange: (u) => w(u.target.value),
324
+ onChange: (h) => N(h.target.value),
316
325
  required: !0,
317
326
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
318
327
  placeholder: n("login.password_placeholder"),
@@ -340,8 +349,8 @@ function vt({ onLoginSuccess: t }) {
340
349
  ] })
341
350
  ] });
342
351
  }
343
- function yt() {
344
- const { t, i18n: n } = ee(["admin", "translation"]), { app: o } = me(), m = o?.userMetadataFields || [], [b, p] = x([]), [N, _] = x(null), [w, H] = x([]), [T, A] = x(!1), [I, D] = x(!1), [C, O] = x(""), [U, v] = x(""), [z, R] = x(""), [E, V] = x(0), [Z, B] = x(!0), u = n.language === "fa", J = u ? "fa-IR" : "en-US", d = async (s = !1) => {
352
+ function Nt() {
353
+ const { t, i18n: n } = ee(["admin", "translation"]), { app: o } = me(), m = o?.userMetadataFields || [], [x, u] = b([]), [v, _] = b(null), [N, H] = b([]), [T, A] = b(!1), [I, D] = b(!1), [C, O] = b(""), [U, y] = b(""), [z, R] = b(""), [E, V] = b(0), [Z, B] = b(!0), h = n.language === "fa", J = h ? "fa-IR" : "en-US", d = async (s = !1) => {
345
354
  s ? D(!0) : (A(!0), V(0)), O("");
346
355
  try {
347
356
  const f = s ? E + 50 : 0, q = await k.listThreads(
@@ -350,7 +359,7 @@ function yt() {
350
359
  U || void 0,
351
360
  z || void 0
352
361
  );
353
- s ? (p((i) => [...i, ...q.threads]), V(f)) : (p(q.threads), V(0)), B(q.threads.length === 50);
362
+ s ? (u((i) => [...i, ...q.threads]), V(f)) : (u(q.threads), V(0)), B(q.threads.length === 50);
354
363
  } catch (f) {
355
364
  O(f instanceof Error ? f.message : t("error_loading"));
356
365
  } finally {
@@ -370,11 +379,11 @@ function yt() {
370
379
  s.stopPropagation();
371
380
  try {
372
381
  const q = await k.shareThread(f.id), i = `${window.location.origin}${q.url}`;
373
- navigator.clipboard.writeText(i), je.success(t("sidebar.share_success"), {
382
+ navigator.clipboard.writeText(i), Te.success(t("sidebar.share_success"), {
374
383
  description: t("sidebar.share_description")
375
384
  });
376
385
  } catch {
377
- je.error(t("sidebar.share_failed"));
386
+ Te.error(t("sidebar.share_failed"));
378
387
  }
379
388
  };
380
389
  W(() => {
@@ -385,7 +394,7 @@ function yt() {
385
394
  }, [U, z]);
386
395
  const g = (s) => {
387
396
  const f = new Date(s);
388
- return new Intl.DateTimeFormat(u ? "fa-IR" : "en-US", {
397
+ return new Intl.DateTimeFormat(h ? "fa-IR" : "en-US", {
389
398
  year: "numeric",
390
399
  month: "long",
391
400
  day: "numeric",
@@ -401,7 +410,7 @@ function yt() {
401
410
  }
402
411
  return JSON.stringify(s, null, 2);
403
412
  }, P = ({ part: s, idx: f }) => {
404
- const [q, i] = x(!1), y = s.tool_name || (s.type && s.type.startsWith("tool-") ? s.type.slice(5) : "tool");
413
+ const [q, i] = b(!1), w = s.tool_name || (s.type && s.type.startsWith("tool-") ? s.type.slice(5) : "tool");
405
414
  return /* @__PURE__ */ r("div", { dir: "ltr", className: "my-2 border border-border/50 rounded-xl overflow-hidden bg-muted/20 text-left", children: [
406
415
  /* @__PURE__ */ r(
407
416
  "div",
@@ -421,7 +430,7 @@ function yt() {
421
430
  }
422
431
  ),
423
432
  /* @__PURE__ */ e("span", { className: "text-[10px] font-bold uppercase tracking-widest text-muted-foreground", children: "Tool" }),
424
- /* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: y })
433
+ /* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: w })
425
434
  ] }),
426
435
  /* @__PURE__ */ e("span", { className: `text-[10px] px-2 py-0.5 rounded-full ${s.state === "output-available" ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"}`, children: s.state === "output-available" ? t("chat_history.output_available") : t("chat_history.running") })
427
436
  ]
@@ -438,10 +447,10 @@ function yt() {
438
447
  ] })
439
448
  ] })
440
449
  ] }, f);
441
- }, h = async (s, f) => {
450
+ }, p = async (s, f) => {
442
451
  try {
443
- const q = await k.getAttachmentBlob(s), i = window.URL.createObjectURL(q), y = document.createElement("a");
444
- y.href = i, y.download = f || s.split("/").pop() || "download", document.body.appendChild(y), y.click(), window.URL.revokeObjectURL(i), document.body.removeChild(y);
452
+ const q = await k.getAttachmentBlob(s), i = window.URL.createObjectURL(q), w = document.createElement("a");
453
+ w.href = i, w.download = f || s.split("/").pop() || "download", document.body.appendChild(w), w.click(), window.URL.revokeObjectURL(i), document.body.removeChild(w);
445
454
  } catch (q) {
446
455
  console.error("Download failed:", q), O(q instanceof Error ? q.message : "Download failed");
447
456
  }
@@ -459,7 +468,7 @@ function yt() {
459
468
  s.object_name && /* @__PURE__ */ e(
460
469
  "button",
461
470
  {
462
- onClick: () => h(s.object_name, s.filename),
471
+ onClick: () => p(s.object_name, s.filename),
463
472
  className: "flex-shrink-0 p-2 hover:bg-card rounded-lg border border-transparent hover:border-border transition-all text-muted-foreground hover:text-primary",
464
473
  title: t("chat_history.download_file", "Download File"),
465
474
  children: /* @__PURE__ */ e("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) })
@@ -469,7 +478,7 @@ function yt() {
469
478
  const { scrollTop: f, scrollHeight: q, clientHeight: i } = s.currentTarget;
470
479
  q - f <= i + 50 && !I && Z && d(!0);
471
480
  };
472
- return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: u ? "rtl" : "ltr", children: [
481
+ return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: h ? "rtl" : "ltr", children: [
473
482
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
474
483
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-4", children: [
475
484
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("chat_history.title") }),
@@ -487,7 +496,7 @@ function yt() {
487
496
  {
488
497
  type: "text",
489
498
  value: U,
490
- onChange: (s) => v(s.target.value),
499
+ onChange: (s) => y(s.target.value),
491
500
  placeholder: t("chat_history.search_placeholder"),
492
501
  className: "flex-1 px-4 py-2.5 border-0 rounded-xl glass-surface text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm"
493
502
  }
@@ -526,7 +535,7 @@ function yt() {
526
535
  /* @__PURE__ */ e("div", { className: "px-5 py-2.5 border-b border-border/30", children: /* @__PURE__ */ r("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide", children: [
527
536
  t("chat_history.threads_list"),
528
537
  " (",
529
- (b.length || 0).toLocaleString(J),
538
+ (x.length || 0).toLocaleString(J),
530
539
  ")"
531
540
  ] }) }),
532
541
  /* @__PURE__ */ e(
@@ -534,18 +543,18 @@ function yt() {
534
543
  {
535
544
  className: "flex-1 overflow-y-auto p-2 custom-scrollbar",
536
545
  onScroll: M,
537
- children: T && b.length === 0 ? /* @__PURE__ */ e("div", { className: "p-8 text-center text-muted-foreground text-sm", children: t("chat_history.no_threads") }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: [
538
- b.map((s) => /* @__PURE__ */ r(
546
+ children: T && x.length === 0 ? /* @__PURE__ */ e("div", { className: "p-8 text-center text-muted-foreground text-sm", children: t("chat_history.no_threads") }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: [
547
+ x.map((s) => /* @__PURE__ */ r(
539
548
  "div",
540
549
  {
541
550
  onClick: () => c(s),
542
- className: `p-2.5 cursor-pointer transition-all rounded-xl border ${N?.id === s.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
551
+ className: `p-2.5 cursor-pointer transition-all rounded-xl border ${v?.id === s.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
543
552
  children: [
544
553
  /* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-1.5 gap-4", children: [
545
554
  /* @__PURE__ */ e(
546
555
  "h3",
547
556
  {
548
- className: `font-medium text-sm truncate flex-1 ${N?.id === s.id ? "text-primary" : "text-foreground"}`,
557
+ className: `font-medium text-sm truncate flex-1 ${v?.id === s.id ? "text-primary" : "text-foreground"}`,
549
558
  title: s.title || t("chat_history.no_thread_title"),
550
559
  children: s.title || t("chat_history.no_thread_title")
551
560
  }
@@ -563,7 +572,7 @@ function yt() {
563
572
  title: `${s.user_info.name} ${s.user_info.surname} ${s.user_info.phone ? ` • ${s.user_info.phone}` : ""}${m.filter((f) => s.user_info?.metadata?.[f.key] !== void 0 && s.user_info?.metadata?.[f.key] !== "").map((f) => {
564
573
  const q = s.user_info?.metadata?.[f.key];
565
574
  if (f.type === "select") {
566
- const i = f.options?.find((y) => String(y.value) === String(q));
575
+ const i = f.options?.find((w) => String(w.value) === String(q));
567
576
  return ` • ${i ? t(i.label) : q}`;
568
577
  }
569
578
  return ` • ${q}`;
@@ -587,14 +596,14 @@ function yt() {
587
596
  return q != null && q !== "";
588
597
  }).map((f, q) => {
589
598
  const i = s.user_info?.metadata?.[f.key];
590
- let y = String(i);
599
+ let w = String(i);
591
600
  if (f.type === "select") {
592
601
  const F = f.options?.find((X) => String(X.value) === String(i));
593
- F && (y = t(F.label));
594
- } else f.type === "checkbox" && (y = i ? "✓" : "✗");
602
+ F && (w = t(F.label));
603
+ } else f.type === "checkbox" && (w = i ? "✓" : "✗");
595
604
  return /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
596
605
  q > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
597
- y
606
+ w
598
607
  ] }, f.key);
599
608
  }),
600
609
  s.user_info.metadata?.values !== void 0 && !m.some((f) => f.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
@@ -622,18 +631,18 @@ function yt() {
622
631
  ] }),
623
632
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col", children: [
624
633
  /* @__PURE__ */ r("div", { className: "px-5 py-2.5 border-b border-border/30 flex items-center justify-between gap-4", children: [
625
- /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: N ? t("chat_history.messages_for", { title: N.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
626
- N && /* @__PURE__ */ e(
634
+ /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: v ? t("chat_history.messages_for", { title: v.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
635
+ v && /* @__PURE__ */ e(
627
636
  "button",
628
637
  {
629
- onClick: (s) => l(s, N),
638
+ onClick: (s) => l(s, v),
630
639
  className: "flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 text-primary flex items-center justify-center hover:bg-primary/20 transition-all shadow-sm",
631
640
  title: t("sidebar.share_conversation"),
632
- children: /* @__PURE__ */ e(lt, { className: "w-4 h-4" })
641
+ children: /* @__PURE__ */ e(dt, { className: "w-4 h-4" })
633
642
  }
634
643
  )
635
644
  ] }),
636
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: N ? T ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : w.length === 0 ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.empty_thread") }) : /* @__PURE__ */ e("div", { className: "space-y-6", children: w.map((s) => {
645
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: v ? T ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : N.length === 0 ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.empty_thread") }) : /* @__PURE__ */ e("div", { className: "space-y-6", children: N.map((s) => {
637
646
  const f = s.role === "user", q = s.role === "assistant";
638
647
  return /* @__PURE__ */ r(
639
648
  "div",
@@ -642,10 +651,10 @@ function yt() {
642
651
  children: [
643
652
  s.feedback && /* @__PURE__ */ e("div", { className: "absolute -bottom-2 -left-2 flex items-center justify-center w-8 h-8 rounded-full shadow-md bg-card border border-border animate-in fade-in zoom-in duration-300 z-10", children: /* @__PURE__ */ e("span", { className: "text-base", children: s.feedback === "like" ? "👍" : "👎" }) }),
644
653
  /* @__PURE__ */ r("div", { className: "flex justify-between items-center mb-1.5", children: [
645
- /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${f || q ? "text-primary" : "text-muted-foreground"}`, children: f ? N?.user_info?.name ? `${N.user_info.name} ${N.user_info.surname || ""}`.trim() : t("chat_history.user_label") : q ? t("chat_history.assistant_label") : `${s.role}` }),
654
+ /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${f || q ? "text-primary" : "text-muted-foreground"}`, children: f ? v?.user_info?.name ? `${v.user_info.name} ${v.user_info.surname || ""}`.trim() : t("chat_history.user_label") : q ? t("chat_history.assistant_label") : `${s.role}` }),
646
655
  /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: g(s.created_at) })
647
656
  ] }),
648
- /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: s.parts && s.parts.length > 0 ? s.parts.map((i, y) => j(i, y)) : typeof s.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(s.content, null, 2) }) : s.content })
657
+ /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: s.parts && s.parts.length > 0 ? s.parts.map((i, w) => j(i, w)) : typeof s.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(s.content, null, 2) }) : s.content })
649
658
  ]
650
659
  },
651
660
  s.id
@@ -658,14 +667,14 @@ function yt() {
658
667
  ] })
659
668
  ] });
660
669
  }
661
- function Nt() {
662
- const { t, i18n: n } = ee(["admin", "translation"]), [o, m] = x([]), [b, p] = x(!1), [N, _] = x(""), [w, H] = x(!1), [T, A] = x(null), [I, D] = x([]), [C, O] = x(null), U = n.language === "fa", [v, z] = x({
670
+ function wt() {
671
+ const { t, i18n: n } = ee(["admin", "translation"]), [o, m] = b([]), [x, u] = b(!1), [v, _] = b(""), [N, H] = b(!1), [T, A] = b(null), [I, D] = b([]), [C, O] = b(null), U = n.language === "fa", [y, z] = b({
663
672
  username: "",
664
673
  password: "",
665
674
  name: "",
666
675
  permissions: []
667
676
  }), R = async () => {
668
- p(!0), _("");
677
+ u(!0), _("");
669
678
  try {
670
679
  const c = await k.listAdmins();
671
680
  m(c.admins || []);
@@ -674,7 +683,7 @@ function Nt() {
674
683
  } catch (c) {
675
684
  _(c instanceof Error ? c.message : t("error_loading"));
676
685
  } finally {
677
- p(!1);
686
+ u(!1);
678
687
  }
679
688
  }, E = async () => {
680
689
  try {
@@ -688,32 +697,32 @@ function Nt() {
688
697
  R(), E();
689
698
  }, []);
690
699
  const V = async (c) => {
691
- c.preventDefault(), p(!0);
700
+ c.preventDefault(), u(!0);
692
701
  try {
693
702
  await k.register(
694
- v.username,
695
- v.password,
696
- v.name,
697
- v.permissions
703
+ y.username,
704
+ y.password,
705
+ y.name,
706
+ y.permissions
698
707
  ), H(!1), z({ username: "", password: "", name: "", permissions: [] }), R();
699
708
  } catch (l) {
700
709
  _(l instanceof Error ? l.message : t("error_loading"));
701
710
  } finally {
702
- p(!1);
711
+ u(!1);
703
712
  }
704
713
  }, Z = async (c) => {
705
714
  if (c.preventDefault(), !!T) {
706
- p(!0);
715
+ u(!0);
707
716
  try {
708
717
  const l = {
709
- name: v.name,
710
- permissions: v.permissions
718
+ name: y.name,
719
+ permissions: y.permissions
711
720
  };
712
- if (v.password && (l.password = v.password), await k.updateAdmin(T.id, l), T.id === C) {
721
+ if (y.password && (l.password = y.password), await k.updateAdmin(T.id, l), T.id === C) {
713
722
  const g = localStorage.getItem("admin_info");
714
723
  if (g) {
715
724
  const L = JSON.parse(g);
716
- L.name = v.name, L.permissions = v.permissions, localStorage.setItem("admin_info", JSON.stringify(L)), window.location.reload();
725
+ L.name = y.name, L.permissions = y.permissions, localStorage.setItem("admin_info", JSON.stringify(L)), window.location.reload();
717
726
  return;
718
727
  }
719
728
  }
@@ -721,7 +730,7 @@ function Nt() {
721
730
  } catch (l) {
722
731
  _(l instanceof Error ? l.message : t("error_loading"));
723
732
  } finally {
724
- p(!1);
733
+ u(!1);
725
734
  }
726
735
  }
727
736
  }, B = async (c) => {
@@ -731,7 +740,7 @@ function Nt() {
731
740
  } catch (l) {
732
741
  _(l instanceof Error ? l.message : t("error_loading"));
733
742
  }
734
- }, u = (c) => {
743
+ }, h = (c) => {
735
744
  A(c), z({
736
745
  username: c.username,
737
746
  password: "",
@@ -779,8 +788,8 @@ function Nt() {
779
788
  )
780
789
  ] })
781
790
  ] }),
782
- N && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0", children: N }),
783
- w && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-md shadow-2xl overflow-hidden", children: [
791
+ v && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0", children: v }),
792
+ N && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-md shadow-2xl overflow-hidden", children: [
784
793
  /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(T ? "admins.edit_admin" : "admins.add_admin") }) }),
785
794
  /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: T ? Z : V, className: "space-y-5", children: [
786
795
  /* @__PURE__ */ r("div", { children: [
@@ -790,8 +799,8 @@ function Nt() {
790
799
  {
791
800
  type: "text",
792
801
  disabled: !!T,
793
- value: v.username,
794
- onChange: (c) => z({ ...v, username: c.target.value }),
802
+ value: y.username,
803
+ onChange: (c) => z({ ...y, username: c.target.value }),
795
804
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground disabled:opacity-50 focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
796
805
  required: !0,
797
806
  dir: "ltr"
@@ -804,8 +813,8 @@ function Nt() {
804
813
  "input",
805
814
  {
806
815
  type: "text",
807
- value: v.name,
808
- onChange: (c) => z({ ...v, name: c.target.value }),
816
+ value: y.name,
817
+ onChange: (c) => z({ ...y, name: c.target.value }),
809
818
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm",
810
819
  required: !0
811
820
  }
@@ -817,8 +826,8 @@ function Nt() {
817
826
  "input",
818
827
  {
819
828
  type: "password",
820
- value: v.password,
821
- onChange: (c) => z({ ...v, password: c.target.value }),
829
+ value: y.password,
830
+ onChange: (c) => z({ ...y, password: c.target.value }),
822
831
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
823
832
  required: !T,
824
833
  dir: "ltr"
@@ -832,9 +841,9 @@ function Nt() {
832
841
  "input",
833
842
  {
834
843
  type: "checkbox",
835
- checked: v.permissions.includes(c),
844
+ checked: y.permissions.includes(c),
836
845
  onChange: () => J(c),
837
- disabled: v.username === "admin" && c === "admin_management",
846
+ disabled: y.username === "admin" && c === "admin_management",
838
847
  className: "peer h-4 w-4 rounded border-input text-primary focus:ring-ring transition-all disabled:opacity-50"
839
848
  }
840
849
  ) }),
@@ -855,9 +864,9 @@ function Nt() {
855
864
  "button",
856
865
  {
857
866
  type: "submit",
858
- disabled: b,
867
+ disabled: x,
859
868
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
860
- children: t(b ? "saving" : "save")
869
+ children: t(x ? "saving" : "save")
861
870
  }
862
871
  )
863
872
  ] })
@@ -879,7 +888,7 @@ function Nt() {
879
888
  /* @__PURE__ */ e(
880
889
  "button",
881
890
  {
882
- onClick: () => u(c),
891
+ onClick: () => h(c),
883
892
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
884
893
  title: t("edit"),
885
894
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" }) })
@@ -897,20 +906,20 @@ function Nt() {
897
906
  ] }) })
898
907
  ] }, c.id)) })
899
908
  ] }),
900
- o.length === 0 && !b && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
909
+ o.length === 0 && !x && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
901
910
  /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1, stroke: "currentColor", className: "w-12 h-12 opacity-20", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" }) }),
902
911
  t("admins.no_admins")
903
912
  ] }),
904
- b && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
913
+ x && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
905
914
  /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
906
915
  /* @__PURE__ */ e("span", { children: t("loading") })
907
916
  ] })
908
917
  ] }) })
909
918
  ] });
910
919
  }
911
- const wt = (t) => t.replace(/[^0-9]/g, "");
912
- function _t() {
913
- const { t, i18n: n } = ee(["admin", "translation"]), { app: o } = me(), [m, b] = x([]), [p, N] = x(!1), [_, w] = x(""), [H, T] = x(!1), [A, I] = x(null), [D, C] = x(""), [O, U] = x(0), [v, z] = x(null), R = pe(() => o?.userMetadataFields || [], [o?.userMetadataFields]), [E, V] = x(null), [Z, B] = x(""), [u, J] = x(""), [d, c] = x(""), [l, g] = x(""), L = n.language === "fa", P = L ? "text-right" : "text-left", [h, j] = x({
920
+ const _t = (t) => t.replace(/[^0-9]/g, "");
921
+ function kt() {
922
+ const { t, i18n: n } = ee(["admin", "translation"]), { app: o } = me(), [m, x] = b([]), [u, v] = b(!1), [_, N] = b(""), [H, T] = b(!1), [A, I] = b(null), [D, C] = b(""), [O, U] = b(0), [y, z] = b(null), R = pe(() => o?.userMetadataFields || [], [o?.userMetadataFields]), [E, V] = b(null), [Z, B] = b(""), [h, J] = b(""), [d, c] = b(""), [l, g] = b(""), L = n.language === "fa", P = L ? "text-right" : "text-left", [p, j] = b({
914
923
  phone: "",
915
924
  name: "",
916
925
  surname: "",
@@ -920,15 +929,15 @@ function _t() {
920
929
  requestsLimit: "",
921
930
  metadata: ""
922
931
  // Keep raw JSON for advanced users
923
- }), [M, s] = x({}), f = async () => {
924
- N(!0), w("");
932
+ }), [M, s] = b({}), f = async () => {
933
+ v(!0), N("");
925
934
  try {
926
935
  const a = await k.listUsers(0, 100, D);
927
- b(a.users || []), U(a.count || 0);
936
+ x(a.users || []), U(a.count || 0);
928
937
  } catch (a) {
929
- w(a instanceof Error ? a.message : t("error_loading"));
938
+ N(a instanceof Error ? a.message : t("error_loading"));
930
939
  } finally {
931
- N(!1);
940
+ v(!1);
932
941
  }
933
942
  }, q = async () => {
934
943
  try {
@@ -941,99 +950,99 @@ function _t() {
941
950
  W(() => {
942
951
  q();
943
952
  }, []), W(() => {
944
- v && !A && !h.tokens && !h.requests && j((a) => ({
953
+ y && !A && !p.tokens && !p.requests && j((a) => ({
945
954
  ...a,
946
- tokens: v.initial_balance_tokens?.toString() || "",
947
- requests: v.initial_balance_requests?.toString() || "",
948
- tokensLimit: v.initial_balance_tokens?.toString() || "",
949
- requestsLimit: v.initial_balance_requests?.toString() || ""
955
+ tokens: y.initial_balance_tokens?.toString() || "",
956
+ requests: y.initial_balance_requests?.toString() || "",
957
+ tokensLimit: y.initial_balance_tokens?.toString() || "",
958
+ requestsLimit: y.initial_balance_requests?.toString() || ""
950
959
  }));
951
- }, [v]), W(() => {
960
+ }, [y]), W(() => {
952
961
  const a = setTimeout(() => {
953
962
  f();
954
963
  }, 500);
955
964
  return () => clearTimeout(a);
956
965
  }, [D]), W(() => {
957
966
  try {
958
- const S = { ...h.metadata ? JSON.parse(h.metadata) : {}, ...M }, $ = JSON.stringify(S, null, 2);
959
- $ !== h.metadata && j((K) => ({ ...K, metadata: $ }));
967
+ const S = { ...p.metadata ? JSON.parse(p.metadata) : {}, ...M }, $ = JSON.stringify(S, null, 2);
968
+ $ !== p.metadata && j((G) => ({ ...G, metadata: $ }));
960
969
  } catch {
961
970
  }
962
971
  }, [M]), W(() => {
963
972
  const a = { ...M };
964
973
  let S = !1;
965
974
  R.forEach(($) => {
966
- $.condition && !ke($.condition, M) && a[$.key] !== void 0 && (delete a[$.key], S = !0);
975
+ $.condition && !Se($.condition, M) && a[$.key] !== void 0 && (delete a[$.key], S = !0);
967
976
  }), S && s(a);
968
977
  }, [M, R]);
969
978
  const i = async (a) => {
970
979
  a.preventDefault();
971
- const S = h.tokens ? parseInt(h.tokens) : 0, $ = h.requests ? parseInt(h.requests) : 0, K = h.tokensLimit ? parseInt(h.tokensLimit) : S, te = h.requestsLimit ? parseInt(h.requestsLimit) : $;
972
- if (S > K) {
973
- w(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
980
+ const S = p.tokens ? parseInt(p.tokens) : 0, $ = p.requests ? parseInt(p.requests) : 0, G = p.tokensLimit ? parseInt(p.tokensLimit) : S, te = p.requestsLimit ? parseInt(p.requestsLimit) : $;
981
+ if (S > G) {
982
+ N(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
974
983
  return;
975
984
  }
976
985
  if ($ > te) {
977
- w(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
986
+ N(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
978
987
  return;
979
988
  }
980
989
  let ge = {};
981
- if (h.metadata)
990
+ if (p.metadata)
982
991
  try {
983
- ge = JSON.parse(h.metadata);
992
+ ge = JSON.parse(p.metadata);
984
993
  } catch {
985
- w(t("users.invalid_json", "Invalid JSON format"));
994
+ N(t("users.invalid_json", "Invalid JSON format"));
986
995
  return;
987
996
  }
988
- N(!0);
997
+ v(!0);
989
998
  try {
990
999
  await k.createUser(
991
- h.phone,
992
- h.name,
993
- h.surname,
994
- h.tokens ? parseInt(h.tokens) : void 0,
995
- h.requests ? parseInt(h.requests) : void 0,
996
- h.tokensLimit ? parseInt(h.tokensLimit) : void 0,
997
- h.requestsLimit ? parseInt(h.requestsLimit) : void 0,
1000
+ p.phone,
1001
+ p.name,
1002
+ p.surname,
1003
+ p.tokens ? parseInt(p.tokens) : void 0,
1004
+ p.requests ? parseInt(p.requests) : void 0,
1005
+ p.tokensLimit ? parseInt(p.tokensLimit) : void 0,
1006
+ p.requestsLimit ? parseInt(p.requestsLimit) : void 0,
998
1007
  ge
999
1008
  ), T(!1), F(), f();
1000
1009
  } catch (fe) {
1001
- w(fe instanceof Error ? fe.message : t("error_loading"));
1010
+ N(fe instanceof Error ? fe.message : t("error_loading"));
1002
1011
  } finally {
1003
- N(!1);
1012
+ v(!1);
1004
1013
  }
1005
- }, y = async (a) => {
1014
+ }, w = async (a) => {
1006
1015
  if (a.preventDefault(), !A) return;
1007
1016
  let S = {};
1008
- if (h.metadata)
1017
+ if (p.metadata)
1009
1018
  try {
1010
- S = JSON.parse(h.metadata);
1019
+ S = JSON.parse(p.metadata);
1011
1020
  } catch {
1012
- w(t("users.invalid_json", "Invalid JSON format"));
1021
+ N(t("users.invalid_json", "Invalid JSON format"));
1013
1022
  return;
1014
1023
  }
1015
- N(!0);
1024
+ v(!0);
1016
1025
  try {
1017
1026
  await k.updateUser(A.id, {
1018
- phone: h.phone,
1019
- name: h.name,
1020
- surname: h.surname,
1027
+ phone: p.phone,
1028
+ name: p.name,
1029
+ surname: p.surname,
1021
1030
  metadata: S
1022
1031
  }), I(null), T(!1), F(), f();
1023
1032
  } catch ($) {
1024
- w($ instanceof Error ? $.message : t("error_loading"));
1033
+ N($ instanceof Error ? $.message : t("error_loading"));
1025
1034
  } finally {
1026
- N(!1);
1035
+ v(!1);
1027
1036
  }
1028
1037
  }, F = () => {
1029
1038
  j({
1030
1039
  phone: "",
1031
1040
  name: "",
1032
1041
  surname: "",
1033
- tokens: v?.initial_balance_tokens?.toString() || "",
1034
- requests: v?.initial_balance_requests?.toString() || "",
1035
- tokensLimit: v?.initial_balance_tokens?.toString() || "",
1036
- requestsLimit: v?.initial_balance_requests?.toString() || "",
1042
+ tokens: y?.initial_balance_tokens?.toString() || "",
1043
+ requests: y?.initial_balance_requests?.toString() || "",
1044
+ tokensLimit: y?.initial_balance_tokens?.toString() || "",
1045
+ requestsLimit: y?.initial_balance_requests?.toString() || "",
1037
1046
  metadata: ""
1038
1047
  }), s({});
1039
1048
  }, X = async (a) => {
@@ -1041,58 +1050,58 @@ function _t() {
1041
1050
  try {
1042
1051
  await k.deleteUser(a), f();
1043
1052
  } catch (S) {
1044
- w(S instanceof Error ? S.message : t("error_loading"));
1053
+ N(S instanceof Error ? S.message : t("error_loading"));
1045
1054
  }
1046
- }, $e = async (a) => {
1055
+ }, De = async (a) => {
1047
1056
  try {
1048
1057
  const $ = (await k.refreshUserToken(a.id))?.user?.token;
1049
1058
  if (!$) {
1050
- w(t("users.no_token"));
1059
+ N(t("users.no_token"));
1051
1060
  return;
1052
1061
  }
1053
1062
  await navigator.clipboard.writeText($), alert(t("users.token_copied"));
1054
1063
  } catch (S) {
1055
- w(S instanceof Error ? S.message : t("error_loading"));
1064
+ N(S instanceof Error ? S.message : t("error_loading"));
1056
1065
  }
1057
- }, De = async (a, S, $, K) => {
1066
+ }, Ee = async (a, S, $, G) => {
1058
1067
  if (E) {
1059
- N(!0);
1068
+ v(!0);
1060
1069
  try {
1061
1070
  await k.updateUserBalance(
1062
1071
  E.id,
1063
1072
  a,
1064
1073
  S,
1065
1074
  $,
1066
- K
1075
+ G
1067
1076
  ), V(null), B(""), J(""), c(""), g(""), f();
1068
1077
  } catch (te) {
1069
- w(te instanceof Error ? te.message : t("error_loading"));
1078
+ N(te instanceof Error ? te.message : t("error_loading"));
1070
1079
  } finally {
1071
- N(!1);
1080
+ v(!1);
1072
1081
  }
1073
1082
  }
1074
- }, Ee = async (a) => {
1083
+ }, Oe = async (a) => {
1075
1084
  if (a.preventDefault(), !E) return;
1076
- const S = parseInt(Z) || 0, $ = parseInt(u) || 0, K = d ? parseInt(d) : E.balance?.token_limit || 0, te = l ? parseInt(l) : E.balance?.request_limit || 0;
1077
- if (S > K) {
1078
- w(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1085
+ const S = parseInt(Z) || 0, $ = parseInt(h) || 0, G = d ? parseInt(d) : E.balance?.token_limit || 0, te = l ? parseInt(l) : E.balance?.request_limit || 0;
1086
+ if (S > G) {
1087
+ N(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1079
1088
  return;
1080
1089
  }
1081
1090
  if ($ > te) {
1082
- w(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1091
+ N(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1083
1092
  return;
1084
1093
  }
1085
- await De(
1094
+ await Ee(
1086
1095
  S,
1087
1096
  $,
1088
1097
  d ? parseInt(d) : void 0,
1089
1098
  l ? parseInt(l) : void 0
1090
1099
  );
1091
- }, Oe = () => {
1100
+ }, Re = () => {
1092
1101
  if (!E) return;
1093
1102
  const a = d || String(E.balance?.token_limit || 0), S = l || String(E.balance?.request_limit || 0);
1094
1103
  B(a), J(S);
1095
- }, Re = (a) => {
1104
+ }, Fe = (a) => {
1096
1105
  I(a);
1097
1106
  const S = a.metadata ? JSON.stringify(a.metadata, null, 2) : "";
1098
1107
  if (j({
@@ -1106,8 +1115,8 @@ function _t() {
1106
1115
  metadata: S
1107
1116
  }), a.metadata) {
1108
1117
  const $ = {};
1109
- R.forEach((K) => {
1110
- a.metadata?.[K.key] !== void 0 ? $[K.key] = a.metadata[K.key] : K.defaultValue !== void 0 && ($[K.key] = K.defaultValue);
1118
+ R.forEach((G) => {
1119
+ a.metadata?.[G.key] !== void 0 ? $[G.key] = a.metadata[G.key] : G.defaultValue !== void 0 && ($[G.key] = G.defaultValue);
1111
1120
  }), s($);
1112
1121
  }
1113
1122
  T(!0);
@@ -1143,11 +1152,11 @@ function _t() {
1143
1152
  ] }),
1144
1153
  _ && /* @__PURE__ */ r("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0 flex justify-between items-center group", children: [
1145
1154
  /* @__PURE__ */ e("span", { children: _ }),
1146
- /* @__PURE__ */ e("button", { onClick: () => w(""), className: "opacity-50 hover:opacity-100 transition-opacity p-1", children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) })
1155
+ /* @__PURE__ */ e("button", { onClick: () => N(""), className: "opacity-50 hover:opacity-100 transition-opacity p-1", children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) })
1147
1156
  ] }),
1148
1157
  H && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-xl shadow-2xl overflow-hidden", children: [
1149
1158
  /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(A ? "users.edit_user" : "users.add_user") }) }),
1150
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: A ? y : i, children: [
1159
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: A ? w : i, children: [
1151
1160
  /* @__PURE__ */ r("div", { className: "space-y-6 max-h-[60vh] overflow-y-auto px-1 custom-scrollbar", children: [
1152
1161
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1153
1162
  /* @__PURE__ */ r("div", { children: [
@@ -1156,8 +1165,8 @@ function _t() {
1156
1165
  "input",
1157
1166
  {
1158
1167
  type: "text",
1159
- value: h.phone,
1160
- onChange: (a) => j({ ...h, phone: wt(a.target.value) }),
1168
+ value: p.phone,
1169
+ onChange: (a) => j({ ...p, phone: _t(a.target.value) }),
1161
1170
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1162
1171
  placeholder: t("users.phone_placeholder"),
1163
1172
  required: !0,
@@ -1172,8 +1181,8 @@ function _t() {
1172
1181
  "input",
1173
1182
  {
1174
1183
  type: "text",
1175
- value: h.name,
1176
- onChange: (a) => j({ ...h, name: a.target.value }),
1184
+ value: p.name,
1185
+ onChange: (a) => j({ ...p, name: a.target.value }),
1177
1186
  className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${P}`,
1178
1187
  required: !0
1179
1188
  }
@@ -1185,8 +1194,8 @@ function _t() {
1185
1194
  "input",
1186
1195
  {
1187
1196
  type: "text",
1188
- value: h.surname,
1189
- onChange: (a) => j({ ...h, surname: a.target.value }),
1197
+ value: p.surname,
1198
+ onChange: (a) => j({ ...p, surname: a.target.value }),
1190
1199
  className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${P}`,
1191
1200
  required: !0
1192
1201
  }
@@ -1203,8 +1212,8 @@ function _t() {
1203
1212
  "input",
1204
1213
  {
1205
1214
  type: "number",
1206
- value: h.tokens,
1207
- onChange: (a) => j({ ...h, tokens: a.target.value }),
1215
+ value: p.tokens,
1216
+ onChange: (a) => j({ ...p, tokens: a.target.value }),
1208
1217
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1209
1218
  dir: "ltr",
1210
1219
  placeholder: "0"
@@ -1217,11 +1226,11 @@ function _t() {
1217
1226
  "input",
1218
1227
  {
1219
1228
  type: "number",
1220
- value: h.tokensLimit,
1221
- onChange: (a) => j({ ...h, tokensLimit: a.target.value }),
1229
+ value: p.tokensLimit,
1230
+ onChange: (a) => j({ ...p, tokensLimit: a.target.value }),
1222
1231
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1223
1232
  dir: "ltr",
1224
- placeholder: h.tokens || String(v?.initial_balance_tokens ?? "250000")
1233
+ placeholder: p.tokens || String(y?.initial_balance_tokens ?? "250000")
1225
1234
  }
1226
1235
  )
1227
1236
  ] })
@@ -1233,11 +1242,11 @@ function _t() {
1233
1242
  "input",
1234
1243
  {
1235
1244
  type: "number",
1236
- value: h.requests,
1237
- onChange: (a) => j({ ...h, requests: a.target.value }),
1245
+ value: p.requests,
1246
+ onChange: (a) => j({ ...p, requests: a.target.value }),
1238
1247
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1239
1248
  dir: "ltr",
1240
- placeholder: h.requests || String(v?.initial_balance_requests ?? "0")
1249
+ placeholder: p.requests || String(y?.initial_balance_requests ?? "0")
1241
1250
  }
1242
1251
  )
1243
1252
  ] }),
@@ -1247,11 +1256,11 @@ function _t() {
1247
1256
  "input",
1248
1257
  {
1249
1258
  type: "number",
1250
- value: h.requestsLimit,
1251
- onChange: (a) => j({ ...h, requestsLimit: a.target.value }),
1259
+ value: p.requestsLimit,
1260
+ onChange: (a) => j({ ...p, requestsLimit: a.target.value }),
1252
1261
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1253
1262
  dir: "ltr",
1254
- placeholder: h.requests || String(v?.initial_balance_requests ?? "100")
1263
+ placeholder: p.requests || String(y?.initial_balance_requests ?? "100")
1255
1264
  }
1256
1265
  )
1257
1266
  ] })
@@ -1259,7 +1268,7 @@ function _t() {
1259
1268
  ] }),
1260
1269
  R.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1261
1270
  /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.custom_fields") }),
1262
- /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: R.map((a) => ke(a.condition, M) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1271
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: R.map((a) => Se(a.condition, M) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1263
1272
  /* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
1264
1273
  t(a.label),
1265
1274
  " ",
@@ -1274,12 +1283,12 @@ function _t() {
1274
1283
  dir: L ? "rtl" : "ltr",
1275
1284
  children: [
1276
1285
  /* @__PURE__ */ e(ie, { className: be("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", P), children: /* @__PURE__ */ e(oe, { placeholder: t(a.placeholder || "select_placeholder") }) }),
1277
- /* @__PURE__ */ e(le, { className: "rounded-xl border-border bg-card", children: a.options?.map((S) => /* @__PURE__ */ e(G, { value: String(S.value), children: t(S.label) }, String(S.value))) })
1286
+ /* @__PURE__ */ e(le, { className: "rounded-xl border-border bg-card", children: a.options?.map((S) => /* @__PURE__ */ e(K, { value: String(S.value), children: t(S.label) }, String(S.value))) })
1278
1287
  ]
1279
1288
  }
1280
1289
  ) : a.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 h-[46px] px-1", children: [
1281
1290
  /* @__PURE__ */ e(
1282
- Pe,
1291
+ He,
1283
1292
  {
1284
1293
  id: `admin-md-${a.key}`,
1285
1294
  checked: !!M[a.key],
@@ -1309,8 +1318,8 @@ function _t() {
1309
1318
  /* @__PURE__ */ e(
1310
1319
  "textarea",
1311
1320
  {
1312
- value: h.metadata,
1313
- onChange: (a) => j({ ...h, metadata: a.target.value }),
1321
+ value: p.metadata,
1322
+ onChange: (a) => j({ ...p, metadata: a.target.value }),
1314
1323
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-xs font-mono min-h-[100px] custom-scrollbar",
1315
1324
  placeholder: '{ "key": "value" }',
1316
1325
  dir: "ltr"
@@ -1334,9 +1343,9 @@ function _t() {
1334
1343
  "button",
1335
1344
  {
1336
1345
  type: "submit",
1337
- disabled: p,
1346
+ disabled: u,
1338
1347
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
1339
- children: t(p ? "saving" : "save")
1348
+ children: t(u ? "saving" : "save")
1340
1349
  }
1341
1350
  )
1342
1351
  ] })
@@ -1353,14 +1362,14 @@ function _t() {
1353
1362
  "button",
1354
1363
  {
1355
1364
  onClick: () => {
1356
- V(null), w("");
1365
+ V(null), N("");
1357
1366
  },
1358
1367
  className: "text-muted-foreground hover:text-foreground transition-colors",
1359
1368
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-5 h-5", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
1360
1369
  }
1361
1370
  )
1362
1371
  ] }),
1363
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: Ee, children: [
1372
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: Oe, children: [
1364
1373
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1365
1374
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1366
1375
  /* @__PURE__ */ r("div", { children: [
@@ -1399,7 +1408,7 @@ function _t() {
1399
1408
  "input",
1400
1409
  {
1401
1410
  type: "number",
1402
- value: u,
1411
+ value: h,
1403
1412
  onChange: (a) => J(a.target.value),
1404
1413
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1405
1414
  required: !0,
@@ -1417,7 +1426,7 @@ function _t() {
1417
1426
  onChange: (a) => g(a.target.value),
1418
1427
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1419
1428
  dir: "ltr",
1420
- placeholder: u
1429
+ placeholder: h
1421
1430
  }
1422
1431
  )
1423
1432
  ] })
@@ -1428,7 +1437,7 @@ function _t() {
1428
1437
  "button",
1429
1438
  {
1430
1439
  type: "button",
1431
- onClick: Oe,
1440
+ onClick: Re,
1432
1441
  className: "flex-1 px-4 py-3 bg-secondary text-secondary-foreground border border-border rounded-xl text-sm font-medium hover:bg-secondary/80 transition-colors",
1433
1442
  children: t("users.full_charge")
1434
1443
  }
@@ -1437,9 +1446,9 @@ function _t() {
1437
1446
  "button",
1438
1447
  {
1439
1448
  type: "submit",
1440
- disabled: p,
1449
+ disabled: u,
1441
1450
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
1442
- children: t(p ? "users.updating" : "users.update_balance")
1451
+ children: t(u ? "users.updating" : "users.update_balance")
1443
1452
  }
1444
1453
  )
1445
1454
  ] })
@@ -1457,16 +1466,16 @@ function _t() {
1457
1466
  ] }) }),
1458
1467
  /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: m.map((a) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
1459
1468
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground font-mono", dir: "ltr", children: a.phone }),
1460
- /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: a.name }),
1469
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground", children: a.name }),
1461
1470
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: a.surname }),
1462
1471
  R.map((S) => {
1463
1472
  const $ = a.metadata?.[S.key];
1464
- let K = String($ ?? "");
1473
+ let G = String($ ?? "");
1465
1474
  if (S.type === "select" && $ !== void 0) {
1466
1475
  const te = S.options?.find((ge) => String(ge.value) === String($));
1467
- te && (K = t(te.label));
1476
+ te && (G = t(te.label));
1468
1477
  }
1469
- return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: S.type === "checkbox" ? $ ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : K }, S.key);
1478
+ return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: S.type === "checkbox" ? $ ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : G }, S.key);
1470
1479
  }),
1471
1480
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground w-[120px]", children: a.balance ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 min-w-0 py-1", children: [
1472
1481
  /* @__PURE__ */ r("div", { className: "space-y-1", children: [
@@ -1506,7 +1515,7 @@ function _t() {
1506
1515
  /* @__PURE__ */ e(
1507
1516
  "button",
1508
1517
  {
1509
- onClick: () => Re(a),
1518
+ onClick: () => Fe(a),
1510
1519
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1511
1520
  title: t("edit"),
1512
1521
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" }) })
@@ -1516,7 +1525,7 @@ function _t() {
1516
1525
  "button",
1517
1526
  {
1518
1527
  onClick: () => {
1519
- V(a), B(String(a.balance?.tokens || 0)), J(String(a.balance?.requests || 0)), c(String(a.balance?.token_limit || 0)), g(String(a.balance?.request_limit || 0)), w("");
1528
+ V(a), B(String(a.balance?.tokens || 0)), J(String(a.balance?.requests || 0)), c(String(a.balance?.token_limit || 0)), g(String(a.balance?.request_limit || 0)), N("");
1520
1529
  },
1521
1530
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1522
1531
  title: t("users.recharge"),
@@ -1526,7 +1535,7 @@ function _t() {
1526
1535
  /* @__PURE__ */ e(
1527
1536
  "button",
1528
1537
  {
1529
- onClick: () => $e(a),
1538
+ onClick: () => De(a),
1530
1539
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1531
1540
  title: t("users.copy_token"),
1532
1541
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" }) })
@@ -1544,22 +1553,22 @@ function _t() {
1544
1553
  ] }) })
1545
1554
  ] }, a.id)) })
1546
1555
  ] }),
1547
- m.length === 0 && !p && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1556
+ m.length === 0 && !u && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1548
1557
  /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/xl", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1, stroke: "currentColor", className: "w-12 h-12 opacity-20", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" }) }),
1549
1558
  t("users.no_users")
1550
1559
  ] }),
1551
- p && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
1560
+ u && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
1552
1561
  /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
1553
1562
  /* @__PURE__ */ e("span", { children: t("loading") })
1554
1563
  ] })
1555
1564
  ] }) })
1556
1565
  ] });
1557
1566
  }
1558
- function kt() {
1559
- const { t, i18n: n } = ee(["admin", "translation"]), [o, m] = x(null), [b, p] = x(!0), [N, _] = x(""), [w, H] = x(30), [T, A] = x(0), I = Me(null), D = n.language === "fa", C = D ? "fa-IR" : "en-US", O = D ? "fa-IR-u-ca-persian" : "en-US";
1567
+ function St() {
1568
+ const { t, i18n: n } = ee(["admin", "translation"]), [o, m] = b(null), [x, u] = b(!0), [v, _] = b(""), [N, H] = b(30), [T, A] = b(0), I = Ie(null), D = n.language === "fa", C = D ? "fa-IR" : "en-US", O = D ? "fa-IR-u-ca-persian" : "en-US";
1560
1569
  W(() => {
1561
1570
  z();
1562
- }, [w]), W(() => {
1571
+ }, [N]), W(() => {
1563
1572
  if (!I.current) return;
1564
1573
  const d = new ResizeObserver((c) => {
1565
1574
  for (const l of c)
@@ -1568,33 +1577,33 @@ function kt() {
1568
1577
  return d.observe(I.current), () => d.disconnect();
1569
1578
  }, []);
1570
1579
  const U = (d, c, l) => {
1571
- const g = [], L = /* @__PURE__ */ new Date(), P = d || [], h = new Map(P.map((j) => [j.date, j]));
1580
+ const g = [], L = /* @__PURE__ */ new Date(), P = d || [], p = new Map(P.map((j) => [j.date, j]));
1572
1581
  for (let j = c - 1; j >= 0; j--) {
1573
1582
  const s = new Date(L.getTime() - j * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1574
- if (h.has(s))
1575
- g.push(h.get(s));
1583
+ if (p.has(s))
1584
+ g.push(p.get(s));
1576
1585
  else {
1577
1586
  const f = { date: s };
1578
1587
  l.forEach((q) => f[q] = 0), g.push(f);
1579
1588
  }
1580
1589
  }
1581
1590
  return g;
1582
- }, v = (d) => {
1591
+ }, y = (d) => {
1583
1592
  if (!d || d.length === 0) return null;
1584
1593
  const c = d.length, l = new Intl.DateTimeFormat(O, { month: "short" });
1585
1594
  let g = [];
1586
- if (w <= 14)
1595
+ if (N <= 14)
1587
1596
  g = Array.from({ length: c }, (L, P) => P);
1588
1597
  else {
1589
- const L = D ? 45 : 35, P = T > 0 ? Math.floor(T / L) : 6, h = Math.max(1, Math.ceil(c / Math.max(1, P)));
1590
- for (let j = 0; j < c; j += h)
1598
+ const L = D ? 45 : 35, P = T > 0 ? Math.floor(T / L) : 6, p = Math.max(1, Math.ceil(c / Math.max(1, P)));
1599
+ for (let j = 0; j < c; j += p)
1591
1600
  g.push(j);
1592
- g.length > 0 && g[g.length - 1] !== c - 1 && (c - 1 - g[g.length - 1] > h / 2 ? g.push(c - 1) : g[g.length - 1] = c - 1);
1601
+ g.length > 0 && g[g.length - 1] !== c - 1 && (c - 1 - g[g.length - 1] > p / 2 ? g.push(c - 1) : g[g.length - 1] = c - 1);
1593
1602
  }
1594
1603
  return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: D ? "rtl" : "ltr", children: g.map((L) => {
1595
1604
  const P = d[L];
1596
1605
  if (!P) return null;
1597
- const h = new Date(P.date), j = h.toLocaleDateString(O, { day: "numeric" }), M = l.format(h), s = c > 1 ? L / (c - 1) * 100 : 50;
1606
+ const p = new Date(P.date), j = p.toLocaleDateString(O, { day: "numeric" }), M = l.format(p), s = c > 1 ? L / (c - 1) * 100 : 50;
1598
1607
  return /* @__PURE__ */ r(
1599
1608
  "div",
1600
1609
  {
@@ -1609,9 +1618,9 @@ function kt() {
1609
1618
  );
1610
1619
  }) });
1611
1620
  }, z = async () => {
1612
- p(!0), _("");
1621
+ u(!0), _("");
1613
1622
  try {
1614
- const d = await k.getAnalytics(w), c = {
1623
+ const d = await k.getAnalytics(N), c = {
1615
1624
  ...d,
1616
1625
  overview: d.overview || {
1617
1626
  total_users: 0,
@@ -1621,10 +1630,10 @@ function kt() {
1621
1630
  },
1622
1631
  trends: {
1623
1632
  ...d.trends || {},
1624
- users: U(d.trends?.users, w, ["count"]),
1625
- threads: U(d.trends?.threads, w, ["count"]),
1626
- messages: U(d.trends?.messages, w, ["count"]),
1627
- token_usage: U(d.trends?.token_usage, w, ["tokens", "requests"])
1633
+ users: U(d.trends?.users, N, ["count"]),
1634
+ threads: U(d.trends?.threads, N, ["count"]),
1635
+ messages: U(d.trends?.messages, N, ["count"]),
1636
+ token_usage: U(d.trends?.token_usage, N, ["tokens", "requests"])
1628
1637
  },
1629
1638
  distributions: {
1630
1639
  ...d.distributions || {},
@@ -1636,14 +1645,14 @@ function kt() {
1636
1645
  } catch (d) {
1637
1646
  _(d instanceof Error ? d.message : t("analytics.error_loading"));
1638
1647
  } finally {
1639
- p(!1);
1648
+ u(!1);
1640
1649
  }
1641
1650
  };
1642
- if (b)
1651
+ if (x)
1643
1652
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground", children: t("analytics.loading_analytics") });
1644
- if (N)
1653
+ if (v)
1645
1654
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
1646
- /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: N }),
1655
+ /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: v }),
1647
1656
  /* @__PURE__ */ e(
1648
1657
  "button",
1649
1658
  {
@@ -1659,7 +1668,7 @@ function kt() {
1659
1668
  const c = d * 1.15, l = Math.pow(10, Math.floor(Math.log10(c))), g = c / l;
1660
1669
  let L;
1661
1670
  return g <= 1.2 ? L = 0.2 : g <= 2.5 ? L = 0.5 : g <= 5 ? L = 1 : L = 2, Math.ceil(c / (L * l)) * (L * l);
1662
- }, E = Math.max(...o.trends.threads.map((d) => d.count) || [1]), V = Math.max(...o.trends.messages.map((d) => d.count) || [1]), Z = Math.max(...o.trends.token_usage.map((d) => d.tokens) || [1]), B = R(E), u = R(V), J = R(Z);
1671
+ }, E = Math.max(...o.trends.threads.map((d) => d.count) || [1]), V = Math.max(...o.trends.messages.map((d) => d.count) || [1]), Z = Math.max(...o.trends.token_usage.map((d) => d.tokens) || [1]), B = R(E), h = R(V), J = R(Z);
1663
1672
  return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: D ? "rtl" : "ltr", children: [
1664
1673
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3", children: [
1665
1674
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("analytics.title") }),
@@ -1667,7 +1676,7 @@ function kt() {
1667
1676
  "button",
1668
1677
  {
1669
1678
  onClick: () => H(d),
1670
- className: `px-4 py-2 text-sm font-medium rounded-xl transition-all shadow-sm ${w === d ? "bg-primary text-primary-foreground shadow-md" : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground border border-border/50"}`,
1679
+ className: `px-4 py-2 text-sm font-medium rounded-xl transition-all shadow-sm ${N === d ? "bg-primary text-primary-foreground shadow-md" : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground border border-border/50"}`,
1671
1680
  children: t("analytics.days", { count: d })
1672
1681
  },
1673
1682
  d
@@ -1733,7 +1742,7 @@ function kt() {
1733
1742
  ] }),
1734
1743
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1735
1744
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1736
- v(o.trends.threads)
1745
+ y(o.trends.threads)
1737
1746
  ] })
1738
1747
  ] })
1739
1748
  ] }),
@@ -1742,8 +1751,8 @@ function kt() {
1742
1751
  /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: I, children: [
1743
1752
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
1744
1753
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
1745
- /* @__PURE__ */ e("span", { children: (u || 0).toLocaleString(C) }),
1746
- /* @__PURE__ */ e("span", { children: Math.floor((u || 0) / 2).toLocaleString(C) }),
1754
+ /* @__PURE__ */ e("span", { children: (h || 0).toLocaleString(C) }),
1755
+ /* @__PURE__ */ e("span", { children: Math.floor((h || 0) / 2).toLocaleString(C) }),
1747
1756
  /* @__PURE__ */ e("span", { children: "0" })
1748
1757
  ] }),
1749
1758
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -1755,7 +1764,7 @@ function kt() {
1755
1764
  "div",
1756
1765
  {
1757
1766
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
1758
- style: { height: `${d.count / u * 100}%` },
1767
+ style: { height: `${d.count / h * 100}%` },
1759
1768
  children: /* @__PURE__ */ r("div", { className: "absolute bottom-full mb-1 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-card px-2 py-1 rounded border border-border shadow-sm z-20 pointer-events-none flex flex-col items-center", children: [
1760
1769
  /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: d.count.toLocaleString(C) }),
1761
1770
  /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(d.date).toLocaleDateString(O, { month: "short", day: "numeric" }) })
@@ -1766,7 +1775,7 @@ function kt() {
1766
1775
  ] }),
1767
1776
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1768
1777
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1769
- v(o.trends.messages)
1778
+ y(o.trends.messages)
1770
1779
  ] })
1771
1780
  ] })
1772
1781
  ] }),
@@ -1799,7 +1808,7 @@ function kt() {
1799
1808
  ] }),
1800
1809
  /* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
1801
1810
  /* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
1802
- v(o.trends.token_usage)
1811
+ y(o.trends.token_usage)
1803
1812
  ] })
1804
1813
  ] })
1805
1814
  ] }),
@@ -1812,8 +1821,8 @@ function kt() {
1812
1821
  (M) => M.sentiment === "positive" || M.sentiment === "negative"
1813
1822
  ), c = d.reduce((M, s) => M + s.count, 0);
1814
1823
  if (c === 0) return null;
1815
- const l = d.find((M) => M.sentiment === "positive")?.count || 0, g = d.find((M) => M.sentiment === "negative")?.count || 0, L = 40, P = 2 * Math.PI * L, h = l / c * 100, j = g / c * 100;
1816
- return /* @__PURE__ */ r(Fe, { children: [
1824
+ const l = d.find((M) => M.sentiment === "positive")?.count || 0, g = d.find((M) => M.sentiment === "negative")?.count || 0, L = 40, P = 2 * Math.PI * L, p = l / c * 100, j = g / c * 100;
1825
+ return /* @__PURE__ */ r(Ue, { children: [
1817
1826
  /* @__PURE__ */ e(
1818
1827
  "circle",
1819
1828
  {
@@ -1845,8 +1854,8 @@ function kt() {
1845
1854
  fill: "transparent",
1846
1855
  stroke: "url(#posGradient)",
1847
1856
  strokeWidth: "10",
1848
- strokeDasharray: `${h / 100 * P} ${P}`,
1849
- strokeLinecap: h > 0 ? "round" : "butt",
1857
+ strokeDasharray: `${p / 100 * P} ${P}`,
1858
+ strokeLinecap: p > 0 ? "round" : "butt",
1850
1859
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
1851
1860
  }
1852
1861
  ),
@@ -1860,7 +1869,7 @@ function kt() {
1860
1869
  stroke: "url(#negGradient)",
1861
1870
  strokeWidth: "10",
1862
1871
  strokeDasharray: `${j / 100 * P} ${P}`,
1863
- strokeDashoffset: -(h / 100 * P),
1872
+ strokeDashoffset: -(p / 100 * P),
1864
1873
  strokeLinecap: j > 0 ? "round" : "butt",
1865
1874
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
1866
1875
  }
@@ -1875,14 +1884,14 @@ function kt() {
1875
1884
  /* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...o.distributions.feedback_sentiment].filter((d) => d.sentiment === "positive" || d.sentiment === "negative").sort((d, c) => d.sentiment === "positive" ? -1 : 1).map((d) => {
1876
1885
  const l = o.distributions.feedback_sentiment.filter(
1877
1886
  (j) => j.sentiment === "positive" || j.sentiment === "negative"
1878
- ).reduce((j, M) => j + M.count, 0), g = l > 0 ? d.count / l * 100 : 0, L = d.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), P = d.sentiment === "positive" ? "bg-primary" : "bg-destructive", h = d.sentiment === "positive" ? "👍" : "👎";
1887
+ ).reduce((j, M) => j + M.count, 0), g = l > 0 ? d.count / l * 100 : 0, L = d.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), P = d.sentiment === "positive" ? "bg-primary" : "bg-destructive", p = d.sentiment === "positive" ? "👍" : "👎";
1879
1888
  return /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-6 group", children: [
1880
1889
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
1881
1890
  /* @__PURE__ */ e("div", { className: `w-3 h-3 rounded-full ${P} shadow-sm group-hover:scale-110 transition-transform` }),
1882
1891
  /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground font-medium", children: [
1883
1892
  L,
1884
1893
  " ",
1885
- h
1894
+ p
1886
1895
  ] })
1887
1896
  ] }),
1888
1897
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
@@ -1926,7 +1935,7 @@ function kt() {
1926
1935
  }
1927
1936
  function Y({ className: t, ...n }) {
1928
1937
  return /* @__PURE__ */ e(
1929
- Te.Root,
1938
+ Ae.Root,
1930
1939
  {
1931
1940
  "data-slot": "switch",
1932
1941
  className: be(
@@ -1935,7 +1944,7 @@ function Y({ className: t, ...n }) {
1935
1944
  ),
1936
1945
  ...n,
1937
1946
  children: /* @__PURE__ */ e(
1938
- Te.Thumb,
1947
+ Ae.Thumb,
1939
1948
  {
1940
1949
  "data-slot": "switch-thumb",
1941
1950
  className: be(
@@ -1946,54 +1955,54 @@ function Y({ className: t, ...n }) {
1946
1955
  }
1947
1956
  );
1948
1957
  }
1949
- function St() {
1950
- const { t, i18n: n } = ee(["admin", "translation", "settings"]), { app: o, welcome: m, disclaimer: b, history: p, threadActions: N, composer: _, settings: w } = me(), [H, T] = x(!1), [A, I] = x(!1), [D, C] = x(""), [O, U] = x(""), [v, z] = x("fa"), [R, E] = x("translation"), [V, Z] = x("{}"), [B, u] = x(""), [J, d] = x(!1), c = pe(() => ({
1958
+ function Ct() {
1959
+ const { t, i18n: n } = ee(["admin", "translation", "settings"]), { app: o, welcome: m, disclaimer: x, history: u, threadActions: v, composer: _, settings: N } = me(), [H, T] = b(!1), [A, I] = b(!1), [D, C] = b(""), [O, U] = b(""), [y, z] = b("fa"), [R, E] = b("translation"), [V, Z] = b("{}"), [B, h] = b(""), [J, d] = b(!1), c = pe(() => ({
1951
1960
  app_name: o?.name || "Gentiq",
1952
1961
  admin_title: o?.adminTitle || "",
1953
1962
  welcome_greeting: m?.greeting || "",
1954
1963
  welcome_subtitle: m?.subtitle || "",
1955
- disclaimer: typeof b == "string" ? b : "",
1964
+ disclaimer: typeof x == "string" ? x : "",
1956
1965
  show_tool_details: o?.showToolDetails ?? !0,
1957
1966
  show_settings: o?.showSettings ?? !0,
1958
1967
  composer_attachments: _?.attachments?.enabled ?? !0,
1959
- thread_actions_feedback: N?.feedback ?? !0,
1960
- thread_actions_retry: N?.retry ?? !0,
1961
- history_enabled: p?.enabled ?? !0,
1962
- history_show_delete: p?.showDelete ?? !0,
1963
- history_show_rename: p?.showRename ?? !0,
1964
- history_show_share: p?.showShare ?? !0,
1965
- history_show_pin: p?.showPin ?? !0,
1968
+ thread_actions_feedback: v?.feedback ?? !0,
1969
+ thread_actions_retry: v?.retry ?? !0,
1970
+ history_enabled: u?.enabled ?? !0,
1971
+ history_show_delete: u?.showDelete ?? !0,
1972
+ history_show_rename: u?.showRename ?? !0,
1973
+ history_show_share: u?.showShare ?? !0,
1974
+ history_show_pin: u?.showPin ?? !0,
1966
1975
  settings_general_mode: o?.settingsGeneralMode || "editable",
1967
1976
  settings_profile_mode: o?.settingsProfileMode || "editable",
1968
1977
  settings_account_mode: o?.settingsAccountMode || "editable",
1969
- settings_general_fields: w?.sections?.general?.fields || {},
1970
- settings_profile_fields: w?.sections?.profile?.fields || {},
1971
- settings_account_fields: w?.sections?.account?.fields || {},
1978
+ settings_general_fields: N?.sections?.general?.fields || {},
1979
+ settings_profile_fields: N?.sections?.profile?.fields || {},
1980
+ settings_account_fields: N?.sections?.account?.fields || {},
1972
1981
  language: n.language || "fa",
1973
1982
  initial_balance_tokens: 25e4,
1974
1983
  initial_balance_requests: 100,
1975
1984
  translations: {}
1976
- }), [o, m, b, p, N, _, n.language, w]), [l, g] = x(c), L = n.language === "fa";
1985
+ }), [o, m, x, u, v, _, n.language, N]), [l, g] = b(c), L = n.language === "fa";
1977
1986
  W(() => {
1978
1987
  (async () => {
1979
1988
  T(!0);
1980
1989
  try {
1981
- const y = await k.getSettings();
1982
- if (y && Object.keys(y).length > 0) {
1990
+ const w = await k.getSettings();
1991
+ if (w && Object.keys(w).length > 0) {
1983
1992
  const F = JSON.parse(JSON.stringify(n.store.data));
1984
- y.translations && Object.keys(y.translations).forEach((X) => {
1985
- F[X] || (F[X] = {}), Object.assign(F[X], y.translations[X]);
1993
+ w.translations && Object.keys(w.translations).forEach((X) => {
1994
+ F[X] || (F[X] = {}), Object.assign(F[X], w.translations[X]);
1986
1995
  }), g((X) => ({
1987
1996
  ...X,
1988
- ...y,
1997
+ ...w,
1989
1998
  translations: F
1990
1999
  }));
1991
2000
  } else {
1992
2001
  const F = { ...c, translations: n.store.data };
1993
- g(F), y || k.updateSettings(F).catch(console.error);
2002
+ g(F), w || k.updateSettings(F).catch(console.error);
1994
2003
  }
1995
- } catch (y) {
1996
- console.error("Failed to fetch settings", y), C(t("app_settings.save_error"));
2004
+ } catch (w) {
2005
+ console.error("Failed to fetch settings", w), C(t("app_settings.save_error"));
1997
2006
  } finally {
1998
2007
  T(!1);
1999
2008
  }
@@ -2003,12 +2012,12 @@ function St() {
2003
2012
  i && i.preventDefault(), I(!0), U(""), C("");
2004
2013
  try {
2005
2014
  await k.updateSettings(l), U(t("app_settings.save_success")), setTimeout(() => U(""), 3e3);
2006
- } catch (y) {
2007
- C(y instanceof Error ? y.message : t("app_settings.save_error"));
2015
+ } catch (w) {
2016
+ C(w instanceof Error ? w.message : t("app_settings.save_error"));
2008
2017
  } finally {
2009
2018
  I(!1);
2010
2019
  }
2011
- }, h = async () => {
2020
+ }, p = async () => {
2012
2021
  T(!0), C("");
2013
2022
  try {
2014
2023
  await k.resetSettings(), d(!1), window.location.reload();
@@ -2019,59 +2028,59 @@ function St() {
2019
2028
  }
2020
2029
  };
2021
2030
  W(() => {
2022
- const i = l.translations?.[v]?.[R] || {};
2023
- Z(JSON.stringify(i, null, 2)), u("");
2024
- }, [v, R, l.translations]);
2031
+ const i = l.translations?.[y]?.[R] || {};
2032
+ Z(JSON.stringify(i, null, 2)), h("");
2033
+ }, [y, R, l.translations]);
2025
2034
  const j = (i) => {
2026
2035
  Z(i);
2027
2036
  try {
2028
- const y = JSON.parse(i);
2037
+ const w = JSON.parse(i);
2029
2038
  g((F) => ({
2030
2039
  ...F,
2031
2040
  translations: {
2032
2041
  ...F.translations,
2033
- [v]: {
2034
- ...F.translations?.[v],
2035
- [R]: y
2042
+ [y]: {
2043
+ ...F.translations?.[y],
2044
+ [R]: w
2036
2045
  }
2037
2046
  }
2038
- })), u("");
2047
+ })), h("");
2039
2048
  } catch {
2040
- u("Invalid JSON format");
2049
+ h("Invalid JSON format");
2041
2050
  }
2042
- }, M = ({ title: i, icon: y }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
2051
+ }, M = ({ title: i, icon: w }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
2043
2052
  /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center", "aria-hidden": "true", children: /* @__PURE__ */ e("div", { className: "w-full border-t border-border/60" }) }),
2044
2053
  /* @__PURE__ */ e("div", { className: "relative flex justify-center", children: /* @__PURE__ */ r("span", { className: "bg-background px-6 text-sm font-bold text-muted-foreground uppercase tracking-[0.2em] flex items-center gap-3", children: [
2045
- /* @__PURE__ */ e(y, { className: "size-4 text-primary/60" }),
2054
+ /* @__PURE__ */ e(w, { className: "size-4 text-primary/60" }),
2046
2055
  i
2047
2056
  ] }) })
2048
2057
  ] }), s = ({ value: i }) => {
2049
2058
  if (!i || !i.includes(":") && !i.includes(".")) return null;
2050
- const y = t(i);
2051
- return y === i ? null : /* @__PURE__ */ r("div", { className: "mt-1.5 px-3 py-1 bg-primary/5 rounded-lg border border-primary/10 inline-flex items-center gap-2", children: [
2059
+ const w = t(i);
2060
+ return w === i ? null : /* @__PURE__ */ r("div", { className: "mt-1.5 px-3 py-1 bg-primary/5 rounded-lg border border-primary/10 inline-flex items-center gap-2", children: [
2052
2061
  /* @__PURE__ */ r("span", { className: "text-[10px] font-bold text-primary/60 uppercase tracking-tighter", children: [
2053
2062
  t("app_settings.preview", { defaultValue: "Preview" }),
2054
2063
  ":"
2055
2064
  ] }),
2056
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: y })
2065
+ /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: w })
2057
2066
  ] });
2058
2067
  }, f = () => {
2059
2068
  const i = prompt("Enter language code (e.g. en, fa, fr):");
2060
- i && !l.translations?.[i] && (g((y) => ({
2061
- ...y,
2069
+ i && !l.translations?.[i] && (g((w) => ({
2070
+ ...w,
2062
2071
  translations: {
2063
- ...y.translations,
2072
+ ...w.translations,
2064
2073
  [i]: {}
2065
2074
  }
2066
2075
  })), z(i));
2067
2076
  }, q = () => {
2068
2077
  const i = prompt("Enter namespace (e.g. chat, admin):");
2069
- i && !l.translations?.[v]?.[i] && (g((y) => ({
2070
- ...y,
2078
+ i && !l.translations?.[y]?.[i] && (g((w) => ({
2079
+ ...w,
2071
2080
  translations: {
2072
- ...y.translations,
2073
- [v]: {
2074
- ...y.translations?.[v],
2081
+ ...w.translations,
2082
+ [y]: {
2083
+ ...w.translations?.[y],
2075
2084
  [i]: {}
2076
2085
  }
2077
2086
  }
@@ -2087,26 +2096,26 @@ function St() {
2087
2096
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("app_settings.subtitle") })
2088
2097
  ] }),
2089
2098
  /* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
2090
- /* @__PURE__ */ r(He, { open: J, onOpenChange: d, children: [
2091
- /* @__PURE__ */ e(Be, { asChild: !0, children: /* @__PURE__ */ r(
2099
+ /* @__PURE__ */ r(Be, { open: J, onOpenChange: d, children: [
2100
+ /* @__PURE__ */ e(Ve, { asChild: !0, children: /* @__PURE__ */ r(
2092
2101
  "button",
2093
2102
  {
2094
2103
  type: "button",
2095
2104
  className: "px-4 py-2 bg-muted/20 text-muted-foreground hover:bg-muted/40 rounded-xl text-xs font-bold transition-all flex items-center gap-2 border border-border/50",
2096
2105
  children: [
2097
- /* @__PURE__ */ e(Le, { className: "size-3.5" }),
2106
+ /* @__PURE__ */ e(qe, { className: "size-3.5" }),
2098
2107
  t("app_settings.reset_button", { defaultValue: "Reset to Defaults" })
2099
2108
  ]
2100
2109
  }
2101
2110
  ) }),
2102
- /* @__PURE__ */ r(Ve, { children: [
2103
- /* @__PURE__ */ r(We, { children: [
2111
+ /* @__PURE__ */ r(We, { children: [
2112
+ /* @__PURE__ */ r(Ge, { children: [
2104
2113
  /* @__PURE__ */ e(Ke, { children: t("app_settings.reset_confirm_title") }),
2105
- /* @__PURE__ */ e(Ge, { children: t("app_settings.reset_confirm_description") })
2114
+ /* @__PURE__ */ e(Ze, { children: t("app_settings.reset_confirm_description") })
2106
2115
  ] }),
2107
- /* @__PURE__ */ r(Ze, { children: [
2108
- /* @__PURE__ */ e(Qe, { asChild: !0, children: /* @__PURE__ */ e(he, { variant: "ghost", children: t("cancel") }) }),
2109
- /* @__PURE__ */ e(he, { variant: "destructive", onClick: h, children: t("app_settings.reset_button") })
2116
+ /* @__PURE__ */ r(Qe, { children: [
2117
+ /* @__PURE__ */ e(Xe, { asChild: !0, children: /* @__PURE__ */ e(he, { variant: "ghost", children: t("cancel") }) }),
2118
+ /* @__PURE__ */ e(he, { variant: "destructive", onClick: p, children: t("app_settings.reset_button") })
2110
2119
  ] })
2111
2120
  ] })
2112
2121
  ] }),
@@ -2173,21 +2182,21 @@ function St() {
2173
2182
  children: [
2174
2183
  /* @__PURE__ */ e(ie, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(oe, {}) }),
2175
2184
  /* @__PURE__ */ r(le, { children: [
2176
- /* @__PURE__ */ e(G, { value: "fa", children: "فارسی (Persian)" }),
2177
- /* @__PURE__ */ e(G, { value: "en", children: "English" })
2185
+ /* @__PURE__ */ e(K, { value: "fa", children: "فارسی (Persian)" }),
2186
+ /* @__PURE__ */ e(K, { value: "en", children: "English" })
2178
2187
  ] })
2179
2188
  ]
2180
2189
  }
2181
2190
  ),
2182
2191
  /* @__PURE__ */ r("p", { className: "mt-3 text-[10px] text-muted-foreground/50 italic flex items-center gap-1.5 ml-1", children: [
2183
- /* @__PURE__ */ e(Le, { className: "size-3" }),
2192
+ /* @__PURE__ */ e(qe, { className: "size-3" }),
2184
2193
  t("app_settings.general.language_help")
2185
2194
  ] })
2186
2195
  ] })
2187
2196
  ] })
2188
2197
  ] }),
2189
2198
  /* @__PURE__ */ r("section", { children: [
2190
- /* @__PURE__ */ e(M, { title: t("app_settings.sections.chat"), icon: dt }),
2199
+ /* @__PURE__ */ e(M, { title: t("app_settings.sections.chat"), icon: ct }),
2191
2200
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2192
2201
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2193
2202
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
@@ -2223,7 +2232,7 @@ function St() {
2223
2232
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2224
2233
  /* @__PURE__ */ e(Q, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.disclaimer") }),
2225
2234
  /* @__PURE__ */ e(
2226
- Se,
2235
+ Ce,
2227
2236
  {
2228
2237
  value: l.disclaimer || "",
2229
2238
  onChange: (i) => g({ ...l, disclaimer: i.target.value }),
@@ -2370,14 +2379,14 @@ function St() {
2370
2379
  ne,
2371
2380
  {
2372
2381
  value: l[i.id],
2373
- onValueChange: (y) => g({ ...l, [i.id]: y }),
2382
+ onValueChange: (w) => g({ ...l, [i.id]: w }),
2374
2383
  dir: L ? "rtl" : "ltr",
2375
2384
  children: [
2376
2385
  /* @__PURE__ */ e(ie, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(oe, {}) }),
2377
2386
  /* @__PURE__ */ r(le, { children: [
2378
- /* @__PURE__ */ e(G, { value: "editable", children: t("app_settings.chat.mode_editable") }),
2379
- /* @__PURE__ */ e(G, { value: "faded", children: t("app_settings.chat.mode_faded") }),
2380
- /* @__PURE__ */ e(G, { value: "hidden", children: t("app_settings.chat.mode_hidden") })
2387
+ /* @__PURE__ */ e(K, { value: "editable", children: t("app_settings.chat.mode_editable") }),
2388
+ /* @__PURE__ */ e(K, { value: "faded", children: t("app_settings.chat.mode_faded") }),
2389
+ /* @__PURE__ */ e(K, { value: "hidden", children: t("app_settings.chat.mode_hidden") })
2381
2390
  ] })
2382
2391
  ]
2383
2392
  }
@@ -2406,17 +2415,17 @@ function St() {
2406
2415
  ne,
2407
2416
  {
2408
2417
  value: l.settings_general_fields?.[i.id] || "editable",
2409
- onValueChange: (y) => g((F) => ({
2418
+ onValueChange: (w) => g((F) => ({
2410
2419
  ...F,
2411
- settings_general_fields: { ...F.settings_general_fields, [i.id]: y }
2420
+ settings_general_fields: { ...F.settings_general_fields, [i.id]: w }
2412
2421
  })),
2413
2422
  dir: L ? "rtl" : "ltr",
2414
2423
  children: [
2415
2424
  /* @__PURE__ */ e(ie, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(oe, {}) }),
2416
2425
  /* @__PURE__ */ r(le, { children: [
2417
- /* @__PURE__ */ e(G, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2418
- /* @__PURE__ */ e(G, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2419
- /* @__PURE__ */ e(G, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2426
+ /* @__PURE__ */ e(K, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2427
+ /* @__PURE__ */ e(K, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2428
+ /* @__PURE__ */ e(K, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2420
2429
  ] })
2421
2430
  ]
2422
2431
  }
@@ -2440,17 +2449,17 @@ function St() {
2440
2449
  ne,
2441
2450
  {
2442
2451
  value: l.settings_profile_fields?.[i.id] || "editable",
2443
- onValueChange: (y) => g((F) => ({
2452
+ onValueChange: (w) => g((F) => ({
2444
2453
  ...F,
2445
- settings_profile_fields: { ...F.settings_profile_fields, [i.id]: y }
2454
+ settings_profile_fields: { ...F.settings_profile_fields, [i.id]: w }
2446
2455
  })),
2447
2456
  dir: L ? "rtl" : "ltr",
2448
2457
  children: [
2449
2458
  /* @__PURE__ */ e(ie, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(oe, {}) }),
2450
2459
  /* @__PURE__ */ r(le, { children: [
2451
- /* @__PURE__ */ e(G, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2452
- /* @__PURE__ */ e(G, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2453
- /* @__PURE__ */ e(G, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2460
+ /* @__PURE__ */ e(K, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2461
+ /* @__PURE__ */ e(K, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2462
+ /* @__PURE__ */ e(K, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2454
2463
  ] })
2455
2464
  ]
2456
2465
  }
@@ -2471,17 +2480,17 @@ function St() {
2471
2480
  ne,
2472
2481
  {
2473
2482
  value: l.settings_account_fields?.[i.id] || "editable",
2474
- onValueChange: (y) => g((F) => ({
2483
+ onValueChange: (w) => g((F) => ({
2475
2484
  ...F,
2476
- settings_account_fields: { ...F.settings_account_fields, [i.id]: y }
2485
+ settings_account_fields: { ...F.settings_account_fields, [i.id]: w }
2477
2486
  })),
2478
2487
  dir: L ? "rtl" : "ltr",
2479
2488
  children: [
2480
2489
  /* @__PURE__ */ e(ie, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(oe, {}) }),
2481
2490
  /* @__PURE__ */ r(le, { children: [
2482
- /* @__PURE__ */ e(G, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2483
- /* @__PURE__ */ e(G, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2484
- /* @__PURE__ */ e(G, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2491
+ /* @__PURE__ */ e(K, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2492
+ /* @__PURE__ */ e(K, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2493
+ /* @__PURE__ */ e(K, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2485
2494
  ] })
2486
2495
  ]
2487
2496
  }
@@ -2493,7 +2502,7 @@ function St() {
2493
2502
  ] })
2494
2503
  ] }),
2495
2504
  /* @__PURE__ */ r("section", { children: [
2496
- /* @__PURE__ */ e(M, { title: t("app_settings.sections.user_billing"), icon: ct }),
2505
+ /* @__PURE__ */ e(M, { title: t("app_settings.sections.user_billing"), icon: mt }),
2497
2506
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2498
2507
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2499
2508
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
@@ -2527,33 +2536,33 @@ function St() {
2527
2536
  ] })
2528
2537
  ] }),
2529
2538
  /* @__PURE__ */ r("section", { children: [
2530
- /* @__PURE__ */ e(M, { title: t("app_settings.translations_management"), icon: mt }),
2539
+ /* @__PURE__ */ e(M, { title: t("app_settings.translations_management"), icon: ut }),
2531
2540
  /* @__PURE__ */ r("div", { className: "border border-border/60 rounded-2xl overflow-hidden bg-background", children: [
2532
2541
  /* @__PURE__ */ r("div", { className: "p-6 border-b border-border/50 bg-muted/5 flex flex-col sm:flex-row items-center gap-4", children: [
2533
2542
  /* @__PURE__ */ r("div", { className: "flex-1 flex items-center gap-4 p-1.5 bg-background border border-border/60 rounded-xl w-full", children: [
2534
2543
  /* @__PURE__ */ e("div", { className: "p-2 px-3 bg-muted/20 rounded-lg border border-border/40 ml-1", children: /* @__PURE__ */ e(xe, { className: "size-4 text-muted-foreground" }) }),
2535
- /* @__PURE__ */ r(ne, { value: v, onValueChange: z, children: [
2544
+ /* @__PURE__ */ r(ne, { value: y, onValueChange: z, children: [
2536
2545
  /* @__PURE__ */ e(ie, { size: "sm", className: "border-none shadow-none bg-transparent h-8 font-black uppercase tracking-wider", children: /* @__PURE__ */ e(oe, {}) }),
2537
- /* @__PURE__ */ e(le, { children: Object.keys(l.translations || {}).sort().map((i) => /* @__PURE__ */ e(G, { value: i, children: i.toUpperCase() }, i)) })
2546
+ /* @__PURE__ */ e(le, { children: Object.keys(l.translations || {}).sort().map((i) => /* @__PURE__ */ e(K, { value: i, children: i.toUpperCase() }, i)) })
2538
2547
  ] }),
2539
2548
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-border/60" }),
2540
2549
  /* @__PURE__ */ r(ne, { value: R, onValueChange: E, children: [
2541
2550
  /* @__PURE__ */ e(ie, { size: "sm", className: "border-none shadow-none bg-transparent h-8 flex-1 font-bold", children: /* @__PURE__ */ e(oe, {}) }),
2542
- /* @__PURE__ */ e(le, { children: Object.keys(l.translations?.[v] || {}).sort().map((i) => /* @__PURE__ */ e(G, { value: i, children: i }, i)) })
2551
+ /* @__PURE__ */ e(le, { children: Object.keys(l.translations?.[y] || {}).sort().map((i) => /* @__PURE__ */ e(K, { value: i, children: i }, i)) })
2543
2552
  ] })
2544
2553
  ] }),
2545
2554
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
2546
- /* @__PURE__ */ e("button", { type: "button", onClick: f, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(ut, { className: "size-4" }) }),
2555
+ /* @__PURE__ */ e("button", { type: "button", onClick: f, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(ht, { className: "size-4" }) }),
2547
2556
  /* @__PURE__ */ e("button", { type: "button", onClick: q, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(xe, { className: "size-4" }) })
2548
2557
  ] })
2549
2558
  ] }),
2550
2559
  /* @__PURE__ */ r("div", { className: "relative p-6", children: [
2551
2560
  /* @__PURE__ */ r("div", { className: "absolute top-8 right-10 flex items-center gap-2", children: [
2552
2561
  /* @__PURE__ */ e("span", { className: "text-[10px] font-bold text-muted-foreground/40 uppercase tracking-widest", children: "JSON EDITOR" }),
2553
- /* @__PURE__ */ e(ht, { className: "size-3 text-muted-foreground/30" })
2562
+ /* @__PURE__ */ e(pt, { className: "size-3 text-muted-foreground/30" })
2554
2563
  ] }),
2555
2564
  /* @__PURE__ */ e(
2556
- Se,
2565
+ Ce,
2557
2566
  {
2558
2567
  value: V,
2559
2568
  onChange: (i) => j(i.target.value),
@@ -2580,28 +2589,28 @@ function St() {
2580
2589
  function ce() {
2581
2590
  const { t, i18n: n } = ee(["admin"]), o = n.language === "fa";
2582
2591
  return /* @__PURE__ */ r("div", { className: "h-full flex flex-col items-center justify-center p-6 text-center gap-4 animate-in fade-in duration-500", dir: o ? "rtl" : "ltr", children: [
2583
- /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(pt, { className: "size-10 text-destructive/70" }) }),
2592
+ /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(gt, { className: "size-10 text-destructive/70" }) }),
2584
2593
  /* @__PURE__ */ r("div", { className: "space-y-1 max-w-sm", children: [
2585
2594
  /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground tracking-tight", children: t("errors.access_denied_title", "Access Denied") }),
2586
2595
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground leading-relaxed", children: t("errors.access_denied_message", "You don't have permission to access this page.") })
2587
2596
  ] })
2588
2597
  ] });
2589
2598
  }
2590
- const Ct = ({ className: t }) => {
2591
- const { t: n } = ee(["theme"]), { theme: o, setTheme: m } = we(), b = () => {
2599
+ const Lt = ({ className: t }) => {
2600
+ const { t: n } = ee(["theme"]), { theme: o, setTheme: m } = we(), x = () => {
2592
2601
  m(o === "system" ? "light" : o === "light" ? "dark" : "system");
2593
- }, p = () => {
2602
+ }, u = () => {
2594
2603
  switch (o) {
2595
2604
  case "light":
2596
- return /* @__PURE__ */ e(ft, { className: "h-[1.2rem] w-[1.2rem]" });
2605
+ return /* @__PURE__ */ e(xt, { className: "h-[1.2rem] w-[1.2rem]" });
2597
2606
  case "dark":
2598
- return /* @__PURE__ */ e(gt, { className: "h-[1.2rem] w-[1.2rem]" });
2607
+ return /* @__PURE__ */ e(ft, { className: "h-[1.2rem] w-[1.2rem]" });
2599
2608
  case "system":
2600
- return /* @__PURE__ */ e(qe, { className: "h-[1.2rem] w-[1.2rem]" });
2609
+ return /* @__PURE__ */ e(je, { className: "h-[1.2rem] w-[1.2rem]" });
2601
2610
  default:
2602
- return /* @__PURE__ */ e(qe, { className: "h-[1.2rem] w-[1.2rem]" });
2611
+ return /* @__PURE__ */ e(je, { className: "h-[1.2rem] w-[1.2rem]" });
2603
2612
  }
2604
- }, N = () => {
2613
+ }, v = () => {
2605
2614
  switch (o) {
2606
2615
  case "light":
2607
2616
  return n("dark");
@@ -2614,28 +2623,28 @@ const Ct = ({ className: t }) => {
2614
2623
  }
2615
2624
  };
2616
2625
  return /* @__PURE__ */ r(ve, { children: [
2617
- /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ r(he, { variant: "ghost", size: "icon", onClick: b, className: t, children: [
2618
- p(),
2626
+ /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ r(he, { variant: "ghost", size: "icon", onClick: x, className: t, children: [
2627
+ u(),
2619
2628
  /* @__PURE__ */ e("span", { className: "sr-only", children: n("toggle") })
2620
2629
  ] }) }),
2621
- /* @__PURE__ */ e(Ne, { children: N() })
2630
+ /* @__PURE__ */ e(Ne, { children: v() })
2622
2631
  ] });
2623
2632
  };
2624
- function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2625
- const o = nt(), m = it(), { t: b, i18n: p } = ee(["admin", "settings", "translation"]), { app: N } = me(), { theme: _ } = we(), [w, H] = x([]), [T, A] = x(!1), I = Me(!1), [D, C] = x("light");
2633
+ function qt({ extraPages: t = [], disabledPages: n = [] }) {
2634
+ const o = it(), m = ot(), { t: x, i18n: u } = ee(["admin", "settings", "translation"]), { app: v } = me(), { theme: _ } = we(), [N, H] = b([]), [T, A] = b(!1), I = Ie(!1), [D, C] = b("light");
2626
2635
  W(() => {
2627
2636
  if (_ === "system") {
2628
- const u = window.matchMedia("(prefers-color-scheme: dark)").matches;
2629
- C(u ? "dark" : "light");
2637
+ const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
2638
+ C(h ? "dark" : "light");
2630
2639
  } else
2631
2640
  C(_);
2632
2641
  }, [_]);
2633
- const O = pe(() => N?.logo ? typeof N.logo == "string" ? N.logo : D === "dark" ? N.logo.dark : N.logo.light : Ie, [N?.logo, D]), U = N?.adminTitle || N?.name, v = p.language === "fa";
2642
+ const O = pe(() => v?.logo ? typeof v.logo == "string" ? v.logo : D === "dark" ? v.logo.dark : v.logo.light : $e, [v?.logo, D]), U = v?.adminTitle || v?.name, y = u.language === "fa";
2634
2643
  W(() => {
2635
- const u = localStorage.getItem("admin_info");
2636
- if (u)
2644
+ const h = localStorage.getItem("admin_info");
2645
+ if (h)
2637
2646
  try {
2638
- const d = JSON.parse(u).permissions || [];
2647
+ const d = JSON.parse(h).permissions || [];
2639
2648
  if (H(d), m.pathname === "/admin" || m.pathname === "/admin/")
2640
2649
  if (d.includes("analytics") && !n.includes("analytics"))
2641
2650
  o("/admin/analytics", { replace: !0 });
@@ -2659,10 +2668,10 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2659
2668
  }, [o, m.pathname]);
2660
2669
  const z = () => {
2661
2670
  k.clearToken(), window.location.reload();
2662
- }, R = (u) => w.includes(u), E = (u) => w.includes(u) && !n.includes(u), V = Object.keys(p.services?.resourceStore?.data || {}).filter((u) => u !== "dev"), Z = V.length > 0 ? V : ["en", "fa"], B = (u) => {
2663
- localStorage.setItem("gentiq-admin-language", u), p.changeLanguage(u), A(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
2671
+ }, R = (h) => N.includes(h), E = (h) => N.includes(h) && !n.includes(h), V = Object.keys(u.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), Z = V.length > 0 ? V : ["en", "fa"], B = (h) => {
2672
+ localStorage.setItem("gentiq-admin-language", h), u.changeLanguage(h), A(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
2664
2673
  };
2665
- return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: v ? "rtl" : "ltr", children: [
2674
+ return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: y ? "rtl" : "ltr", children: [
2666
2675
  /* @__PURE__ */ e("header", { className: "glass border-b border-border sticky top-0 z-50", children: /* @__PURE__ */ e("div", { className: "px-8", children: /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch justify-between min-h-[72px] gap-y-4", children: [
2667
2676
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch gap-x-12", children: [
2668
2677
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3 py-4 md:py-0", children: [
@@ -2675,7 +2684,7 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2675
2684
  {
2676
2685
  onClick: () => o("/admin/analytics"),
2677
2686
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/analytics" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2678
- children: b("dashboard.tabs.analytics")
2687
+ children: x("dashboard.tabs.analytics")
2679
2688
  }
2680
2689
  ),
2681
2690
  !n.includes("chat_history") && /* @__PURE__ */ e(
@@ -2683,7 +2692,7 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2683
2692
  {
2684
2693
  onClick: () => o("/admin/chat-history"),
2685
2694
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/chat-history" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2686
- children: b("dashboard.tabs.chat_history")
2695
+ children: x("dashboard.tabs.chat_history")
2687
2696
  }
2688
2697
  ),
2689
2698
  !n.includes("user_management") && /* @__PURE__ */ e(
@@ -2691,7 +2700,7 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2691
2700
  {
2692
2701
  onClick: () => o("/admin/users"),
2693
2702
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/users" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2694
- children: b("dashboard.tabs.users")
2703
+ children: x("dashboard.tabs.users")
2695
2704
  }
2696
2705
  ),
2697
2706
  !n.includes("admin_management") && /* @__PURE__ */ e(
@@ -2699,7 +2708,7 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2699
2708
  {
2700
2709
  onClick: () => o("/admin/admins"),
2701
2710
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/admins" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2702
- children: b("dashboard.tabs.admins")
2711
+ children: x("dashboard.tabs.admins")
2703
2712
  }
2704
2713
  ),
2705
2714
  !n.includes("settings") && /* @__PURE__ */ e(
@@ -2707,23 +2716,23 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2707
2716
  {
2708
2717
  onClick: () => o("/admin/settings"),
2709
2718
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === "/admin/settings" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2710
- children: b("dashboard.tabs.settings")
2719
+ children: x("dashboard.tabs.settings")
2711
2720
  }
2712
2721
  ),
2713
- t.map((u) => /* @__PURE__ */ e(
2722
+ t.map((h) => /* @__PURE__ */ e(
2714
2723
  "button",
2715
2724
  {
2716
- onClick: () => o(`/admin/${u.path}`),
2717
- className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === `/admin/${u.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2718
- children: typeof u.label == "string" ? b(u.label) : u.label
2725
+ onClick: () => o(`/admin/${h.path}`),
2726
+ className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${m.pathname === `/admin/${h.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
2727
+ children: typeof h.label == "string" ? x(h.label) : h.label
2719
2728
  },
2720
- `tab-${u.path}`
2729
+ `tab-${h.path}`
2721
2730
  ))
2722
2731
  ] })
2723
2732
  ] }),
2724
2733
  /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 py-4 md:py-0", children: [
2725
- /* @__PURE__ */ r(Xe, { onOpenChange: (u) => {
2726
- u ? A(!1) : (I.current = !0, setTimeout(() => {
2734
+ /* @__PURE__ */ r(Ye, { onOpenChange: (h) => {
2735
+ h ? A(!1) : (I.current = !0, setTimeout(() => {
2727
2736
  I.current = !1;
2728
2737
  }, 200));
2729
2738
  }, children: [
@@ -2731,35 +2740,35 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2731
2740
  ve,
2732
2741
  {
2733
2742
  open: T,
2734
- onOpenChange: (u) => {
2735
- u && I.current || A(u);
2743
+ onOpenChange: (h) => {
2744
+ h && I.current || A(h);
2736
2745
  },
2737
2746
  children: [
2738
- /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ e(Ye, { asChild: !0, children: /* @__PURE__ */ e(
2747
+ /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ e(et, { asChild: !0, children: /* @__PURE__ */ e(
2739
2748
  he,
2740
2749
  {
2741
2750
  variant: "ghost",
2742
2751
  size: "icon",
2743
2752
  className: "font-bold text-xs text-muted-foreground hover:bg-muted",
2744
2753
  onPointerDown: () => A(!1),
2745
- children: (p.language?.split("-")[0] || "").toUpperCase()
2754
+ children: (u.language?.split("-")[0] || "").toUpperCase()
2746
2755
  }
2747
2756
  ) }) }),
2748
- /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: b("dashboard.language", "Change Language") })
2757
+ /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: x("dashboard.language", "Change Language") })
2749
2758
  ]
2750
2759
  }
2751
2760
  ),
2752
- /* @__PURE__ */ e(et, { align: "center", className: "min-w-[8rem]", children: Z.map((u) => /* @__PURE__ */ e(
2753
- tt,
2761
+ /* @__PURE__ */ e(tt, { align: "center", className: "min-w-[8rem]", children: Z.map((h) => /* @__PURE__ */ e(
2762
+ rt,
2754
2763
  {
2755
- onClick: () => B(u),
2756
- className: u === p.language ? "bg-primary/10" : "",
2757
- children: b(`general.languages.${u}`, u.toUpperCase())
2764
+ onClick: () => B(h),
2765
+ className: h === u.language ? "bg-primary/10" : "",
2766
+ children: x(`general.languages.${h}`, h.toUpperCase())
2758
2767
  },
2759
- u
2768
+ h
2760
2769
  )) })
2761
2770
  ] }),
2762
- /* @__PURE__ */ e(Ct, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
2771
+ /* @__PURE__ */ e(Lt, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
2763
2772
  /* @__PURE__ */ e("div", { className: "w-px h-5 bg-border mx-1" }),
2764
2773
  /* @__PURE__ */ r(ve, { children: [
2765
2774
  /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ e(
@@ -2769,37 +2778,37 @@ function Lt({ extraPages: t = [], disabledPages: n = [] }) {
2769
2778
  size: "icon",
2770
2779
  className: "hover:bg-destructive/10 hover:scale-105 active:scale-95 text-muted-foreground hover:text-destructive",
2771
2780
  onClick: z,
2772
- children: /* @__PURE__ */ e(xt, { className: "size-5" })
2781
+ children: /* @__PURE__ */ e(bt, { className: "size-5" })
2773
2782
  }
2774
2783
  ) }),
2775
- /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: b("dashboard.logout") })
2784
+ /* @__PURE__ */ e(Ne, { side: "bottom", className: "text-xs", children: x("dashboard.logout") })
2776
2785
  ] })
2777
2786
  ] })
2778
2787
  ] }) }) }),
2779
- /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(ot, { children: [
2780
- /* @__PURE__ */ e(ae, { path: "/", element: /* @__PURE__ */ e(Ce, { to: "/admin/analytics", replace: !0 }) }),
2781
- /* @__PURE__ */ e(ae, { path: "/analytics", element: E("analytics") ? /* @__PURE__ */ e(kt, {}) : /* @__PURE__ */ e(ce, {}) }),
2782
- /* @__PURE__ */ e(ae, { path: "/chat-history", element: E("chat_history") ? /* @__PURE__ */ e(yt, {}) : /* @__PURE__ */ e(ce, {}) }),
2783
- /* @__PURE__ */ e(ae, { path: "/admins", element: E("admin_management") ? /* @__PURE__ */ e(Nt, {}) : /* @__PURE__ */ e(ce, {}) }),
2784
- /* @__PURE__ */ e(ae, { path: "/settings", element: E("settings") ? /* @__PURE__ */ e(St, {}) : /* @__PURE__ */ e(ce, {}) }),
2785
- /* @__PURE__ */ e(ae, { path: "/users", element: E("user_management") ? /* @__PURE__ */ e(_t, {}) : /* @__PURE__ */ e(ce, {}) }),
2786
- t.map((u) => /* @__PURE__ */ e(
2788
+ /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(lt, { children: [
2789
+ /* @__PURE__ */ e(ae, { path: "/", element: /* @__PURE__ */ e(Le, { to: "/admin/analytics", replace: !0 }) }),
2790
+ /* @__PURE__ */ e(ae, { path: "/analytics", element: E("analytics") ? /* @__PURE__ */ e(St, {}) : /* @__PURE__ */ e(ce, {}) }),
2791
+ /* @__PURE__ */ e(ae, { path: "/chat-history", element: E("chat_history") ? /* @__PURE__ */ e(Nt, {}) : /* @__PURE__ */ e(ce, {}) }),
2792
+ /* @__PURE__ */ e(ae, { path: "/admins", element: E("admin_management") ? /* @__PURE__ */ e(wt, {}) : /* @__PURE__ */ e(ce, {}) }),
2793
+ /* @__PURE__ */ e(ae, { path: "/settings", element: E("settings") ? /* @__PURE__ */ e(Ct, {}) : /* @__PURE__ */ e(ce, {}) }),
2794
+ /* @__PURE__ */ e(ae, { path: "/users", element: E("user_management") ? /* @__PURE__ */ e(kt, {}) : /* @__PURE__ */ e(ce, {}) }),
2795
+ t.map((h) => /* @__PURE__ */ e(
2787
2796
  ae,
2788
2797
  {
2789
- path: `/${u.path}`,
2790
- element: u.permission && !R(u.permission) ? /* @__PURE__ */ e(ce, {}) : u.element
2798
+ path: `/${h.path}`,
2799
+ element: h.permission && !R(h.permission) ? /* @__PURE__ */ e(ce, {}) : h.element
2791
2800
  },
2792
- `route-${u.path}`
2801
+ `route-${h.path}`
2793
2802
  )),
2794
- /* @__PURE__ */ e(ae, { path: "*", element: /* @__PURE__ */ e(Ce, { to: "/admin/analytics", replace: !0 }) })
2803
+ /* @__PURE__ */ e(ae, { path: "*", element: /* @__PURE__ */ e(Le, { to: "/admin/analytics", replace: !0 }) })
2795
2804
  ] }) }) })
2796
2805
  ] });
2797
2806
  }
2798
- function Rt(t) {
2807
+ function Ft(t) {
2799
2808
  const n = pe(() => {
2800
- const o = Ue.createInstance();
2801
- return o.use(rt).use(ze).init({
2802
- resources: st,
2809
+ const o = ze.createInstance();
2810
+ return o.use(st).use(Je).init({
2811
+ resources: at,
2803
2812
  fallbackLng: "en",
2804
2813
  interpolation: { escapeValue: !1 },
2805
2814
  detection: {
@@ -2809,97 +2818,97 @@ function Rt(t) {
2809
2818
  }
2810
2819
  }), o;
2811
2820
  }, []);
2812
- return /* @__PURE__ */ e(Je, { i18n: n, children: /* @__PURE__ */ e(qt, { ...t }) });
2821
+ return /* @__PURE__ */ e(Pe, { i18n: n, children: /* @__PURE__ */ e(jt, { ...t }) });
2813
2822
  }
2814
- function qt({ extraPages: t, disabledPages: n = [] }) {
2815
- const { app: o, i18n: m } = me(), { t: b, i18n: p } = ee(["admin", "translation"]), [N, _] = x(!1), [w, H] = x(!0), [T, A] = x(!1);
2823
+ function jt({ extraPages: t, disabledPages: n = [] }) {
2824
+ const { app: o, i18n: m } = me(), { t: x, i18n: u } = ee(["admin", "translation"]), [v, _] = b(!1), [N, H] = b(!0), [T, A] = b(!1);
2816
2825
  W(() => {
2817
2826
  m?.resources && Object.entries(m.resources).forEach(([C, O]) => {
2818
- Object.entries(O).forEach(([U, v]) => {
2819
- p.addResourceBundle(C, U, v, !0, !0);
2827
+ Object.entries(O).forEach(([U, y]) => {
2828
+ u.addResourceBundle(C, U, y, !0, !0);
2820
2829
  });
2821
- }), !localStorage.getItem("gentiq-admin-language") && o?.language && p.language !== o.language && p.changeLanguage(o.language), A(!0);
2822
- }, [m?.resources, p, o?.language]), W(() => {
2830
+ }), !localStorage.getItem("gentiq-admin-language") && o?.language && u.language !== o.language && u.changeLanguage(o.language), A(!0);
2831
+ }, [m?.resources, u, o?.language]), W(() => {
2823
2832
  const D = k.getToken();
2824
2833
  return _(!!D), H(!1), document.body.classList.add("admin-theme-root"), () => {
2825
2834
  document.body.classList.remove("admin-theme-root");
2826
2835
  };
2827
2836
  }, []), W(() => {
2828
- T && (document.documentElement.dir = p.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = p.language);
2829
- }, [T, p.language]);
2837
+ T && (document.documentElement.dir = u.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = u.language);
2838
+ }, [T, u.language]);
2830
2839
  const I = () => {
2831
2840
  _(!0);
2832
2841
  };
2833
- return w || !T ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: b("loading") }) }) : /* @__PURE__ */ e(at, { storageKey: "gentiq-admin-theme", children: N ? /* @__PURE__ */ e(Lt, { extraPages: t, disabledPages: n }) : /* @__PURE__ */ e(vt, { onLoginSuccess: I }) });
2842
+ return N || !T ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: x("loading") }) }) : /* @__PURE__ */ e(nt, { storageKey: "gentiq-admin-theme", children: v ? /* @__PURE__ */ e(qt, { extraPages: t, disabledPages: n }) : /* @__PURE__ */ e(yt, { onLoginSuccess: I }) });
2834
2843
  }
2835
2844
  const se = "gentiq_admin";
2836
- function Ft(t = 0, n = 100, o = "") {
2845
+ function Ut(t = 0, n = 100, o = "") {
2837
2846
  return ue({
2838
2847
  queryKey: [se, "users", t, n, o],
2839
2848
  queryFn: () => k.listUsers(t, n, o)
2840
2849
  });
2841
2850
  }
2842
- function Ut() {
2851
+ function zt() {
2843
2852
  const t = _e(), n = () => {
2844
2853
  t.invalidateQueries({ queryKey: [se, "users"] });
2845
2854
  }, o = re({
2846
2855
  mutationFn: (_) => k.createUser(_.phone, _.name, _.surname, _.tokens, _.requests),
2847
2856
  onSuccess: n
2848
2857
  }), m = re({
2849
- mutationFn: ({ userId: _, data: w }) => k.updateUser(_, w),
2858
+ mutationFn: ({ userId: _, data: N }) => k.updateUser(_, N),
2850
2859
  onSuccess: n
2851
- }), b = re({
2860
+ }), x = re({
2852
2861
  mutationFn: (_) => k.deleteUser(_),
2853
2862
  onSuccess: n
2854
- }), p = re({
2855
- mutationFn: ({ userId: _, tokens: w, requests: H }) => k.updateUserBalance(_, w, H),
2863
+ }), u = re({
2864
+ mutationFn: ({ userId: _, tokens: N, requests: H }) => k.updateUserBalance(_, N, H),
2856
2865
  onSuccess: n
2857
- }), N = re({
2866
+ }), v = re({
2858
2867
  mutationFn: (_) => k.refreshUserToken(_)
2859
2868
  });
2860
- return { createUser: o, updateUser: m, deleteUser: b, updateBalance: p, refreshToken: N };
2869
+ return { createUser: o, updateUser: m, deleteUser: x, updateBalance: u, refreshToken: v };
2861
2870
  }
2862
- function zt(t = 30) {
2871
+ function Jt(t = 30) {
2863
2872
  return ue({
2864
2873
  queryKey: [se, "analytics", t],
2865
2874
  queryFn: () => k.getAnalytics(t)
2866
2875
  });
2867
2876
  }
2868
- function Jt() {
2877
+ function Pt() {
2869
2878
  return ue({
2870
2879
  queryKey: [se, "admins"],
2871
2880
  queryFn: () => k.listAdmins()
2872
2881
  });
2873
2882
  }
2874
- function Pt() {
2883
+ function Ht() {
2875
2884
  const t = _e(), n = () => {
2876
2885
  t.invalidateQueries({ queryKey: [se, "admins"] });
2877
2886
  }, o = re({
2878
- mutationFn: (p) => k.register(p.username, p.password, p.name, p.permissions),
2887
+ mutationFn: (u) => k.register(u.username, u.password, u.name, u.permissions),
2879
2888
  onSuccess: n
2880
2889
  }), m = re({
2881
- mutationFn: ({ adminId: p, data: N }) => k.updateAdmin(p, N),
2890
+ mutationFn: ({ adminId: u, data: v }) => k.updateAdmin(u, v),
2882
2891
  onSuccess: n
2883
- }), b = re({
2884
- mutationFn: (p) => k.deleteAdmin(p),
2892
+ }), x = re({
2893
+ mutationFn: (u) => k.deleteAdmin(u),
2885
2894
  onSuccess: n
2886
2895
  });
2887
- return { createAdmin: o, updateAdmin: m, deleteAdmin: b };
2896
+ return { createAdmin: o, updateAdmin: m, deleteAdmin: x };
2888
2897
  }
2889
- function Ht(t = 0, n = 50, o, m) {
2898
+ function Bt(t = 0, n = 50, o, m) {
2890
2899
  return ue({
2891
2900
  queryKey: [se, "threads", t, n, o, m],
2892
2901
  queryFn: () => k.listThreads(t, n, o, m)
2893
2902
  });
2894
2903
  }
2895
- function Bt(t) {
2904
+ function Vt(t) {
2896
2905
  return ue({
2897
2906
  queryKey: [se, "threadItems", t],
2898
2907
  queryFn: () => k.getThreadItems(t),
2899
2908
  enabled: !!t
2900
2909
  });
2901
2910
  }
2902
- function Vt(t = 20, n) {
2911
+ function Wt(t = 20, n) {
2903
2912
  return ue({
2904
2913
  queryKey: [se, "jobs", t, n],
2905
2914
  queryFn: () => k.listJobs(t, n),
@@ -2907,7 +2916,7 @@ function Vt(t = 20, n) {
2907
2916
  // Auto-refresh jobs every 5 seconds
2908
2917
  });
2909
2918
  }
2910
- function Wt() {
2919
+ function Gt() {
2911
2920
  const t = _e();
2912
2921
  return { cancelJob: re({
2913
2922
  mutationFn: (m) => k.cancelJob(m),
@@ -2925,15 +2934,15 @@ function Kt() {
2925
2934
  };
2926
2935
  }
2927
2936
  export {
2928
- Rt as AdminPanel,
2929
- Jt as useAdminAdmins,
2930
- Pt as useAdminAdminsMutations,
2931
- zt as useAdminAnalytics,
2937
+ Ft as AdminPanel,
2938
+ Pt as useAdminAdmins,
2939
+ Ht as useAdminAdminsMutations,
2940
+ Jt as useAdminAnalytics,
2932
2941
  Kt as useAdminAuth,
2933
- Vt as useAdminJobs,
2934
- Wt as useAdminJobsMutations,
2935
- Bt as useAdminThreadItems,
2936
- Ht as useAdminThreads,
2937
- Ft as useAdminUsers,
2938
- Ut as useAdminUsersMutations
2942
+ Wt as useAdminJobs,
2943
+ Gt as useAdminJobsMutations,
2944
+ Vt as useAdminThreadItems,
2945
+ Bt as useAdminThreads,
2946
+ Ut as useAdminUsers,
2947
+ zt as useAdminUsersMutations
2939
2948
  };