gentiq 0.8.2 → 0.8.3

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