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