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