gentiq 0.10.2 → 0.11.0
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.
- package/dist/{checkbox-Bk6TjhJn.js → checkbox-Bo_Q86i6.js} +500 -474
- package/dist/gentiq-admin.es.js +925 -871
- package/dist/gentiq-index.es.js +2 -2
- package/dist/gentiq.css +1 -1
- package/dist/src/admin/lib/api.d.ts +4 -0
- package/dist/src/locales/en.json.d.ts +3 -0
- package/dist/src/locales/fa.json.d.ts +3 -0
- package/package.json +1 -1
package/dist/gentiq-admin.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as e, jsxs as r, Fragment as
|
|
2
|
-
import { useState as y, useEffect as H, useMemo as he, useRef as
|
|
3
|
-
import
|
|
4
|
-
import { useTranslation as F, initReactI18next as
|
|
5
|
-
import { G as
|
|
6
|
-
import { useNavigate as
|
|
7
|
-
import { Share2 as
|
|
8
|
-
import { toast as
|
|
9
|
-
import { useQuery as oe, useQueryClient as
|
|
10
|
-
import * as
|
|
11
|
-
const
|
|
12
|
-
class
|
|
1
|
+
import { jsx as e, jsxs as r, Fragment as at } from "react/jsx-runtime";
|
|
2
|
+
import { useState as y, useEffect as H, useMemo as he, useRef as nt } from "react";
|
|
3
|
+
import mt from "i18next";
|
|
4
|
+
import { useTranslation as F, initReactI18next as ht, I18nextProvider as pt } from "react-i18next";
|
|
5
|
+
import { G as Qe, u as ve, p as Ue, z as st, S as X, t as Y, v as ee, w as te, x as E, i as Se, q as Ge, P as Ce, D as Le, s as je, K as Te, M as Ae, N as Ie, L as z, I as se, aa as De, ab as qe, B as ne, O as Be, ac as ze, r as gt, m as Ee, n as Fe, o as Pe, E as ft, F as bt, H as xt, J as vt, ad as yt, d as _t, T as Nt } from "./checkbox-Bo_Q86i6.js";
|
|
6
|
+
import { useNavigate as wt, useLocation as kt, Routes as Ct, Route as ue, Navigate as Ze } from "react-router-dom";
|
|
7
|
+
import { Share2 as St, Bot as Xe, Sparkles as Lt, User as qt, Info as jt, ArrowUpDown as Tt, ArrowUp as At, ArrowDown as It, UsersRound as Dt, Globe as Je, RefreshCcw as ot, Palette as Rt, Keyboard as Mt, Wrench as $t, Play as Ve, History as Ot, Terminal as Et, ChevronDown as it, Loader2 as He, AlertTriangle as Ft, Ban as Pt, Plus as Jt, Hash as Ut, Wallet as Bt, Languages as zt, ShieldAlert as Vt, Monitor as Ye, Moon as Ht, Sun as Wt, LogOut as Kt } from "lucide-react";
|
|
8
|
+
import { toast as xe } from "sonner";
|
|
9
|
+
import { useQuery as oe, useQueryClient as we, useMutation as ae, keepPreviousData as Qt } from "@tanstack/react-query";
|
|
10
|
+
import * as et from "@radix-ui/react-switch";
|
|
11
|
+
const tt = "/api";
|
|
12
|
+
class Gt {
|
|
13
13
|
token = null;
|
|
14
14
|
constructor() {
|
|
15
15
|
this.token = localStorage.getItem("admin_token");
|
|
@@ -24,22 +24,22 @@ class Ht {
|
|
|
24
24
|
return this.token;
|
|
25
25
|
}
|
|
26
26
|
async request(a, s = {}) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const o = await fetch(`${
|
|
27
|
+
const l = new Headers(s.headers);
|
|
28
|
+
l.has("Content-Type") || l.set("Content-Type", "application/json"), this.token && l.set("Authorization", `Bearer ${this.token}`);
|
|
29
|
+
const o = await fetch(`${tt}${a}`, {
|
|
30
30
|
...s,
|
|
31
|
-
headers:
|
|
31
|
+
headers: l
|
|
32
32
|
});
|
|
33
33
|
if (!o.ok) {
|
|
34
34
|
const n = await o.json().catch(() => ({}));
|
|
35
35
|
if (n.error && (typeof n.error.code == "string" || typeof n.error.message == "string"))
|
|
36
|
-
throw new
|
|
37
|
-
let
|
|
38
|
-
throw typeof n.detail == "string" ?
|
|
36
|
+
throw new Qe(n, o.status);
|
|
37
|
+
let d = `HTTP ${o.status}`, g = "error", _ = null;
|
|
38
|
+
throw typeof n.detail == "string" ? d = n.detail : typeof n.message == "string" ? d = n.message : typeof n.error == "string" ? d = n.error : Array.isArray(n.detail) ? (d = "Validation failed", _ = n.detail, g = "validation_error") : n.error && typeof n.error.message == "string" && (d = n.error.message), new Qe(
|
|
39
39
|
{
|
|
40
40
|
error: {
|
|
41
41
|
code: g,
|
|
42
|
-
message:
|
|
42
|
+
message: d,
|
|
43
43
|
details: _
|
|
44
44
|
}
|
|
45
45
|
},
|
|
@@ -49,26 +49,26 @@ class Ht {
|
|
|
49
49
|
return o.json();
|
|
50
50
|
}
|
|
51
51
|
async login(a, s) {
|
|
52
|
-
const
|
|
52
|
+
const l = await this.request("/admin/login", {
|
|
53
53
|
method: "POST",
|
|
54
54
|
body: JSON.stringify({ username: a, password: s })
|
|
55
55
|
});
|
|
56
|
-
this.setToken(
|
|
56
|
+
this.setToken(l.token);
|
|
57
57
|
const o = {
|
|
58
|
-
admin_id:
|
|
59
|
-
username:
|
|
60
|
-
name:
|
|
61
|
-
permissions:
|
|
58
|
+
admin_id: l.admin_id,
|
|
59
|
+
username: l.username,
|
|
60
|
+
name: l.name,
|
|
61
|
+
permissions: l.permissions
|
|
62
62
|
};
|
|
63
|
-
return localStorage.setItem("admin_info", JSON.stringify(o)),
|
|
63
|
+
return localStorage.setItem("admin_info", JSON.stringify(o)), l;
|
|
64
64
|
}
|
|
65
65
|
async checkSetupStatus() {
|
|
66
66
|
return this.request("/admin/setup-status");
|
|
67
67
|
}
|
|
68
|
-
async register(a, s,
|
|
68
|
+
async register(a, s, l, o) {
|
|
69
69
|
return this.request("/admin/admins", {
|
|
70
70
|
method: "POST",
|
|
71
|
-
body: JSON.stringify({ username: a, password: s, name:
|
|
71
|
+
body: JSON.stringify({ username: a, password: s, name: l, permissions: o })
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
async listAdmins() {
|
|
@@ -88,13 +88,13 @@ class Ht {
|
|
|
88
88
|
async listPermissions() {
|
|
89
89
|
return this.request("/admin/permissions");
|
|
90
90
|
}
|
|
91
|
-
async listThreads(a = 0, s = 50,
|
|
92
|
-
const
|
|
91
|
+
async listThreads(a = 0, s = 50, l, o, n = "human") {
|
|
92
|
+
const d = new URLSearchParams({
|
|
93
93
|
skip: a.toString(),
|
|
94
94
|
limit: s.toString(),
|
|
95
95
|
source: n
|
|
96
96
|
});
|
|
97
|
-
return
|
|
97
|
+
return l && d.append("query", l), o && d.append("feedback", o), this.request(`/admin/chat-history/threads?${d}`);
|
|
98
98
|
}
|
|
99
99
|
async getThreadItems(a) {
|
|
100
100
|
return this.request(`/admin/chat-history/threads/${a}/items`);
|
|
@@ -104,21 +104,21 @@ class Ht {
|
|
|
104
104
|
method: "POST"
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
async listUsers(a = 0, s = 100,
|
|
107
|
+
async listUsers(a = 0, s = 100, l = "", o = "name", n = "asc", d = "human") {
|
|
108
108
|
const g = new URLSearchParams({
|
|
109
109
|
skip: a.toString(),
|
|
110
110
|
limit: s.toString(),
|
|
111
111
|
sort_by: o,
|
|
112
112
|
sort_order: n,
|
|
113
|
-
source:
|
|
113
|
+
source: d
|
|
114
114
|
});
|
|
115
|
-
return
|
|
115
|
+
return l && g.append("query", l), this.request(`/admin/users?${g.toString()}`);
|
|
116
116
|
}
|
|
117
|
-
async createUser(a, s,
|
|
118
|
-
const x = o !== void 0 || n !== void 0 ||
|
|
117
|
+
async createUser(a, s, l, o, n, d, g, _, S, w = "human") {
|
|
118
|
+
const x = o !== void 0 || n !== void 0 || d !== void 0 || g !== void 0 ? {
|
|
119
119
|
tokens: o || 0,
|
|
120
120
|
requests: n || 0,
|
|
121
|
-
token_limit:
|
|
121
|
+
token_limit: d || o || 0,
|
|
122
122
|
request_limit: g || n || 0
|
|
123
123
|
} : void 0;
|
|
124
124
|
return this.request("/admin/users", {
|
|
@@ -126,7 +126,7 @@ class Ht {
|
|
|
126
126
|
body: JSON.stringify({
|
|
127
127
|
phone: a || void 0,
|
|
128
128
|
name: s,
|
|
129
|
-
surname:
|
|
129
|
+
surname: l || void 0,
|
|
130
130
|
balance: x,
|
|
131
131
|
metadata: _,
|
|
132
132
|
recharge_policy: S,
|
|
@@ -145,10 +145,10 @@ class Ht {
|
|
|
145
145
|
method: "DELETE"
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
async updateUserBalance(a, s,
|
|
148
|
+
async updateUserBalance(a, s, l, o, n) {
|
|
149
149
|
return this.request(`/admin/users/${a}/balance`, {
|
|
150
150
|
method: "POST",
|
|
151
|
-
body: JSON.stringify({ tokens: s, requests:
|
|
151
|
+
body: JSON.stringify({ tokens: s, requests: l, token_limit: o, request_limit: n })
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
async bulkUpdateUserBalance(a) {
|
|
@@ -175,8 +175,8 @@ class Ht {
|
|
|
175
175
|
return this.request(`/admin/analytics?days=${a}&source=${s}`);
|
|
176
176
|
}
|
|
177
177
|
async listJobs(a = 20, s) {
|
|
178
|
-
const
|
|
179
|
-
return s &&
|
|
178
|
+
const l = new URLSearchParams({ limit: a.toString() });
|
|
179
|
+
return s && l.append("type", s), this.request(`/admin/jobs?${l}`);
|
|
180
180
|
}
|
|
181
181
|
async cancelJob(a) {
|
|
182
182
|
return this.request(`/admin/jobs/${a}/cancel`, {
|
|
@@ -202,8 +202,8 @@ class Ht {
|
|
|
202
202
|
async listJobRuns(a = {}) {
|
|
203
203
|
const s = new URLSearchParams();
|
|
204
204
|
a.limit && s.append("limit", String(a.limit)), a.kind && s.append("kind", a.kind), a.status && s.append("status", a.status);
|
|
205
|
-
const
|
|
206
|
-
return this.request(`/admin/jobs/runs${
|
|
205
|
+
const l = s.toString();
|
|
206
|
+
return this.request(`/admin/jobs/runs${l ? `?${l}` : ""}`);
|
|
207
207
|
}
|
|
208
208
|
async getJobRun(a) {
|
|
209
209
|
return this.request(`/admin/jobs/runs/${a}`);
|
|
@@ -230,20 +230,20 @@ class Ht {
|
|
|
230
230
|
async getAttachmentBlob(a) {
|
|
231
231
|
const s = {};
|
|
232
232
|
this.token && (s.Authorization = `Bearer ${this.token}`);
|
|
233
|
-
const
|
|
233
|
+
const l = await fetch(`${tt}/admin/chat-history/attachments/${a}`, {
|
|
234
234
|
method: "GET",
|
|
235
235
|
headers: s
|
|
236
236
|
});
|
|
237
|
-
if (!
|
|
238
|
-
const o = await
|
|
239
|
-
throw new Error(o.error || `HTTP ${
|
|
237
|
+
if (!l.ok) {
|
|
238
|
+
const o = await l.json().catch(() => ({ error: "Request failed" }));
|
|
239
|
+
throw new Error(o.error || `HTTP ${l.status}`);
|
|
240
240
|
}
|
|
241
|
-
return
|
|
241
|
+
return l.blob();
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
const T = new
|
|
245
|
-
function
|
|
246
|
-
const { t: a, i18n: s } = F(["admin", "translation"]), { app:
|
|
244
|
+
const T = new Gt();
|
|
245
|
+
function Zt({ onLoginSuccess: t }) {
|
|
246
|
+
const { t: a, i18n: s } = F(["admin", "translation"]), { app: l } = ve(), { theme: o } = Ue(), [n, d] = y(""), [g, _] = y(""), [S, w] = y(""), [x, i] = y(""), [b, h] = y(!1), [N, I] = y(null), [p, R] = y("light");
|
|
247
247
|
H(() => {
|
|
248
248
|
if (o === "system") {
|
|
249
249
|
const v = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -251,11 +251,11 @@ function Wt({ onLoginSuccess: t }) {
|
|
|
251
251
|
} else
|
|
252
252
|
R(o);
|
|
253
253
|
}, [o]);
|
|
254
|
-
const
|
|
254
|
+
const u = he(() => l?.logo ? typeof l.logo == "string" ? l.logo : p === "dark" ? l.logo.dark : l.logo.light : st, [l?.logo, p]), f = l?.adminTitle || l?.name, C = s.language === "fa";
|
|
255
255
|
H(() => {
|
|
256
|
-
T.checkSetupStatus().then((v) =>
|
|
256
|
+
T.checkSetupStatus().then((v) => I(v.needs_setup)).catch(() => I(!1));
|
|
257
257
|
}, []);
|
|
258
|
-
const
|
|
258
|
+
const q = async (v) => {
|
|
259
259
|
v.preventDefault(), i(""), h(!0);
|
|
260
260
|
try {
|
|
261
261
|
await T.login(n, g), t();
|
|
@@ -299,7 +299,7 @@ function Wt({ onLoginSuccess: t }) {
|
|
|
299
299
|
/* @__PURE__ */ r("div", { className: "glass rounded-3xl p-10 shadow-2xl", children: [
|
|
300
300
|
/* @__PURE__ */ r("div", { className: "text-center mb-10", children: [
|
|
301
301
|
/* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-4 mb-6", children: [
|
|
302
|
-
/* @__PURE__ */ e("img", { src:
|
|
302
|
+
/* @__PURE__ */ e("img", { src: u, alt: f, className: "size-16 object-contain" }),
|
|
303
303
|
/* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: N ? a("login.setup_title") : f })
|
|
304
304
|
] }),
|
|
305
305
|
N && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-3", children: a("login.setup_description") })
|
|
@@ -381,7 +381,7 @@ function Wt({ onLoginSuccess: t }) {
|
|
|
381
381
|
] })
|
|
382
382
|
) : (
|
|
383
383
|
/* ---- LOGIN FORM ---- */
|
|
384
|
-
/* @__PURE__ */ r("form", { onSubmit:
|
|
384
|
+
/* @__PURE__ */ r("form", { onSubmit: q, className: "space-y-7", children: [
|
|
385
385
|
/* @__PURE__ */ r("div", { children: [
|
|
386
386
|
/* @__PURE__ */ e(
|
|
387
387
|
"label",
|
|
@@ -397,7 +397,7 @@ function Wt({ onLoginSuccess: t }) {
|
|
|
397
397
|
id: "username",
|
|
398
398
|
type: "text",
|
|
399
399
|
value: n,
|
|
400
|
-
onChange: (v) =>
|
|
400
|
+
onChange: (v) => d(v.target.value),
|
|
401
401
|
required: !0,
|
|
402
402
|
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",
|
|
403
403
|
placeholder: a("login.username_placeholder"),
|
|
@@ -451,18 +451,18 @@ function Wt({ onLoginSuccess: t }) {
|
|
|
451
451
|
);
|
|
452
452
|
}
|
|
453
453
|
const re = "gentiq_admin";
|
|
454
|
-
function
|
|
454
|
+
function Xt(t = 0, a = 100, s = "", l = "name", o = "asc", n = "human") {
|
|
455
455
|
return oe({
|
|
456
|
-
queryKey: [re, "users", t, a, s,
|
|
457
|
-
queryFn: () => T.listUsers(t, a, s,
|
|
456
|
+
queryKey: [re, "users", t, a, s, l, o, n],
|
|
457
|
+
queryFn: () => T.listUsers(t, a, s, l, o, n),
|
|
458
458
|
// Infinite scroll grows `limit`, which changes the query key. Keep the previous
|
|
459
459
|
// (smaller) page mounted while the larger one loads so the list never collapses to
|
|
460
460
|
// empty — otherwise the scroll container resets to the top on every "load more".
|
|
461
|
-
placeholderData:
|
|
461
|
+
placeholderData: Qt
|
|
462
462
|
});
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
const t =
|
|
464
|
+
function Yt() {
|
|
465
|
+
const t = we(), a = () => {
|
|
466
466
|
t.invalidateQueries({ queryKey: [re, "users"] });
|
|
467
467
|
}, s = ae({
|
|
468
468
|
mutationFn: (g) => T.createUser(
|
|
@@ -478,7 +478,7 @@ function Qt() {
|
|
|
478
478
|
g.type ?? "human"
|
|
479
479
|
),
|
|
480
480
|
onSuccess: a
|
|
481
|
-
}),
|
|
481
|
+
}), l = ae({
|
|
482
482
|
mutationFn: ({
|
|
483
483
|
userId: g,
|
|
484
484
|
data: _
|
|
@@ -494,55 +494,55 @@ function Qt() {
|
|
|
494
494
|
requests: S
|
|
495
495
|
}) => T.updateUserBalance(g, _, S),
|
|
496
496
|
onSuccess: a
|
|
497
|
-
}),
|
|
497
|
+
}), d = ae({
|
|
498
498
|
mutationFn: (g) => T.refreshUserToken(g)
|
|
499
499
|
});
|
|
500
|
-
return { createUser: s, updateUser:
|
|
500
|
+
return { createUser: s, updateUser: l, deleteUser: o, updateBalance: n, refreshToken: d };
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function er(t = 30, a = "human") {
|
|
503
503
|
return oe({
|
|
504
504
|
queryKey: [re, "analytics", t, a],
|
|
505
505
|
queryFn: () => T.getAnalytics(t, a)
|
|
506
506
|
});
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function tr() {
|
|
509
509
|
return oe({
|
|
510
510
|
queryKey: [re, "admins"],
|
|
511
511
|
queryFn: () => T.listAdmins()
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
const t =
|
|
514
|
+
function rr() {
|
|
515
|
+
const t = we(), a = () => {
|
|
516
516
|
t.invalidateQueries({ queryKey: [re, "admins"] });
|
|
517
517
|
}, s = ae({
|
|
518
518
|
mutationFn: (n) => T.register(n.username, n.password, n.name, n.permissions),
|
|
519
519
|
onSuccess: a
|
|
520
|
-
}),
|
|
520
|
+
}), l = ae({
|
|
521
521
|
mutationFn: ({
|
|
522
522
|
adminId: n,
|
|
523
|
-
data:
|
|
524
|
-
}) => T.updateAdmin(n,
|
|
523
|
+
data: d
|
|
524
|
+
}) => T.updateAdmin(n, d),
|
|
525
525
|
onSuccess: a
|
|
526
526
|
}), o = ae({
|
|
527
527
|
mutationFn: (n) => T.deleteAdmin(n),
|
|
528
528
|
onSuccess: a
|
|
529
529
|
});
|
|
530
|
-
return { createAdmin: s, updateAdmin:
|
|
530
|
+
return { createAdmin: s, updateAdmin: l, deleteAdmin: o };
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function ar(t = 0, a = 50, s, l, o = "human") {
|
|
533
533
|
return oe({
|
|
534
|
-
queryKey: [re, "threads", t, a, s,
|
|
535
|
-
queryFn: () => T.listThreads(t, a, s,
|
|
534
|
+
queryKey: [re, "threads", t, a, s, l, o],
|
|
535
|
+
queryFn: () => T.listThreads(t, a, s, l, o)
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function nr(t) {
|
|
539
539
|
return oe({
|
|
540
540
|
queryKey: [re, "threadItems", t],
|
|
541
541
|
queryFn: () => T.getThreadItems(t),
|
|
542
542
|
enabled: !!t
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function Vr(t = 20, a) {
|
|
546
546
|
return oe({
|
|
547
547
|
queryKey: [re, "jobs", t, a],
|
|
548
548
|
queryFn: () => T.listJobs(t, a),
|
|
@@ -550,23 +550,23 @@ function Pr(t = 20, a) {
|
|
|
550
550
|
// Auto-refresh jobs every 5 seconds
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
|
-
function
|
|
554
|
-
const t =
|
|
553
|
+
function Hr() {
|
|
554
|
+
const t = we();
|
|
555
555
|
return { cancelJob: ae({
|
|
556
|
-
mutationFn: (
|
|
556
|
+
mutationFn: (l) => T.cancelJob(l),
|
|
557
557
|
onSuccess: () => {
|
|
558
558
|
t.invalidateQueries({ queryKey: [re, "jobs"] });
|
|
559
559
|
}
|
|
560
560
|
}) };
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function sr(t = !0) {
|
|
563
563
|
return oe({
|
|
564
564
|
queryKey: [re, "registeredJobs"],
|
|
565
565
|
queryFn: () => T.listRegisteredJobs(),
|
|
566
566
|
enabled: t
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function or(t = {}, a = !0) {
|
|
570
570
|
return oe({
|
|
571
571
|
queryKey: [re, "jobRuns", t],
|
|
572
572
|
queryFn: () => T.listJobRuns(t),
|
|
@@ -575,7 +575,7 @@ function rr(t = {}, a = !0) {
|
|
|
575
575
|
enabled: a
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function ir(t, a = !1) {
|
|
579
579
|
return oe({
|
|
580
580
|
queryKey: [re, "jobRun", t],
|
|
581
581
|
queryFn: () => T.getJobRun(t),
|
|
@@ -583,24 +583,24 @@ function ar(t, a = !1) {
|
|
|
583
583
|
refetchInterval: a ? 2e3 : !1
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
const t =
|
|
586
|
+
function We() {
|
|
587
|
+
const t = we(), a = () => t.invalidateQueries({ queryKey: [re, "jobRuns"] }), s = ae({
|
|
588
588
|
mutationFn: (n) => T.runRegisteredJob(n.jobId, {
|
|
589
589
|
params: n.params,
|
|
590
590
|
dry_run: n.dry_run,
|
|
591
591
|
confirm: n.confirm
|
|
592
592
|
}),
|
|
593
593
|
onSuccess: a
|
|
594
|
-
}),
|
|
594
|
+
}), l = ae({
|
|
595
595
|
mutationFn: (n) => T.runRawJob(n),
|
|
596
596
|
onSuccess: a
|
|
597
597
|
}), o = ae({
|
|
598
598
|
mutationFn: (n) => T.cancelJobRun(n),
|
|
599
599
|
onSuccess: a
|
|
600
600
|
});
|
|
601
|
-
return { runRegisteredJob: s, runRawJob:
|
|
601
|
+
return { runRegisteredJob: s, runRawJob: l, cancelJobRun: o };
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function Wr() {
|
|
604
604
|
return {
|
|
605
605
|
login: async (t, a) => T.login(t, a),
|
|
606
606
|
logout: () => T.clearToken(),
|
|
@@ -608,87 +608,112 @@ function Ur() {
|
|
|
608
608
|
isAuthenticated: !!T.getToken()
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
const
|
|
611
|
+
function lt(t, a, s) {
|
|
612
|
+
const l = (t || 0) / 1e6;
|
|
613
613
|
try {
|
|
614
614
|
return new Intl.NumberFormat(s, {
|
|
615
615
|
style: "currency",
|
|
616
616
|
currency: a,
|
|
617
|
-
minimumFractionDigits:
|
|
617
|
+
minimumFractionDigits: l > 0 && l < 0.01 ? 6 : 2,
|
|
618
618
|
maximumFractionDigits: 6
|
|
619
|
-
}).format(
|
|
619
|
+
}).format(l);
|
|
620
620
|
} catch {
|
|
621
|
-
return `${a} ${
|
|
621
|
+
return `${a} ${l.toLocaleString(s, { maximumFractionDigits: 6 })}`;
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
function me(t, a, s) {
|
|
625
|
-
const
|
|
625
|
+
const l = (t || 0) / 1e6;
|
|
626
626
|
try {
|
|
627
627
|
return new Intl.NumberFormat(s, {
|
|
628
628
|
style: "currency",
|
|
629
629
|
currency: a,
|
|
630
630
|
minimumFractionDigits: 2,
|
|
631
631
|
maximumFractionDigits: 2
|
|
632
|
-
}).format(
|
|
632
|
+
}).format(l);
|
|
633
633
|
} catch {
|
|
634
|
-
return `${a} ${
|
|
634
|
+
return `${a} ${l.toLocaleString(s, {
|
|
635
635
|
minimumFractionDigits: 2,
|
|
636
636
|
maximumFractionDigits: 2
|
|
637
637
|
})}`;
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
-
function
|
|
641
|
-
const
|
|
640
|
+
function lr(t) {
|
|
641
|
+
const a = [];
|
|
642
|
+
for (const s of t)
|
|
643
|
+
if (s.subagent) {
|
|
644
|
+
const l = a[a.length - 1];
|
|
645
|
+
l && l.kind === "subagent" && l.agent === s.agent ? l.items.push(s) : a.push({ kind: "subagent", agent: s.agent, items: [s] });
|
|
646
|
+
} else
|
|
647
|
+
a.push({ kind: "message", item: s });
|
|
648
|
+
return a;
|
|
649
|
+
}
|
|
650
|
+
function rt({ kind: t }) {
|
|
651
|
+
const a = {
|
|
652
|
+
user: { Icon: qt, cls: "bg-primary/15 text-primary" },
|
|
653
|
+
assistant: { Icon: Lt, cls: "bg-primary/15 text-primary" },
|
|
654
|
+
subagent: { Icon: Xe, cls: "bg-amber-500/15 text-amber-600 dark:text-amber-400" },
|
|
655
|
+
other: { Icon: Xe, cls: "bg-muted text-muted-foreground" }
|
|
656
|
+
}[t];
|
|
657
|
+
return /* @__PURE__ */ e(
|
|
658
|
+
"span",
|
|
659
|
+
{
|
|
660
|
+
className: `flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center ${a.cls}`,
|
|
661
|
+
children: /* @__PURE__ */ e(a.Icon, { className: "w-3.5 h-3.5" })
|
|
662
|
+
}
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
function dr() {
|
|
666
|
+
const { t, i18n: a } = F(["admin", "translation"]), { app: s } = ve(), l = s?.userMetadataFields || [], [o, n] = y(null), [d, g] = y(""), [_, S] = y(""), [w, x] = y(""), [i, b] = y("human"), [h, N] = y(0), [I, p] = y([]), [R, u] = y(!0), [f, C] = y(""), q = a.language === "fa", $ = q ? "fa-IR" : "en-US";
|
|
642
667
|
H(() => {
|
|
643
|
-
const
|
|
644
|
-
return () => clearTimeout(
|
|
645
|
-
}, [
|
|
646
|
-
const v =
|
|
668
|
+
const c = setTimeout(() => S(d), 500);
|
|
669
|
+
return () => clearTimeout(c);
|
|
670
|
+
}, [d]);
|
|
671
|
+
const v = ar(
|
|
647
672
|
h,
|
|
648
673
|
50,
|
|
649
674
|
_ || void 0,
|
|
650
675
|
w || void 0,
|
|
651
676
|
i
|
|
652
|
-
), O =
|
|
677
|
+
), O = nr(o?.id ?? "");
|
|
653
678
|
H(() => {
|
|
654
|
-
N(0), p([]),
|
|
679
|
+
N(0), p([]), u(!0);
|
|
655
680
|
}, [_, w, i]), H(() => {
|
|
656
|
-
const
|
|
657
|
-
|
|
681
|
+
const c = v.data?.threads;
|
|
682
|
+
c && (p((L) => h === 0 ? c : [...L, ...c]), u(c.length === 50));
|
|
658
683
|
}, [v.data, h]);
|
|
659
|
-
const P = O.data?.items ?? [], Z = v.isLoading, k = v.isFetching && h > 0, m = O.isLoading,
|
|
660
|
-
n(
|
|
684
|
+
const P = O.data?.items ?? [], Z = v.isLoading, k = v.isFetching && h > 0, m = O.isLoading, j = f || (v.error instanceof Error ? v.error.message : "") || (O.error instanceof Error ? O.error.message : "") || (v.error || O.error ? t("error_loading") : ""), A = (c) => {
|
|
685
|
+
n(c);
|
|
661
686
|
}, K = () => {
|
|
662
|
-
N((
|
|
663
|
-
}, M = async (
|
|
664
|
-
|
|
687
|
+
N((c) => c + 50);
|
|
688
|
+
}, M = async (c, L) => {
|
|
689
|
+
c.stopPropagation();
|
|
665
690
|
try {
|
|
666
|
-
const
|
|
667
|
-
navigator.clipboard.writeText(
|
|
691
|
+
const D = await T.shareThread(L.id), U = `${window.location.origin}${D.url}`;
|
|
692
|
+
navigator.clipboard.writeText(U), xe.success(t("sidebar:share_success"), {
|
|
668
693
|
description: t("sidebar:share_description")
|
|
669
694
|
});
|
|
670
695
|
} catch {
|
|
671
|
-
|
|
696
|
+
xe.error(t("sidebar:share_failed"));
|
|
672
697
|
}
|
|
673
|
-
},
|
|
674
|
-
const
|
|
675
|
-
return new Intl.DateTimeFormat(
|
|
698
|
+
}, B = (c) => {
|
|
699
|
+
const L = new Date(c);
|
|
700
|
+
return new Intl.DateTimeFormat(q ? "fa-IR" : "en-US", {
|
|
676
701
|
year: "numeric",
|
|
677
702
|
month: "long",
|
|
678
703
|
day: "numeric",
|
|
679
704
|
hour: "2-digit",
|
|
680
705
|
minute: "2-digit"
|
|
681
|
-
}).format(
|
|
682
|
-
}, Q = (
|
|
683
|
-
if (typeof
|
|
706
|
+
}).format(L);
|
|
707
|
+
}, Q = (c) => {
|
|
708
|
+
if (typeof c == "string")
|
|
684
709
|
try {
|
|
685
|
-
return JSON.stringify(JSON.parse(
|
|
710
|
+
return JSON.stringify(JSON.parse(c), null, 2);
|
|
686
711
|
} catch {
|
|
687
|
-
return
|
|
712
|
+
return c;
|
|
688
713
|
}
|
|
689
|
-
return JSON.stringify(
|
|
690
|
-
}, W = ({ part:
|
|
691
|
-
const [
|
|
714
|
+
return JSON.stringify(c, null, 2);
|
|
715
|
+
}, W = ({ part: c, idx: L }) => {
|
|
716
|
+
const [D, U] = y(!1), G = c.tool_name || (c.type && c.type.startsWith("tool-") ? c.type.slice(5) : "tool");
|
|
692
717
|
return /* @__PURE__ */ r(
|
|
693
718
|
"div",
|
|
694
719
|
{
|
|
@@ -698,14 +723,14 @@ function nr() {
|
|
|
698
723
|
/* @__PURE__ */ r(
|
|
699
724
|
"div",
|
|
700
725
|
{
|
|
701
|
-
onClick: () =>
|
|
726
|
+
onClick: () => U(!D),
|
|
702
727
|
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",
|
|
703
728
|
children: [
|
|
704
729
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
705
730
|
/* @__PURE__ */ e(
|
|
706
731
|
"svg",
|
|
707
732
|
{
|
|
708
|
-
className: `w-3 h-3 text-gray-400 transition-transform ${
|
|
733
|
+
className: `w-3 h-3 text-gray-400 transition-transform ${D ? "rotate-180" : ""}`,
|
|
709
734
|
fill: "none",
|
|
710
735
|
viewBox: "0 0 24 24",
|
|
711
736
|
stroke: "currentColor",
|
|
@@ -726,45 +751,45 @@ function nr() {
|
|
|
726
751
|
/* @__PURE__ */ e(
|
|
727
752
|
"span",
|
|
728
753
|
{
|
|
729
|
-
className: `text-[10px] px-2 py-0.5 rounded-full ${
|
|
730
|
-
children:
|
|
754
|
+
className: `text-[10px] px-2 py-0.5 rounded-full ${c.state === "output-available" ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"}`,
|
|
755
|
+
children: c.state === "output-available" ? t("chat_history.output_available") : t("chat_history.running")
|
|
731
756
|
}
|
|
732
757
|
)
|
|
733
758
|
]
|
|
734
759
|
}
|
|
735
760
|
),
|
|
736
|
-
|
|
761
|
+
D && /* @__PURE__ */ r("div", { className: "p-2.5 space-y-2.5 animate-in fade-in slide-in-from-top-1 duration-200", children: [
|
|
737
762
|
/* @__PURE__ */ r("div", { children: [
|
|
738
763
|
/* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: "Input" }),
|
|
739
|
-
/* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children: Q(
|
|
764
|
+
/* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children: Q(c.input) })
|
|
740
765
|
] }),
|
|
741
|
-
(
|
|
742
|
-
/* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children:
|
|
766
|
+
(c.output || c.error_text || c.errorText) && /* @__PURE__ */ r("div", { children: [
|
|
767
|
+
/* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: c.error_text || c.errorText ? "Error" : "Output" }),
|
|
743
768
|
/* @__PURE__ */ e(
|
|
744
769
|
"pre",
|
|
745
770
|
{
|
|
746
|
-
className: `text-xs p-2 rounded-lg overflow-x-auto ${
|
|
747
|
-
children: Q(
|
|
771
|
+
className: `text-xs p-2 rounded-lg overflow-x-auto ${c.error_text || c.errorText ? "bg-destructive/10 text-destructive" : "bg-primary/5 text-foreground/80"}`,
|
|
772
|
+
children: Q(c.output || c.error_text || c.errorText)
|
|
748
773
|
}
|
|
749
774
|
)
|
|
750
775
|
] })
|
|
751
776
|
] })
|
|
752
777
|
]
|
|
753
778
|
},
|
|
754
|
-
|
|
779
|
+
L
|
|
755
780
|
);
|
|
756
|
-
},
|
|
781
|
+
}, V = async (c, L) => {
|
|
757
782
|
try {
|
|
758
|
-
const
|
|
759
|
-
G.href =
|
|
760
|
-
} catch (
|
|
761
|
-
console.error("Download failed:",
|
|
783
|
+
const D = await T.getAttachmentBlob(c), U = window.URL.createObjectURL(D), G = document.createElement("a");
|
|
784
|
+
G.href = U, G.download = L || c.split("/").pop() || "download", document.body.appendChild(G), G.click(), window.URL.revokeObjectURL(U), document.body.removeChild(G);
|
|
785
|
+
} catch (D) {
|
|
786
|
+
console.error("Download failed:", D), C(D instanceof Error ? D.message : "Download failed");
|
|
762
787
|
}
|
|
763
|
-
}, de = (
|
|
764
|
-
if (typeof
|
|
765
|
-
if (
|
|
766
|
-
return /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children:
|
|
767
|
-
if (
|
|
788
|
+
}, de = (c, L) => {
|
|
789
|
+
if (typeof c == "string") return /* @__PURE__ */ e("div", { children: c }, L);
|
|
790
|
+
if (c.type === "text")
|
|
791
|
+
return /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: c.text }, L);
|
|
792
|
+
if (c.type === "reasoning")
|
|
768
793
|
return /* @__PURE__ */ r(
|
|
769
794
|
"div",
|
|
770
795
|
{
|
|
@@ -772,27 +797,27 @@ function nr() {
|
|
|
772
797
|
dir: "auto",
|
|
773
798
|
children: [
|
|
774
799
|
/* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter opacity-70", children: "Reasoning" }),
|
|
775
|
-
|
|
800
|
+
c.text
|
|
776
801
|
]
|
|
777
802
|
},
|
|
778
|
-
|
|
803
|
+
L
|
|
779
804
|
);
|
|
780
|
-
if (
|
|
781
|
-
const
|
|
805
|
+
if (c.type === "data-reference") {
|
|
806
|
+
const D = c.data || c.reference;
|
|
782
807
|
return /* @__PURE__ */ r(
|
|
783
808
|
"div",
|
|
784
809
|
{
|
|
785
810
|
className: "my-2 p-2.5 bg-primary/5 rounded-lg border border-primary/15 text-xs",
|
|
786
811
|
dir: "auto",
|
|
787
812
|
children: [
|
|
788
|
-
/* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter text-primary/80", children:
|
|
789
|
-
/* @__PURE__ */ e("div", { className: "text-muted-foreground line-clamp-3", children:
|
|
813
|
+
/* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter text-primary/80", children: D?.label || t("chat.reference", "Reference") }),
|
|
814
|
+
/* @__PURE__ */ e("div", { className: "text-muted-foreground line-clamp-3", children: D?.excerpt || t("chat.source_unavailable", "Source unavailable") })
|
|
790
815
|
]
|
|
791
816
|
},
|
|
792
|
-
|
|
817
|
+
L
|
|
793
818
|
);
|
|
794
819
|
}
|
|
795
|
-
return
|
|
820
|
+
return c.type === "data-choice-question" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(c.data ?? c, null, 2) }, L) : c.type === "dynamic-tool" || c.type && c.type.startsWith("tool-") || c.tool_call_id ? /* @__PURE__ */ e(W, { part: c, idx: L }, L) : c.type === "file" ? /* @__PURE__ */ r(
|
|
796
821
|
"div",
|
|
797
822
|
{
|
|
798
823
|
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",
|
|
@@ -804,17 +829,17 @@ function nr() {
|
|
|
804
829
|
"span",
|
|
805
830
|
{
|
|
806
831
|
className: "text-sm text-foreground font-medium truncate",
|
|
807
|
-
title:
|
|
808
|
-
children:
|
|
832
|
+
title: c.filename || "File",
|
|
833
|
+
children: c.filename || t("chat_history.unnamed_file")
|
|
809
834
|
}
|
|
810
835
|
),
|
|
811
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground uppercase tracking-wider font-bold", children:
|
|
836
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground uppercase tracking-wider font-bold", children: c.media_type || c.mime_type || c.mediaType || "file" })
|
|
812
837
|
] })
|
|
813
838
|
] }),
|
|
814
|
-
|
|
839
|
+
c.object_name && /* @__PURE__ */ e(
|
|
815
840
|
"button",
|
|
816
841
|
{
|
|
817
|
-
onClick: () =>
|
|
842
|
+
onClick: () => V(c.object_name, c.filename),
|
|
818
843
|
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",
|
|
819
844
|
title: t("chat_history.download_file", "Download File"),
|
|
820
845
|
children: /* @__PURE__ */ e("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e(
|
|
@@ -830,20 +855,23 @@ function nr() {
|
|
|
830
855
|
)
|
|
831
856
|
]
|
|
832
857
|
},
|
|
833
|
-
|
|
858
|
+
L
|
|
834
859
|
) : /* @__PURE__ */ e(
|
|
835
860
|
"div",
|
|
836
861
|
{
|
|
837
862
|
className: "my-2 p-2 bg-muted/40 rounded-lg border border-border text-xs font-mono opacity-60",
|
|
838
|
-
children: JSON.stringify(
|
|
863
|
+
children: JSON.stringify(c)
|
|
839
864
|
},
|
|
840
|
-
|
|
865
|
+
L
|
|
841
866
|
);
|
|
842
|
-
},
|
|
843
|
-
const
|
|
844
|
-
|
|
867
|
+
}, pe = (c) => {
|
|
868
|
+
const L = c.parts || [];
|
|
869
|
+
return L.length > 0 ? L.map((D, U) => de(D, U)) : typeof c.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(c.content, null, 2) }) : c.content;
|
|
870
|
+
}, Re = (c) => {
|
|
871
|
+
const { scrollTop: L, scrollHeight: D, clientHeight: U } = c.currentTarget;
|
|
872
|
+
D - L <= U + 50 && !k && R && K();
|
|
845
873
|
};
|
|
846
|
-
return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir:
|
|
874
|
+
return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: q ? "rtl" : "ltr", children: [
|
|
847
875
|
/* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
|
|
848
876
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-4", children: [
|
|
849
877
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("chat_history.title") }),
|
|
@@ -851,8 +879,8 @@ function nr() {
|
|
|
851
879
|
/* @__PURE__ */ r(
|
|
852
880
|
"form",
|
|
853
881
|
{
|
|
854
|
-
onSubmit: (
|
|
855
|
-
|
|
882
|
+
onSubmit: (c) => {
|
|
883
|
+
c.preventDefault(), S(d);
|
|
856
884
|
},
|
|
857
885
|
className: "flex-1 min-w-[16rem] flex gap-2",
|
|
858
886
|
children: [
|
|
@@ -860,8 +888,8 @@ function nr() {
|
|
|
860
888
|
"input",
|
|
861
889
|
{
|
|
862
890
|
type: "text",
|
|
863
|
-
value:
|
|
864
|
-
onChange: (
|
|
891
|
+
value: d,
|
|
892
|
+
onChange: (c) => g(c.target.value),
|
|
865
893
|
placeholder: t("chat_history.search_placeholder"),
|
|
866
894
|
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"
|
|
867
895
|
}
|
|
@@ -881,8 +909,8 @@ function nr() {
|
|
|
881
909
|
X,
|
|
882
910
|
{
|
|
883
911
|
value: w || "all",
|
|
884
|
-
onValueChange: (
|
|
885
|
-
dir:
|
|
912
|
+
onValueChange: (c) => x(c === "all" ? "" : c),
|
|
913
|
+
dir: q ? "rtl" : "ltr",
|
|
886
914
|
children: [
|
|
887
915
|
/* @__PURE__ */ e(Y, { className: "min-w-[160px] px-4 py-2 h-auto text-sm font-medium rounded-xl glass-surface border-0 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
888
916
|
/* @__PURE__ */ r(te, { className: "rounded-xl border-border bg-card", children: [
|
|
@@ -898,117 +926,117 @@ function nr() {
|
|
|
898
926
|
X,
|
|
899
927
|
{
|
|
900
928
|
value: i,
|
|
901
|
-
onValueChange: (
|
|
902
|
-
dir:
|
|
929
|
+
onValueChange: (c) => b(c),
|
|
930
|
+
dir: q ? "rtl" : "ltr",
|
|
903
931
|
children: [
|
|
904
932
|
/* @__PURE__ */ e(Y, { className: "min-w-[140px] px-4 py-2 h-auto text-sm font-medium rounded-xl glass-surface border-0 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
905
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((
|
|
933
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((c) => /* @__PURE__ */ e(E, { value: c, children: t(`chat_history.source_${c}`) }, c)) })
|
|
906
934
|
]
|
|
907
935
|
}
|
|
908
936
|
)
|
|
909
937
|
] })
|
|
910
938
|
] }),
|
|
911
|
-
|
|
939
|
+
j && /* @__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: j })
|
|
912
940
|
] }),
|
|
913
941
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-[380px_1fr] gap-4 flex-1 min-h-0", children: [
|
|
914
942
|
/* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col min-w-0", children: [
|
|
915
943
|
/* @__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: [
|
|
916
944
|
t("chat_history.threads_list"),
|
|
917
945
|
" (",
|
|
918
|
-
(
|
|
946
|
+
(I.length || 0).toLocaleString($),
|
|
919
947
|
")"
|
|
920
948
|
] }) }),
|
|
921
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-2 custom-scrollbar", onScroll:
|
|
922
|
-
|
|
949
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-2 custom-scrollbar", onScroll: Re, children: Z && I.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: [
|
|
950
|
+
I.map((c) => /* @__PURE__ */ r(
|
|
923
951
|
"div",
|
|
924
952
|
{
|
|
925
|
-
onClick: () => A(
|
|
926
|
-
className: `p-2.5 cursor-pointer transition-all rounded-xl border ${o?.id ===
|
|
953
|
+
onClick: () => A(c),
|
|
954
|
+
className: `p-2.5 cursor-pointer transition-all rounded-xl border ${o?.id === c.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
|
|
927
955
|
children: [
|
|
928
956
|
/* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-1.5 gap-4", children: [
|
|
929
957
|
/* @__PURE__ */ e(
|
|
930
958
|
"h3",
|
|
931
959
|
{
|
|
932
|
-
className: `font-medium text-sm truncate flex-1 ${o?.id ===
|
|
933
|
-
title:
|
|
934
|
-
children:
|
|
960
|
+
className: `font-medium text-sm truncate flex-1 ${o?.id === c.id ? "text-primary" : "text-foreground"}`,
|
|
961
|
+
title: c.title || t("chat_history.no_thread_title"),
|
|
962
|
+
children: c.title || t("chat_history.no_thread_title")
|
|
935
963
|
}
|
|
936
964
|
),
|
|
937
965
|
/* @__PURE__ */ r("div", { className: "flex gap-1 items-center", children: [
|
|
938
|
-
|
|
966
|
+
c.metadata?.external_user_id && /* @__PURE__ */ e(
|
|
939
967
|
"span",
|
|
940
968
|
{
|
|
941
969
|
className: "text-[10px] px-1.5 py-0.5 rounded-md bg-primary/10 text-primary font-medium truncate max-w-[120px]",
|
|
942
|
-
title: `${t("chat_history.external_user_id")}: ${
|
|
943
|
-
children:
|
|
970
|
+
title: `${t("chat_history.external_user_id")}: ${c.metadata.external_user_id}`,
|
|
971
|
+
children: c.metadata.external_user_id
|
|
944
972
|
}
|
|
945
973
|
),
|
|
946
|
-
|
|
947
|
-
|
|
974
|
+
c.feedback_info && c.feedback_info.like > 0 && /* @__PURE__ */ e("span", { className: "text-xs", children: "👍" }),
|
|
975
|
+
c.feedback_info && c.feedback_info.dislike > 0 && /* @__PURE__ */ e("span", { className: "text-xs", children: "👎" })
|
|
948
976
|
] })
|
|
949
977
|
] }),
|
|
950
978
|
/* @__PURE__ */ r("div", { className: "text-xs space-y-1.5 text-muted-foreground", children: [
|
|
951
|
-
|
|
979
|
+
c.user_info && /* @__PURE__ */ r(
|
|
952
980
|
"div",
|
|
953
981
|
{
|
|
954
982
|
className: "flex flex-col gap-0.5 min-w-0",
|
|
955
|
-
title: `${[
|
|
956
|
-
(
|
|
957
|
-
).map((
|
|
958
|
-
const
|
|
959
|
-
if (
|
|
960
|
-
const
|
|
961
|
-
(G) => String(G.value) === String(
|
|
983
|
+
title: `${[c.user_info.name, c.user_info.surname].filter(Boolean).join(" ")}${c.user_info.phone ? ` • ${c.user_info.phone}` : ""}${l.filter(
|
|
984
|
+
(L) => c.user_info?.metadata?.[L.key] !== void 0 && c.user_info?.metadata?.[L.key] !== ""
|
|
985
|
+
).map((L) => {
|
|
986
|
+
const D = c.user_info?.metadata?.[L.key];
|
|
987
|
+
if (L.type === "select") {
|
|
988
|
+
const U = L.options?.find(
|
|
989
|
+
(G) => String(G.value) === String(D)
|
|
962
990
|
);
|
|
963
|
-
return ` • ${
|
|
991
|
+
return ` • ${U ? t(U.label) : D}`;
|
|
964
992
|
}
|
|
965
|
-
return ` • ${
|
|
993
|
+
return ` • ${D}`;
|
|
966
994
|
}).join(
|
|
967
995
|
""
|
|
968
|
-
)}${
|
|
996
|
+
)}${c.user_info.metadata?.values !== void 0 && !l.some((L) => L.key === "values") ? ` • ${c.user_info.metadata.values}` : ""}`,
|
|
969
997
|
children: [
|
|
970
998
|
/* @__PURE__ */ r("div", { className: "font-medium text-foreground truncate flex items-center gap-1.5", children: [
|
|
971
|
-
/* @__PURE__ */ e("span", { children: [
|
|
972
|
-
|
|
999
|
+
/* @__PURE__ */ e("span", { children: [c.user_info.name, c.user_info.surname].filter(Boolean).join(" ") }),
|
|
1000
|
+
c.user_info.phone && /* @__PURE__ */ r("span", { className: "text-[11px] text-foreground/70 font-normal", children: [
|
|
973
1001
|
"•",
|
|
974
1002
|
" ",
|
|
975
|
-
|
|
1003
|
+
c.user_info.phone
|
|
976
1004
|
] })
|
|
977
1005
|
] }),
|
|
978
1006
|
/* @__PURE__ */ r("div", { className: "text-[10px] text-muted-foreground/70 truncate flex items-center gap-1", children: [
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
return
|
|
982
|
-
}).map((
|
|
983
|
-
const
|
|
984
|
-
let G = String(
|
|
985
|
-
if (
|
|
986
|
-
const
|
|
987
|
-
(
|
|
1007
|
+
l.filter((L) => {
|
|
1008
|
+
const D = c.user_info?.metadata?.[L.key];
|
|
1009
|
+
return D != null && D !== "";
|
|
1010
|
+
}).map((L, D) => {
|
|
1011
|
+
const U = c.user_info?.metadata?.[L.key];
|
|
1012
|
+
let G = String(U);
|
|
1013
|
+
if (L.type === "select") {
|
|
1014
|
+
const ge = L.options?.find(
|
|
1015
|
+
(ye) => String(ye.value) === String(U)
|
|
988
1016
|
);
|
|
989
|
-
|
|
990
|
-
} else
|
|
1017
|
+
ge && (G = t(ge.label));
|
|
1018
|
+
} else L.type === "checkbox" && (G = U ? "✓" : "✗");
|
|
991
1019
|
return /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
|
|
992
|
-
|
|
1020
|
+
D > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
|
|
993
1021
|
G
|
|
994
|
-
] },
|
|
1022
|
+
] }, L.key);
|
|
995
1023
|
}),
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
(
|
|
1024
|
+
c.user_info.metadata?.values !== void 0 && !l.some((L) => L.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
|
|
1025
|
+
l.some(
|
|
1026
|
+
(L) => c.user_info?.metadata?.[L.key] !== void 0
|
|
999
1027
|
) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
|
|
1000
|
-
String(
|
|
1028
|
+
String(c.user_info.metadata.values)
|
|
1001
1029
|
] })
|
|
1002
1030
|
] })
|
|
1003
1031
|
]
|
|
1004
1032
|
}
|
|
1005
1033
|
),
|
|
1006
|
-
|
|
1034
|
+
c.metadata?.usage && /* @__PURE__ */ r("div", { className: "flex gap-2 mt-2 pt-2 border-border/30", children: [
|
|
1007
1035
|
/* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.input_tokens", {
|
|
1008
|
-
value: (
|
|
1036
|
+
value: (c.metadata.usage.cumulative_input_tokens ?? c.metadata.usage.input_tokens ?? 0).toLocaleString($)
|
|
1009
1037
|
}) }),
|
|
1010
1038
|
/* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.output_tokens", {
|
|
1011
|
-
value: (
|
|
1039
|
+
value: (c.metadata.usage.output_tokens || 0).toLocaleString(
|
|
1012
1040
|
$
|
|
1013
1041
|
)
|
|
1014
1042
|
}) }),
|
|
@@ -1016,26 +1044,26 @@ function nr() {
|
|
|
1016
1044
|
"span",
|
|
1017
1045
|
{
|
|
1018
1046
|
className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground",
|
|
1019
|
-
title:
|
|
1020
|
-
|
|
1021
|
-
|
|
1047
|
+
title: c.metadata.usage.cost_incomplete || c.metadata.usage.total_cost_microunits === void 0 ? void 0 : lt(
|
|
1048
|
+
c.metadata.usage.total_cost_microunits || 0,
|
|
1049
|
+
c.metadata.usage.currency || "USD",
|
|
1022
1050
|
$
|
|
1023
1051
|
),
|
|
1024
|
-
children:
|
|
1052
|
+
children: c.metadata.usage.cost_incomplete || c.metadata.usage.total_cost_microunits === void 0 ? t("chat_history.unpriced") : t("chat_history.cost", {
|
|
1025
1053
|
value: me(
|
|
1026
|
-
|
|
1027
|
-
|
|
1054
|
+
c.metadata.usage.total_cost_microunits || 0,
|
|
1055
|
+
c.metadata.usage.currency || "USD",
|
|
1028
1056
|
$
|
|
1029
1057
|
)
|
|
1030
1058
|
})
|
|
1031
1059
|
}
|
|
1032
1060
|
)
|
|
1033
1061
|
] }),
|
|
1034
|
-
/* @__PURE__ */ e("div", { className: "text-[10px] text-muted-foreground mt-1", children:
|
|
1062
|
+
/* @__PURE__ */ e("div", { className: "text-[10px] text-muted-foreground mt-1", children: B(c.created_at) })
|
|
1035
1063
|
] })
|
|
1036
1064
|
]
|
|
1037
1065
|
},
|
|
1038
|
-
|
|
1066
|
+
c.id
|
|
1039
1067
|
)),
|
|
1040
1068
|
k && /* @__PURE__ */ e("div", { className: "p-4 text-center text-muted-foreground text-xs", children: t("loading_more") })
|
|
1041
1069
|
] }) })
|
|
@@ -1048,35 +1076,61 @@ function nr() {
|
|
|
1048
1076
|
o && /* @__PURE__ */ e(
|
|
1049
1077
|
"button",
|
|
1050
1078
|
{
|
|
1051
|
-
onClick: (
|
|
1079
|
+
onClick: (c) => M(c, o),
|
|
1052
1080
|
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",
|
|
1053
1081
|
title: t("sidebar:share_conversation"),
|
|
1054
|
-
children: /* @__PURE__ */ e(
|
|
1082
|
+
children: /* @__PURE__ */ e(St, { className: "w-4 h-4" })
|
|
1055
1083
|
}
|
|
1056
1084
|
)
|
|
1057
1085
|
] }),
|
|
1058
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: o ? m ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : P.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-
|
|
1059
|
-
|
|
1086
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: o ? m ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : P.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-4", children: lr(P).map((c) => {
|
|
1087
|
+
if (c.kind === "subagent") {
|
|
1088
|
+
const ye = c.items[c.items.length - 1];
|
|
1089
|
+
return /* @__PURE__ */ r(
|
|
1090
|
+
"div",
|
|
1091
|
+
{
|
|
1092
|
+
className: "ms-3 ps-4 border-s-2 border-dashed border-amber-500/40",
|
|
1093
|
+
children: [
|
|
1094
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 mb-2", children: [
|
|
1095
|
+
/* @__PURE__ */ e(rt, { kind: "subagent" }),
|
|
1096
|
+
/* @__PURE__ */ r("span", { className: "px-2 py-0.5 rounded-md text-[11px] font-semibold bg-amber-500/10 text-amber-600 dark:text-amber-400", children: [
|
|
1097
|
+
t("chat_history.subagent_label", "Subagent"),
|
|
1098
|
+
c.agent ? ` · ${c.agent}` : ""
|
|
1099
|
+
] }),
|
|
1100
|
+
/* @__PURE__ */ e("span", { className: "ms-auto text-[10px] text-muted-foreground", children: B(ye.created_at) })
|
|
1101
|
+
] }),
|
|
1102
|
+
/* @__PURE__ */ e("div", { className: "rounded-xl border border-dashed border-border/70 bg-muted/20 divide-y divide-border/40 overflow-hidden", children: c.items.map((fe) => /* @__PURE__ */ r("div", { className: "p-3", children: [
|
|
1103
|
+
/* @__PURE__ */ e("span", { className: "inline-block mb-1.5 text-[9px] font-bold uppercase tracking-wider text-muted-foreground px-1.5 py-0.5 rounded bg-muted", children: fe.role }),
|
|
1104
|
+
/* @__PURE__ */ e(
|
|
1105
|
+
"div",
|
|
1106
|
+
{
|
|
1107
|
+
className: "text-sm text-foreground/90 leading-relaxed",
|
|
1108
|
+
dir: "auto",
|
|
1109
|
+
children: pe(fe)
|
|
1110
|
+
}
|
|
1111
|
+
)
|
|
1112
|
+
] }, fe.id)) })
|
|
1113
|
+
]
|
|
1114
|
+
},
|
|
1115
|
+
`subagent-${c.items[0].id}`
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
const L = c.item, D = L.role === "user", U = L.role === "assistant", G = D ? "user" : U ? "assistant" : "other", ge = D ? o?.user_info?.name ? `${o.user_info.name} ${o.user_info.surname || ""}`.trim() : t("chat_history.user_label") : U ? t("chat_history.assistant_label") : L.role;
|
|
1060
1119
|
return /* @__PURE__ */ r(
|
|
1061
1120
|
"div",
|
|
1062
1121
|
{
|
|
1063
|
-
className: `p-3.5
|
|
1122
|
+
className: `relative rounded-2xl border p-3.5 transition-all ${D ? "border-primary/20 bg-primary/5" : U ? "border-border bg-card/60 shadow-sm" : "border-border/50 bg-muted/30"}`,
|
|
1064
1123
|
children: [
|
|
1065
|
-
|
|
1066
|
-
/* @__PURE__ */ r("div", { className: "flex
|
|
1067
|
-
/* @__PURE__ */ e(
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
className: `text-[10px] font-bold uppercase tracking-wider ${j || I ? "text-primary" : "text-muted-foreground"}`,
|
|
1071
|
-
children: j ? o?.user_info?.name ? `${o.user_info.name} ${o.user_info.surname || ""}`.trim() : t("chat_history.user_label") : I ? t("chat_history.assistant_label") : `${u.role}`
|
|
1072
|
-
}
|
|
1073
|
-
),
|
|
1074
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: z(u.created_at) })
|
|
1124
|
+
L.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: L.feedback === "like" ? "👍" : "👎" }) }),
|
|
1125
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 mb-2", children: [
|
|
1126
|
+
/* @__PURE__ */ e(rt, { kind: G }),
|
|
1127
|
+
/* @__PURE__ */ e("span", { className: "text-xs font-semibold text-foreground", children: ge }),
|
|
1128
|
+
/* @__PURE__ */ e("span", { className: "ms-auto text-[10px] text-muted-foreground", children: B(L.created_at) })
|
|
1075
1129
|
] }),
|
|
1076
|
-
/* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children:
|
|
1130
|
+
/* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed ps-9", dir: "auto", children: pe(L) })
|
|
1077
1131
|
]
|
|
1078
1132
|
},
|
|
1079
|
-
|
|
1133
|
+
L.id
|
|
1080
1134
|
);
|
|
1081
1135
|
}) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col items-center justify-center text-muted-foreground", children: [
|
|
1082
1136
|
/* @__PURE__ */ e(
|
|
@@ -1103,11 +1157,11 @@ function nr() {
|
|
|
1103
1157
|
] })
|
|
1104
1158
|
] });
|
|
1105
1159
|
}
|
|
1106
|
-
function
|
|
1107
|
-
const { t, i18n: a } = F(["admin", "translation"]), [s,
|
|
1160
|
+
function cr() {
|
|
1161
|
+
const { t, i18n: a } = F(["admin", "translation"]), [s, l] = y(""), [o, n] = y(!1), [d, g] = y(null), [_, S] = y(null), w = a.language === "fa", x = tr(), i = x.data?.admins || [], b = x.isLoading, { createAdmin: h, updateAdmin: N, deleteAdmin: I } = rr(), R = oe({
|
|
1108
1162
|
queryKey: ["gentiq_admin", "permissions"],
|
|
1109
1163
|
queryFn: () => T.listPermissions()
|
|
1110
|
-
}).data?.permissions || [],
|
|
1164
|
+
}).data?.permissions || [], u = s || (x.error ? x.error instanceof Error ? x.error.message : t("error_loading") : ""), [f, C] = y({
|
|
1111
1165
|
username: "",
|
|
1112
1166
|
password: "",
|
|
1113
1167
|
name: "",
|
|
@@ -1117,8 +1171,8 @@ function sr() {
|
|
|
1117
1171
|
const k = localStorage.getItem("admin_info");
|
|
1118
1172
|
k && S(JSON.parse(k).admin_id);
|
|
1119
1173
|
}, []);
|
|
1120
|
-
const
|
|
1121
|
-
k.preventDefault(),
|
|
1174
|
+
const q = async (k) => {
|
|
1175
|
+
k.preventDefault(), l("");
|
|
1122
1176
|
try {
|
|
1123
1177
|
await h.mutateAsync({
|
|
1124
1178
|
username: f.username,
|
|
@@ -1127,36 +1181,36 @@ function sr() {
|
|
|
1127
1181
|
permissions: f.permissions
|
|
1128
1182
|
}), n(!1), C({ username: "", password: "", name: "", permissions: [] });
|
|
1129
1183
|
} catch (m) {
|
|
1130
|
-
|
|
1184
|
+
l(m instanceof Error ? m.message : t("error_loading"));
|
|
1131
1185
|
}
|
|
1132
1186
|
}, $ = async (k) => {
|
|
1133
|
-
if (k.preventDefault(), !!
|
|
1134
|
-
|
|
1187
|
+
if (k.preventDefault(), !!d) {
|
|
1188
|
+
l("");
|
|
1135
1189
|
try {
|
|
1136
1190
|
const m = {
|
|
1137
1191
|
name: f.name,
|
|
1138
1192
|
permissions: f.permissions
|
|
1139
1193
|
};
|
|
1140
|
-
if (f.password && (m.password = f.password), await N.mutateAsync({ adminId:
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
const A = JSON.parse(
|
|
1194
|
+
if (f.password && (m.password = f.password), await N.mutateAsync({ adminId: d.id, data: m }), d.id === _) {
|
|
1195
|
+
const j = localStorage.getItem("admin_info");
|
|
1196
|
+
if (j) {
|
|
1197
|
+
const A = JSON.parse(j);
|
|
1144
1198
|
A.name = f.name, A.permissions = f.permissions, localStorage.setItem("admin_info", JSON.stringify(A)), window.location.reload();
|
|
1145
1199
|
return;
|
|
1146
1200
|
}
|
|
1147
1201
|
}
|
|
1148
1202
|
g(null), C({ username: "", password: "", name: "", permissions: [] });
|
|
1149
1203
|
} catch (m) {
|
|
1150
|
-
|
|
1204
|
+
l(m instanceof Error ? m.message : t("error_loading"));
|
|
1151
1205
|
}
|
|
1152
1206
|
}
|
|
1153
1207
|
}, v = async (k) => {
|
|
1154
1208
|
if (confirm(t("admins.confirm_delete_admin"))) {
|
|
1155
|
-
|
|
1209
|
+
l("");
|
|
1156
1210
|
try {
|
|
1157
|
-
await
|
|
1211
|
+
await I.mutateAsync(k);
|
|
1158
1212
|
} catch (m) {
|
|
1159
|
-
|
|
1213
|
+
l(m instanceof Error ? m.message : t("error_loading"));
|
|
1160
1214
|
}
|
|
1161
1215
|
}
|
|
1162
1216
|
}, O = (k) => {
|
|
@@ -1169,12 +1223,12 @@ function sr() {
|
|
|
1169
1223
|
}, P = (k) => {
|
|
1170
1224
|
C((m) => ({
|
|
1171
1225
|
...m,
|
|
1172
|
-
permissions: m.permissions.includes(k) ? m.permissions.filter((
|
|
1226
|
+
permissions: m.permissions.includes(k) ? m.permissions.filter((j) => j !== k) : [...m.permissions, k]
|
|
1173
1227
|
}));
|
|
1174
1228
|
}, Z = (k) => {
|
|
1175
|
-
const m = `admins.perm_${k}`,
|
|
1176
|
-
if (
|
|
1177
|
-
return
|
|
1229
|
+
const m = `admins.perm_${k}`, j = t(m);
|
|
1230
|
+
if (j !== m)
|
|
1231
|
+
return j;
|
|
1178
1232
|
switch (k) {
|
|
1179
1233
|
case "chat_history":
|
|
1180
1234
|
return t("admins.perm_chat_history");
|
|
@@ -1207,13 +1261,13 @@ function sr() {
|
|
|
1207
1261
|
)
|
|
1208
1262
|
] })
|
|
1209
1263
|
] }),
|
|
1210
|
-
|
|
1264
|
+
u && /* @__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: u }),
|
|
1211
1265
|
o && /* @__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: [
|
|
1212
|
-
/* @__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(
|
|
1266
|
+
/* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(d ? "admins.edit_admin" : "admins.add_admin") }) }),
|
|
1213
1267
|
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r(
|
|
1214
1268
|
"form",
|
|
1215
1269
|
{
|
|
1216
|
-
onSubmit:
|
|
1270
|
+
onSubmit: d ? $ : q,
|
|
1217
1271
|
className: "space-y-5",
|
|
1218
1272
|
children: [
|
|
1219
1273
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -1222,7 +1276,7 @@ function sr() {
|
|
|
1222
1276
|
"input",
|
|
1223
1277
|
{
|
|
1224
1278
|
type: "text",
|
|
1225
|
-
disabled: !!
|
|
1279
|
+
disabled: !!d,
|
|
1226
1280
|
value: f.username,
|
|
1227
1281
|
onChange: (k) => C({ ...f, username: k.target.value }),
|
|
1228
1282
|
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",
|
|
@@ -1245,7 +1299,7 @@ function sr() {
|
|
|
1245
1299
|
)
|
|
1246
1300
|
] }),
|
|
1247
1301
|
/* @__PURE__ */ r("div", { children: [
|
|
1248
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t(
|
|
1302
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t(d ? "admins.password_edit" : "admins.password") }),
|
|
1249
1303
|
/* @__PURE__ */ e(
|
|
1250
1304
|
"input",
|
|
1251
1305
|
{
|
|
@@ -1253,7 +1307,7 @@ function sr() {
|
|
|
1253
1307
|
value: f.password,
|
|
1254
1308
|
onChange: (k) => C({ ...f, password: k.target.value }),
|
|
1255
1309
|
className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
|
|
1256
|
-
required: !
|
|
1310
|
+
required: !d,
|
|
1257
1311
|
dir: "ltr"
|
|
1258
1312
|
}
|
|
1259
1313
|
)
|
|
@@ -1411,7 +1465,7 @@ function sr() {
|
|
|
1411
1465
|
] }) })
|
|
1412
1466
|
] });
|
|
1413
1467
|
}
|
|
1414
|
-
function
|
|
1468
|
+
function ur({ message: t, onDismiss: a }) {
|
|
1415
1469
|
return /* @__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: [
|
|
1416
1470
|
/* @__PURE__ */ e("span", { children: t }),
|
|
1417
1471
|
/* @__PURE__ */ e("button", { onClick: a, className: "opacity-50 hover:opacity-100 transition-opacity p-1", children: /* @__PURE__ */ e(
|
|
@@ -1428,14 +1482,14 @@ function or({ message: t, onDismiss: a }) {
|
|
|
1428
1482
|
) })
|
|
1429
1483
|
] });
|
|
1430
1484
|
}
|
|
1431
|
-
function
|
|
1485
|
+
function mr({
|
|
1432
1486
|
users: t,
|
|
1433
1487
|
loading: a,
|
|
1434
1488
|
totalCount: s,
|
|
1435
|
-
userMetadataFields:
|
|
1489
|
+
userMetadataFields: l,
|
|
1436
1490
|
sortBy: o,
|
|
1437
1491
|
sortOrder: n,
|
|
1438
|
-
onSort:
|
|
1492
|
+
onSort: d,
|
|
1439
1493
|
onLoadMore: g,
|
|
1440
1494
|
onUsage: _,
|
|
1441
1495
|
onEdit: S,
|
|
@@ -1443,7 +1497,7 @@ function ir({
|
|
|
1443
1497
|
onCopyToken: x,
|
|
1444
1498
|
onDelete: i
|
|
1445
1499
|
}) {
|
|
1446
|
-
const { t: b, i18n: h } = F(["admin", "translation"]), N = h.language === "fa",
|
|
1500
|
+
const { t: b, i18n: h } = F(["admin", "translation"]), N = h.language === "fa", I = (p) => o !== p ? /* @__PURE__ */ e(Tt, { className: "w-3.5 h-3.5 opacity-50" }) : n === "asc" ? /* @__PURE__ */ e(At, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ e(It, { className: "w-3.5 h-3.5" });
|
|
1447
1501
|
return /* @__PURE__ */ e("div", { className: "glass-surface border border-border rounded-2xl overflow-hidden shadow-sm flex-1 flex flex-col", children: /* @__PURE__ */ r(
|
|
1448
1502
|
"div",
|
|
1449
1503
|
{
|
|
@@ -1464,21 +1518,21 @@ function ir({
|
|
|
1464
1518
|
"button",
|
|
1465
1519
|
{
|
|
1466
1520
|
type: "button",
|
|
1467
|
-
onClick: () =>
|
|
1521
|
+
onClick: () => d(p),
|
|
1468
1522
|
className: "inline-flex items-center gap-1.5 hover:text-foreground transition-colors",
|
|
1469
1523
|
title: b(
|
|
1470
1524
|
o === p && n === "asc" ? "users.sort_descending" : "users.sort_ascending"
|
|
1471
1525
|
),
|
|
1472
1526
|
children: [
|
|
1473
1527
|
/* @__PURE__ */ e("span", { children: b(`users.${p}`) }),
|
|
1474
|
-
|
|
1528
|
+
I(p)
|
|
1475
1529
|
]
|
|
1476
1530
|
}
|
|
1477
1531
|
)
|
|
1478
1532
|
},
|
|
1479
1533
|
p
|
|
1480
1534
|
)),
|
|
1481
|
-
|
|
1535
|
+
l.map((p) => /* @__PURE__ */ e(
|
|
1482
1536
|
"th",
|
|
1483
1537
|
{
|
|
1484
1538
|
className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50",
|
|
@@ -1500,14 +1554,14 @@ function ir({
|
|
|
1500
1554
|
p.type === "service" && /* @__PURE__ */ e("span", { className: "text-[10px] px-1.5 py-0.5 rounded-md bg-primary/10 text-primary font-medium uppercase tracking-wide", children: "API" })
|
|
1501
1555
|
] }) }),
|
|
1502
1556
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: p.surname || /* @__PURE__ */ e("span", { className: "text-muted-foreground/50", children: "—" }) }),
|
|
1503
|
-
|
|
1504
|
-
const
|
|
1505
|
-
let f = String(
|
|
1506
|
-
if (R.type === "select" &&
|
|
1507
|
-
const C = R.options?.find((
|
|
1557
|
+
l.map((R) => {
|
|
1558
|
+
const u = p.metadata?.[R.key];
|
|
1559
|
+
let f = String(u ?? "");
|
|
1560
|
+
if (R.type === "select" && u !== void 0) {
|
|
1561
|
+
const C = R.options?.find((q) => String(q.value) === String(u));
|
|
1508
1562
|
C && (f = b(C.label));
|
|
1509
1563
|
}
|
|
1510
|
-
return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: R.type === "checkbox" ?
|
|
1564
|
+
return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: R.type === "checkbox" ? u ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : f }, R.key);
|
|
1511
1565
|
}),
|
|
1512
1566
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground w-[120px]", children: p.balance ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 min-w-0 py-1", children: [
|
|
1513
1567
|
/* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
@@ -1556,7 +1610,7 @@ function ir({
|
|
|
1556
1610
|
onClick: () => _(p),
|
|
1557
1611
|
className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
|
|
1558
1612
|
title: b("users.usage_summary"),
|
|
1559
|
-
children: /* @__PURE__ */ e(
|
|
1613
|
+
children: /* @__PURE__ */ e(jt, { className: "w-4 h-4" })
|
|
1560
1614
|
}
|
|
1561
1615
|
),
|
|
1562
1616
|
/* @__PURE__ */ e(
|
|
@@ -1709,7 +1763,7 @@ function ir({
|
|
|
1709
1763
|
}
|
|
1710
1764
|
) });
|
|
1711
1765
|
}
|
|
1712
|
-
function
|
|
1766
|
+
function dt(t, a = /* @__PURE__ */ new Date()) {
|
|
1713
1767
|
const s = new Date(a);
|
|
1714
1768
|
switch (s.setMilliseconds(0), t) {
|
|
1715
1769
|
case "minute":
|
|
@@ -1723,8 +1777,8 @@ function ot(t, a = /* @__PURE__ */ new Date()) {
|
|
|
1723
1777
|
break;
|
|
1724
1778
|
case "week": {
|
|
1725
1779
|
s.setHours(0, 0, 0, 0);
|
|
1726
|
-
const
|
|
1727
|
-
s.setDate(s.getDate() -
|
|
1780
|
+
const l = (s.getDay() + 6) % 7;
|
|
1781
|
+
s.setDate(s.getDate() - l), s.getTime() < a.getTime() && s.setDate(s.getDate() + 7);
|
|
1728
1782
|
break;
|
|
1729
1783
|
}
|
|
1730
1784
|
case "month":
|
|
@@ -1735,20 +1789,20 @@ function ot(t, a = /* @__PURE__ */ new Date()) {
|
|
|
1735
1789
|
}
|
|
1736
1790
|
function le({ className: t, ...a }) {
|
|
1737
1791
|
return /* @__PURE__ */ e(
|
|
1738
|
-
|
|
1792
|
+
et.Root,
|
|
1739
1793
|
{
|
|
1740
1794
|
"data-slot": "switch",
|
|
1741
1795
|
dir: "ltr",
|
|
1742
|
-
className:
|
|
1796
|
+
className: Se(
|
|
1743
1797
|
"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",
|
|
1744
1798
|
t
|
|
1745
1799
|
),
|
|
1746
1800
|
...a,
|
|
1747
1801
|
children: /* @__PURE__ */ e(
|
|
1748
|
-
|
|
1802
|
+
et.Thumb,
|
|
1749
1803
|
{
|
|
1750
1804
|
"data-slot": "switch-thumb",
|
|
1751
|
-
className:
|
|
1805
|
+
className: Se(
|
|
1752
1806
|
"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)] data-[state=unchecked]:translate-x-0"
|
|
1753
1807
|
)
|
|
1754
1808
|
}
|
|
@@ -1756,16 +1810,16 @@ function le({ className: t, ...a }) {
|
|
|
1756
1810
|
}
|
|
1757
1811
|
);
|
|
1758
1812
|
}
|
|
1759
|
-
const
|
|
1760
|
-
function
|
|
1813
|
+
const hr = (t) => t.replace(/[^0-9]/g, "");
|
|
1814
|
+
function pr({
|
|
1761
1815
|
editingUser: t,
|
|
1762
1816
|
appSettings: a,
|
|
1763
1817
|
userMetadataFields: s,
|
|
1764
|
-
onClose:
|
|
1818
|
+
onClose: l,
|
|
1765
1819
|
onSaved: o,
|
|
1766
1820
|
onError: n
|
|
1767
1821
|
}) {
|
|
1768
|
-
const { t:
|
|
1822
|
+
const { t: d, i18n: g } = F(["admin", "translation"]), _ = g.language === "fa", S = _ ? "text-right" : "text-left", [w, x] = y(!1), [i, b] = y(
|
|
1769
1823
|
() => t ? {
|
|
1770
1824
|
accountType: t.type ?? "human",
|
|
1771
1825
|
phone: t.phone ?? "",
|
|
@@ -1797,45 +1851,45 @@ function dr({
|
|
|
1797
1851
|
}
|
|
1798
1852
|
), [h, N] = y(() => {
|
|
1799
1853
|
if (!t?.metadata) return {};
|
|
1800
|
-
const
|
|
1854
|
+
const u = {};
|
|
1801
1855
|
return s.forEach((f) => {
|
|
1802
|
-
t.metadata?.[f.key] !== void 0 ?
|
|
1803
|
-
}),
|
|
1856
|
+
t.metadata?.[f.key] !== void 0 ? u[f.key] = t.metadata[f.key] : f.defaultValue !== void 0 && (u[f.key] = f.defaultValue);
|
|
1857
|
+
}), u;
|
|
1804
1858
|
});
|
|
1805
1859
|
H(() => {
|
|
1806
1860
|
try {
|
|
1807
1861
|
const f = { ...i.metadata ? JSON.parse(i.metadata) : {}, ...h }, C = JSON.stringify(f, null, 2);
|
|
1808
|
-
C !== i.metadata && b((
|
|
1862
|
+
C !== i.metadata && b((q) => ({ ...q, metadata: C }));
|
|
1809
1863
|
} catch {
|
|
1810
1864
|
}
|
|
1811
1865
|
}, [h]), H(() => {
|
|
1812
|
-
const
|
|
1866
|
+
const u = { ...h };
|
|
1813
1867
|
let f = !1;
|
|
1814
1868
|
s.forEach((C) => {
|
|
1815
|
-
C.condition && !
|
|
1816
|
-
}), f && N(
|
|
1869
|
+
C.condition && !Ge(C.condition, h) && u[C.key] !== void 0 && (delete u[C.key], f = !0);
|
|
1870
|
+
}), f && N(u);
|
|
1817
1871
|
}, [h, s]);
|
|
1818
|
-
const
|
|
1872
|
+
const I = () => {
|
|
1819
1873
|
if (!i.rechargeEnabled)
|
|
1820
1874
|
return { enabled: !1 };
|
|
1821
|
-
const
|
|
1822
|
-
return !Number.isInteger(
|
|
1875
|
+
const u = Number(i.rechargeIntervalValue);
|
|
1876
|
+
return !Number.isInteger(u) || u <= 0 ? (n(d("users.recharge_interval_invalid")), null) : {
|
|
1823
1877
|
enabled: !0,
|
|
1824
|
-
interval_value:
|
|
1878
|
+
interval_value: u,
|
|
1825
1879
|
interval_unit: i.rechargeIntervalUnit,
|
|
1826
1880
|
// When blank, default to the next round boundary of the interval in the admin's
|
|
1827
1881
|
// local time (e.g. next local midnight for daily) rather than the request time.
|
|
1828
|
-
anchor_at: i.rechargeAnchorAt ? new Date(i.rechargeAnchorAt).toISOString() :
|
|
1882
|
+
anchor_at: i.rechargeAnchorAt ? new Date(i.rechargeAnchorAt).toISOString() : dt(i.rechargeIntervalUnit)
|
|
1829
1883
|
};
|
|
1830
|
-
}, p = async (
|
|
1831
|
-
|
|
1832
|
-
const f = i.tokens ? parseInt(i.tokens) : 0, C = i.requests ? parseInt(i.requests) : 0,
|
|
1833
|
-
if (f >
|
|
1834
|
-
n(
|
|
1884
|
+
}, p = async (u) => {
|
|
1885
|
+
u.preventDefault();
|
|
1886
|
+
const f = i.tokens ? parseInt(i.tokens) : 0, C = i.requests ? parseInt(i.requests) : 0, q = i.tokensLimit ? parseInt(i.tokensLimit) : f, $ = i.requestsLimit ? parseInt(i.requestsLimit) : C;
|
|
1887
|
+
if (f > q) {
|
|
1888
|
+
n(d("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
|
|
1835
1889
|
return;
|
|
1836
1890
|
}
|
|
1837
1891
|
if (C > $) {
|
|
1838
|
-
n(
|
|
1892
|
+
n(d("users.requests_exceed_limit", "Requests cannot exceed limit"));
|
|
1839
1893
|
return;
|
|
1840
1894
|
}
|
|
1841
1895
|
let v = {};
|
|
@@ -1843,10 +1897,10 @@ function dr({
|
|
|
1843
1897
|
try {
|
|
1844
1898
|
v = JSON.parse(i.metadata);
|
|
1845
1899
|
} catch {
|
|
1846
|
-
n(
|
|
1900
|
+
n(d("users.invalid_json", "Invalid JSON format"));
|
|
1847
1901
|
return;
|
|
1848
1902
|
}
|
|
1849
|
-
const O =
|
|
1903
|
+
const O = I();
|
|
1850
1904
|
if (O) {
|
|
1851
1905
|
x(!0);
|
|
1852
1906
|
try {
|
|
@@ -1863,22 +1917,22 @@ function dr({
|
|
|
1863
1917
|
i.accountType
|
|
1864
1918
|
), o();
|
|
1865
1919
|
} catch (P) {
|
|
1866
|
-
n(P instanceof Error ? P.message :
|
|
1920
|
+
n(P instanceof Error ? P.message : d("error_loading"));
|
|
1867
1921
|
} finally {
|
|
1868
1922
|
x(!1);
|
|
1869
1923
|
}
|
|
1870
1924
|
}
|
|
1871
|
-
}, R = async (
|
|
1872
|
-
if (
|
|
1925
|
+
}, R = async (u) => {
|
|
1926
|
+
if (u.preventDefault(), !t) return;
|
|
1873
1927
|
let f = {};
|
|
1874
1928
|
if (i.metadata)
|
|
1875
1929
|
try {
|
|
1876
1930
|
f = JSON.parse(i.metadata);
|
|
1877
1931
|
} catch {
|
|
1878
|
-
n(
|
|
1932
|
+
n(d("users.invalid_json", "Invalid JSON format"));
|
|
1879
1933
|
return;
|
|
1880
1934
|
}
|
|
1881
|
-
const C =
|
|
1935
|
+
const C = I();
|
|
1882
1936
|
if (C) {
|
|
1883
1937
|
x(!0);
|
|
1884
1938
|
try {
|
|
@@ -1890,10 +1944,10 @@ function dr({
|
|
|
1890
1944
|
recharge_policy: C
|
|
1891
1945
|
})).user.recharge_policy;
|
|
1892
1946
|
if (!($?.enabled === C.enabled && (!C.enabled || $.interval_value === C.interval_value && $.interval_unit === C.interval_unit)))
|
|
1893
|
-
throw new Error(
|
|
1947
|
+
throw new Error(d("users.recharge_policy_not_saved"));
|
|
1894
1948
|
o();
|
|
1895
|
-
} catch (
|
|
1896
|
-
n(
|
|
1949
|
+
} catch (q) {
|
|
1950
|
+
n(q instanceof Error ? q.message : d("error_loading"));
|
|
1897
1951
|
} finally {
|
|
1898
1952
|
x(!1);
|
|
1899
1953
|
}
|
|
@@ -1907,35 +1961,35 @@ function dr({
|
|
|
1907
1961
|
"aria-modal": "true",
|
|
1908
1962
|
"aria-labelledby": "user-form-modal-title",
|
|
1909
1963
|
children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-xl shadow-2xl overflow-hidden", children: [
|
|
1910
|
-
/* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { id: "user-form-modal-title", className: "text-lg font-bold text-foreground", children:
|
|
1964
|
+
/* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { id: "user-form-modal-title", className: "text-lg font-bold text-foreground", children: d(t ? "users.edit_user" : "users.add_user") }) }),
|
|
1911
1965
|
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: t ? R : p, children: [
|
|
1912
1966
|
/* @__PURE__ */ r("div", { className: "space-y-6 max-h-[60vh] overflow-y-auto px-1 custom-scrollbar", children: [
|
|
1913
1967
|
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
1914
1968
|
!t && /* @__PURE__ */ r("div", { children: [
|
|
1915
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
1969
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.account_type") }),
|
|
1916
1970
|
/* @__PURE__ */ r(
|
|
1917
1971
|
X,
|
|
1918
1972
|
{
|
|
1919
1973
|
value: i.accountType,
|
|
1920
|
-
onValueChange: (
|
|
1974
|
+
onValueChange: (u) => b({ ...i, accountType: u }),
|
|
1921
1975
|
dir: _ ? "rtl" : "ltr",
|
|
1922
1976
|
children: [
|
|
1923
1977
|
/* @__PURE__ */ e(Y, { 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(ee, {}) }),
|
|
1924
1978
|
/* @__PURE__ */ r(te, { className: "rounded-xl border-border bg-card", children: [
|
|
1925
|
-
/* @__PURE__ */ e(E, { value: "human", children:
|
|
1926
|
-
/* @__PURE__ */ e(E, { value: "service", children:
|
|
1979
|
+
/* @__PURE__ */ e(E, { value: "human", children: d("users.account_type_human") }),
|
|
1980
|
+
/* @__PURE__ */ e(E, { value: "service", children: d("users.account_type_service") })
|
|
1927
1981
|
] })
|
|
1928
1982
|
]
|
|
1929
1983
|
}
|
|
1930
1984
|
),
|
|
1931
|
-
i.accountType === "service" && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children:
|
|
1985
|
+
i.accountType === "service" && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children: d("users.account_type_service_help") })
|
|
1932
1986
|
] }),
|
|
1933
1987
|
/* @__PURE__ */ r("div", { children: [
|
|
1934
1988
|
/* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
|
|
1935
|
-
|
|
1989
|
+
d("users.phone"),
|
|
1936
1990
|
i.accountType === "service" && /* @__PURE__ */ r("span", { className: "ml-1 normal-case text-muted-foreground/60", children: [
|
|
1937
1991
|
"(",
|
|
1938
|
-
|
|
1992
|
+
d("users.optional"),
|
|
1939
1993
|
")"
|
|
1940
1994
|
] })
|
|
1941
1995
|
] }),
|
|
@@ -1944,9 +1998,9 @@ function dr({
|
|
|
1944
1998
|
{
|
|
1945
1999
|
type: "text",
|
|
1946
2000
|
value: i.phone,
|
|
1947
|
-
onChange: (
|
|
2001
|
+
onChange: (u) => b({ ...i, phone: hr(u.target.value) }),
|
|
1948
2002
|
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",
|
|
1949
|
-
placeholder:
|
|
2003
|
+
placeholder: d("users.phone_placeholder"),
|
|
1950
2004
|
required: i.accountType === "human",
|
|
1951
2005
|
dir: "ltr"
|
|
1952
2006
|
}
|
|
@@ -1955,41 +2009,41 @@ function dr({
|
|
|
1955
2009
|
i.accountType === "service" ? (
|
|
1956
2010
|
// A service account is an integration, not a person: a single service name, no surname.
|
|
1957
2011
|
/* @__PURE__ */ r("div", { children: [
|
|
1958
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2012
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.service_name") }),
|
|
1959
2013
|
/* @__PURE__ */ e(
|
|
1960
2014
|
"input",
|
|
1961
2015
|
{
|
|
1962
2016
|
type: "text",
|
|
1963
2017
|
value: i.name,
|
|
1964
|
-
onChange: (
|
|
2018
|
+
onChange: (u) => b({ ...i, name: u.target.value }),
|
|
1965
2019
|
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 ${S}`,
|
|
1966
|
-
placeholder:
|
|
2020
|
+
placeholder: d("users.service_name_placeholder"),
|
|
1967
2021
|
required: !0
|
|
1968
2022
|
}
|
|
1969
2023
|
)
|
|
1970
2024
|
] })
|
|
1971
2025
|
) : /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
1972
2026
|
/* @__PURE__ */ r("div", { children: [
|
|
1973
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2027
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.name") }),
|
|
1974
2028
|
/* @__PURE__ */ e(
|
|
1975
2029
|
"input",
|
|
1976
2030
|
{
|
|
1977
2031
|
type: "text",
|
|
1978
2032
|
value: i.name,
|
|
1979
|
-
onChange: (
|
|
2033
|
+
onChange: (u) => b({ ...i, name: u.target.value }),
|
|
1980
2034
|
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 ${S}`,
|
|
1981
2035
|
required: !0
|
|
1982
2036
|
}
|
|
1983
2037
|
)
|
|
1984
2038
|
] }),
|
|
1985
2039
|
/* @__PURE__ */ r("div", { children: [
|
|
1986
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2040
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.surname") }),
|
|
1987
2041
|
/* @__PURE__ */ e(
|
|
1988
2042
|
"input",
|
|
1989
2043
|
{
|
|
1990
2044
|
type: "text",
|
|
1991
2045
|
value: i.surname ?? "",
|
|
1992
|
-
onChange: (
|
|
2046
|
+
onChange: (u) => b({ ...i, surname: u.target.value }),
|
|
1993
2047
|
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 ${S}`,
|
|
1994
2048
|
required: !0
|
|
1995
2049
|
}
|
|
@@ -1998,16 +2052,16 @@ function dr({
|
|
|
1998
2052
|
] })
|
|
1999
2053
|
] }),
|
|
2000
2054
|
!t && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
|
|
2001
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children:
|
|
2055
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: d("users.initial_balance") }),
|
|
2002
2056
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
2003
2057
|
/* @__PURE__ */ r("div", { children: [
|
|
2004
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2058
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.initial_tokens") }),
|
|
2005
2059
|
/* @__PURE__ */ e(
|
|
2006
2060
|
"input",
|
|
2007
2061
|
{
|
|
2008
2062
|
type: "number",
|
|
2009
2063
|
value: i.tokens,
|
|
2010
|
-
onChange: (
|
|
2064
|
+
onChange: (u) => b({ ...i, tokens: u.target.value }),
|
|
2011
2065
|
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",
|
|
2012
2066
|
dir: "ltr",
|
|
2013
2067
|
placeholder: "0"
|
|
@@ -2015,13 +2069,13 @@ function dr({
|
|
|
2015
2069
|
)
|
|
2016
2070
|
] }),
|
|
2017
2071
|
/* @__PURE__ */ r("div", { children: [
|
|
2018
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2072
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.token_limit") }),
|
|
2019
2073
|
/* @__PURE__ */ e(
|
|
2020
2074
|
"input",
|
|
2021
2075
|
{
|
|
2022
2076
|
type: "number",
|
|
2023
2077
|
value: i.tokensLimit,
|
|
2024
|
-
onChange: (
|
|
2078
|
+
onChange: (u) => b({ ...i, tokensLimit: u.target.value }),
|
|
2025
2079
|
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",
|
|
2026
2080
|
dir: "ltr",
|
|
2027
2081
|
placeholder: i.tokens || String(a?.initial_balance_tokens ?? "250000")
|
|
@@ -2031,13 +2085,13 @@ function dr({
|
|
|
2031
2085
|
] }),
|
|
2032
2086
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
2033
2087
|
/* @__PURE__ */ r("div", { children: [
|
|
2034
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2088
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.initial_requests") }),
|
|
2035
2089
|
/* @__PURE__ */ e(
|
|
2036
2090
|
"input",
|
|
2037
2091
|
{
|
|
2038
2092
|
type: "number",
|
|
2039
2093
|
value: i.requests,
|
|
2040
|
-
onChange: (
|
|
2094
|
+
onChange: (u) => b({ ...i, requests: u.target.value }),
|
|
2041
2095
|
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",
|
|
2042
2096
|
dir: "ltr",
|
|
2043
2097
|
placeholder: i.requests || String(a?.initial_balance_requests ?? "0")
|
|
@@ -2045,13 +2099,13 @@ function dr({
|
|
|
2045
2099
|
)
|
|
2046
2100
|
] }),
|
|
2047
2101
|
/* @__PURE__ */ r("div", { children: [
|
|
2048
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2102
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.request_limit") }),
|
|
2049
2103
|
/* @__PURE__ */ e(
|
|
2050
2104
|
"input",
|
|
2051
2105
|
{
|
|
2052
2106
|
type: "number",
|
|
2053
2107
|
value: i.requestsLimit,
|
|
2054
|
-
onChange: (
|
|
2108
|
+
onChange: (u) => b({ ...i, requestsLimit: u.target.value }),
|
|
2055
2109
|
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",
|
|
2056
2110
|
dir: "ltr",
|
|
2057
2111
|
placeholder: i.requests || String(a?.initial_balance_requests ?? "100")
|
|
@@ -2063,8 +2117,8 @@ function dr({
|
|
|
2063
2117
|
/* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
|
|
2064
2118
|
/* @__PURE__ */ r("div", { className: "flex items-start gap-4", children: [
|
|
2065
2119
|
/* @__PURE__ */ r("div", { children: [
|
|
2066
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children:
|
|
2067
|
-
/* @__PURE__ */ e("p", { className: "mt-1 text-xs text-muted-foreground", children:
|
|
2120
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: d("users.auto_recharge") }),
|
|
2121
|
+
/* @__PURE__ */ e("p", { className: "mt-1 text-xs text-muted-foreground", children: d("users.auto_recharge_help") })
|
|
2068
2122
|
] }),
|
|
2069
2123
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 shrink-0 pt-0.5", children: [
|
|
2070
2124
|
/* @__PURE__ */ e(
|
|
@@ -2072,11 +2126,11 @@ function dr({
|
|
|
2072
2126
|
{
|
|
2073
2127
|
id: "admin-recharge-enabled",
|
|
2074
2128
|
checked: i.rechargeEnabled,
|
|
2075
|
-
onCheckedChange: (
|
|
2129
|
+
onCheckedChange: (u) => b({
|
|
2076
2130
|
...i,
|
|
2077
|
-
rechargeEnabled:
|
|
2131
|
+
rechargeEnabled: u
|
|
2078
2132
|
}),
|
|
2079
|
-
"aria-label":
|
|
2133
|
+
"aria-label": d("users.auto_recharge")
|
|
2080
2134
|
}
|
|
2081
2135
|
),
|
|
2082
2136
|
/* @__PURE__ */ e(
|
|
@@ -2084,7 +2138,7 @@ function dr({
|
|
|
2084
2138
|
{
|
|
2085
2139
|
htmlFor: "admin-recharge-enabled",
|
|
2086
2140
|
className: "text-sm text-foreground cursor-pointer",
|
|
2087
|
-
children:
|
|
2141
|
+
children: d("users.enabled")
|
|
2088
2142
|
}
|
|
2089
2143
|
)
|
|
2090
2144
|
] })
|
|
@@ -2092,7 +2146,7 @@ function dr({
|
|
|
2092
2146
|
i.rechargeEnabled && /* @__PURE__ */ r("div", { className: "space-y-4 rounded-xl border border-border/60 bg-muted/15 p-4", children: [
|
|
2093
2147
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
2094
2148
|
/* @__PURE__ */ r("div", { children: [
|
|
2095
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2149
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.recharge_interval") }),
|
|
2096
2150
|
/* @__PURE__ */ e(
|
|
2097
2151
|
"input",
|
|
2098
2152
|
{
|
|
@@ -2100,7 +2154,7 @@ function dr({
|
|
|
2100
2154
|
min: "1",
|
|
2101
2155
|
step: "1",
|
|
2102
2156
|
value: i.rechargeIntervalValue,
|
|
2103
|
-
onChange: (
|
|
2157
|
+
onChange: (u) => b({ ...i, rechargeIntervalValue: u.target.value }),
|
|
2104
2158
|
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",
|
|
2105
2159
|
required: !0,
|
|
2106
2160
|
dir: "ltr"
|
|
@@ -2108,132 +2162,132 @@ function dr({
|
|
|
2108
2162
|
)
|
|
2109
2163
|
] }),
|
|
2110
2164
|
/* @__PURE__ */ r("div", { children: [
|
|
2111
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children:
|
|
2165
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: d("users.recharge_unit") }),
|
|
2112
2166
|
/* @__PURE__ */ r(
|
|
2113
2167
|
X,
|
|
2114
2168
|
{
|
|
2115
2169
|
value: i.rechargeIntervalUnit,
|
|
2116
|
-
onValueChange: (
|
|
2170
|
+
onValueChange: (u) => b({
|
|
2117
2171
|
...i,
|
|
2118
|
-
rechargeIntervalUnit:
|
|
2172
|
+
rechargeIntervalUnit: u
|
|
2119
2173
|
}),
|
|
2120
2174
|
dir: _ ? "rtl" : "ltr",
|
|
2121
2175
|
children: [
|
|
2122
2176
|
/* @__PURE__ */ e(Y, { 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(ee, {}) }),
|
|
2123
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((
|
|
2177
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((u) => /* @__PURE__ */ e(E, { value: u, children: d(`users.recharge_unit_${u}`) }, u)) })
|
|
2124
2178
|
]
|
|
2125
2179
|
}
|
|
2126
2180
|
)
|
|
2127
2181
|
] })
|
|
2128
2182
|
] }),
|
|
2129
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children:
|
|
2183
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: d("users.recharge_schedule_help") }),
|
|
2130
2184
|
t?.recharge_policy?.enabled && /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs", children: [
|
|
2131
2185
|
/* @__PURE__ */ r("div", { className: "rounded-lg bg-background/50 border border-border/50 p-3", children: [
|
|
2132
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children:
|
|
2186
|
+
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: d("users.next_recharge") }),
|
|
2133
2187
|
/* @__PURE__ */ e("p", { className: "mt-1 font-medium text-foreground", dir: "ltr", children: t.recharge_policy.next_recharge_at ? new Date(
|
|
2134
2188
|
t.recharge_policy.next_recharge_at
|
|
2135
|
-
).toLocaleString(g.language) :
|
|
2189
|
+
).toLocaleString(g.language) : d("users.not_available") })
|
|
2136
2190
|
] }),
|
|
2137
2191
|
/* @__PURE__ */ r("div", { className: "rounded-lg bg-background/50 border border-border/50 p-3", children: [
|
|
2138
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children:
|
|
2192
|
+
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: d("users.last_recharge") }),
|
|
2139
2193
|
/* @__PURE__ */ e("p", { className: "mt-1 font-medium text-foreground", dir: "ltr", children: t.recharge_policy.last_recharged_at ? new Date(
|
|
2140
2194
|
t.recharge_policy.last_recharged_at
|
|
2141
|
-
).toLocaleString(g.language) :
|
|
2195
|
+
).toLocaleString(g.language) : d("users.not_available") })
|
|
2142
2196
|
] })
|
|
2143
2197
|
] })
|
|
2144
2198
|
] })
|
|
2145
2199
|
] }),
|
|
2146
2200
|
s.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
|
|
2147
|
-
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children:
|
|
2148
|
-
/* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: s.map((
|
|
2201
|
+
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: d("users.custom_fields") }),
|
|
2202
|
+
/* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: s.map((u) => Ge(u.condition, h) ? /* @__PURE__ */ r(
|
|
2149
2203
|
"div",
|
|
2150
2204
|
{
|
|
2151
2205
|
className: "animate-in fade-in slide-in-from-top-1 duration-200",
|
|
2152
2206
|
children: [
|
|
2153
2207
|
/* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
|
|
2154
|
-
|
|
2208
|
+
d(u.label),
|
|
2155
2209
|
" ",
|
|
2156
|
-
|
|
2210
|
+
u.required && /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
|
|
2157
2211
|
] }),
|
|
2158
|
-
|
|
2212
|
+
u.type === "select" ? /* @__PURE__ */ r(
|
|
2159
2213
|
X,
|
|
2160
2214
|
{
|
|
2161
|
-
value: String(h[
|
|
2215
|
+
value: String(h[u.key] || ""),
|
|
2162
2216
|
onValueChange: (f) => N({
|
|
2163
2217
|
...h,
|
|
2164
|
-
[
|
|
2218
|
+
[u.key]: f
|
|
2165
2219
|
}),
|
|
2166
|
-
required:
|
|
2220
|
+
required: u.required,
|
|
2167
2221
|
dir: _ ? "rtl" : "ltr",
|
|
2168
2222
|
children: [
|
|
2169
2223
|
/* @__PURE__ */ e(
|
|
2170
2224
|
Y,
|
|
2171
2225
|
{
|
|
2172
|
-
className:
|
|
2226
|
+
className: Se(
|
|
2173
2227
|
"w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]",
|
|
2174
2228
|
S
|
|
2175
2229
|
),
|
|
2176
2230
|
children: /* @__PURE__ */ e(
|
|
2177
2231
|
ee,
|
|
2178
2232
|
{
|
|
2179
|
-
placeholder:
|
|
2233
|
+
placeholder: d(u.placeholder || "select_placeholder")
|
|
2180
2234
|
}
|
|
2181
2235
|
)
|
|
2182
2236
|
}
|
|
2183
2237
|
),
|
|
2184
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children:
|
|
2238
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: u.options?.map((f) => /* @__PURE__ */ e(E, { value: String(f.value), children: d(f.label) }, String(f.value))) })
|
|
2185
2239
|
]
|
|
2186
2240
|
}
|
|
2187
|
-
) :
|
|
2241
|
+
) : u.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 h-[46px] px-1", children: [
|
|
2188
2242
|
/* @__PURE__ */ e(
|
|
2189
|
-
|
|
2243
|
+
Ce,
|
|
2190
2244
|
{
|
|
2191
|
-
id: `admin-md-${
|
|
2192
|
-
checked: !!h[
|
|
2245
|
+
id: `admin-md-${u.key}`,
|
|
2246
|
+
checked: !!h[u.key],
|
|
2193
2247
|
onCheckedChange: (f) => N({
|
|
2194
2248
|
...h,
|
|
2195
|
-
[
|
|
2249
|
+
[u.key]: !!f
|
|
2196
2250
|
}),
|
|
2197
|
-
required:
|
|
2251
|
+
required: u.required
|
|
2198
2252
|
}
|
|
2199
2253
|
),
|
|
2200
2254
|
/* @__PURE__ */ e(
|
|
2201
2255
|
"label",
|
|
2202
2256
|
{
|
|
2203
|
-
htmlFor: `admin-md-${
|
|
2257
|
+
htmlFor: `admin-md-${u.key}`,
|
|
2204
2258
|
className: "text-sm text-foreground/80 cursor-pointer select-none",
|
|
2205
|
-
children:
|
|
2259
|
+
children: d(u.placeholder || u.label)
|
|
2206
2260
|
}
|
|
2207
2261
|
)
|
|
2208
2262
|
] }) : /* @__PURE__ */ e(
|
|
2209
2263
|
"input",
|
|
2210
2264
|
{
|
|
2211
|
-
type:
|
|
2212
|
-
value: h[
|
|
2265
|
+
type: u.type,
|
|
2266
|
+
value: h[u.key] || "",
|
|
2213
2267
|
onChange: (f) => N({
|
|
2214
2268
|
...h,
|
|
2215
|
-
[
|
|
2269
|
+
[u.key]: f.target.value
|
|
2216
2270
|
}),
|
|
2217
2271
|
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 ${S}`,
|
|
2218
|
-
placeholder:
|
|
2219
|
-
required:
|
|
2272
|
+
placeholder: d(u.placeholder || ""),
|
|
2273
|
+
required: u.required
|
|
2220
2274
|
}
|
|
2221
2275
|
)
|
|
2222
2276
|
]
|
|
2223
2277
|
},
|
|
2224
|
-
|
|
2278
|
+
u.key
|
|
2225
2279
|
) : null) })
|
|
2226
2280
|
] }),
|
|
2227
2281
|
/* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4", children: [
|
|
2228
2282
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between mb-2", children: [
|
|
2229
|
-
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider", children:
|
|
2230
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground opacity-60", children:
|
|
2283
|
+
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider", children: d("users.metadata_raw") }),
|
|
2284
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground opacity-60", children: d("users.advanced_usage") })
|
|
2231
2285
|
] }),
|
|
2232
2286
|
/* @__PURE__ */ e(
|
|
2233
2287
|
"textarea",
|
|
2234
2288
|
{
|
|
2235
2289
|
value: i.metadata,
|
|
2236
|
-
onChange: (
|
|
2290
|
+
onChange: (u) => b({ ...i, metadata: u.target.value }),
|
|
2237
2291
|
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",
|
|
2238
2292
|
placeholder: '{ "key": "value" }',
|
|
2239
2293
|
dir: "ltr"
|
|
@@ -2246,9 +2300,9 @@ function dr({
|
|
|
2246
2300
|
"button",
|
|
2247
2301
|
{
|
|
2248
2302
|
type: "button",
|
|
2249
|
-
onClick:
|
|
2303
|
+
onClick: l,
|
|
2250
2304
|
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",
|
|
2251
|
-
children:
|
|
2305
|
+
children: d("cancel")
|
|
2252
2306
|
}
|
|
2253
2307
|
),
|
|
2254
2308
|
/* @__PURE__ */ e(
|
|
@@ -2257,7 +2311,7 @@ function dr({
|
|
|
2257
2311
|
type: "submit",
|
|
2258
2312
|
disabled: w,
|
|
2259
2313
|
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",
|
|
2260
|
-
children:
|
|
2314
|
+
children: d(w ? "saving" : "save")
|
|
2261
2315
|
}
|
|
2262
2316
|
)
|
|
2263
2317
|
] })
|
|
@@ -2266,7 +2320,7 @@ function dr({
|
|
|
2266
2320
|
}
|
|
2267
2321
|
);
|
|
2268
2322
|
}
|
|
2269
|
-
function
|
|
2323
|
+
function ct({ onClick: t, label: a = "Close" }) {
|
|
2270
2324
|
return /* @__PURE__ */ e(
|
|
2271
2325
|
"button",
|
|
2272
2326
|
{
|
|
@@ -2289,33 +2343,33 @@ function it({ onClick: t, label: a = "Close" }) {
|
|
|
2289
2343
|
}
|
|
2290
2344
|
);
|
|
2291
2345
|
}
|
|
2292
|
-
function
|
|
2293
|
-
const { t: o } = F(["admin", "translation"]), [n,
|
|
2346
|
+
function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
2347
|
+
const { t: o } = F(["admin", "translation"]), [n, d] = y(!1), [g, _] = y(String(t.balance?.tokens || 0)), [S, w] = y(String(t.balance?.requests || 0)), [x, i] = y(String(t.balance?.token_limit || 0)), [b, h] = y(String(t.balance?.request_limit || 0)), N = () => {
|
|
2294
2348
|
_(x || String(t.balance?.token_limit || 0)), w(b || String(t.balance?.request_limit || 0));
|
|
2295
|
-
},
|
|
2349
|
+
}, I = async (p) => {
|
|
2296
2350
|
p.preventDefault();
|
|
2297
|
-
const R = parseInt(g) || 0,
|
|
2351
|
+
const R = parseInt(g) || 0, u = parseInt(S) || 0, f = x ? parseInt(x) : t.balance?.token_limit || 0, C = b ? parseInt(b) : t.balance?.request_limit || 0;
|
|
2298
2352
|
if (R > f) {
|
|
2299
|
-
|
|
2353
|
+
l(o("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
|
|
2300
2354
|
return;
|
|
2301
2355
|
}
|
|
2302
|
-
if (
|
|
2303
|
-
|
|
2356
|
+
if (u > C) {
|
|
2357
|
+
l(o("users.requests_exceed_limit", "Requests cannot exceed limit"));
|
|
2304
2358
|
return;
|
|
2305
2359
|
}
|
|
2306
|
-
|
|
2360
|
+
d(!0);
|
|
2307
2361
|
try {
|
|
2308
2362
|
await T.updateUserBalance(
|
|
2309
2363
|
t.id,
|
|
2310
2364
|
R,
|
|
2311
|
-
|
|
2365
|
+
u,
|
|
2312
2366
|
x ? parseInt(x) : void 0,
|
|
2313
2367
|
b ? parseInt(b) : void 0
|
|
2314
2368
|
), s();
|
|
2315
|
-
} catch (
|
|
2316
|
-
|
|
2369
|
+
} catch (q) {
|
|
2370
|
+
l(q instanceof Error ? q.message : o("error_loading"));
|
|
2317
2371
|
} finally {
|
|
2318
|
-
|
|
2372
|
+
d(!1);
|
|
2319
2373
|
}
|
|
2320
2374
|
};
|
|
2321
2375
|
return /* @__PURE__ */ e(
|
|
@@ -2332,9 +2386,9 @@ function cr({ user: t, onClose: a, onSaved: s, onError: d }) {
|
|
|
2332
2386
|
" ",
|
|
2333
2387
|
t.name
|
|
2334
2388
|
] }),
|
|
2335
|
-
/* @__PURE__ */ e(
|
|
2389
|
+
/* @__PURE__ */ e(ct, { onClick: a })
|
|
2336
2390
|
] }),
|
|
2337
|
-
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit:
|
|
2391
|
+
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: I, children: [
|
|
2338
2392
|
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
2339
2393
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
2340
2394
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -2422,7 +2476,7 @@ function cr({ user: t, onClose: a, onSaved: s, onError: d }) {
|
|
|
2422
2476
|
}
|
|
2423
2477
|
);
|
|
2424
2478
|
}
|
|
2425
|
-
const
|
|
2479
|
+
const fr = {
|
|
2426
2480
|
applyBalance: !0,
|
|
2427
2481
|
operation: "add",
|
|
2428
2482
|
tokens: "",
|
|
@@ -2438,32 +2492,32 @@ const ur = {
|
|
|
2438
2492
|
userIds: "",
|
|
2439
2493
|
metadata: "{}"
|
|
2440
2494
|
};
|
|
2441
|
-
function
|
|
2495
|
+
function br({
|
|
2442
2496
|
searchQuery: t,
|
|
2443
2497
|
userMetadataFields: a,
|
|
2444
2498
|
onClose: s,
|
|
2445
|
-
onApplied:
|
|
2499
|
+
onApplied: l,
|
|
2446
2500
|
onError: o
|
|
2447
2501
|
}) {
|
|
2448
|
-
const { t: n, i18n:
|
|
2449
|
-
let
|
|
2502
|
+
const { t: n, i18n: d } = F(["admin", "translation"]), g = d.language === "fa", [_, S] = y(!1), [w, x] = y(null), [i, b] = y(fr), h = () => {
|
|
2503
|
+
let u = {};
|
|
2450
2504
|
if (i.metadata.trim())
|
|
2451
2505
|
try {
|
|
2452
|
-
|
|
2506
|
+
u = JSON.parse(i.metadata);
|
|
2453
2507
|
} catch {
|
|
2454
2508
|
return o(n("users.invalid_json", "Invalid JSON format")), null;
|
|
2455
2509
|
}
|
|
2456
2510
|
const f = {};
|
|
2457
|
-
Object.entries(
|
|
2458
|
-
Array.isArray($) ? f[
|
|
2511
|
+
Object.entries(u).forEach(([q, $]) => {
|
|
2512
|
+
Array.isArray($) ? f[q] = $ : $ !== "" && $ !== void 0 && $ !== null && (f[q] = [$]);
|
|
2459
2513
|
});
|
|
2460
|
-
const C = i.userIds.split(/[\s,]+/).map((
|
|
2514
|
+
const C = i.userIds.split(/[\s,]+/).map((q) => q.trim()).filter(Boolean);
|
|
2461
2515
|
return {
|
|
2462
2516
|
query: i.useCurrentSearch && t || void 0,
|
|
2463
2517
|
user_ids: C.length > 0 ? C : void 0,
|
|
2464
2518
|
metadata_in: Object.keys(f).length > 0 ? f : void 0
|
|
2465
2519
|
};
|
|
2466
|
-
}, N = (
|
|
2520
|
+
}, N = (u) => {
|
|
2467
2521
|
const f = h();
|
|
2468
2522
|
return f ? {
|
|
2469
2523
|
operation: i.operation,
|
|
@@ -2472,16 +2526,16 @@ function mr({
|
|
|
2472
2526
|
token_limit: i.tokenLimit === "" ? void 0 : Number(i.tokenLimit),
|
|
2473
2527
|
request_limit: i.requestLimit === "" ? void 0 : Number(i.requestLimit),
|
|
2474
2528
|
filters: f,
|
|
2475
|
-
dry_run:
|
|
2529
|
+
dry_run: u
|
|
2476
2530
|
} : null;
|
|
2477
|
-
},
|
|
2531
|
+
}, I = (u) => {
|
|
2478
2532
|
const f = h();
|
|
2479
2533
|
if (!f) return null;
|
|
2480
2534
|
if (!i.renewalEnabled)
|
|
2481
2535
|
return {
|
|
2482
2536
|
recharge_policy: { enabled: !1 },
|
|
2483
2537
|
filters: f,
|
|
2484
|
-
dry_run:
|
|
2538
|
+
dry_run: u
|
|
2485
2539
|
};
|
|
2486
2540
|
const C = Number(i.renewalIntervalValue);
|
|
2487
2541
|
return !Number.isInteger(C) || C <= 0 ? (o(n("users.recharge_interval_invalid")), null) : {
|
|
@@ -2491,33 +2545,33 @@ function mr({
|
|
|
2491
2545
|
interval_unit: i.renewalIntervalUnit,
|
|
2492
2546
|
// When blank, default to the next round boundary of the interval in the admin's
|
|
2493
2547
|
// local time (e.g. next local midnight for daily) rather than the request time.
|
|
2494
|
-
anchor_at: i.renewalAnchorAt ? new Date(i.renewalAnchorAt).toISOString() :
|
|
2548
|
+
anchor_at: i.renewalAnchorAt ? new Date(i.renewalAnchorAt).toISOString() : dt(i.renewalIntervalUnit)
|
|
2495
2549
|
},
|
|
2496
2550
|
filters: f,
|
|
2497
|
-
dry_run:
|
|
2551
|
+
dry_run: u
|
|
2498
2552
|
};
|
|
2499
2553
|
}, p = async () => {
|
|
2500
2554
|
if (i.applyRenewal && !i.applyBalance) {
|
|
2501
|
-
const C =
|
|
2555
|
+
const C = I(!0);
|
|
2502
2556
|
return C ? (await T.bulkUpdateUserRenewal(C)).matched : null;
|
|
2503
2557
|
}
|
|
2504
|
-
const
|
|
2505
|
-
return
|
|
2506
|
-
}, R = async (
|
|
2507
|
-
if (
|
|
2558
|
+
const u = N(!0);
|
|
2559
|
+
return u ? (await T.bulkUpdateUserBalance(u)).matched : null;
|
|
2560
|
+
}, R = async (u) => {
|
|
2561
|
+
if (u.preventDefault(), !i.applyBalance && !i.applyRenewal) {
|
|
2508
2562
|
o(n("users.bulk_select_change"));
|
|
2509
2563
|
return;
|
|
2510
2564
|
}
|
|
2511
|
-
const f = i.applyBalance ? N(!1) : null, C = i.applyRenewal ?
|
|
2565
|
+
const f = i.applyBalance ? N(!1) : null, C = i.applyRenewal ? I(!1) : null;
|
|
2512
2566
|
if (!(i.applyBalance && !f) && !(i.applyRenewal && !C)) {
|
|
2513
2567
|
S(!0);
|
|
2514
2568
|
try {
|
|
2515
|
-
const
|
|
2516
|
-
if (
|
|
2569
|
+
const q = await p();
|
|
2570
|
+
if (q === null || (x(q), !confirm(n("users.bulk_balance_confirm", { count: q })))) return;
|
|
2517
2571
|
const v = f ? await T.bulkUpdateUserBalance(f) : null, O = C ? await T.bulkUpdateUserRenewal(C) : null;
|
|
2518
|
-
x((O || v)?.matched ?? null),
|
|
2519
|
-
} catch (
|
|
2520
|
-
o(
|
|
2572
|
+
x((O || v)?.matched ?? null), l();
|
|
2573
|
+
} catch (q) {
|
|
2574
|
+
o(q instanceof Error ? q.message : n("error_loading"));
|
|
2521
2575
|
} finally {
|
|
2522
2576
|
S(!1);
|
|
2523
2577
|
}
|
|
@@ -2536,18 +2590,18 @@ function mr({
|
|
|
2536
2590
|
/* @__PURE__ */ e("h3", { id: "bulk-balance-modal-title", className: "text-lg font-bold text-foreground", children: n("users.bulk_balance") }),
|
|
2537
2591
|
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground mt-1", children: n("users.bulk_balance_help") })
|
|
2538
2592
|
] }),
|
|
2539
|
-
/* @__PURE__ */ e(
|
|
2593
|
+
/* @__PURE__ */ e(ct, { onClick: s })
|
|
2540
2594
|
] }),
|
|
2541
2595
|
/* @__PURE__ */ r("form", { onSubmit: R, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
2542
2596
|
/* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4 space-y-4 custom-scrollbar", children: [
|
|
2543
2597
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
2544
2598
|
/* @__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: [
|
|
2545
2599
|
/* @__PURE__ */ e(
|
|
2546
|
-
|
|
2600
|
+
Ce,
|
|
2547
2601
|
{
|
|
2548
2602
|
checked: i.applyBalance,
|
|
2549
|
-
onCheckedChange: (
|
|
2550
|
-
b({ ...i, applyBalance: !!
|
|
2603
|
+
onCheckedChange: (u) => {
|
|
2604
|
+
b({ ...i, applyBalance: !!u }), x(null);
|
|
2551
2605
|
}
|
|
2552
2606
|
}
|
|
2553
2607
|
),
|
|
@@ -2555,11 +2609,11 @@ function mr({
|
|
|
2555
2609
|
] }),
|
|
2556
2610
|
/* @__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: [
|
|
2557
2611
|
/* @__PURE__ */ e(
|
|
2558
|
-
|
|
2612
|
+
Ce,
|
|
2559
2613
|
{
|
|
2560
2614
|
checked: i.applyRenewal,
|
|
2561
|
-
onCheckedChange: (
|
|
2562
|
-
b({ ...i, applyRenewal: !!
|
|
2615
|
+
onCheckedChange: (u) => {
|
|
2616
|
+
b({ ...i, applyRenewal: !!u }), x(null);
|
|
2563
2617
|
}
|
|
2564
2618
|
}
|
|
2565
2619
|
),
|
|
@@ -2573,10 +2627,10 @@ function mr({
|
|
|
2573
2627
|
X,
|
|
2574
2628
|
{
|
|
2575
2629
|
value: i.operation,
|
|
2576
|
-
onValueChange: (
|
|
2630
|
+
onValueChange: (u) => {
|
|
2577
2631
|
b({
|
|
2578
2632
|
...i,
|
|
2579
|
-
operation:
|
|
2633
|
+
operation: u
|
|
2580
2634
|
}), x(null);
|
|
2581
2635
|
},
|
|
2582
2636
|
dir: g ? "rtl" : "ltr",
|
|
@@ -2593,12 +2647,12 @@ function mr({
|
|
|
2593
2647
|
] }),
|
|
2594
2648
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 md:pt-6", children: [
|
|
2595
2649
|
/* @__PURE__ */ e(
|
|
2596
|
-
|
|
2650
|
+
Ce,
|
|
2597
2651
|
{
|
|
2598
2652
|
id: "bulk-use-search",
|
|
2599
2653
|
checked: i.useCurrentSearch,
|
|
2600
|
-
onCheckedChange: (
|
|
2601
|
-
b({ ...i, useCurrentSearch: !!
|
|
2654
|
+
onCheckedChange: (u) => {
|
|
2655
|
+
b({ ...i, useCurrentSearch: !!u }), x(null);
|
|
2602
2656
|
}
|
|
2603
2657
|
}
|
|
2604
2658
|
),
|
|
@@ -2613,8 +2667,8 @@ function mr({
|
|
|
2613
2667
|
{
|
|
2614
2668
|
type: "number",
|
|
2615
2669
|
value: i.tokens,
|
|
2616
|
-
onChange: (
|
|
2617
|
-
b({ ...i, tokens:
|
|
2670
|
+
onChange: (u) => {
|
|
2671
|
+
b({ ...i, tokens: u.target.value }), x(null);
|
|
2618
2672
|
},
|
|
2619
2673
|
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",
|
|
2620
2674
|
disabled: i.operation === "full_charge",
|
|
@@ -2630,8 +2684,8 @@ function mr({
|
|
|
2630
2684
|
{
|
|
2631
2685
|
type: "number",
|
|
2632
2686
|
value: i.requests,
|
|
2633
|
-
onChange: (
|
|
2634
|
-
b({ ...i, requests:
|
|
2687
|
+
onChange: (u) => {
|
|
2688
|
+
b({ ...i, requests: u.target.value }), x(null);
|
|
2635
2689
|
},
|
|
2636
2690
|
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",
|
|
2637
2691
|
disabled: i.operation === "full_charge",
|
|
@@ -2647,8 +2701,8 @@ function mr({
|
|
|
2647
2701
|
{
|
|
2648
2702
|
type: "number",
|
|
2649
2703
|
value: i.tokenLimit,
|
|
2650
|
-
onChange: (
|
|
2651
|
-
b({ ...i, tokenLimit:
|
|
2704
|
+
onChange: (u) => {
|
|
2705
|
+
b({ ...i, tokenLimit: u.target.value }), x(null);
|
|
2652
2706
|
},
|
|
2653
2707
|
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",
|
|
2654
2708
|
dir: "ltr"
|
|
@@ -2662,8 +2716,8 @@ function mr({
|
|
|
2662
2716
|
{
|
|
2663
2717
|
type: "number",
|
|
2664
2718
|
value: i.requestLimit,
|
|
2665
|
-
onChange: (
|
|
2666
|
-
b({ ...i, requestLimit:
|
|
2719
|
+
onChange: (u) => {
|
|
2720
|
+
b({ ...i, requestLimit: u.target.value }), x(null);
|
|
2667
2721
|
},
|
|
2668
2722
|
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",
|
|
2669
2723
|
dir: "ltr"
|
|
@@ -2682,8 +2736,8 @@ function mr({
|
|
|
2682
2736
|
le,
|
|
2683
2737
|
{
|
|
2684
2738
|
checked: i.renewalEnabled,
|
|
2685
|
-
onCheckedChange: (
|
|
2686
|
-
b({ ...i, renewalEnabled:
|
|
2739
|
+
onCheckedChange: (u) => {
|
|
2740
|
+
b({ ...i, renewalEnabled: u }), x(null);
|
|
2687
2741
|
}
|
|
2688
2742
|
}
|
|
2689
2743
|
),
|
|
@@ -2700,8 +2754,8 @@ function mr({
|
|
|
2700
2754
|
min: "1",
|
|
2701
2755
|
step: "1",
|
|
2702
2756
|
value: i.renewalIntervalValue,
|
|
2703
|
-
onChange: (
|
|
2704
|
-
b({ ...i, renewalIntervalValue:
|
|
2757
|
+
onChange: (u) => {
|
|
2758
|
+
b({ ...i, renewalIntervalValue: u.target.value }), x(null);
|
|
2705
2759
|
},
|
|
2706
2760
|
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",
|
|
2707
2761
|
required: !0,
|
|
@@ -2715,16 +2769,16 @@ function mr({
|
|
|
2715
2769
|
X,
|
|
2716
2770
|
{
|
|
2717
2771
|
value: i.renewalIntervalUnit,
|
|
2718
|
-
onValueChange: (
|
|
2772
|
+
onValueChange: (u) => {
|
|
2719
2773
|
b({
|
|
2720
2774
|
...i,
|
|
2721
|
-
renewalIntervalUnit:
|
|
2775
|
+
renewalIntervalUnit: u
|
|
2722
2776
|
}), x(null);
|
|
2723
2777
|
},
|
|
2724
2778
|
dir: g ? "rtl" : "ltr",
|
|
2725
2779
|
children: [
|
|
2726
2780
|
/* @__PURE__ */ e(Y, { className: "w-full px-3 bg-input/50 border border-border rounded-lg text-foreground transition-all text-sm h-10", children: /* @__PURE__ */ e(ee, {}) }),
|
|
2727
|
-
/* @__PURE__ */ e(te, { className: "rounded-lg border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((
|
|
2781
|
+
/* @__PURE__ */ e(te, { className: "rounded-lg border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((u) => /* @__PURE__ */ e(E, { value: u, children: n(`users.recharge_unit_${u}`) }, u)) })
|
|
2728
2782
|
]
|
|
2729
2783
|
}
|
|
2730
2784
|
)
|
|
@@ -2736,8 +2790,8 @@ function mr({
|
|
|
2736
2790
|
{
|
|
2737
2791
|
type: "datetime-local",
|
|
2738
2792
|
value: i.renewalAnchorAt,
|
|
2739
|
-
onChange: (
|
|
2740
|
-
b({ ...i, renewalAnchorAt:
|
|
2793
|
+
onChange: (u) => {
|
|
2794
|
+
b({ ...i, renewalAnchorAt: u.target.value }), x(null);
|
|
2741
2795
|
},
|
|
2742
2796
|
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",
|
|
2743
2797
|
dir: "ltr"
|
|
@@ -2753,8 +2807,8 @@ function mr({
|
|
|
2753
2807
|
"textarea",
|
|
2754
2808
|
{
|
|
2755
2809
|
value: i.userIds,
|
|
2756
|
-
onChange: (
|
|
2757
|
-
b({ ...i, userIds:
|
|
2810
|
+
onChange: (u) => {
|
|
2811
|
+
b({ ...i, userIds: u.target.value }), x(null);
|
|
2758
2812
|
},
|
|
2759
2813
|
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]",
|
|
2760
2814
|
placeholder: "user_abc, user_xyz",
|
|
@@ -2768,8 +2822,8 @@ function mr({
|
|
|
2768
2822
|
"textarea",
|
|
2769
2823
|
{
|
|
2770
2824
|
value: i.metadata,
|
|
2771
|
-
onChange: (
|
|
2772
|
-
b({ ...i, metadata:
|
|
2825
|
+
onChange: (u) => {
|
|
2826
|
+
b({ ...i, metadata: u.target.value }), x(null);
|
|
2773
2827
|
},
|
|
2774
2828
|
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]",
|
|
2775
2829
|
placeholder: '{ "grade": ["10", "11"], "major": ["math", "science"] }',
|
|
@@ -2780,7 +2834,7 @@ function mr({
|
|
|
2780
2834
|
n("users.bulk_available_metadata"),
|
|
2781
2835
|
":",
|
|
2782
2836
|
" ",
|
|
2783
|
-
a.map((
|
|
2837
|
+
a.map((u) => u.key).join(", ")
|
|
2784
2838
|
] })
|
|
2785
2839
|
] })
|
|
2786
2840
|
] })
|
|
@@ -2802,50 +2856,50 @@ function mr({
|
|
|
2802
2856
|
}
|
|
2803
2857
|
);
|
|
2804
2858
|
}
|
|
2805
|
-
function
|
|
2806
|
-
const { t:
|
|
2859
|
+
function xr({ user: t, onClose: a, onError: s }) {
|
|
2860
|
+
const { t: l, i18n: o } = F(["admin", "translation"]), n = o.language === "fa" ? "fa-IR" : "en-US", [d, g] = y(null), [_, S] = y(!1);
|
|
2807
2861
|
return H(() => {
|
|
2808
2862
|
if (!t) return;
|
|
2809
2863
|
let w = !1;
|
|
2810
2864
|
return g(null), S(!0), T.getUserUsageSummary(t.id).then((x) => {
|
|
2811
2865
|
w || g(x);
|
|
2812
2866
|
}).catch((x) => {
|
|
2813
|
-
w || (s(x instanceof Error ? x.message :
|
|
2867
|
+
w || (s(x instanceof Error ? x.message : l("error_loading")), a());
|
|
2814
2868
|
}).finally(() => {
|
|
2815
2869
|
w || S(!1);
|
|
2816
2870
|
}), () => {
|
|
2817
2871
|
w = !0;
|
|
2818
2872
|
};
|
|
2819
|
-
}, [t]), /* @__PURE__ */ e(
|
|
2820
|
-
/* @__PURE__ */ r(
|
|
2821
|
-
/* @__PURE__ */ e(
|
|
2822
|
-
/* @__PURE__ */ e(
|
|
2873
|
+
}, [t]), /* @__PURE__ */ e(Le, { open: !!t, onOpenChange: (w) => !w && a(), children: /* @__PURE__ */ r(je, { children: [
|
|
2874
|
+
/* @__PURE__ */ r(Te, { children: [
|
|
2875
|
+
/* @__PURE__ */ e(Ae, { children: l("users.usage_summary") }),
|
|
2876
|
+
/* @__PURE__ */ e(Ie, { children: t ? `${t.name} ${t.surname}` : "" })
|
|
2823
2877
|
] }),
|
|
2824
|
-
_ ? /* @__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" }) }) :
|
|
2825
|
-
[
|
|
2826
|
-
[
|
|
2827
|
-
[
|
|
2828
|
-
[
|
|
2878
|
+
_ ? /* @__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" }) }) : d ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
2879
|
+
[l("users.input_tokens"), d.input_tokens.toLocaleString(n)],
|
|
2880
|
+
[l("users.output_tokens"), d.output_tokens.toLocaleString(n)],
|
|
2881
|
+
[l("users.total_tokens"), d.total_tokens.toLocaleString(n)],
|
|
2882
|
+
[l("users.requests_made"), d.requests.toLocaleString(n)],
|
|
2829
2883
|
[
|
|
2830
|
-
|
|
2831
|
-
|
|
2884
|
+
l("users.total_cost"),
|
|
2885
|
+
lt(d.total_cost_microunits, d.currency, n)
|
|
2832
2886
|
],
|
|
2833
|
-
[
|
|
2834
|
-
[
|
|
2887
|
+
[l("users.renewals"), d.renewal_count.toLocaleString(n)],
|
|
2888
|
+
[l("users.unpriced_requests"), d.unpriced_requests.toLocaleString(n)]
|
|
2835
2889
|
].map(([w, x]) => /* @__PURE__ */ r("div", { className: "rounded-xl border border-border bg-muted/20 p-4", children: [
|
|
2836
2890
|
/* @__PURE__ */ e("p", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children: w }),
|
|
2837
2891
|
/* @__PURE__ */ e("p", { className: "mt-1 text-lg font-semibold text-foreground", children: x })
|
|
2838
2892
|
] }, w)) }) : null
|
|
2839
2893
|
] }) });
|
|
2840
2894
|
}
|
|
2841
|
-
const
|
|
2842
|
-
function
|
|
2843
|
-
const { t, i18n: a } = F(["admin", "translation"]), { app: s } =
|
|
2895
|
+
const Me = 25;
|
|
2896
|
+
function vr() {
|
|
2897
|
+
const { t, i18n: a } = F(["admin", "translation"]), { app: s } = ve(), l = we(), o = a.language === "fa", [n, d] = y(""), [g, _] = y(""), [S, w] = y(""), [x, i] = y("name"), [b, h] = y("asc"), [N, I] = y("human"), [p, R] = y(null), [u, f] = y(Me), [C, q] = y(!1), [$, v] = y(null), [O, P] = y(null), [Z, k] = y(null), [m, j] = y(!1), A = Yt(), K = () => l.invalidateQueries({ queryKey: ["gentiq_admin", "users"] }), {
|
|
2844
2898
|
data: M,
|
|
2845
|
-
isLoading:
|
|
2899
|
+
isLoading: B,
|
|
2846
2900
|
isFetching: Q,
|
|
2847
2901
|
error: W
|
|
2848
|
-
} =
|
|
2902
|
+
} = Xt(0, u, S, x, b, N), V = M?.users ?? [], de = M?.count ?? 0, pe = B || Q, Re = W ? W instanceof Error ? W.message : t("error_loading") : "", c = n || Re, L = he(() => s?.userMetadataFields || [], [s?.userMetadataFields]);
|
|
2849
2903
|
H(() => {
|
|
2850
2904
|
T.getSettings().then(R).catch((J) => console.error("Failed to load app settings", J));
|
|
2851
2905
|
}, []), H(() => {
|
|
@@ -2854,34 +2908,34 @@ function pr() {
|
|
|
2854
2908
|
}, 500);
|
|
2855
2909
|
return () => clearTimeout(J);
|
|
2856
2910
|
}, [g]), H(() => {
|
|
2857
|
-
f(
|
|
2911
|
+
f(Me);
|
|
2858
2912
|
}, [S, x, b, N]);
|
|
2859
|
-
const
|
|
2913
|
+
const D = (J) => {
|
|
2860
2914
|
x === J ? h((ce) => ce === "asc" ? "desc" : "asc") : (i(J), h("asc"));
|
|
2861
|
-
},
|
|
2915
|
+
}, U = async (J) => {
|
|
2862
2916
|
if (confirm(t("users.confirm_delete_user")))
|
|
2863
2917
|
try {
|
|
2864
2918
|
await A.deleteUser.mutateAsync(J);
|
|
2865
2919
|
} catch (ce) {
|
|
2866
|
-
|
|
2920
|
+
d(ce instanceof Error ? ce.message : t("error_loading"));
|
|
2867
2921
|
}
|
|
2868
|
-
},
|
|
2922
|
+
}, G = async (J) => {
|
|
2869
2923
|
try {
|
|
2870
|
-
const
|
|
2871
|
-
if (!
|
|
2872
|
-
|
|
2924
|
+
const Ke = (await T.refreshUserToken(J.id))?.user?.token;
|
|
2925
|
+
if (!Ke) {
|
|
2926
|
+
d(t("users.no_token"));
|
|
2873
2927
|
return;
|
|
2874
2928
|
}
|
|
2875
|
-
await navigator.clipboard.writeText(
|
|
2929
|
+
await navigator.clipboard.writeText(Ke), alert(t("users.token_copied"));
|
|
2876
2930
|
} catch (ce) {
|
|
2877
|
-
|
|
2931
|
+
d(ce instanceof Error ? ce.message : t("error_loading"));
|
|
2878
2932
|
}
|
|
2879
|
-
},
|
|
2880
|
-
v(null),
|
|
2881
|
-
},
|
|
2882
|
-
v(J),
|
|
2883
|
-
},
|
|
2884
|
-
|
|
2933
|
+
}, ge = () => {
|
|
2934
|
+
v(null), q(!0);
|
|
2935
|
+
}, ye = (J) => {
|
|
2936
|
+
v(J), q(!0);
|
|
2937
|
+
}, fe = () => {
|
|
2938
|
+
q(!1), v(null);
|
|
2885
2939
|
};
|
|
2886
2940
|
return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: o ? "rtl" : "ltr", children: [
|
|
2887
2941
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
|
|
@@ -2902,7 +2956,7 @@ function pr() {
|
|
|
2902
2956
|
X,
|
|
2903
2957
|
{
|
|
2904
2958
|
value: N,
|
|
2905
|
-
onValueChange: (J) =>
|
|
2959
|
+
onValueChange: (J) => I(J),
|
|
2906
2960
|
dir: o ? "rtl" : "ltr",
|
|
2907
2961
|
children: [
|
|
2908
2962
|
/* @__PURE__ */ e(Y, { className: "min-w-[140px] px-4 py-2 h-auto text-sm font-medium rounded-xl glass-surface border-0 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
@@ -2914,10 +2968,10 @@ function pr() {
|
|
|
2914
2968
|
/* @__PURE__ */ r(
|
|
2915
2969
|
"button",
|
|
2916
2970
|
{
|
|
2917
|
-
onClick: () =>
|
|
2971
|
+
onClick: () => j(!0),
|
|
2918
2972
|
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",
|
|
2919
2973
|
children: [
|
|
2920
|
-
/* @__PURE__ */ e(
|
|
2974
|
+
/* @__PURE__ */ e(Dt, { className: "w-4 h-4" }),
|
|
2921
2975
|
t("users.bulk_balance")
|
|
2922
2976
|
]
|
|
2923
2977
|
}
|
|
@@ -2925,7 +2979,7 @@ function pr() {
|
|
|
2925
2979
|
/* @__PURE__ */ e(
|
|
2926
2980
|
"button",
|
|
2927
2981
|
{
|
|
2928
|
-
onClick:
|
|
2982
|
+
onClick: ge,
|
|
2929
2983
|
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",
|
|
2930
2984
|
children: t("users.add_user")
|
|
2931
2985
|
}
|
|
@@ -2933,92 +2987,92 @@ function pr() {
|
|
|
2933
2987
|
] })
|
|
2934
2988
|
] })
|
|
2935
2989
|
] }),
|
|
2936
|
-
/* @__PURE__ */ e(
|
|
2937
|
-
|
|
2990
|
+
/* @__PURE__ */ e(xr, { user: Z, onClose: () => k(null), onError: d }),
|
|
2991
|
+
c && /* @__PURE__ */ e(ur, { message: c, onDismiss: () => d("") }),
|
|
2938
2992
|
m && /* @__PURE__ */ e(
|
|
2939
|
-
|
|
2993
|
+
br,
|
|
2940
2994
|
{
|
|
2941
2995
|
searchQuery: g,
|
|
2942
|
-
userMetadataFields:
|
|
2996
|
+
userMetadataFields: L,
|
|
2943
2997
|
onClose: () => {
|
|
2944
|
-
|
|
2998
|
+
j(!1), d("");
|
|
2945
2999
|
},
|
|
2946
3000
|
onApplied: () => {
|
|
2947
|
-
|
|
3001
|
+
j(!1), K();
|
|
2948
3002
|
},
|
|
2949
|
-
onError:
|
|
3003
|
+
onError: d
|
|
2950
3004
|
}
|
|
2951
3005
|
),
|
|
2952
3006
|
C && /* @__PURE__ */ e(
|
|
2953
|
-
|
|
3007
|
+
pr,
|
|
2954
3008
|
{
|
|
2955
3009
|
editingUser: $,
|
|
2956
3010
|
appSettings: p,
|
|
2957
|
-
userMetadataFields:
|
|
2958
|
-
onClose:
|
|
3011
|
+
userMetadataFields: L,
|
|
3012
|
+
onClose: fe,
|
|
2959
3013
|
onSaved: () => {
|
|
2960
|
-
K(),
|
|
3014
|
+
K(), fe();
|
|
2961
3015
|
},
|
|
2962
|
-
onError:
|
|
3016
|
+
onError: d
|
|
2963
3017
|
}
|
|
2964
3018
|
),
|
|
2965
3019
|
O && /* @__PURE__ */ e(
|
|
2966
|
-
|
|
3020
|
+
gr,
|
|
2967
3021
|
{
|
|
2968
3022
|
user: O,
|
|
2969
3023
|
onClose: () => {
|
|
2970
|
-
P(null),
|
|
3024
|
+
P(null), d("");
|
|
2971
3025
|
},
|
|
2972
3026
|
onSaved: () => {
|
|
2973
3027
|
K(), P(null);
|
|
2974
3028
|
},
|
|
2975
|
-
onError:
|
|
3029
|
+
onError: d
|
|
2976
3030
|
}
|
|
2977
3031
|
),
|
|
2978
3032
|
/* @__PURE__ */ e(
|
|
2979
|
-
|
|
3033
|
+
mr,
|
|
2980
3034
|
{
|
|
2981
|
-
users:
|
|
2982
|
-
loading:
|
|
3035
|
+
users: V,
|
|
3036
|
+
loading: pe,
|
|
2983
3037
|
totalCount: de,
|
|
2984
|
-
userMetadataFields:
|
|
3038
|
+
userMetadataFields: L,
|
|
2985
3039
|
sortBy: x,
|
|
2986
3040
|
sortOrder: b,
|
|
2987
|
-
onSort:
|
|
2988
|
-
onLoadMore: () => f((J) => J +
|
|
3041
|
+
onSort: D,
|
|
3042
|
+
onLoadMore: () => f((J) => J + Me),
|
|
2989
3043
|
onUsage: k,
|
|
2990
|
-
onEdit:
|
|
3044
|
+
onEdit: ye,
|
|
2991
3045
|
onRecharge: (J) => {
|
|
2992
|
-
P(J),
|
|
3046
|
+
P(J), d("");
|
|
2993
3047
|
},
|
|
2994
|
-
onCopyToken:
|
|
2995
|
-
onDelete:
|
|
3048
|
+
onCopyToken: G,
|
|
3049
|
+
onDelete: U
|
|
2996
3050
|
}
|
|
2997
3051
|
)
|
|
2998
3052
|
] });
|
|
2999
3053
|
}
|
|
3000
|
-
function
|
|
3001
|
-
const
|
|
3054
|
+
function ke(t, a, s) {
|
|
3055
|
+
const l = [], o = /* @__PURE__ */ new Date(), n = t || [], d = new Map(n.map((g) => [g.date, g]));
|
|
3002
3056
|
for (let g = a - 1; g >= 0; g--) {
|
|
3003
3057
|
const S = new Date(o.getTime() - g * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
|
3004
|
-
if (
|
|
3005
|
-
|
|
3058
|
+
if (d.has(S))
|
|
3059
|
+
l.push(d.get(S));
|
|
3006
3060
|
else {
|
|
3007
3061
|
const w = { date: S };
|
|
3008
|
-
s.forEach((x) => w[x] = 0),
|
|
3062
|
+
s.forEach((x) => w[x] = 0), l.push(w);
|
|
3009
3063
|
}
|
|
3010
3064
|
}
|
|
3011
|
-
return
|
|
3065
|
+
return l;
|
|
3012
3066
|
}
|
|
3013
|
-
function
|
|
3014
|
-
const { t, i18n: a } = F(["admin", "translation"]), [s,
|
|
3015
|
-
data:
|
|
3067
|
+
function yr() {
|
|
3068
|
+
const { t, i18n: a } = F(["admin", "translation"]), [s, l] = y(30), [o, n] = y("human"), {
|
|
3069
|
+
data: d,
|
|
3016
3070
|
isLoading: g,
|
|
3017
3071
|
error: _,
|
|
3018
3072
|
refetch: S
|
|
3019
|
-
} =
|
|
3020
|
-
if (!
|
|
3021
|
-
const m =
|
|
3073
|
+
} = er(s, o), [w, x] = y({}), i = nt({}), b = a.language === "fa", h = b ? "fa-IR" : "en-US", N = b ? "fa-IR-u-ca-persian" : "en-US", I = _ ? _ instanceof Error ? _.message : t("analytics.error_loading") : "", p = he(() => {
|
|
3074
|
+
if (!d) return null;
|
|
3075
|
+
const m = d;
|
|
3022
3076
|
return {
|
|
3023
3077
|
...m,
|
|
3024
3078
|
overview: m.overview || {
|
|
@@ -3033,10 +3087,10 @@ function gr() {
|
|
|
3033
3087
|
},
|
|
3034
3088
|
trends: {
|
|
3035
3089
|
...m.trends || {},
|
|
3036
|
-
users:
|
|
3037
|
-
threads:
|
|
3038
|
-
messages:
|
|
3039
|
-
token_usage:
|
|
3090
|
+
users: ke(m.trends?.users, s, ["count"]),
|
|
3091
|
+
threads: ke(m.trends?.threads, s, ["count"]),
|
|
3092
|
+
messages: ke(m.trends?.messages, s, ["count"]),
|
|
3093
|
+
token_usage: ke(m.trends?.token_usage, s, [
|
|
3040
3094
|
"input_tokens",
|
|
3041
3095
|
"output_tokens",
|
|
3042
3096
|
"requests",
|
|
@@ -3050,60 +3104,60 @@ function gr() {
|
|
|
3050
3104
|
},
|
|
3051
3105
|
active_users: m.active_users || []
|
|
3052
3106
|
};
|
|
3053
|
-
}, [
|
|
3107
|
+
}, [d, s]);
|
|
3054
3108
|
H(() => {
|
|
3055
3109
|
const m = Object.entries(i.current).filter(
|
|
3056
3110
|
(A) => !!A[1]
|
|
3057
3111
|
);
|
|
3058
3112
|
if (m.length === 0) return;
|
|
3059
|
-
const
|
|
3113
|
+
const j = new ResizeObserver((A) => {
|
|
3060
3114
|
for (const K of A) {
|
|
3061
3115
|
const M = K.target.dataset.chartId;
|
|
3062
|
-
M && x((
|
|
3063
|
-
...
|
|
3116
|
+
M && x((B) => ({
|
|
3117
|
+
...B,
|
|
3064
3118
|
[M]: K.contentRect.width
|
|
3065
3119
|
}));
|
|
3066
3120
|
}
|
|
3067
3121
|
});
|
|
3068
|
-
return m.forEach(([, A]) =>
|
|
3122
|
+
return m.forEach(([, A]) => j.observe(A)), () => j.disconnect();
|
|
3069
3123
|
}, [p]);
|
|
3070
|
-
const R = (m) => (
|
|
3071
|
-
i.current[m] =
|
|
3072
|
-
},
|
|
3124
|
+
const R = (m) => (j) => {
|
|
3125
|
+
i.current[m] = j;
|
|
3126
|
+
}, u = (m, j = 0) => {
|
|
3073
3127
|
if (!m || m.length === 0) return null;
|
|
3074
3128
|
const A = m.length, K = new Intl.DateTimeFormat(N, { month: "short" });
|
|
3075
3129
|
let M = [];
|
|
3076
3130
|
if (s <= 14)
|
|
3077
|
-
M = Array.from({ length: A }, (
|
|
3131
|
+
M = Array.from({ length: A }, (B, Q) => Q);
|
|
3078
3132
|
else {
|
|
3079
|
-
const
|
|
3080
|
-
for (let
|
|
3081
|
-
M.push(
|
|
3133
|
+
const B = b ? 45 : 35, Q = j > 0 ? Math.floor(j / B) : 6, W = Math.max(1, Math.ceil(A / Math.max(1, Q)));
|
|
3134
|
+
for (let V = 0; V < A; V += W)
|
|
3135
|
+
M.push(V);
|
|
3082
3136
|
M.length > 0 && M[M.length - 1] !== A - 1 && (A - 1 - M[M.length - 1] > W / 2 ? M.push(A - 1) : M[M.length - 1] = A - 1);
|
|
3083
3137
|
}
|
|
3084
|
-
return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: b ? "rtl" : "ltr", children: M.map((
|
|
3085
|
-
const Q = m[
|
|
3138
|
+
return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: b ? "rtl" : "ltr", children: M.map((B) => {
|
|
3139
|
+
const Q = m[B];
|
|
3086
3140
|
if (!Q) return null;
|
|
3087
|
-
const W = new Date(Q.date),
|
|
3141
|
+
const W = new Date(Q.date), V = W.toLocaleDateString(N, { day: "numeric" }), de = K.format(W), pe = A > 1 ? B / (A - 1) * 100 : 50;
|
|
3088
3142
|
return /* @__PURE__ */ r(
|
|
3089
3143
|
"div",
|
|
3090
3144
|
{
|
|
3091
3145
|
className: "absolute top-0 transform -translate-x-1/2 flex flex-col items-center",
|
|
3092
|
-
style: { left: `${
|
|
3146
|
+
style: { left: `${pe}%` },
|
|
3093
3147
|
children: [
|
|
3094
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children:
|
|
3148
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: V }),
|
|
3095
3149
|
/* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: de })
|
|
3096
3150
|
]
|
|
3097
3151
|
},
|
|
3098
|
-
|
|
3152
|
+
B
|
|
3099
3153
|
);
|
|
3100
3154
|
}) });
|
|
3101
3155
|
};
|
|
3102
3156
|
if (g)
|
|
3103
3157
|
return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground", children: t("analytics.loading_analytics") });
|
|
3104
|
-
if (
|
|
3158
|
+
if (I)
|
|
3105
3159
|
return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
|
|
3106
|
-
/* @__PURE__ */ e("div", { className: "text-destructive mb-4", children:
|
|
3160
|
+
/* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: I }),
|
|
3107
3161
|
/* @__PURE__ */ e(
|
|
3108
3162
|
"button",
|
|
3109
3163
|
{
|
|
@@ -3116,14 +3170,14 @@ function gr() {
|
|
|
3116
3170
|
if (!p) return null;
|
|
3117
3171
|
const f = (m) => {
|
|
3118
3172
|
if (m <= 0) return 10;
|
|
3119
|
-
const
|
|
3173
|
+
const j = m * 1.15, A = Math.pow(10, Math.floor(Math.log10(j))), K = j / A;
|
|
3120
3174
|
let M;
|
|
3121
|
-
return K <= 1.2 ? M = 0.2 : K <= 2.5 ? M = 0.5 : K <= 5 ? M = 1 : M = 2, Math.ceil(
|
|
3122
|
-
}, C = Math.max(...p.trends.threads.map((m) => m.count) || [1]),
|
|
3175
|
+
return K <= 1.2 ? M = 0.2 : K <= 2.5 ? M = 0.5 : K <= 5 ? M = 1 : M = 2, Math.ceil(j / (M * A)) * (M * A);
|
|
3176
|
+
}, C = Math.max(...p.trends.threads.map((m) => m.count) || [1]), q = Math.max(...p.trends.messages.map((m) => m.count) || [1]), $ = Math.max(
|
|
3123
3177
|
...p.trends.token_usage.map((m) => (m.input_tokens || 0) + (m.output_tokens || 0)) || [1]
|
|
3124
3178
|
), v = Math.max(
|
|
3125
3179
|
...p.trends.token_usage.map((m) => m.cost_microunits) || [1]
|
|
3126
|
-
), O = f(C), P = f(
|
|
3180
|
+
), O = f(C), P = f(q), Z = f($), k = f(v);
|
|
3127
3181
|
return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: b ? "rtl" : "ltr", children: [
|
|
3128
3182
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3", children: [
|
|
3129
3183
|
/* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: [
|
|
@@ -3148,7 +3202,7 @@ function gr() {
|
|
|
3148
3202
|
[7, 14, 30, 90].map((m) => /* @__PURE__ */ e(
|
|
3149
3203
|
"button",
|
|
3150
3204
|
{
|
|
3151
|
-
onClick: () =>
|
|
3205
|
+
onClick: () => l(m),
|
|
3152
3206
|
title: t("analytics.days", { count: m }),
|
|
3153
3207
|
"aria-pressed": s === m,
|
|
3154
3208
|
className: `px-3 py-1.5 text-sm font-medium rounded-lg transition-all ${s === m ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
|
|
@@ -3307,7 +3361,7 @@ function gr() {
|
|
|
3307
3361
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3308
3362
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3309
3363
|
] }),
|
|
3310
|
-
p.trends.threads.length > 0 ? p.trends.threads.map((m,
|
|
3364
|
+
p.trends.threads.length > 0 ? p.trends.threads.map((m, j) => /* @__PURE__ */ e(
|
|
3311
3365
|
"div",
|
|
3312
3366
|
{
|
|
3313
3367
|
className: "w-1.5 group relative flex flex-col justify-end h-full",
|
|
@@ -3326,13 +3380,13 @@ function gr() {
|
|
|
3326
3380
|
}
|
|
3327
3381
|
)
|
|
3328
3382
|
},
|
|
3329
|
-
|
|
3383
|
+
j
|
|
3330
3384
|
)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3331
3385
|
] })
|
|
3332
3386
|
] }),
|
|
3333
3387
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3334
3388
|
/* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
|
|
3335
|
-
|
|
3389
|
+
u(p.trends.threads, w.threads)
|
|
3336
3390
|
] })
|
|
3337
3391
|
]
|
|
3338
3392
|
}
|
|
@@ -3358,7 +3412,7 @@ function gr() {
|
|
|
3358
3412
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3359
3413
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3360
3414
|
] }),
|
|
3361
|
-
p.trends.messages.length > 0 ? p.trends.messages.map((m,
|
|
3415
|
+
p.trends.messages.length > 0 ? p.trends.messages.map((m, j) => /* @__PURE__ */ e(
|
|
3362
3416
|
"div",
|
|
3363
3417
|
{
|
|
3364
3418
|
className: "w-1.5 group relative flex flex-col justify-end h-full",
|
|
@@ -3377,13 +3431,13 @@ function gr() {
|
|
|
3377
3431
|
}
|
|
3378
3432
|
)
|
|
3379
3433
|
},
|
|
3380
|
-
|
|
3434
|
+
j
|
|
3381
3435
|
)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3382
3436
|
] })
|
|
3383
3437
|
] }),
|
|
3384
3438
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3385
3439
|
/* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
|
|
3386
|
-
|
|
3440
|
+
u(p.trends.messages, w.messages)
|
|
3387
3441
|
] })
|
|
3388
3442
|
]
|
|
3389
3443
|
}
|
|
@@ -3409,7 +3463,7 @@ function gr() {
|
|
|
3409
3463
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3410
3464
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3411
3465
|
] }),
|
|
3412
|
-
p.trends.token_usage.length > 0 ? p.trends.token_usage.map((m,
|
|
3466
|
+
p.trends.token_usage.length > 0 ? p.trends.token_usage.map((m, j) => {
|
|
3413
3467
|
const A = (m.input_tokens || 0) + (m.output_tokens || 0);
|
|
3414
3468
|
return /* @__PURE__ */ e(
|
|
3415
3469
|
"div",
|
|
@@ -3430,14 +3484,14 @@ function gr() {
|
|
|
3430
3484
|
}
|
|
3431
3485
|
)
|
|
3432
3486
|
},
|
|
3433
|
-
|
|
3487
|
+
j
|
|
3434
3488
|
);
|
|
3435
3489
|
}) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3436
3490
|
] })
|
|
3437
3491
|
] }),
|
|
3438
3492
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3439
3493
|
/* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
|
|
3440
|
-
|
|
3494
|
+
u(p.trends.token_usage, w["token-usage"])
|
|
3441
3495
|
] })
|
|
3442
3496
|
]
|
|
3443
3497
|
}
|
|
@@ -3471,7 +3525,7 @@ function gr() {
|
|
|
3471
3525
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3472
3526
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3473
3527
|
] }),
|
|
3474
|
-
p.trends.token_usage.length > 0 ? p.trends.token_usage.map((m,
|
|
3528
|
+
p.trends.token_usage.length > 0 ? p.trends.token_usage.map((m, j) => /* @__PURE__ */ e(
|
|
3475
3529
|
"div",
|
|
3476
3530
|
{
|
|
3477
3531
|
className: "w-1.5 group relative flex flex-col justify-end h-full",
|
|
@@ -3496,13 +3550,13 @@ function gr() {
|
|
|
3496
3550
|
}
|
|
3497
3551
|
)
|
|
3498
3552
|
},
|
|
3499
|
-
|
|
3553
|
+
j
|
|
3500
3554
|
)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3501
3555
|
] })
|
|
3502
3556
|
] }),
|
|
3503
3557
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3504
3558
|
/* @__PURE__ */ e("div", { className: "min-w-[70px] invisible" }),
|
|
3505
|
-
|
|
3559
|
+
u(p.trends.token_usage, w.cost)
|
|
3506
3560
|
] })
|
|
3507
3561
|
]
|
|
3508
3562
|
}
|
|
@@ -3516,11 +3570,11 @@ function gr() {
|
|
|
3516
3570
|
/* @__PURE__ */ r("div", { className: "relative w-56 h-56 lg:w-60 lg:h-60", children: [
|
|
3517
3571
|
/* @__PURE__ */ e("svg", { viewBox: "0 0 100 100", className: "w-full h-full -rotate-90 drop-shadow-md", children: (() => {
|
|
3518
3572
|
const m = p.distributions.feedback_sentiment.filter(
|
|
3519
|
-
(
|
|
3520
|
-
),
|
|
3521
|
-
if (
|
|
3522
|
-
const A = m.find((
|
|
3523
|
-
return /* @__PURE__ */ r(
|
|
3573
|
+
(V) => V.sentiment === "positive" || V.sentiment === "negative"
|
|
3574
|
+
), j = m.reduce((V, de) => V + de.count, 0);
|
|
3575
|
+
if (j === 0) return null;
|
|
3576
|
+
const A = m.find((V) => V.sentiment === "positive")?.count || 0, K = m.find((V) => V.sentiment === "negative")?.count || 0, M = 40, B = 2 * Math.PI * M, Q = A / j * 100, W = K / j * 100;
|
|
3577
|
+
return /* @__PURE__ */ r(at, { children: [
|
|
3524
3578
|
/* @__PURE__ */ e(
|
|
3525
3579
|
"circle",
|
|
3526
3580
|
{
|
|
@@ -3552,7 +3606,7 @@ function gr() {
|
|
|
3552
3606
|
fill: "transparent",
|
|
3553
3607
|
stroke: "url(#posGradient)",
|
|
3554
3608
|
strokeWidth: "10",
|
|
3555
|
-
strokeDasharray: `${Q / 100 *
|
|
3609
|
+
strokeDasharray: `${Q / 100 * B} ${B}`,
|
|
3556
3610
|
strokeLinecap: Q > 0 ? "round" : "butt",
|
|
3557
3611
|
className: "transition-all duration-1000 ease-out drop-shadow-sm"
|
|
3558
3612
|
}
|
|
@@ -3566,8 +3620,8 @@ function gr() {
|
|
|
3566
3620
|
fill: "transparent",
|
|
3567
3621
|
stroke: "url(#negGradient)",
|
|
3568
3622
|
strokeWidth: "10",
|
|
3569
|
-
strokeDasharray: `${W / 100 *
|
|
3570
|
-
strokeDashoffset: -(Q / 100 *
|
|
3623
|
+
strokeDasharray: `${W / 100 * B} ${B}`,
|
|
3624
|
+
strokeDashoffset: -(Q / 100 * B),
|
|
3571
3625
|
strokeLinecap: W > 0 ? "round" : "butt",
|
|
3572
3626
|
className: "transition-all duration-1000 ease-out drop-shadow-sm"
|
|
3573
3627
|
}
|
|
@@ -3575,16 +3629,16 @@ function gr() {
|
|
|
3575
3629
|
] });
|
|
3576
3630
|
})() }),
|
|
3577
3631
|
/* @__PURE__ */ r("div", { className: "absolute inset-0 flex flex-col items-center justify-center pointer-events-none", children: [
|
|
3578
|
-
/* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children: p.distributions.feedback_sentiment.filter((m) => m.sentiment === "positive" || m.sentiment === "negative").reduce((m,
|
|
3632
|
+
/* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children: p.distributions.feedback_sentiment.filter((m) => m.sentiment === "positive" || m.sentiment === "negative").reduce((m, j) => m + (j.count || 0), 0).toLocaleString(h) }),
|
|
3579
3633
|
/* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground uppercase tracking-widest mt-1", children: t("analytics.total_feedback") })
|
|
3580
3634
|
] })
|
|
3581
3635
|
] }),
|
|
3582
3636
|
/* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...p.distributions.feedback_sentiment].filter(
|
|
3583
3637
|
(m) => m.sentiment === "positive" || m.sentiment === "negative"
|
|
3584
|
-
).sort((m,
|
|
3638
|
+
).sort((m, j) => m.sentiment === "positive" ? -1 : 1).map((m) => {
|
|
3585
3639
|
const A = p.distributions.feedback_sentiment.filter(
|
|
3586
3640
|
(W) => W.sentiment === "positive" || W.sentiment === "negative"
|
|
3587
|
-
).reduce((W,
|
|
3641
|
+
).reduce((W, V) => W + V.count, 0), K = A > 0 ? m.count / A * 100 : 0, M = m.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), B = m.sentiment === "positive" ? "bg-primary" : "bg-destructive", Q = m.sentiment === "positive" ? "👍" : "👎";
|
|
3588
3642
|
return /* @__PURE__ */ r(
|
|
3589
3643
|
"div",
|
|
3590
3644
|
{
|
|
@@ -3594,7 +3648,7 @@ function gr() {
|
|
|
3594
3648
|
/* @__PURE__ */ e(
|
|
3595
3649
|
"div",
|
|
3596
3650
|
{
|
|
3597
|
-
className: `w-3 h-3 rounded-full ${
|
|
3651
|
+
className: `w-3 h-3 rounded-full ${B} shadow-sm group-hover:scale-110 transition-transform`
|
|
3598
3652
|
}
|
|
3599
3653
|
),
|
|
3600
3654
|
/* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground font-medium", children: [
|
|
@@ -3647,7 +3701,7 @@ function gr() {
|
|
|
3647
3701
|
] })
|
|
3648
3702
|
] });
|
|
3649
3703
|
}
|
|
3650
|
-
function
|
|
3704
|
+
function Ne({ title: t, icon: a }) {
|
|
3651
3705
|
return /* @__PURE__ */ r("div", { className: "relative py-12", children: [
|
|
3652
3706
|
/* @__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" }) }),
|
|
3653
3707
|
/* @__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: [
|
|
@@ -3656,7 +3710,7 @@ function ye({ title: t, icon: a }) {
|
|
|
3656
3710
|
] }) })
|
|
3657
3711
|
] });
|
|
3658
3712
|
}
|
|
3659
|
-
function
|
|
3713
|
+
function _e({ value: t }) {
|
|
3660
3714
|
const { t: a } = F(["admin", "translation", "settings"]);
|
|
3661
3715
|
if (!t || !t.includes(":") && !t.includes(".")) return null;
|
|
3662
3716
|
const s = a(t);
|
|
@@ -3668,19 +3722,19 @@ function ve({ value: t }) {
|
|
|
3668
3722
|
/* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: s })
|
|
3669
3723
|
] });
|
|
3670
3724
|
}
|
|
3671
|
-
function
|
|
3725
|
+
function _r({
|
|
3672
3726
|
settings: t,
|
|
3673
3727
|
setSettings: a,
|
|
3674
3728
|
accentValue: s,
|
|
3675
|
-
accentIsValid:
|
|
3729
|
+
accentIsValid: l
|
|
3676
3730
|
}) {
|
|
3677
3731
|
const { t: o } = F(["admin", "translation", "settings"]);
|
|
3678
3732
|
return /* @__PURE__ */ r("section", { children: [
|
|
3679
|
-
/* @__PURE__ */ e(
|
|
3733
|
+
/* @__PURE__ */ e(Ne, { title: o("app_settings.sections.general"), icon: Je }),
|
|
3680
3734
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
|
|
3681
3735
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
|
|
3682
3736
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3683
|
-
/* @__PURE__ */ e(
|
|
3737
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.general.app_name") }),
|
|
3684
3738
|
/* @__PURE__ */ e(
|
|
3685
3739
|
se,
|
|
3686
3740
|
{
|
|
@@ -3692,10 +3746,10 @@ function fr({
|
|
|
3692
3746
|
dir: "auto"
|
|
3693
3747
|
}
|
|
3694
3748
|
),
|
|
3695
|
-
/* @__PURE__ */ e(
|
|
3749
|
+
/* @__PURE__ */ e(_e, { value: t.app_name })
|
|
3696
3750
|
] }),
|
|
3697
3751
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3698
|
-
/* @__PURE__ */ e(
|
|
3752
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.general.admin_title") }),
|
|
3699
3753
|
/* @__PURE__ */ e(
|
|
3700
3754
|
se,
|
|
3701
3755
|
{
|
|
@@ -3707,11 +3761,11 @@ function fr({
|
|
|
3707
3761
|
dir: "auto"
|
|
3708
3762
|
}
|
|
3709
3763
|
),
|
|
3710
|
-
/* @__PURE__ */ e(
|
|
3764
|
+
/* @__PURE__ */ e(_e, { value: t.admin_title || "" })
|
|
3711
3765
|
] })
|
|
3712
3766
|
] }),
|
|
3713
3767
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3714
|
-
/* @__PURE__ */ e(
|
|
3768
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.general.language") }),
|
|
3715
3769
|
/* @__PURE__ */ r(
|
|
3716
3770
|
X,
|
|
3717
3771
|
{
|
|
@@ -3727,13 +3781,13 @@ function fr({
|
|
|
3727
3781
|
}
|
|
3728
3782
|
),
|
|
3729
3783
|
/* @__PURE__ */ r("p", { className: "mt-3 text-[10px] text-muted-foreground/50 italic flex items-center gap-1.5 ml-1", children: [
|
|
3730
|
-
/* @__PURE__ */ e(
|
|
3784
|
+
/* @__PURE__ */ e(ot, { className: "size-3" }),
|
|
3731
3785
|
o("app_settings.general.language_help")
|
|
3732
3786
|
] })
|
|
3733
3787
|
] }),
|
|
3734
3788
|
/* @__PURE__ */ r("div", { className: "space-y-5 rounded-2xl border border-border/50 bg-muted/10 p-5", children: [
|
|
3735
3789
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
3736
|
-
/* @__PURE__ */ e(
|
|
3790
|
+
/* @__PURE__ */ e(Rt, { className: "size-4 text-primary" }),
|
|
3737
3791
|
/* @__PURE__ */ r("div", { children: [
|
|
3738
3792
|
/* @__PURE__ */ e("h3", { className: "text-sm font-bold text-foreground/80", children: o("app_settings.general.appearance") }),
|
|
3739
3793
|
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: o("app_settings.general.appearance_help") })
|
|
@@ -3741,7 +3795,7 @@ function fr({
|
|
|
3741
3795
|
] }),
|
|
3742
3796
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [
|
|
3743
3797
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3744
|
-
/* @__PURE__ */ e(
|
|
3798
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.general.default_theme") }),
|
|
3745
3799
|
/* @__PURE__ */ r(
|
|
3746
3800
|
X,
|
|
3747
3801
|
{
|
|
@@ -3762,14 +3816,14 @@ function fr({
|
|
|
3762
3816
|
)
|
|
3763
3817
|
] }),
|
|
3764
3818
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3765
|
-
/* @__PURE__ */ e(
|
|
3819
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.general.default_accent") }),
|
|
3766
3820
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
3767
3821
|
/* @__PURE__ */ e(
|
|
3768
3822
|
"div",
|
|
3769
3823
|
{
|
|
3770
3824
|
className: "size-10 shrink-0 rounded-xl border border-border shadow-sm",
|
|
3771
3825
|
style: {
|
|
3772
|
-
backgroundColor:
|
|
3826
|
+
backgroundColor: l && s ? s : "transparent"
|
|
3773
3827
|
},
|
|
3774
3828
|
"aria-label": o("app_settings.general.default_accent_preview")
|
|
3775
3829
|
}
|
|
@@ -3783,15 +3837,15 @@ function fr({
|
|
|
3783
3837
|
className: "bg-muted/20 border-transparent focus:bg-background h-11 font-mono",
|
|
3784
3838
|
placeholder: "oklch(0.623 0.214 259.815)",
|
|
3785
3839
|
dir: "ltr",
|
|
3786
|
-
"aria-invalid": !
|
|
3840
|
+
"aria-invalid": !l
|
|
3787
3841
|
}
|
|
3788
3842
|
)
|
|
3789
3843
|
] }),
|
|
3790
3844
|
/* @__PURE__ */ e(
|
|
3791
3845
|
"p",
|
|
3792
3846
|
{
|
|
3793
|
-
className: `text-[10px] ${
|
|
3794
|
-
children: o(
|
|
3847
|
+
className: `text-[10px] ${l ? "text-muted-foreground/60" : "text-destructive"}`,
|
|
3848
|
+
children: o(l ? "app_settings.general.default_accent_help" : "app_settings.general.default_accent_invalid")
|
|
3795
3849
|
}
|
|
3796
3850
|
)
|
|
3797
3851
|
] })
|
|
@@ -3804,13 +3858,13 @@ function ie({
|
|
|
3804
3858
|
title: t,
|
|
3805
3859
|
help: a,
|
|
3806
3860
|
checked: s,
|
|
3807
|
-
onCheckedChange:
|
|
3861
|
+
onCheckedChange: l,
|
|
3808
3862
|
className: o
|
|
3809
3863
|
}) {
|
|
3810
3864
|
return /* @__PURE__ */ r(
|
|
3811
3865
|
"div",
|
|
3812
3866
|
{
|
|
3813
|
-
className:
|
|
3867
|
+
className: Se(
|
|
3814
3868
|
"p-5 border border-border/40 rounded-2xl flex items-center justify-between hover:bg-muted/5 transition-colors",
|
|
3815
3869
|
o
|
|
3816
3870
|
),
|
|
@@ -3819,19 +3873,19 @@ function ie({
|
|
|
3819
3873
|
/* @__PURE__ */ e("p", { className: "text-xs font-bold text-foreground/80", children: t }),
|
|
3820
3874
|
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/60 leading-relaxed mt-1", children: a })
|
|
3821
3875
|
] }),
|
|
3822
|
-
/* @__PURE__ */ e(le, { checked: s, onCheckedChange:
|
|
3876
|
+
/* @__PURE__ */ e(le, { checked: s, onCheckedChange: l })
|
|
3823
3877
|
]
|
|
3824
3878
|
}
|
|
3825
3879
|
);
|
|
3826
3880
|
}
|
|
3827
|
-
function
|
|
3881
|
+
function $e({
|
|
3828
3882
|
title: t,
|
|
3829
3883
|
fields: a,
|
|
3830
3884
|
values: s,
|
|
3831
|
-
onChange:
|
|
3885
|
+
onChange: l,
|
|
3832
3886
|
columns: o = 4
|
|
3833
3887
|
}) {
|
|
3834
|
-
const { t: n, i18n:
|
|
3888
|
+
const { t: n, i18n: d } = F(["admin"]), g = d.language === "fa";
|
|
3835
3889
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3836
3890
|
/* @__PURE__ */ r("h4", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground/50 flex items-center gap-2", children: [
|
|
3837
3891
|
/* @__PURE__ */ e("div", { className: "w-1 h-1 rounded-full bg-primary/40" }),
|
|
@@ -3846,12 +3900,12 @@ function Re({
|
|
|
3846
3900
|
{
|
|
3847
3901
|
className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5",
|
|
3848
3902
|
children: [
|
|
3849
|
-
/* @__PURE__ */ e(
|
|
3903
|
+
/* @__PURE__ */ e(z, { className: "text-[10px] font-medium text-muted-foreground/70", children: _.label }),
|
|
3850
3904
|
/* @__PURE__ */ r(
|
|
3851
3905
|
X,
|
|
3852
3906
|
{
|
|
3853
3907
|
value: s?.[_.id] || "editable",
|
|
3854
|
-
onValueChange: (S) =>
|
|
3908
|
+
onValueChange: (S) => l(_.id, S),
|
|
3855
3909
|
dir: g ? "rtl" : "ltr",
|
|
3856
3910
|
children: [
|
|
3857
3911
|
/* @__PURE__ */ e(Y, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ee, {}) }),
|
|
@@ -3871,19 +3925,19 @@ function Re({
|
|
|
3871
3925
|
)
|
|
3872
3926
|
] });
|
|
3873
3927
|
}
|
|
3874
|
-
function
|
|
3928
|
+
function Nr({
|
|
3875
3929
|
settings: t,
|
|
3876
3930
|
setSettings: a,
|
|
3877
3931
|
userMetadataFields: s,
|
|
3878
|
-
isRtl:
|
|
3932
|
+
isRtl: l
|
|
3879
3933
|
}) {
|
|
3880
3934
|
const { t: o } = F(["admin", "translation", "settings"]);
|
|
3881
3935
|
return /* @__PURE__ */ r("section", { children: [
|
|
3882
|
-
/* @__PURE__ */ e(
|
|
3936
|
+
/* @__PURE__ */ e(Ne, { title: o("app_settings.sections.chat"), icon: Mt }),
|
|
3883
3937
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
|
|
3884
3938
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
|
|
3885
3939
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3886
|
-
/* @__PURE__ */ e(
|
|
3940
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.chat.welcome_greeting") }),
|
|
3887
3941
|
/* @__PURE__ */ e(
|
|
3888
3942
|
se,
|
|
3889
3943
|
{
|
|
@@ -3895,10 +3949,10 @@ function br({
|
|
|
3895
3949
|
dir: "auto"
|
|
3896
3950
|
}
|
|
3897
3951
|
),
|
|
3898
|
-
/* @__PURE__ */ e(
|
|
3952
|
+
/* @__PURE__ */ e(_e, { value: t.welcome_greeting || "" })
|
|
3899
3953
|
] }),
|
|
3900
3954
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3901
|
-
/* @__PURE__ */ e(
|
|
3955
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.chat.welcome_subtitle") }),
|
|
3902
3956
|
/* @__PURE__ */ e(
|
|
3903
3957
|
se,
|
|
3904
3958
|
{
|
|
@@ -3909,13 +3963,13 @@ function br({
|
|
|
3909
3963
|
dir: "auto"
|
|
3910
3964
|
}
|
|
3911
3965
|
),
|
|
3912
|
-
/* @__PURE__ */ e(
|
|
3966
|
+
/* @__PURE__ */ e(_e, { value: t.welcome_subtitle || "" })
|
|
3913
3967
|
] })
|
|
3914
3968
|
] }),
|
|
3915
3969
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
3916
|
-
/* @__PURE__ */ e(
|
|
3970
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: o("app_settings.chat.disclaimer") }),
|
|
3917
3971
|
/* @__PURE__ */ e(
|
|
3918
|
-
|
|
3972
|
+
De,
|
|
3919
3973
|
{
|
|
3920
3974
|
value: t.disclaimer || "",
|
|
3921
3975
|
onChange: (n) => a({ ...t, disclaimer: n.target.value }),
|
|
@@ -3923,7 +3977,7 @@ function br({
|
|
|
3923
3977
|
dir: "auto"
|
|
3924
3978
|
}
|
|
3925
3979
|
),
|
|
3926
|
-
/* @__PURE__ */ e(
|
|
3980
|
+
/* @__PURE__ */ e(_e, { value: t.disclaimer || "" })
|
|
3927
3981
|
] }),
|
|
3928
3982
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-6 pt-2", children: [
|
|
3929
3983
|
/* @__PURE__ */ e(
|
|
@@ -4011,7 +4065,7 @@ function br({
|
|
|
4011
4065
|
),
|
|
4012
4066
|
t.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: [
|
|
4013
4067
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
4014
|
-
/* @__PURE__ */ e(
|
|
4068
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-medium text-foreground/70", children: o("app_settings.chat.history_show_delete") }),
|
|
4015
4069
|
/* @__PURE__ */ e(
|
|
4016
4070
|
le,
|
|
4017
4071
|
{
|
|
@@ -4021,7 +4075,7 @@ function br({
|
|
|
4021
4075
|
)
|
|
4022
4076
|
] }),
|
|
4023
4077
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
4024
|
-
/* @__PURE__ */ e(
|
|
4078
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-medium text-foreground/70", children: o("app_settings.chat.history_show_rename") }),
|
|
4025
4079
|
/* @__PURE__ */ e(
|
|
4026
4080
|
le,
|
|
4027
4081
|
{
|
|
@@ -4031,7 +4085,7 @@ function br({
|
|
|
4031
4085
|
)
|
|
4032
4086
|
] }),
|
|
4033
4087
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
4034
|
-
/* @__PURE__ */ e(
|
|
4088
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-medium text-foreground/70", children: o("app_settings.chat.history_show_share") }),
|
|
4035
4089
|
/* @__PURE__ */ e(
|
|
4036
4090
|
le,
|
|
4037
4091
|
{
|
|
@@ -4041,7 +4095,7 @@ function br({
|
|
|
4041
4095
|
)
|
|
4042
4096
|
] }),
|
|
4043
4097
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
4044
|
-
/* @__PURE__ */ e(
|
|
4098
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-medium text-foreground/70", children: o("app_settings.chat.history_show_pin") }),
|
|
4045
4099
|
/* @__PURE__ */ e(
|
|
4046
4100
|
le,
|
|
4047
4101
|
{
|
|
@@ -4066,13 +4120,13 @@ function br({
|
|
|
4066
4120
|
{
|
|
4067
4121
|
className: "p-4 border border-border/40 rounded-2xl space-y-3 bg-muted/5",
|
|
4068
4122
|
children: [
|
|
4069
|
-
/* @__PURE__ */ e(
|
|
4123
|
+
/* @__PURE__ */ e(z, { className: "text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70", children: o(n.label) }),
|
|
4070
4124
|
/* @__PURE__ */ r(
|
|
4071
4125
|
X,
|
|
4072
4126
|
{
|
|
4073
4127
|
value: t[n.id],
|
|
4074
|
-
onValueChange: (
|
|
4075
|
-
dir:
|
|
4128
|
+
onValueChange: (d) => a({ ...t, [n.id]: d }),
|
|
4129
|
+
dir: l ? "rtl" : "ltr",
|
|
4076
4130
|
children: [
|
|
4077
4131
|
/* @__PURE__ */ e(Y, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(ee, {}) }),
|
|
4078
4132
|
/* @__PURE__ */ r(te, { children: [
|
|
@@ -4095,7 +4149,7 @@ function br({
|
|
|
4095
4149
|
] }),
|
|
4096
4150
|
/* @__PURE__ */ r("div", { className: "space-y-10", children: [
|
|
4097
4151
|
/* @__PURE__ */ e(
|
|
4098
|
-
|
|
4152
|
+
$e,
|
|
4099
4153
|
{
|
|
4100
4154
|
title: o("app_settings.chat.general_tab"),
|
|
4101
4155
|
fields: [
|
|
@@ -4105,14 +4159,14 @@ function br({
|
|
|
4105
4159
|
{ id: "language", label: o("settings:general.language") }
|
|
4106
4160
|
],
|
|
4107
4161
|
values: t.settings_general_fields,
|
|
4108
|
-
onChange: (n,
|
|
4162
|
+
onChange: (n, d) => a((g) => ({
|
|
4109
4163
|
...g,
|
|
4110
|
-
settings_general_fields: { ...g.settings_general_fields, [n]:
|
|
4164
|
+
settings_general_fields: { ...g.settings_general_fields, [n]: d }
|
|
4111
4165
|
}))
|
|
4112
4166
|
}
|
|
4113
4167
|
),
|
|
4114
4168
|
/* @__PURE__ */ e(
|
|
4115
|
-
|
|
4169
|
+
$e,
|
|
4116
4170
|
{
|
|
4117
4171
|
title: o("app_settings.chat.profile_tab"),
|
|
4118
4172
|
fields: [
|
|
@@ -4126,14 +4180,14 @@ function br({
|
|
|
4126
4180
|
}))
|
|
4127
4181
|
],
|
|
4128
4182
|
values: t.settings_profile_fields,
|
|
4129
|
-
onChange: (n,
|
|
4183
|
+
onChange: (n, d) => a((g) => ({
|
|
4130
4184
|
...g,
|
|
4131
|
-
settings_profile_fields: { ...g.settings_profile_fields, [n]:
|
|
4185
|
+
settings_profile_fields: { ...g.settings_profile_fields, [n]: d }
|
|
4132
4186
|
}))
|
|
4133
4187
|
}
|
|
4134
4188
|
),
|
|
4135
4189
|
/* @__PURE__ */ e(
|
|
4136
|
-
|
|
4190
|
+
$e,
|
|
4137
4191
|
{
|
|
4138
4192
|
title: o("app_settings.chat.account_tab"),
|
|
4139
4193
|
fields: [
|
|
@@ -4141,9 +4195,9 @@ function br({
|
|
|
4141
4195
|
{ id: "logout", label: o("settings:account.logout") }
|
|
4142
4196
|
],
|
|
4143
4197
|
values: t.settings_account_fields,
|
|
4144
|
-
onChange: (n,
|
|
4198
|
+
onChange: (n, d) => a((g) => ({
|
|
4145
4199
|
...g,
|
|
4146
|
-
settings_account_fields: { ...g.settings_account_fields, [n]:
|
|
4200
|
+
settings_account_fields: { ...g.settings_account_fields, [n]: d }
|
|
4147
4201
|
})),
|
|
4148
4202
|
columns: 2
|
|
4149
4203
|
}
|
|
@@ -4153,8 +4207,8 @@ function br({
|
|
|
4153
4207
|
] })
|
|
4154
4208
|
] });
|
|
4155
4209
|
}
|
|
4156
|
-
const
|
|
4157
|
-
function
|
|
4210
|
+
const Oe = "I understand this runs arbitrary code";
|
|
4211
|
+
function wr() {
|
|
4158
4212
|
try {
|
|
4159
4213
|
const t = localStorage.getItem("admin_info");
|
|
4160
4214
|
return t ? JSON.parse(t).permissions || [] : [];
|
|
@@ -4162,10 +4216,10 @@ function xr() {
|
|
|
4162
4216
|
return [];
|
|
4163
4217
|
}
|
|
4164
4218
|
}
|
|
4165
|
-
function
|
|
4219
|
+
function ut(t) {
|
|
4166
4220
|
return t === "destructive" ? "bg-destructive/10 text-destructive border-destructive/20" : t === "caution" ? "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20" : "bg-muted/40 text-muted-foreground border-border/50";
|
|
4167
4221
|
}
|
|
4168
|
-
function
|
|
4222
|
+
function kr(t) {
|
|
4169
4223
|
switch (t) {
|
|
4170
4224
|
case "completed":
|
|
4171
4225
|
return "bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/20";
|
|
@@ -4177,29 +4231,29 @@ function vr(t) {
|
|
|
4177
4231
|
return "bg-primary/10 text-primary border-primary/20";
|
|
4178
4232
|
}
|
|
4179
4233
|
}
|
|
4180
|
-
function
|
|
4181
|
-
const { t: s } = F(["admin"]), { runRegisteredJob:
|
|
4234
|
+
function Cr({ job: t, onClose: a }) {
|
|
4235
|
+
const { t: s } = F(["admin"]), { runRegisteredJob: l } = We(), [o, n] = y(() => {
|
|
4182
4236
|
const h = {};
|
|
4183
4237
|
for (const N of t.params) {
|
|
4184
|
-
const
|
|
4185
|
-
h[N.name] = p ? String(
|
|
4238
|
+
const I = N.default, p = typeof I == "string" || typeof I == "number" || typeof I == "boolean";
|
|
4239
|
+
h[N.name] = p ? String(I) : N.type === "bool" ? "false" : "";
|
|
4186
4240
|
}
|
|
4187
4241
|
return h;
|
|
4188
|
-
}), [
|
|
4242
|
+
}), [d, g] = y(!1), [_, S] = y(""), w = t.danger === "destructive", x = !w || _.trim() === t.name, i = (h, N) => n((I) => ({ ...I, [h]: N })), b = async () => {
|
|
4189
4243
|
const h = {};
|
|
4190
4244
|
for (const N of t.params) {
|
|
4191
|
-
const
|
|
4192
|
-
N.type === "bool" ? h[N.name] =
|
|
4245
|
+
const I = o[N.name];
|
|
4246
|
+
N.type === "bool" ? h[N.name] = I === "true" : I !== "" && (h[N.name] = I);
|
|
4193
4247
|
}
|
|
4194
4248
|
try {
|
|
4195
|
-
await
|
|
4249
|
+
await l.mutateAsync({
|
|
4196
4250
|
jobId: t.id,
|
|
4197
4251
|
params: h,
|
|
4198
|
-
dry_run:
|
|
4252
|
+
dry_run: d,
|
|
4199
4253
|
confirm: w ? _ : void 0
|
|
4200
|
-
}),
|
|
4254
|
+
}), xe.success(s("jobs.run_started", { name: t.name })), a();
|
|
4201
4255
|
} catch (N) {
|
|
4202
|
-
|
|
4256
|
+
xe.error(N instanceof Error ? N.message : s("jobs.run_failed"));
|
|
4203
4257
|
}
|
|
4204
4258
|
};
|
|
4205
4259
|
return (
|
|
@@ -4208,21 +4262,21 @@ function yr({ job: t, onClose: a }) {
|
|
|
4208
4262
|
// close button positions itself with `rtl:` utilities that key off the RTL <body>
|
|
4209
4263
|
// ancestor, so force it back to the right edge for this LTR island.
|
|
4210
4264
|
/* @__PURE__ */ r(
|
|
4211
|
-
|
|
4265
|
+
je,
|
|
4212
4266
|
{
|
|
4213
4267
|
dir: "ltr",
|
|
4214
4268
|
className: "max-w-lg text-left [&_[data-slot=dialog-close]]:!right-4 [&_[data-slot=dialog-close]]:!left-auto",
|
|
4215
4269
|
children: [
|
|
4216
|
-
/* @__PURE__ */ r(
|
|
4217
|
-
/* @__PURE__ */ r(
|
|
4270
|
+
/* @__PURE__ */ r(Te, { className: "text-left", children: [
|
|
4271
|
+
/* @__PURE__ */ r(Ae, { className: "flex items-center gap-2", children: [
|
|
4218
4272
|
t.name,
|
|
4219
|
-
/* @__PURE__ */ e(
|
|
4273
|
+
/* @__PURE__ */ e(qe, { variant: "outline", className: ut(t.danger), children: s(`jobs.danger.${t.danger}`) })
|
|
4220
4274
|
] }),
|
|
4221
|
-
t.description && /* @__PURE__ */ e(
|
|
4275
|
+
t.description && /* @__PURE__ */ e(Ie, { children: t.description })
|
|
4222
4276
|
] }),
|
|
4223
4277
|
/* @__PURE__ */ r("div", { className: "space-y-4 py-2", children: [
|
|
4224
4278
|
t.params.map((h) => /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
4225
|
-
/* @__PURE__ */ r(
|
|
4279
|
+
/* @__PURE__ */ r(z, { className: "text-xs font-bold text-muted-foreground", children: [
|
|
4226
4280
|
h.label || h.name,
|
|
4227
4281
|
h.required && /* @__PURE__ */ e("span", { className: "text-destructive ml-1", children: "*" })
|
|
4228
4282
|
] }),
|
|
@@ -4244,7 +4298,7 @@ function yr({ job: t, onClose: a }) {
|
|
|
4244
4298
|
]
|
|
4245
4299
|
}
|
|
4246
4300
|
) : h.type === "text" ? /* @__PURE__ */ e(
|
|
4247
|
-
|
|
4301
|
+
De,
|
|
4248
4302
|
{
|
|
4249
4303
|
value: o[h.name],
|
|
4250
4304
|
onChange: (N) => i(h.name, N.target.value),
|
|
@@ -4267,11 +4321,11 @@ function yr({ job: t, onClose: a }) {
|
|
|
4267
4321
|
/* @__PURE__ */ e("p", { className: "text-sm font-medium", children: s("jobs.dry_run") }),
|
|
4268
4322
|
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/70", children: s("jobs.dry_run_help") })
|
|
4269
4323
|
] }),
|
|
4270
|
-
/* @__PURE__ */ e(le, { checked:
|
|
4324
|
+
/* @__PURE__ */ e(le, { checked: d, onCheckedChange: g })
|
|
4271
4325
|
] }),
|
|
4272
4326
|
w && /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
4273
|
-
/* @__PURE__ */ r(
|
|
4274
|
-
/* @__PURE__ */ e(
|
|
4327
|
+
/* @__PURE__ */ r(z, { className: "text-xs font-bold text-destructive flex items-center gap-1.5", children: [
|
|
4328
|
+
/* @__PURE__ */ e(Ft, { className: "size-3.5" }),
|
|
4275
4329
|
s("jobs.confirm_destructive", { name: t.name })
|
|
4276
4330
|
] }),
|
|
4277
4331
|
/* @__PURE__ */ e(
|
|
@@ -4285,17 +4339,17 @@ function yr({ job: t, onClose: a }) {
|
|
|
4285
4339
|
)
|
|
4286
4340
|
] })
|
|
4287
4341
|
] }),
|
|
4288
|
-
/* @__PURE__ */ r(
|
|
4289
|
-
/* @__PURE__ */ e(
|
|
4342
|
+
/* @__PURE__ */ r(Be, { children: [
|
|
4343
|
+
/* @__PURE__ */ e(ze, { asChild: !0, children: /* @__PURE__ */ e(ne, { variant: "ghost", children: s("cancel") }) }),
|
|
4290
4344
|
/* @__PURE__ */ r(
|
|
4291
4345
|
ne,
|
|
4292
4346
|
{
|
|
4293
4347
|
variant: w ? "destructive" : "default",
|
|
4294
4348
|
onClick: b,
|
|
4295
|
-
disabled: !x ||
|
|
4349
|
+
disabled: !x || l.isPending,
|
|
4296
4350
|
children: [
|
|
4297
|
-
|
|
4298
|
-
s(
|
|
4351
|
+
l.isPending ? /* @__PURE__ */ e(He, { className: "size-4 animate-spin" }) : /* @__PURE__ */ e(Ve, { className: "size-4" }),
|
|
4352
|
+
s(d ? "jobs.run_dry" : "jobs.run")
|
|
4299
4353
|
]
|
|
4300
4354
|
}
|
|
4301
4355
|
)
|
|
@@ -4305,16 +4359,16 @@ function yr({ job: t, onClose: a }) {
|
|
|
4305
4359
|
)
|
|
4306
4360
|
);
|
|
4307
4361
|
}
|
|
4308
|
-
function
|
|
4362
|
+
function Sr({ run: t }) {
|
|
4309
4363
|
const { t: a } = F(["admin"]), s = t.params && Object.keys(t.params).length > 0;
|
|
4310
4364
|
return /* @__PURE__ */ r("div", { className: "space-y-3 pt-3", dir: "ltr", children: [
|
|
4311
4365
|
(s || t.code) && /* @__PURE__ */ r("div", { children: [
|
|
4312
|
-
/* @__PURE__ */ e(
|
|
4366
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold text-muted-foreground", children: a("jobs.inputs") }),
|
|
4313
4367
|
/* @__PURE__ */ e("pre", { className: "mt-1 max-h-40 overflow-auto rounded-lg bg-muted/30 border border-border/40 p-3 text-[11px] font-mono whitespace-pre-wrap", children: t.code ? t.code : JSON.stringify(t.params, null, 2) })
|
|
4314
4368
|
] }),
|
|
4315
4369
|
t.error && /* @__PURE__ */ e("pre", { className: "max-h-48 overflow-auto rounded-lg bg-destructive/10 border border-destructive/20 p-3 text-[11px] text-destructive whitespace-pre-wrap", children: t.error }),
|
|
4316
4370
|
/* @__PURE__ */ r("div", { children: [
|
|
4317
|
-
/* @__PURE__ */ e(
|
|
4371
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold text-muted-foreground", children: a("jobs.output") }),
|
|
4318
4372
|
/* @__PURE__ */ r("pre", { className: "mt-1 max-h-72 overflow-auto rounded-lg bg-muted/30 border border-border/40 p-3 text-[11px] font-mono whitespace-pre-wrap", children: [
|
|
4319
4373
|
t.output || a("jobs.no_output"),
|
|
4320
4374
|
t.output_truncated ? `
|
|
@@ -4322,13 +4376,13 @@ ${a("jobs.output_truncated")}` : ""
|
|
|
4322
4376
|
] })
|
|
4323
4377
|
] }),
|
|
4324
4378
|
t.result && /* @__PURE__ */ r("div", { children: [
|
|
4325
|
-
/* @__PURE__ */ e(
|
|
4379
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold text-muted-foreground", children: a("jobs.result") }),
|
|
4326
4380
|
/* @__PURE__ */ e("pre", { className: "mt-1 max-h-40 overflow-auto rounded-lg bg-muted/30 border border-border/40 p-3 text-[11px] font-mono whitespace-pre-wrap", children: JSON.stringify(t.result, null, 2) })
|
|
4327
4381
|
] })
|
|
4328
4382
|
] });
|
|
4329
4383
|
}
|
|
4330
|
-
function
|
|
4331
|
-
const { t: a, i18n: s } = F(["admin"]), [
|
|
4384
|
+
function Lr({ summary: t }) {
|
|
4385
|
+
const { t: a, i18n: s } = F(["admin"]), [l, o] = y(!1), n = t.status === "queued" || t.status === "processing", { data: d } = ir(l ? t.id : null, n), { cancelJobRun: g } = We(), _ = d ?? t, S = new Intl.DateTimeFormat(s.language === "fa" ? "fa-IR" : void 0, {
|
|
4332
4386
|
dateStyle: "short",
|
|
4333
4387
|
timeStyle: "short"
|
|
4334
4388
|
});
|
|
@@ -4342,12 +4396,12 @@ function Nr({ summary: t }) {
|
|
|
4342
4396
|
children: [
|
|
4343
4397
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
4344
4398
|
/* @__PURE__ */ e(
|
|
4345
|
-
|
|
4399
|
+
it,
|
|
4346
4400
|
{
|
|
4347
|
-
className: `size-3.5 text-muted-foreground/60 shrink-0 transition-transform ${
|
|
4401
|
+
className: `size-3.5 text-muted-foreground/60 shrink-0 transition-transform ${l ? "" : "-rotate-90"}`
|
|
4348
4402
|
}
|
|
4349
4403
|
),
|
|
4350
|
-
/* @__PURE__ */ e(
|
|
4404
|
+
/* @__PURE__ */ e(qe, { variant: "outline", className: kr(_.status), children: a(`jobs.status.${_.status}`) }),
|
|
4351
4405
|
/* @__PURE__ */ e("span", { className: "text-sm truncate", children: _.name }),
|
|
4352
4406
|
_.dry_run && /* @__PURE__ */ r("span", { className: "text-[10px] text-muted-foreground/60", children: [
|
|
4353
4407
|
"(",
|
|
@@ -4362,8 +4416,8 @@ function Nr({ summary: t }) {
|
|
|
4362
4416
|
]
|
|
4363
4417
|
}
|
|
4364
4418
|
),
|
|
4365
|
-
|
|
4366
|
-
/* @__PURE__ */ e(
|
|
4419
|
+
l && /* @__PURE__ */ e("div", { className: "px-3 pb-3", children: d ? /* @__PURE__ */ r(at, { children: [
|
|
4420
|
+
/* @__PURE__ */ e(Sr, { run: _ }),
|
|
4367
4421
|
n && /* @__PURE__ */ r(
|
|
4368
4422
|
ne,
|
|
4369
4423
|
{
|
|
@@ -4373,34 +4427,34 @@ function Nr({ summary: t }) {
|
|
|
4373
4427
|
onClick: () => g.mutate(_.id),
|
|
4374
4428
|
disabled: g.isPending,
|
|
4375
4429
|
children: [
|
|
4376
|
-
/* @__PURE__ */ e(
|
|
4430
|
+
/* @__PURE__ */ e(Pt, { className: "size-3.5" }),
|
|
4377
4431
|
a("jobs.cancel_run")
|
|
4378
4432
|
]
|
|
4379
4433
|
}
|
|
4380
4434
|
)
|
|
4381
4435
|
] }) : /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-4 text-xs text-muted-foreground/60", children: [
|
|
4382
|
-
/* @__PURE__ */ e(
|
|
4436
|
+
/* @__PURE__ */ e(He, { className: "size-3.5 animate-spin" }),
|
|
4383
4437
|
a("loading")
|
|
4384
4438
|
] }) })
|
|
4385
4439
|
] });
|
|
4386
4440
|
}
|
|
4387
|
-
function
|
|
4441
|
+
function qr({ runs: t }) {
|
|
4388
4442
|
const { t: a } = F(["admin"]);
|
|
4389
|
-
return /* @__PURE__ */ r(
|
|
4390
|
-
/* @__PURE__ */ r(
|
|
4391
|
-
/* @__PURE__ */ e(
|
|
4392
|
-
/* @__PURE__ */ e(
|
|
4443
|
+
return /* @__PURE__ */ r(je, { className: "max-w-2xl", children: [
|
|
4444
|
+
/* @__PURE__ */ r(Te, { children: [
|
|
4445
|
+
/* @__PURE__ */ e(Ae, { children: a("jobs.history") }),
|
|
4446
|
+
/* @__PURE__ */ e(Ie, { children: a("jobs.history_help") })
|
|
4393
4447
|
] }),
|
|
4394
|
-
t.length === 0 ? /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/70 italic py-6 text-center", children: a("jobs.no_runs") }) : /* @__PURE__ */ e("div", { className: "max-h-[60vh] overflow-y-auto rounded-2xl border border-border/40 divide-y divide-border/40", children: t.map((s) => /* @__PURE__ */ e(
|
|
4395
|
-
/* @__PURE__ */ e(
|
|
4448
|
+
t.length === 0 ? /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/70 italic py-6 text-center", children: a("jobs.no_runs") }) : /* @__PURE__ */ e("div", { className: "max-h-[60vh] overflow-y-auto rounded-2xl border border-border/40 divide-y divide-border/40", children: t.map((s) => /* @__PURE__ */ e(Lr, { summary: s }, s.id)) }),
|
|
4449
|
+
/* @__PURE__ */ e(Be, { children: /* @__PURE__ */ e(ze, { asChild: !0, children: /* @__PURE__ */ e(ne, { variant: "ghost", children: a("close") }) }) })
|
|
4396
4450
|
] });
|
|
4397
4451
|
}
|
|
4398
|
-
function
|
|
4399
|
-
const { t } = F(["admin"]), { runRawJob: a } =
|
|
4452
|
+
function jr() {
|
|
4453
|
+
const { t } = F(["admin"]), { runRawJob: a } = We(), [s, l] = y(!1), [o, n] = y(""), [d, g] = y(""), _ = o.trim() !== "" && d.trim() === Oe, S = async () => {
|
|
4400
4454
|
try {
|
|
4401
|
-
await a.mutateAsync({ code: o, confirm_phrase:
|
|
4455
|
+
await a.mutateAsync({ code: o, confirm_phrase: d }), xe.success(t("jobs.run_started", { name: "Raw Python" })), n(""), g("");
|
|
4402
4456
|
} catch (w) {
|
|
4403
|
-
|
|
4457
|
+
xe.error(w instanceof Error ? w.message : t("jobs.run_failed"));
|
|
4404
4458
|
}
|
|
4405
4459
|
};
|
|
4406
4460
|
return /* @__PURE__ */ r("div", { className: "rounded-2xl border border-destructive/30 bg-destructive/5 overflow-hidden", children: [
|
|
@@ -4408,15 +4462,15 @@ function kr() {
|
|
|
4408
4462
|
"button",
|
|
4409
4463
|
{
|
|
4410
4464
|
type: "button",
|
|
4411
|
-
onClick: () =>
|
|
4465
|
+
onClick: () => l((w) => !w),
|
|
4412
4466
|
className: "w-full flex items-center justify-between gap-2 p-4 text-start",
|
|
4413
4467
|
children: [
|
|
4414
4468
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
4415
|
-
/* @__PURE__ */ e(
|
|
4469
|
+
/* @__PURE__ */ e(Et, { className: "size-4 text-destructive" }),
|
|
4416
4470
|
/* @__PURE__ */ e("h3", { className: "text-sm font-bold text-destructive", children: t("jobs.raw.title") })
|
|
4417
4471
|
] }),
|
|
4418
4472
|
/* @__PURE__ */ e(
|
|
4419
|
-
|
|
4473
|
+
it,
|
|
4420
4474
|
{
|
|
4421
4475
|
className: `size-4 text-destructive/70 transition-transform ${s ? "" : "-rotate-90"}`
|
|
4422
4476
|
}
|
|
@@ -4427,7 +4481,7 @@ function kr() {
|
|
|
4427
4481
|
s && /* @__PURE__ */ r("div", { className: "px-4 pb-4 space-y-4", children: [
|
|
4428
4482
|
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/80", children: t("jobs.raw.warning") }),
|
|
4429
4483
|
/* @__PURE__ */ e(
|
|
4430
|
-
|
|
4484
|
+
De,
|
|
4431
4485
|
{
|
|
4432
4486
|
dir: "ltr",
|
|
4433
4487
|
value: o,
|
|
@@ -4440,14 +4494,14 @@ result = {"ok": True}`,
|
|
|
4440
4494
|
}
|
|
4441
4495
|
),
|
|
4442
4496
|
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
4443
|
-
/* @__PURE__ */ e(
|
|
4497
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold text-destructive", children: t("jobs.raw.confirm_label", { phrase: Oe }) }),
|
|
4444
4498
|
/* @__PURE__ */ e(
|
|
4445
4499
|
se,
|
|
4446
4500
|
{
|
|
4447
4501
|
dir: "ltr",
|
|
4448
|
-
value:
|
|
4502
|
+
value: d,
|
|
4449
4503
|
onChange: (w) => g(w.target.value),
|
|
4450
|
-
placeholder:
|
|
4504
|
+
placeholder: Oe,
|
|
4451
4505
|
className: "border-destructive/30 text-left"
|
|
4452
4506
|
}
|
|
4453
4507
|
)
|
|
@@ -4459,7 +4513,7 @@ result = {"ok": True}`,
|
|
|
4459
4513
|
onClick: S,
|
|
4460
4514
|
disabled: !_ || a.isPending,
|
|
4461
4515
|
children: [
|
|
4462
|
-
a.isPending ? /* @__PURE__ */ e(
|
|
4516
|
+
a.isPending ? /* @__PURE__ */ e(He, { className: "size-4 animate-spin" }) : /* @__PURE__ */ e(Ve, { className: "size-4" }),
|
|
4463
4517
|
t("jobs.raw.run")
|
|
4464
4518
|
]
|
|
4465
4519
|
}
|
|
@@ -4467,12 +4521,12 @@ result = {"ok": True}`,
|
|
|
4467
4521
|
] })
|
|
4468
4522
|
] });
|
|
4469
4523
|
}
|
|
4470
|
-
function
|
|
4471
|
-
const { t } = F(["admin"]), a = he(() =>
|
|
4524
|
+
function Tr() {
|
|
4525
|
+
const { t } = F(["admin"]), a = he(() => wr(), []), s = a.includes("jobs"), l = a.includes("dangerous_jobs"), { data: o } = sr(s), { data: n } = or({ limit: 50 }, s), [d, g] = y(null), [_, S] = y(!1);
|
|
4472
4526
|
if (!s) return null;
|
|
4473
4527
|
const w = o?.jobs || [], x = n?.runs || [];
|
|
4474
4528
|
return /* @__PURE__ */ r("section", { children: [
|
|
4475
|
-
/* @__PURE__ */ e(
|
|
4529
|
+
/* @__PURE__ */ e(Ne, { title: t("jobs.section_title"), icon: $t }),
|
|
4476
4530
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-8", children: [
|
|
4477
4531
|
/* @__PURE__ */ r("div", { className: "space-y-3 text-left", dir: "ltr", children: [
|
|
4478
4532
|
w.length === 0 && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/70 italic", children: t("jobs.no_jobs") }),
|
|
@@ -4484,12 +4538,12 @@ function Cr() {
|
|
|
4484
4538
|
/* @__PURE__ */ r("div", { className: "min-w-0", children: [
|
|
4485
4539
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
4486
4540
|
/* @__PURE__ */ e("p", { className: "text-sm font-bold truncate", children: i.name }),
|
|
4487
|
-
/* @__PURE__ */ e(
|
|
4541
|
+
/* @__PURE__ */ e(qe, { variant: "outline", className: ut(i.danger), children: t(`jobs.danger.${i.danger}`) })
|
|
4488
4542
|
] }),
|
|
4489
4543
|
i.description && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground/70 mt-0.5 line-clamp-2", children: i.description })
|
|
4490
4544
|
] }),
|
|
4491
4545
|
/* @__PURE__ */ r(ne, { variant: "outline", size: "sm", onClick: () => g(i), children: [
|
|
4492
|
-
/* @__PURE__ */ e(
|
|
4546
|
+
/* @__PURE__ */ e(Ve, { className: "size-3.5" }),
|
|
4493
4547
|
t("jobs.run")
|
|
4494
4548
|
] })
|
|
4495
4549
|
]
|
|
@@ -4498,30 +4552,30 @@ function Cr() {
|
|
|
4498
4552
|
))
|
|
4499
4553
|
] }),
|
|
4500
4554
|
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ r(ne, { variant: "outline", size: "sm", onClick: () => S(!0), children: [
|
|
4501
|
-
/* @__PURE__ */ e(
|
|
4555
|
+
/* @__PURE__ */ e(Ot, { className: "size-3.5" }),
|
|
4502
4556
|
t("jobs.view_history"),
|
|
4503
|
-
x.length > 0 && /* @__PURE__ */ e(
|
|
4557
|
+
x.length > 0 && /* @__PURE__ */ e(qe, { variant: "secondary", className: "ml-1", children: x.length })
|
|
4504
4558
|
] }) }),
|
|
4505
|
-
|
|
4559
|
+
l && /* @__PURE__ */ e(jr, {})
|
|
4506
4560
|
] }),
|
|
4507
|
-
/* @__PURE__ */ e(
|
|
4508
|
-
/* @__PURE__ */ e(
|
|
4561
|
+
/* @__PURE__ */ e(Le, { open: !!d, onOpenChange: (i) => !i && g(null), children: d && /* @__PURE__ */ e(Cr, { job: d, onClose: () => g(null) }) }),
|
|
4562
|
+
/* @__PURE__ */ e(Le, { open: _, onOpenChange: S, children: _ && /* @__PURE__ */ e(qr, { runs: x }) })
|
|
4509
4563
|
] });
|
|
4510
4564
|
}
|
|
4511
|
-
function
|
|
4512
|
-
const { t: s } = F(["admin"]), [
|
|
4565
|
+
function Ar({ translations: t, onChange: a }) {
|
|
4566
|
+
const { t: s } = F(["admin"]), [l, o] = y("fa"), [n, d] = y("translation"), [g, _] = y("{}"), [S, w] = y("");
|
|
4513
4567
|
H(() => {
|
|
4514
|
-
const h = t?.[
|
|
4568
|
+
const h = t?.[l]?.[n] || {};
|
|
4515
4569
|
_(JSON.stringify(h, null, 2)), w("");
|
|
4516
|
-
}, [
|
|
4570
|
+
}, [l, n, t]);
|
|
4517
4571
|
const x = (h) => {
|
|
4518
4572
|
_(h);
|
|
4519
4573
|
try {
|
|
4520
4574
|
const N = JSON.parse(h);
|
|
4521
4575
|
a({
|
|
4522
4576
|
...t,
|
|
4523
|
-
[
|
|
4524
|
-
...t?.[
|
|
4577
|
+
[l]: {
|
|
4578
|
+
...t?.[l],
|
|
4525
4579
|
[n]: N
|
|
4526
4580
|
}
|
|
4527
4581
|
}), w("");
|
|
@@ -4533,19 +4587,19 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4533
4587
|
h && !t?.[h] && (a({ ...t, [h]: {} }), o(h));
|
|
4534
4588
|
}, b = () => {
|
|
4535
4589
|
const h = prompt("Enter namespace (e.g. chat, admin):");
|
|
4536
|
-
h && !t?.[
|
|
4590
|
+
h && !t?.[l]?.[h] && (a({
|
|
4537
4591
|
...t,
|
|
4538
|
-
[
|
|
4539
|
-
...t?.[
|
|
4592
|
+
[l]: {
|
|
4593
|
+
...t?.[l],
|
|
4540
4594
|
[h]: {}
|
|
4541
4595
|
}
|
|
4542
|
-
}),
|
|
4596
|
+
}), d(h));
|
|
4543
4597
|
};
|
|
4544
4598
|
return /* @__PURE__ */ r("div", { className: "border border-border/60 rounded-2xl overflow-hidden bg-background", children: [
|
|
4545
4599
|
/* @__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: [
|
|
4546
4600
|
/* @__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: [
|
|
4547
|
-
/* @__PURE__ */ e("div", { className: "p-2 px-3 bg-muted/20 rounded-lg border border-border/40 ml-1", children: /* @__PURE__ */ e(
|
|
4548
|
-
/* @__PURE__ */ r(X, { value:
|
|
4601
|
+
/* @__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" }) }),
|
|
4602
|
+
/* @__PURE__ */ r(X, { value: l, onValueChange: o, children: [
|
|
4549
4603
|
/* @__PURE__ */ e(
|
|
4550
4604
|
Y,
|
|
4551
4605
|
{
|
|
@@ -4557,7 +4611,7 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4557
4611
|
/* @__PURE__ */ e(te, { children: Object.keys(t || {}).sort().map((h) => /* @__PURE__ */ e(E, { value: h, children: h.toUpperCase() }, h)) })
|
|
4558
4612
|
] }),
|
|
4559
4613
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-border/60" }),
|
|
4560
|
-
/* @__PURE__ */ r(X, { value: n, onValueChange:
|
|
4614
|
+
/* @__PURE__ */ r(X, { value: n, onValueChange: d, children: [
|
|
4561
4615
|
/* @__PURE__ */ e(
|
|
4562
4616
|
Y,
|
|
4563
4617
|
{
|
|
@@ -4566,7 +4620,7 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4566
4620
|
children: /* @__PURE__ */ e(ee, {})
|
|
4567
4621
|
}
|
|
4568
4622
|
),
|
|
4569
|
-
/* @__PURE__ */ e(te, { children: Object.keys(t?.[
|
|
4623
|
+
/* @__PURE__ */ e(te, { children: Object.keys(t?.[l] || {}).sort().map((h) => /* @__PURE__ */ e(E, { value: h, children: h }, h)) })
|
|
4570
4624
|
] })
|
|
4571
4625
|
] }),
|
|
4572
4626
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
@@ -4577,7 +4631,7 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4577
4631
|
onClick: i,
|
|
4578
4632
|
title: "Add Language",
|
|
4579
4633
|
className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40",
|
|
4580
|
-
children: /* @__PURE__ */ e(
|
|
4634
|
+
children: /* @__PURE__ */ e(Jt, { className: "size-4" })
|
|
4581
4635
|
}
|
|
4582
4636
|
),
|
|
4583
4637
|
/* @__PURE__ */ e(
|
|
@@ -4587,7 +4641,7 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4587
4641
|
onClick: b,
|
|
4588
4642
|
title: "Add Namespace",
|
|
4589
4643
|
className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40",
|
|
4590
|
-
children: /* @__PURE__ */ e(
|
|
4644
|
+
children: /* @__PURE__ */ e(Je, { className: "size-4" })
|
|
4591
4645
|
}
|
|
4592
4646
|
)
|
|
4593
4647
|
] })
|
|
@@ -4595,10 +4649,10 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4595
4649
|
/* @__PURE__ */ r("div", { className: "relative p-6", children: [
|
|
4596
4650
|
/* @__PURE__ */ r("div", { className: "absolute top-8 right-10 flex items-center gap-2", children: [
|
|
4597
4651
|
/* @__PURE__ */ e("span", { className: "text-[10px] font-bold text-muted-foreground/40 uppercase tracking-widest", children: "JSON EDITOR" }),
|
|
4598
|
-
/* @__PURE__ */ e(
|
|
4652
|
+
/* @__PURE__ */ e(Ut, { className: "size-3 text-muted-foreground/30" })
|
|
4599
4653
|
] }),
|
|
4600
4654
|
/* @__PURE__ */ e(
|
|
4601
|
-
|
|
4655
|
+
De,
|
|
4602
4656
|
{
|
|
4603
4657
|
value: g,
|
|
4604
4658
|
onChange: (h) => x(h.target.value),
|
|
@@ -4618,24 +4672,24 @@ function Sr({ translations: t, onChange: a }) {
|
|
|
4618
4672
|
] }) })
|
|
4619
4673
|
] });
|
|
4620
4674
|
}
|
|
4621
|
-
function
|
|
4675
|
+
function Ir() {
|
|
4622
4676
|
const { t, i18n: a } = F(["admin", "translation", "settings"]), {
|
|
4623
4677
|
app: s,
|
|
4624
|
-
welcome:
|
|
4678
|
+
welcome: l,
|
|
4625
4679
|
disclaimer: o,
|
|
4626
4680
|
history: n,
|
|
4627
|
-
threadActions:
|
|
4681
|
+
threadActions: d,
|
|
4628
4682
|
composer: g,
|
|
4629
4683
|
theme: _,
|
|
4630
4684
|
settings: S
|
|
4631
|
-
} =
|
|
4685
|
+
} = ve(), [w, x] = y(!1), [i, b] = y(!1), [h, N] = y(""), [I, p] = y(""), [R, u] = y(!1), f = he(
|
|
4632
4686
|
() => ({
|
|
4633
4687
|
app_name: s?.name || "Gentiq",
|
|
4634
4688
|
admin_title: s?.adminTitle || "",
|
|
4635
4689
|
default_theme: _?.defaultTheme || "system",
|
|
4636
4690
|
default_accent: _?.accent || "oklch(0.623 0.214 259.815)",
|
|
4637
|
-
welcome_greeting: typeof
|
|
4638
|
-
welcome_subtitle:
|
|
4691
|
+
welcome_greeting: typeof l?.greeting == "string" ? l.greeting : "",
|
|
4692
|
+
welcome_subtitle: l?.subtitle || "",
|
|
4639
4693
|
disclaimer: typeof o == "string" ? o : "",
|
|
4640
4694
|
show_tool_details: s?.showToolDetails ?? !0,
|
|
4641
4695
|
show_settings: s?.showSettings ?? !0,
|
|
@@ -4643,8 +4697,8 @@ function Lr() {
|
|
|
4643
4697
|
disable_signup: s?.disableSignup ?? !1,
|
|
4644
4698
|
disable_auth_page: s?.disableAuthPage ?? !1,
|
|
4645
4699
|
composer_attachments: g?.attachments?.enabled ?? !0,
|
|
4646
|
-
thread_actions_feedback:
|
|
4647
|
-
thread_actions_retry:
|
|
4700
|
+
thread_actions_feedback: d?.feedback ?? !0,
|
|
4701
|
+
thread_actions_retry: d?.retry ?? !0,
|
|
4648
4702
|
history_enabled: n?.enabled ?? !0,
|
|
4649
4703
|
history_show_delete: n?.showDelete ?? !0,
|
|
4650
4704
|
history_show_rename: n?.showRename ?? !0,
|
|
@@ -4663,26 +4717,26 @@ function Lr() {
|
|
|
4663
4717
|
}),
|
|
4664
4718
|
[
|
|
4665
4719
|
s,
|
|
4666
|
-
|
|
4720
|
+
l,
|
|
4667
4721
|
o,
|
|
4668
4722
|
n,
|
|
4669
|
-
|
|
4723
|
+
d,
|
|
4670
4724
|
g,
|
|
4671
4725
|
_,
|
|
4672
4726
|
a.language,
|
|
4673
4727
|
S
|
|
4674
4728
|
]
|
|
4675
|
-
), [C,
|
|
4729
|
+
), [C, q] = y(f), $ = a.language === "fa", v = (C.default_accent || "").trim(), O = !v || typeof CSS < "u" && CSS.supports("color", v);
|
|
4676
4730
|
H(() => {
|
|
4677
4731
|
(async () => {
|
|
4678
4732
|
x(!0);
|
|
4679
4733
|
try {
|
|
4680
4734
|
const m = await T.getSettings();
|
|
4681
4735
|
if (m && Object.keys(m).length > 0) {
|
|
4682
|
-
const
|
|
4736
|
+
const j = JSON.parse(JSON.stringify(a.store.data));
|
|
4683
4737
|
m.translations && Object.keys(m.translations).forEach((A) => {
|
|
4684
|
-
|
|
4685
|
-
}),
|
|
4738
|
+
j[A] || (j[A] = {}), Object.assign(j[A], m.translations[A]);
|
|
4739
|
+
}), q((A) => ({
|
|
4686
4740
|
...A,
|
|
4687
4741
|
...m,
|
|
4688
4742
|
// The backend types these field maps as Record<string, unknown>; they
|
|
@@ -4690,14 +4744,14 @@ function Lr() {
|
|
|
4690
4744
|
settings_general_fields: m.settings_general_fields ?? A.settings_general_fields,
|
|
4691
4745
|
settings_profile_fields: m.settings_profile_fields ?? A.settings_profile_fields,
|
|
4692
4746
|
settings_account_fields: m.settings_account_fields ?? A.settings_account_fields,
|
|
4693
|
-
translations:
|
|
4747
|
+
translations: j
|
|
4694
4748
|
}));
|
|
4695
4749
|
} else {
|
|
4696
|
-
const
|
|
4750
|
+
const j = {
|
|
4697
4751
|
...f,
|
|
4698
4752
|
translations: a.store.data
|
|
4699
4753
|
};
|
|
4700
|
-
|
|
4754
|
+
q(j), m || T.updateSettings(j).catch(console.error);
|
|
4701
4755
|
}
|
|
4702
4756
|
} catch (m) {
|
|
4703
4757
|
console.error("Failed to fetch settings", m), N(t("app_settings.save_error"));
|
|
@@ -4725,7 +4779,7 @@ function Lr() {
|
|
|
4725
4779
|
}, Z = async () => {
|
|
4726
4780
|
x(!0), N("");
|
|
4727
4781
|
try {
|
|
4728
|
-
await T.resetSettings(),
|
|
4782
|
+
await T.resetSettings(), u(!1), window.location.reload();
|
|
4729
4783
|
} catch (k) {
|
|
4730
4784
|
N(k instanceof Error ? k.message : t("app_settings.save_error"));
|
|
4731
4785
|
} finally {
|
|
@@ -4748,25 +4802,25 @@ function Lr() {
|
|
|
4748
4802
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("app_settings.subtitle") })
|
|
4749
4803
|
] }),
|
|
4750
4804
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
|
|
4751
|
-
/* @__PURE__ */ r(
|
|
4752
|
-
/* @__PURE__ */ e(
|
|
4805
|
+
/* @__PURE__ */ r(Le, { open: R, onOpenChange: u, children: [
|
|
4806
|
+
/* @__PURE__ */ e(gt, { asChild: !0, children: /* @__PURE__ */ r(
|
|
4753
4807
|
"button",
|
|
4754
4808
|
{
|
|
4755
4809
|
type: "button",
|
|
4756
4810
|
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",
|
|
4757
4811
|
children: [
|
|
4758
|
-
/* @__PURE__ */ e(
|
|
4812
|
+
/* @__PURE__ */ e(ot, { className: "size-3.5" }),
|
|
4759
4813
|
t("app_settings.reset_button", { defaultValue: "Reset to Defaults" })
|
|
4760
4814
|
]
|
|
4761
4815
|
}
|
|
4762
4816
|
) }),
|
|
4763
|
-
/* @__PURE__ */ r(
|
|
4764
|
-
/* @__PURE__ */ r(
|
|
4765
|
-
/* @__PURE__ */ e(
|
|
4766
|
-
/* @__PURE__ */ e(
|
|
4817
|
+
/* @__PURE__ */ r(je, { children: [
|
|
4818
|
+
/* @__PURE__ */ r(Te, { children: [
|
|
4819
|
+
/* @__PURE__ */ e(Ae, { children: t("app_settings.reset_confirm_title") }),
|
|
4820
|
+
/* @__PURE__ */ e(Ie, { children: t("app_settings.reset_confirm_description") })
|
|
4767
4821
|
] }),
|
|
4768
|
-
/* @__PURE__ */ r(
|
|
4769
|
-
/* @__PURE__ */ e(
|
|
4822
|
+
/* @__PURE__ */ r(Be, { children: [
|
|
4823
|
+
/* @__PURE__ */ e(ze, { asChild: !0, children: /* @__PURE__ */ e(ne, { variant: "ghost", children: t("cancel") }) }),
|
|
4770
4824
|
/* @__PURE__ */ e(ne, { variant: "destructive", onClick: Z, children: t("app_settings.reset_button") })
|
|
4771
4825
|
] })
|
|
4772
4826
|
] })
|
|
@@ -4787,11 +4841,11 @@ function Lr() {
|
|
|
4787
4841
|
] })
|
|
4788
4842
|
] }),
|
|
4789
4843
|
/* @__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: [
|
|
4790
|
-
(h ||
|
|
4844
|
+
(h || I) && /* @__PURE__ */ e(
|
|
4791
4845
|
"div",
|
|
4792
4846
|
{
|
|
4793
4847
|
className: `mb-12 px-4 py-3 rounded-xl text-sm border animate-in fade-in slide-in-from-top-1 duration-300 ${h ? "bg-destructive/10 border-destructive/20 text-destructive" : "bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400"}`,
|
|
4794
|
-
children: h ||
|
|
4848
|
+
children: h || I
|
|
4795
4849
|
}
|
|
4796
4850
|
),
|
|
4797
4851
|
/* @__PURE__ */ r(
|
|
@@ -4802,35 +4856,35 @@ function Lr() {
|
|
|
4802
4856
|
className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500",
|
|
4803
4857
|
children: [
|
|
4804
4858
|
/* @__PURE__ */ e(
|
|
4805
|
-
|
|
4859
|
+
_r,
|
|
4806
4860
|
{
|
|
4807
4861
|
settings: C,
|
|
4808
|
-
setSettings:
|
|
4862
|
+
setSettings: q,
|
|
4809
4863
|
accentValue: v,
|
|
4810
4864
|
accentIsValid: O
|
|
4811
4865
|
}
|
|
4812
4866
|
),
|
|
4813
4867
|
/* @__PURE__ */ e(
|
|
4814
|
-
|
|
4868
|
+
Nr,
|
|
4815
4869
|
{
|
|
4816
4870
|
settings: C,
|
|
4817
|
-
setSettings:
|
|
4871
|
+
setSettings: q,
|
|
4818
4872
|
userMetadataFields: s?.userMetadataFields || [],
|
|
4819
4873
|
isRtl: $
|
|
4820
4874
|
}
|
|
4821
4875
|
),
|
|
4822
4876
|
/* @__PURE__ */ r("section", { children: [
|
|
4823
|
-
/* @__PURE__ */ e(
|
|
4877
|
+
/* @__PURE__ */ e(Ne, { title: t("app_settings.sections.user_billing"), icon: Bt }),
|
|
4824
4878
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
|
|
4825
4879
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
|
|
4826
4880
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
4827
|
-
/* @__PURE__ */ e(
|
|
4881
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.user_billing.initial_balance_tokens") }),
|
|
4828
4882
|
/* @__PURE__ */ e(
|
|
4829
4883
|
se,
|
|
4830
4884
|
{
|
|
4831
4885
|
type: "number",
|
|
4832
4886
|
value: C.initial_balance_tokens ?? "",
|
|
4833
|
-
onChange: (k) =>
|
|
4887
|
+
onChange: (k) => q({
|
|
4834
4888
|
...C,
|
|
4835
4889
|
initial_balance_tokens: parseInt(k.target.value) || 0
|
|
4836
4890
|
}),
|
|
@@ -4840,13 +4894,13 @@ function Lr() {
|
|
|
4840
4894
|
)
|
|
4841
4895
|
] }),
|
|
4842
4896
|
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
4843
|
-
/* @__PURE__ */ e(
|
|
4897
|
+
/* @__PURE__ */ e(z, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.user_billing.initial_balance_requests") }),
|
|
4844
4898
|
/* @__PURE__ */ e(
|
|
4845
4899
|
se,
|
|
4846
4900
|
{
|
|
4847
4901
|
type: "number",
|
|
4848
4902
|
value: C.initial_balance_requests ?? "",
|
|
4849
|
-
onChange: (k) =>
|
|
4903
|
+
onChange: (k) => q({
|
|
4850
4904
|
...C,
|
|
4851
4905
|
initial_balance_requests: parseInt(k.target.value) || 0
|
|
4852
4906
|
}),
|
|
@@ -4860,23 +4914,23 @@ function Lr() {
|
|
|
4860
4914
|
] })
|
|
4861
4915
|
] }),
|
|
4862
4916
|
/* @__PURE__ */ r("section", { children: [
|
|
4863
|
-
/* @__PURE__ */ e(
|
|
4917
|
+
/* @__PURE__ */ e(Ne, { title: t("app_settings.translations_management"), icon: zt }),
|
|
4864
4918
|
/* @__PURE__ */ e(
|
|
4865
|
-
|
|
4919
|
+
Ar,
|
|
4866
4920
|
{
|
|
4867
4921
|
translations: C.translations,
|
|
4868
|
-
onChange: (k) =>
|
|
4922
|
+
onChange: (k) => q((m) => ({ ...m, translations: k }))
|
|
4869
4923
|
}
|
|
4870
4924
|
)
|
|
4871
4925
|
] })
|
|
4872
4926
|
]
|
|
4873
4927
|
}
|
|
4874
4928
|
),
|
|
4875
|
-
/* @__PURE__ */ e("div", { className: "mt-16", children: /* @__PURE__ */ e(
|
|
4929
|
+
/* @__PURE__ */ e("div", { className: "mt-16", children: /* @__PURE__ */ e(Tr, {}) })
|
|
4876
4930
|
] }) })
|
|
4877
4931
|
] });
|
|
4878
4932
|
}
|
|
4879
|
-
function
|
|
4933
|
+
function be() {
|
|
4880
4934
|
const { t, i18n: a } = F(["admin"]), s = a.language === "fa";
|
|
4881
4935
|
return /* @__PURE__ */ r(
|
|
4882
4936
|
"div",
|
|
@@ -4884,7 +4938,7 @@ function ge() {
|
|
|
4884
4938
|
className: "h-full flex flex-col items-center justify-center p-6 text-center gap-4 animate-in fade-in duration-500",
|
|
4885
4939
|
dir: s ? "rtl" : "ltr",
|
|
4886
4940
|
children: [
|
|
4887
|
-
/* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(
|
|
4941
|
+
/* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(Vt, { className: "size-10 text-destructive/70" }) }),
|
|
4888
4942
|
/* @__PURE__ */ r("div", { className: "space-y-1 max-w-sm", children: [
|
|
4889
4943
|
/* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground tracking-tight", children: t("errors.access_denied_title", "Access Denied") }),
|
|
4890
4944
|
/* @__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.") })
|
|
@@ -4893,21 +4947,21 @@ function ge() {
|
|
|
4893
4947
|
}
|
|
4894
4948
|
);
|
|
4895
4949
|
}
|
|
4896
|
-
const
|
|
4897
|
-
const { t: a } = F(["theme"]), { theme: s, setTheme:
|
|
4898
|
-
|
|
4950
|
+
const Dr = ({ className: t }) => {
|
|
4951
|
+
const { t: a } = F(["theme"]), { theme: s, setTheme: l } = Ue(), o = () => {
|
|
4952
|
+
l(s === "system" ? "light" : s === "light" ? "dark" : "system");
|
|
4899
4953
|
}, n = () => {
|
|
4900
4954
|
switch (s) {
|
|
4901
4955
|
case "light":
|
|
4902
|
-
return /* @__PURE__ */ e(
|
|
4956
|
+
return /* @__PURE__ */ e(Wt, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
4903
4957
|
case "dark":
|
|
4904
|
-
return /* @__PURE__ */ e(
|
|
4958
|
+
return /* @__PURE__ */ e(Ht, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
4905
4959
|
case "system":
|
|
4906
|
-
return /* @__PURE__ */ e(
|
|
4960
|
+
return /* @__PURE__ */ e(Ye, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
4907
4961
|
default:
|
|
4908
|
-
return /* @__PURE__ */ e(
|
|
4962
|
+
return /* @__PURE__ */ e(Ye, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
4909
4963
|
}
|
|
4910
|
-
},
|
|
4964
|
+
}, d = () => {
|
|
4911
4965
|
switch (s) {
|
|
4912
4966
|
case "light":
|
|
4913
4967
|
return a("dark");
|
|
@@ -4919,16 +4973,16 @@ const qr = ({ className: t }) => {
|
|
|
4919
4973
|
return a("toggle");
|
|
4920
4974
|
}
|
|
4921
4975
|
};
|
|
4922
|
-
return /* @__PURE__ */ r(
|
|
4923
|
-
/* @__PURE__ */ e(
|
|
4976
|
+
return /* @__PURE__ */ r(Ee, { children: [
|
|
4977
|
+
/* @__PURE__ */ e(Fe, { asChild: !0, children: /* @__PURE__ */ r(ne, { variant: "ghost", size: "icon", onClick: o, className: t, children: [
|
|
4924
4978
|
n(),
|
|
4925
4979
|
/* @__PURE__ */ e("span", { className: "sr-only", children: a("toggle") })
|
|
4926
4980
|
] }) }),
|
|
4927
|
-
/* @__PURE__ */ e(
|
|
4981
|
+
/* @__PURE__ */ e(Pe, { children: d() })
|
|
4928
4982
|
] });
|
|
4929
4983
|
};
|
|
4930
|
-
function
|
|
4931
|
-
const s =
|
|
4984
|
+
function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
4985
|
+
const s = wt(), l = kt(), { t: o, i18n: n } = F(["admin", "settings", "translation"]), { app: d } = ve(), { theme: g } = Ue(), [_, S] = y([]), [w, x] = y(!1), i = nt(!1), [b, h] = y("light");
|
|
4932
4986
|
H(() => {
|
|
4933
4987
|
if (g === "system") {
|
|
4934
4988
|
const v = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -4936,13 +4990,13 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
4936
4990
|
} else
|
|
4937
4991
|
h(g);
|
|
4938
4992
|
}, [g]);
|
|
4939
|
-
const N = he(() =>
|
|
4993
|
+
const N = he(() => d?.logo ? typeof d.logo == "string" ? d.logo : b === "dark" ? d.logo.dark : d.logo.light : st, [d?.logo, b]), I = d?.adminTitle || d?.name, p = n.language === "fa";
|
|
4940
4994
|
H(() => {
|
|
4941
4995
|
const v = localStorage.getItem("admin_info");
|
|
4942
4996
|
if (v)
|
|
4943
4997
|
try {
|
|
4944
4998
|
const P = JSON.parse(v).permissions || [];
|
|
4945
|
-
if (S(P),
|
|
4999
|
+
if (S(P), l.pathname === "/admin" || l.pathname === "/admin/")
|
|
4946
5000
|
if (P.includes("analytics") && !a.includes("analytics"))
|
|
4947
5001
|
s("/admin/analytics", { replace: !0 });
|
|
4948
5002
|
else if (P.includes("chat_history") && !a.includes("chat_history"))
|
|
@@ -4964,12 +5018,12 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
4964
5018
|
}
|
|
4965
5019
|
else
|
|
4966
5020
|
console.warn("DashboardPage: No adminInfo found in localStorage");
|
|
4967
|
-
}, [s,
|
|
5021
|
+
}, [s, l.pathname]);
|
|
4968
5022
|
const R = () => {
|
|
4969
5023
|
T.clearToken(), window.location.reload();
|
|
4970
|
-
},
|
|
5024
|
+
}, u = (v) => _.includes(v), f = (v) => _.includes(v) && !a.includes(v), C = Object.keys(n.services?.resourceStore?.data || {}).filter(
|
|
4971
5025
|
(v) => v !== "dev"
|
|
4972
|
-
),
|
|
5026
|
+
), q = C.length > 0 ? C : ["en", "fa"], $ = (v) => {
|
|
4973
5027
|
localStorage.setItem("gentiq-admin-language", v), n.changeLanguage(v), x(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
|
|
4974
5028
|
};
|
|
4975
5029
|
return /* @__PURE__ */ r(
|
|
@@ -4981,15 +5035,15 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
4981
5035
|
/* @__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: [
|
|
4982
5036
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch gap-x-12", children: [
|
|
4983
5037
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 py-4 md:py-0", children: [
|
|
4984
|
-
/* @__PURE__ */ e("img", { src: N, alt:
|
|
4985
|
-
/* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children:
|
|
5038
|
+
/* @__PURE__ */ e("img", { src: N, alt: I, className: "size-8 object-contain" }),
|
|
5039
|
+
/* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: I })
|
|
4986
5040
|
] }),
|
|
4987
5041
|
/* @__PURE__ */ r("nav", { className: "flex items-stretch gap-8", children: [
|
|
4988
5042
|
!a.includes("analytics") && /* @__PURE__ */ e(
|
|
4989
5043
|
"button",
|
|
4990
5044
|
{
|
|
4991
5045
|
onClick: () => s("/admin/analytics"),
|
|
4992
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${
|
|
5046
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === "/admin/analytics" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
4993
5047
|
children: o("dashboard.tabs.analytics")
|
|
4994
5048
|
}
|
|
4995
5049
|
),
|
|
@@ -4997,7 +5051,7 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
4997
5051
|
"button",
|
|
4998
5052
|
{
|
|
4999
5053
|
onClick: () => s("/admin/chat-history"),
|
|
5000
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${
|
|
5054
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === "/admin/chat-history" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
5001
5055
|
children: o("dashboard.tabs.chat_history")
|
|
5002
5056
|
}
|
|
5003
5057
|
),
|
|
@@ -5005,7 +5059,7 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5005
5059
|
"button",
|
|
5006
5060
|
{
|
|
5007
5061
|
onClick: () => s("/admin/users"),
|
|
5008
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${
|
|
5062
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === "/admin/users" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
5009
5063
|
children: o("dashboard.tabs.users")
|
|
5010
5064
|
}
|
|
5011
5065
|
),
|
|
@@ -5013,7 +5067,7 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5013
5067
|
"button",
|
|
5014
5068
|
{
|
|
5015
5069
|
onClick: () => s("/admin/admins"),
|
|
5016
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${
|
|
5070
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === "/admin/admins" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
5017
5071
|
children: o("dashboard.tabs.admins")
|
|
5018
5072
|
}
|
|
5019
5073
|
),
|
|
@@ -5021,7 +5075,7 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5021
5075
|
"button",
|
|
5022
5076
|
{
|
|
5023
5077
|
onClick: () => s("/admin/settings"),
|
|
5024
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${
|
|
5078
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === "/admin/settings" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
5025
5079
|
children: o("dashboard.tabs.settings")
|
|
5026
5080
|
}
|
|
5027
5081
|
),
|
|
@@ -5029,7 +5083,7 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5029
5083
|
"button",
|
|
5030
5084
|
{
|
|
5031
5085
|
onClick: () => s(`/admin/${v.path}`),
|
|
5032
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${
|
|
5086
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === `/admin/${v.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
5033
5087
|
children: typeof v.label == "string" ? o(v.label) : v.label
|
|
5034
5088
|
},
|
|
5035
5089
|
`tab-${v.path}`
|
|
@@ -5038,7 +5092,7 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5038
5092
|
] }),
|
|
5039
5093
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 py-4 md:py-0", children: [
|
|
5040
5094
|
/* @__PURE__ */ r(
|
|
5041
|
-
|
|
5095
|
+
ft,
|
|
5042
5096
|
{
|
|
5043
5097
|
onOpenChange: (v) => {
|
|
5044
5098
|
v ? x(!1) : (i.current = !0, setTimeout(() => {
|
|
@@ -5047,14 +5101,14 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5047
5101
|
},
|
|
5048
5102
|
children: [
|
|
5049
5103
|
/* @__PURE__ */ r(
|
|
5050
|
-
|
|
5104
|
+
Ee,
|
|
5051
5105
|
{
|
|
5052
5106
|
open: w,
|
|
5053
5107
|
onOpenChange: (v) => {
|
|
5054
5108
|
v && i.current || x(v);
|
|
5055
5109
|
},
|
|
5056
5110
|
children: [
|
|
5057
|
-
/* @__PURE__ */ e(
|
|
5111
|
+
/* @__PURE__ */ e(Fe, { asChild: !0, children: /* @__PURE__ */ e(bt, { asChild: !0, children: /* @__PURE__ */ e(
|
|
5058
5112
|
ne,
|
|
5059
5113
|
{
|
|
5060
5114
|
variant: "ghost",
|
|
@@ -5064,12 +5118,12 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5064
5118
|
children: (n.language?.split("-")[0] || "").toUpperCase()
|
|
5065
5119
|
}
|
|
5066
5120
|
) }) }),
|
|
5067
|
-
/* @__PURE__ */ e(
|
|
5121
|
+
/* @__PURE__ */ e(Pe, { side: "bottom", className: "text-xs", children: o("dashboard.language", "Change Language") })
|
|
5068
5122
|
]
|
|
5069
5123
|
}
|
|
5070
5124
|
),
|
|
5071
|
-
/* @__PURE__ */ e(
|
|
5072
|
-
|
|
5125
|
+
/* @__PURE__ */ e(xt, { align: "center", className: "min-w-[8rem]", children: q.map((v) => /* @__PURE__ */ e(
|
|
5126
|
+
vt,
|
|
5073
5127
|
{
|
|
5074
5128
|
onClick: () => $(v),
|
|
5075
5129
|
className: v === n.language ? "bg-primary/10" : "",
|
|
@@ -5080,79 +5134,79 @@ function jr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5080
5134
|
]
|
|
5081
5135
|
}
|
|
5082
5136
|
),
|
|
5083
|
-
/* @__PURE__ */ e(
|
|
5137
|
+
/* @__PURE__ */ e(Dr, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
|
|
5084
5138
|
/* @__PURE__ */ e("div", { className: "w-px h-5 bg-border mx-1" }),
|
|
5085
|
-
/* @__PURE__ */ r(
|
|
5086
|
-
/* @__PURE__ */ e(
|
|
5139
|
+
/* @__PURE__ */ r(Ee, { children: [
|
|
5140
|
+
/* @__PURE__ */ e(Fe, { asChild: !0, children: /* @__PURE__ */ e(
|
|
5087
5141
|
ne,
|
|
5088
5142
|
{
|
|
5089
5143
|
variant: "ghost",
|
|
5090
5144
|
size: "icon",
|
|
5091
5145
|
className: "hover:bg-destructive/10 hover:scale-105 active:scale-95 text-muted-foreground hover:text-destructive",
|
|
5092
5146
|
onClick: R,
|
|
5093
|
-
children: /* @__PURE__ */ e(
|
|
5147
|
+
children: /* @__PURE__ */ e(Kt, { className: "size-5" })
|
|
5094
5148
|
}
|
|
5095
5149
|
) }),
|
|
5096
|
-
/* @__PURE__ */ e(
|
|
5150
|
+
/* @__PURE__ */ e(Pe, { side: "bottom", className: "text-xs", children: o("dashboard.logout") })
|
|
5097
5151
|
] })
|
|
5098
5152
|
] })
|
|
5099
5153
|
] }) }) }),
|
|
5100
|
-
/* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(
|
|
5101
|
-
/* @__PURE__ */ e(ue, { path: "/", element: /* @__PURE__ */ e(
|
|
5154
|
+
/* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(Ct, { children: [
|
|
5155
|
+
/* @__PURE__ */ e(ue, { path: "/", element: /* @__PURE__ */ e(Ze, { to: "/admin/analytics", replace: !0 }) }),
|
|
5102
5156
|
/* @__PURE__ */ e(
|
|
5103
5157
|
ue,
|
|
5104
5158
|
{
|
|
5105
5159
|
path: "/analytics",
|
|
5106
|
-
element: f("analytics") ? /* @__PURE__ */ e(
|
|
5160
|
+
element: f("analytics") ? /* @__PURE__ */ e(yr, {}) : /* @__PURE__ */ e(be, {})
|
|
5107
5161
|
}
|
|
5108
5162
|
),
|
|
5109
5163
|
/* @__PURE__ */ e(
|
|
5110
5164
|
ue,
|
|
5111
5165
|
{
|
|
5112
5166
|
path: "/chat-history",
|
|
5113
|
-
element: f("chat_history") ? /* @__PURE__ */ e(
|
|
5167
|
+
element: f("chat_history") ? /* @__PURE__ */ e(dr, {}) : /* @__PURE__ */ e(be, {})
|
|
5114
5168
|
}
|
|
5115
5169
|
),
|
|
5116
5170
|
/* @__PURE__ */ e(
|
|
5117
5171
|
ue,
|
|
5118
5172
|
{
|
|
5119
5173
|
path: "/admins",
|
|
5120
|
-
element: f("admin_management") ? /* @__PURE__ */ e(
|
|
5174
|
+
element: f("admin_management") ? /* @__PURE__ */ e(cr, {}) : /* @__PURE__ */ e(be, {})
|
|
5121
5175
|
}
|
|
5122
5176
|
),
|
|
5123
5177
|
/* @__PURE__ */ e(
|
|
5124
5178
|
ue,
|
|
5125
5179
|
{
|
|
5126
5180
|
path: "/settings",
|
|
5127
|
-
element: f("settings") ? /* @__PURE__ */ e(
|
|
5181
|
+
element: f("settings") ? /* @__PURE__ */ e(Ir, {}) : /* @__PURE__ */ e(be, {})
|
|
5128
5182
|
}
|
|
5129
5183
|
),
|
|
5130
5184
|
/* @__PURE__ */ e(
|
|
5131
5185
|
ue,
|
|
5132
5186
|
{
|
|
5133
5187
|
path: "/users",
|
|
5134
|
-
element: f("user_management") ? /* @__PURE__ */ e(
|
|
5188
|
+
element: f("user_management") ? /* @__PURE__ */ e(vr, {}) : /* @__PURE__ */ e(be, {})
|
|
5135
5189
|
}
|
|
5136
5190
|
),
|
|
5137
5191
|
t.map((v) => /* @__PURE__ */ e(
|
|
5138
5192
|
ue,
|
|
5139
5193
|
{
|
|
5140
5194
|
path: `/${v.path}`,
|
|
5141
|
-
element: v.permission && !
|
|
5195
|
+
element: v.permission && !u(v.permission) ? /* @__PURE__ */ e(be, {}) : v.element
|
|
5142
5196
|
},
|
|
5143
5197
|
`route-${v.path}`
|
|
5144
5198
|
)),
|
|
5145
|
-
/* @__PURE__ */ e(ue, { path: "*", element: /* @__PURE__ */ e(
|
|
5199
|
+
/* @__PURE__ */ e(ue, { path: "*", element: /* @__PURE__ */ e(Ze, { to: "/admin/analytics", replace: !0 }) })
|
|
5146
5200
|
] }) }) })
|
|
5147
5201
|
]
|
|
5148
5202
|
}
|
|
5149
5203
|
);
|
|
5150
5204
|
}
|
|
5151
|
-
function
|
|
5205
|
+
function Kr(t) {
|
|
5152
5206
|
const a = he(() => {
|
|
5153
|
-
const s =
|
|
5154
|
-
return s.use(
|
|
5155
|
-
resources:
|
|
5207
|
+
const s = mt.createInstance();
|
|
5208
|
+
return s.use(yt).use(ht).init({
|
|
5209
|
+
resources: _t,
|
|
5156
5210
|
fallbackLng: "en",
|
|
5157
5211
|
interpolation: { escapeValue: !1 },
|
|
5158
5212
|
detection: {
|
|
@@ -5162,17 +5216,17 @@ function zr(t) {
|
|
|
5162
5216
|
}
|
|
5163
5217
|
}), s;
|
|
5164
5218
|
}, []);
|
|
5165
|
-
return /* @__PURE__ */ e(
|
|
5219
|
+
return /* @__PURE__ */ e(pt, { i18n: a, children: /* @__PURE__ */ e(Mr, { ...t }) });
|
|
5166
5220
|
}
|
|
5167
|
-
function
|
|
5168
|
-
const { app: s, i18n:
|
|
5221
|
+
function Mr({ extraPages: t, disabledPages: a = [] }) {
|
|
5222
|
+
const { app: s, i18n: l } = ve(), { t: o, i18n: n } = F(["admin", "translation"]), [d, g] = y(!1), [_, S] = y(!0), [w, x] = y(!1);
|
|
5169
5223
|
H(() => {
|
|
5170
|
-
|
|
5171
|
-
Object.entries(N).forEach(([
|
|
5172
|
-
n.addResourceBundle(h,
|
|
5224
|
+
l?.resources && Object.entries(l.resources).forEach(([h, N]) => {
|
|
5225
|
+
Object.entries(N).forEach(([I, p]) => {
|
|
5226
|
+
n.addResourceBundle(h, I, p, !0, !0);
|
|
5173
5227
|
});
|
|
5174
5228
|
}), !localStorage.getItem("gentiq-admin-language") && s?.language && n.language !== s.language && n.changeLanguage(s.language), x(!0);
|
|
5175
|
-
}, [
|
|
5229
|
+
}, [l?.resources, n, s?.language]), H(() => {
|
|
5176
5230
|
const b = T.getToken();
|
|
5177
5231
|
return g(!!b), S(!1), document.body.classList.add("admin-theme-root"), () => {
|
|
5178
5232
|
document.body.classList.remove("admin-theme-root");
|
|
@@ -5183,22 +5237,22 @@ function Tr({ extraPages: t, disabledPages: a = [] }) {
|
|
|
5183
5237
|
const i = () => {
|
|
5184
5238
|
g(!0);
|
|
5185
5239
|
};
|
|
5186
|
-
return _ || !w ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: o("loading") }) }) : /* @__PURE__ */ e(
|
|
5240
|
+
return _ || !w ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: o("loading") }) }) : /* @__PURE__ */ e(Nt, { storageKey: "gentiq-admin-theme", children: d ? /* @__PURE__ */ e(Rr, { extraPages: t, disabledPages: a }) : /* @__PURE__ */ e(Zt, { onLoginSuccess: i }) });
|
|
5187
5241
|
}
|
|
5188
5242
|
export {
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5243
|
+
Kr as AdminPanel,
|
|
5244
|
+
tr as useAdminAdmins,
|
|
5245
|
+
rr as useAdminAdminsMutations,
|
|
5246
|
+
er as useAdminAnalytics,
|
|
5247
|
+
Wr as useAdminAuth,
|
|
5248
|
+
Vr as useAdminJobs,
|
|
5249
|
+
Hr as useAdminJobsMutations,
|
|
5250
|
+
nr as useAdminThreadItems,
|
|
5251
|
+
ar as useAdminThreads,
|
|
5252
|
+
Xt as useAdminUsers,
|
|
5253
|
+
Yt as useAdminUsersMutations,
|
|
5254
|
+
We as useJobMutations,
|
|
5255
|
+
ir as useJobRun,
|
|
5256
|
+
or as useJobRuns,
|
|
5257
|
+
sr as useRegisteredJobs
|
|
5204
5258
|
};
|